Skip to content

Commit ad33f4e

Browse files
committed
Initial commit
0 parents  commit ad33f4e

File tree

11 files changed

+440
-0
lines changed

11 files changed

+440
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Release/*

Build.cmd

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
@echo off
2+
setlocal ENABLEDELAYEDEXPANSION
3+
4+
rem BUILD REQUIREMENTS
5+
rem Go must be installed and in your path, as it is used to build the app image binary launchers
6+
rem The jmods directories for both the JDK and JavaFX SDK both need to include windows, linux, and mac subdirectories containing the jmods for those respective operating systems
7+
rem The following environmental variables need to be set either system-wide, for your user, or you can set them here
8+
rem set JAVA_HOME=C:\path-to-JDK-17
9+
rem set JAVAFX_HOME=C:\path-to-javafx-sdk-17
10+
rem set PATH=%JAVAFX_HOME%\bin;%JAVA_HOME%\bin;%PATH%
11+
12+
echo Generate class path including all JavaFX libraries...
13+
for /f %%0 in ('dir /b "%JAVAFX_HOME%\lib" ^| findstr /e .jar') do set JAVAFX_CLASSES=%JAVAFX_HOME%\lib\%%0;!JAVAFX_CLASSES!
14+
15+
echo Set build information...
16+
set PROJECT=TorPanel
17+
set PACKAGE=torpanel
18+
set ENTRY=Main
19+
set DEPS=javafx.fxml,javafx.controls
20+
21+
echo Clean up old release files...
22+
if exist Release rd /s /q Release
23+
24+
echo Set Java version to build...
25+
set JV=8
26+
27+
echo Compile package source files...
28+
javac.exe -cp "%JAVAFX_CLASSES%" -d Release\%JV% src\%PACKAGE%\*.java --release %JV%
29+
30+
echo Copy fxml gui to compiled package directory...
31+
md Release\%JV%\%PACKAGE%\gui
32+
copy src\torpanel\gui Release\%JV%\%PACKAGE%\gui > nul
33+
34+
echo Archive package to jar file...
35+
cd Release\%JV%
36+
jar.exe cfe %PROJECT%.jar %PACKAGE%.%ENTRY% %PACKAGE%\*.class %PACKAGE%\gui\*.fxml
37+
cd ..\..
38+
39+
echo Set Java version to build...
40+
set JV=17
41+
42+
echo Compile module source files...
43+
javac.exe -p "%JAVAFX_HOME%\lib" --add-modules %DEPS% -d Release\%JV% src\%PACKAGE%\*.java --release %JV%
44+
45+
echo Copy fxml gui to compiled module directory...
46+
md Release\%JV%\%PACKAGE%\gui
47+
copy src\%PACKAGE%\gui Release\%JV%\%PACKAGE%\gui > nul
48+
49+
echo Archive module to jar file...
50+
cd Release\%JV%
51+
jar.exe cfe %PROJECT%.jar %PACKAGE%.%ENTRY% %PACKAGE%\*.class %PACKAGE%\gui\*.fxml
52+
cd ..\..
53+
54+
echo Compile module-info source file...
55+
javac.exe -p "Release\%JV%\%PROJECT%.jar;%JAVAFX_HOME%\lib" --add-modules %DEPS%,%PACKAGE% -d Release\%JV% src\module-info.java
56+
57+
echo Update jar file with compiled module-info...
58+
cd Release\%JV%
59+
jar.exe uf %PROJECT%.jar module-info.class
60+
cd ..\..
61+
62+
echo Build app image for Windows...
63+
jlink.exe -p "Release\%JV%\%PROJECT%.jar;%JAVAFX_HOME%\jmods\windows;%JAVA_HOME%\jmods\windows" --add-modules %DEPS%,%PACKAGE% --compress=2 --no-header-files --no-man-pages --strip-debug --output Release\%JV%\%PROJECT%-Windows
64+
copy README.md Release\%JV%\%PROJECT%-Windows > nul
65+
copy LICENSE Release\%JV%\%PROJECT%-Windows > nul
66+
67+
echo Build launcher for Windows...
68+
set GOOS=windows
69+
go build -ldflags="-s -w -H=windowsgui" -o Release\%JV%\%PROJECT%-Windows\%PROJECT%.exe src\torpanel.go src\include_windows.go
70+
71+
echo Build app image for Linux...
72+
jlink.exe -p "Release\%JV%\%PACKAGE%.jar;%JAVAFX_HOME%\jmods\linux;%JAVA_HOME%\jmods\linux" --add-modules %DEPS%,%PACKAGE% --compress=2 --no-header-files --no-man-pages --strip-debug --output Release\%JV%\%PROJECT%-Linux
73+
copy README.md Release\%JV%\%PROJECT%-Linux > nul
74+
copy LICENSE Release\%JV%\%PROJECT%-Linux > nul
75+
76+
echo Build launcher for Linux...
77+
set GOOS=linux
78+
go build -ldflags="-s -w" -o Release\%JV%\%PROJECT%-Linux\%PROJECT% src\torpanel.go src\include_other.go
79+
80+
echo Build app image for Mac...
81+
jlink.exe -p "Release\%JV%\%PROJECT%.jar;%JAVAFX_HOME%\jmods\mac;%JAVA_HOME%\jmods\mac" --add-modules %DEPS%,%PACKAGE% --compress=2 --no-header-files --no-man-pages --strip-debug --output Release\%JV%\%PROJECT%-Mac
82+
copy README.md Release\%JV%\%PROJECT%-Mac > nul
83+
copy LICENSE Release\%JV%\%PROJECT%-Mac > nul
84+
85+
echo Build launcher for Mac...
86+
set GOOS=darwin
87+
go build -ldflags="-s -w" -o Release\%JV%\%PROJECT%-Mac\%PROJECT%.app src\torpanel.go src\include_other.go
88+
89+
echo Build complete
90+
pause

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 ScriptTiger
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://docs.google.com/forms/d/e/1FAIpQLSfBEe5B_zo69OBk19l3hzvBmz3cOV6ol1ufjh0ER1q3-xd2Rg/viewform)
2+
3+
# TorPanel
4+
A small Tor controller widget that stays conveniently on top and out of the way with a minimal footprint while you go about your activities.
5+
6+
**TorPanel.jar**
7+
Recommended if you are running JDK/JRE 8, 9, or 10. If your JDK/JRE is higher than version 10, you will need to link to the JavaFX SDK manually, or use one of stand-alone app images below.
8+
9+
**TorPanel-Windows.zip**
10+
Supported by 64-bit Windows.
11+
12+
**TorPanel-Linux.zip**
13+
Supported by 64-bit Linux.
14+
15+
**TorPanel-Mac.zip**
16+
Supported by 64-bit Mac.
17+
18+
By default, TorPanel will connect to 127.0.0.1:9051 and attempt to authenticate to Tor without a password. To change the default behavior, you can create a `torpanel.conf` file and include key-value pairs for `host`, `port`, and `secret`, delimited by a `=` (i.e. `secret=password`). If you are running the `TorPanel.jar`, the `torpanel.conf` should be located in the working directory. If you are running one of the stand-alone app images, the `torpanel.conf` should be located in the base directory, the same directory where the `TorPanel` executable launcher is located and root directory for the `bin`, `conf`, `legal`, and `lib` directories.
19+
20+
# More About ScriptTiger
21+
22+
For more ScriptTiger scripts and goodies, check out ScriptTiger's GitHub Pages website:
23+
https://scripttiger.github.io/
24+
25+
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MZ4FH4G5XHGZ4)
26+
27+
Donate Monero (XMR): 441LBeQpcSbC1kgangHYkW8Tzo8cunWvtVK4M6QYMcAjdkMmfwe8XzDJr1c4kbLLn3NuZKxzpLTVsgFd7Jh28qipR5rXAjx

src/include_other.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package main
2+
3+
// Set name of Java executable
4+
const javaName = "java"

src/include_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package main
2+
3+
// Set name of Java executable
4+
const javaName = "javaw"

src/module-info.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module torpanel {
2+
requires javafx.fxml;
3+
requires javafx.controls;
4+
5+
opens torpanel to javafx.fxml;
6+
exports torpanel;
7+
}

src/torpanel.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
"path/filepath"
7+
)
8+
9+
func main() {
10+
11+
// Locate base directory of launcher and establish path to java
12+
dir, err := os.Executable()
13+
if err != nil {os.Exit(1)}
14+
dir, err = filepath.EvalSymlinks(dir)
15+
if err != nil {os.Exit(1)}
16+
dir = filepath.Dir(dir)
17+
javaPath := filepath.Join(filepath.Join(dir, "bin"), javaName)
18+
19+
// Change working directory to base directory
20+
os.Chdir(dir)
21+
22+
// Launch app
23+
exec.Command(javaPath, "-m", "torpanel/torpanel.Main").Start()
24+
25+
// Exit launcher
26+
os.Exit(0)
27+
}

src/torpanel/Controller.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package torpanel;
2+
3+
// Controller standard fxml deps
4+
import javafx.fxml.FXML;
5+
6+
// Label deps
7+
import javafx.scene.control.Label;
8+
9+
// Additional type deps
10+
import javafx.scene.paint.Color;
11+
12+
public class Controller {
13+
14+
private TorConnector torConnector;
15+
16+
@FXML
17+
private Label status;
18+
19+
// Shared torConnector from Main
20+
public void setTorConnector(TorConnector torConnector) {this.torConnector = torConnector;}
21+
22+
// Button OnAction methods
23+
public void newnym() {torConnector.newnym();}
24+
public void reload() {torConnector.reload();}
25+
26+
// Status label methods
27+
public void setStatusText(String text) {status.setText(text);}
28+
public void setStatusFill(Color fill) {status.setTextFill(fill);}
29+
}

0 commit comments

Comments
 (0)