From 1d0cf4aba78569118fb6d03b439e222b89eefd3c Mon Sep 17 00:00:00 2001 From: idk Date: Thu, 17 Feb 2022 16:02:13 -0500 Subject: [PATCH 01/33] make the path that the install and config are placed in configurable --- java/net/i2p/router/WinLauncher.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 2043c15..0a32f42 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -96,6 +96,14 @@ public class WinLauncher { } private static File selectHome() { // throws Exception { + String path_override = System.getenv("I2P"); + File path = new File(path_override); + if (path.exists()) { + if (path.isDirectory()) + return path.getAbsoluteFile(); + else + throw new RuntimeException("I2P is not a directory: " + path); + } if (SystemVersion.isWindows()) { File home = new File(System.getProperty("user.home")); File appData = new File(home, "AppData"); @@ -113,6 +121,14 @@ public class WinLauncher { } private static File selectProgramFile() { + String path_override = System.getenv("I2P_CONFIG"); + File path = new File(path_override); + if (path.exists()) { + if (path.isDirectory()) + return path.getAbsoluteFile(); + else + throw new RuntimeException("I2P_CONFIG is not a directory: " + path); + } if (SystemVersion.isWindows()) { File jrehome = new File(System.getProperty("java.home")); File programs = jrehome.getParentFile(); From 723b4d0e274cf96e64530f220f504a0f81462b4d Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 19 Feb 2022 11:13:27 -0500 Subject: [PATCH 02/33] Switch I2P and I2P_CONFIG for environment variable based install-path configuration --- java/net/i2p/router/WinLauncher.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 0a32f42..7c4682b 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -96,7 +96,7 @@ public class WinLauncher { } private static File selectHome() { // throws Exception { - String path_override = System.getenv("I2P"); + String path_override = System.getenv("I2P_CONFIG"); File path = new File(path_override); if (path.exists()) { if (path.isDirectory()) @@ -121,13 +121,13 @@ public class WinLauncher { } private static File selectProgramFile() { - String path_override = System.getenv("I2P_CONFIG"); + String path_override = System.getenv("I2P"); File path = new File(path_override); if (path.exists()) { if (path.isDirectory()) return path.getAbsoluteFile(); else - throw new RuntimeException("I2P_CONFIG is not a directory: " + path); + throw new RuntimeException("I2P is not a directory: " + path); } if (SystemVersion.isWindows()) { File jrehome = new File(System.getProperty("java.home")); From 3391c23abd3235b300a17bde3c71bc1830810290 Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 20 Feb 2022 20:29:47 -0500 Subject: [PATCH 03/33] Null check path_override --- java/net/i2p/router/WinLauncher.java | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 7c4682b..61fe6c2 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -97,12 +97,14 @@ public class WinLauncher { private static File selectHome() { // throws Exception { String path_override = System.getenv("I2P_CONFIG"); - File path = new File(path_override); - if (path.exists()) { - if (path.isDirectory()) - return path.getAbsoluteFile(); - else - throw new RuntimeException("I2P is not a directory: " + path); + if (path_override != null) { + File path = new File(path_override); + if (path != null && path.exists()) { + if (path.isDirectory()) + return path.getAbsoluteFile(); + else + throw new RuntimeException("I2P_CONFIG is not a directory: " + path); + } } if (SystemVersion.isWindows()) { File home = new File(System.getProperty("user.home")); @@ -122,12 +124,14 @@ public class WinLauncher { private static File selectProgramFile() { String path_override = System.getenv("I2P"); - File path = new File(path_override); - if (path.exists()) { - if (path.isDirectory()) - return path.getAbsoluteFile(); - else - throw new RuntimeException("I2P is not a directory: " + path); + if (path_override != null) { + File path = new File(path_override); + if (path.exists()) { + if (path.isDirectory()) + return path.getAbsoluteFile(); + else + throw new RuntimeException("I2P is not a directory: " + path); + } } if (SystemVersion.isWindows()) { File jrehome = new File(System.getProperty("java.home")); From d8e7551edb634fb0fee17701c771276d9e732a19 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 11 Mar 2022 14:52:07 -0500 Subject: [PATCH 04/33] update the version --- i2pversion | 4 ++-- src/nsis/i2pbrowser-version.nsi | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i2pversion b/i2pversion index a721b68..1f616b6 100644 --- a/i2pversion +++ b/i2pversion @@ -3,8 +3,8 @@ #Comment this out to build from an alternate branch or # the tip of the master branch. -I2P_VERSION=1.6.1 -export I2P_VERSION=1.6.1 +I2P_VERSION=1.7.0 +export I2P_VERSION=1.7.0 VERSION=i2p-"$I2P_VERSION" export VERSION="$VERSION" diff --git a/src/nsis/i2pbrowser-version.nsi b/src/nsis/i2pbrowser-version.nsi index ee60787..7a67fa8 100644 --- a/src/nsis/i2pbrowser-version.nsi +++ b/src/nsis/i2pbrowser-version.nsi @@ -1,3 +1,3 @@ !define VERSIONMAJOR 1 -!define VERSIONMINOR 06 +!define VERSIONMINOR 07 !define VERSIONBUILD 1 From bc36564f5d2ee3e50e092ee78774960337c7cef3 Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 19 Mar 2022 13:44:29 -0400 Subject: [PATCH 05/33] Start adding JNA stuff, for now just copied from zlatinb's but I'll need to customize a bit to account for portables --- build.sh | 11 ++++++++++- i2pversion | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 4cb51f5..b88dae3 100755 --- a/build.sh +++ b/build.sh @@ -52,9 +52,18 @@ I2P_JBIGI="$HERE/../i2p.i2p.jpackage-build/installer/lib/jbigi" echo "compiling custom launcher" mkdir build cp "$I2P_JARS"/*.jar build +if [ ! -f "$HERE/build/jna.jar" ]; then + wget -O "$HERE/build/jna.jar" https://repo1.maven.org/maven2/net/java/dev/jna/jna/$JNA_VERSION/jna-$JNA_VERSION.jar +fi + cd java -"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE"/build/i2p.jar:"$HERE"/build/router.jar:"$HERE"/build/routerconsole.jar net/i2p/router/WinLauncher.java net/i2p/router/WindowsUpdatePostProcessor.java net/i2p/router/WinUpdateProcess.java +"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/jna.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \ + net/i2p/router/Shell32X.java \ + net/i2p/router/WinLauncher.java \ + net/i2p/router/WindowsUpdatePostProcessor.java \ + net/i2p/router/WinUpdateProcess.java + cd .. #echo "building launcher.jar" diff --git a/i2pversion b/i2pversion index 1f616b6..9838730 100644 --- a/i2pversion +++ b/i2pversion @@ -1,5 +1,7 @@ #! /usr/bin/env sh +JNA_VERSION=5.10.0 +export JNA_VERSION=5.10.0 #Comment this out to build from an alternate branch or # the tip of the master branch. From fe99c7bb0528eac5af2e7209b2c22056b3404ea4 Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 19 Mar 2022 16:39:06 -0400 Subject: [PATCH 06/33] Check in Shell32X.java and see if it builds on a real Windows machine? --- java/net/i2p/router/Shell32X.java | 109 ++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 java/net/i2p/router/Shell32X.java diff --git a/java/net/i2p/router/Shell32X.java b/java/net/i2p/router/Shell32X.java new file mode 100644 index 0000000..63f7c7a --- /dev/null +++ b/java/net/i2p/router/Shell32X.java @@ -0,0 +1,109 @@ +import java.util.*; + +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.Structure; +import com.sun.jna.WString; +import com.sun.jna.platform.win32.Shell32; +import com.sun.jna.platform.win32.WinDef.HINSTANCE; +import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinNT.HANDLE; +import com.sun.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.win32.W32APIOptions; + +public interface Shell32X extends Shell32 { + Shell32X INSTANCE = (Shell32X) Native.loadLibrary("shell32", Shell32X.class, W32APIOptions.UNICODE_OPTIONS); + + int SW_HIDE = 0; + int SW_MAXIMIZE = 3; + int SW_MINIMIZE = 6; + int SW_RESTORE = 9; + int SW_SHOW = 5; + int SW_SHOWDEFAULT = 10; + int SW_SHOWMAXIMIZED = 3; + int SW_SHOWMINIMIZED = 2; + int SW_SHOWMINNOACTIVE = 7; + int SW_SHOWNA = 8; + int SW_SHOWNOACTIVATE = 4; + int SW_SHOWNORMAL = 1; + + /** File not found. */ + int SE_ERR_FNF = 2; + + /** Path not found. */ + int SE_ERR_PNF = 3; + + /** Access denied. */ + int SE_ERR_ACCESSDENIED = 5; + + /** Out of memory. */ + int SE_ERR_OOM = 8; + + /** DLL not found. */ + int SE_ERR_DLLNOTFOUND = 32; + + /** Cannot share an open file. */ + int SE_ERR_SHARE = 26; + + int SEE_MASK_NOCLOSEPROCESS = 0x00000040; + + int ShellExecute(int i, String lpVerb, String lpFile, String lpParameters, String lpDirectory, int nShow); + + boolean ShellExecuteEx(SHELLEXECUTEINFO lpExecInfo); + + public static class SHELLEXECUTEINFO extends Structure { + /* + * DWORD cbSize; + * ULONG fMask; + * HWND hwnd; + * LPCTSTR lpVerb; + * LPCTSTR lpFile; + * LPCTSTR lpParameters; + * LPCTSTR lpDirectory; + * int nShow; + * HINSTANCE hInstApp; + * LPVOID lpIDList; + * LPCTSTR lpClass; + * HKEY hkeyClass; + * DWORD dwHotKey; + * union { + * HANDLE hIcon; + * HANDLE hMonitor; + * } DUMMYUNIONNAME; + * HANDLE hProcess; + */ + + public int cbSize = size(); + public int fMask; + public HWND hwnd; + public WString lpVerb; + public WString lpFile; + public WString lpParameters; + public WString lpDirectory; + public int nShow; + public HINSTANCE hInstApp; + public Pointer lpIDList; + public WString lpClass; + public HKEY hKeyClass; + public int dwHotKey; + + /* + * Actually: + * union { + * HANDLE hIcon; + * HANDLE hMonitor; + * } DUMMYUNIONNAME; + */ + public HANDLE hMonitor; + public HANDLE hProcess; + + protected List getFieldOrder() { + return Arrays.asList(new String[] { + "cbSize", "fMask", "hwnd", "lpVerb", "lpFile", "lpParameters", + "lpDirectory", "nShow", "hInstApp", "lpIDList", "lpClass", + "hKeyClass", "dwHotKey", "hMonitor", "hProcess", + }); + } + } + +} From f5a424f0834c7aa0aa871dafbe7c016a222995c0 Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 19 Mar 2022 17:23:55 -0400 Subject: [PATCH 07/33] Fix wrong JNA version --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index b88dae3..740925c 100755 --- a/build.sh +++ b/build.sh @@ -53,7 +53,7 @@ echo "compiling custom launcher" mkdir build cp "$I2P_JARS"/*.jar build if [ ! -f "$HERE/build/jna.jar" ]; then - wget -O "$HERE/build/jna.jar" https://repo1.maven.org/maven2/net/java/dev/jna/jna/$JNA_VERSION/jna-$JNA_VERSION.jar + wget -O "$HERE/build/jna.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/$JNA_VERSION/jna-platform-$JNA_VERSION.jar" fi From e2ad0d190ad176084137cccaa285a64effe705fa Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 19 Mar 2022 17:52:01 -0400 Subject: [PATCH 08/33] Use both JNA jars --- build.sh | 5 +++-- src/app-profile/version.txt | 2 +- src/nsis/i2pbrowser-jpackage.nsi | 2 +- src/profile/version.txt | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 740925c..1ef4171 100755 --- a/build.sh +++ b/build.sh @@ -53,12 +53,13 @@ echo "compiling custom launcher" mkdir build cp "$I2P_JARS"/*.jar build if [ ! -f "$HERE/build/jna.jar" ]; then - wget -O "$HERE/build/jna.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/$JNA_VERSION/jna-platform-$JNA_VERSION.jar" + wget -O "$HERE/build/jna.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna/$JNA_VERSION/jna-$JNA_VERSION.jar" + wget -O "$HERE/build/jna-platform.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/$JNA_VERSION/jna-platform-$JNA_VERSION.jar" fi cd java -"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/jna.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \ +"$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/jna.jar":"$HERE/build/jna-platform.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \ net/i2p/router/Shell32X.java \ net/i2p/router/WinLauncher.java \ net/i2p/router/WindowsUpdatePostProcessor.java \ diff --git a/src/app-profile/version.txt b/src/app-profile/version.txt index 1c5c4af..1c6f4d4 100644 --- a/src/app-profile/version.txt +++ b/src/app-profile/version.txt @@ -1 +1 @@ -1.06.1 +1.07.1 diff --git a/src/nsis/i2pbrowser-jpackage.nsi b/src/nsis/i2pbrowser-jpackage.nsi index d8024bb..88e7fae 100644 --- a/src/nsis/i2pbrowser-jpackage.nsi +++ b/src/nsis/i2pbrowser-jpackage.nsi @@ -1 +1 @@ -!define I2P_VERSION 1.6.1 +!define I2P_VERSION 1.7.0 diff --git a/src/profile/version.txt b/src/profile/version.txt index 1c5c4af..1c6f4d4 100644 --- a/src/profile/version.txt +++ b/src/profile/version.txt @@ -1 +1 @@ -1.06.1 +1.07.1 From 44b2ae44eebeebfcb0873b3e559086048d7355d7 Mon Sep 17 00:00:00 2001 From: idk Date: Sat, 19 Mar 2022 18:10:36 -0400 Subject: [PATCH 09/33] Don't download JNA jars if they're already downloaded --- build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 1ef4171..1a9c7e9 100755 --- a/build.sh +++ b/build.sh @@ -54,9 +54,11 @@ mkdir build cp "$I2P_JARS"/*.jar build if [ ! -f "$HERE/build/jna.jar" ]; then wget -O "$HERE/build/jna.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna/$JNA_VERSION/jna-$JNA_VERSION.jar" - wget -O "$HERE/build/jna-platform.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/$JNA_VERSION/jna-platform-$JNA_VERSION.jar" fi +if [ ! -f "$HERE/build/jna-platform.jar" ]; then + wget -O "$HERE/build/jna-platform.jar" "https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/$JNA_VERSION/jna-platform-$JNA_VERSION.jar" +fi cd java "$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/jna.jar":"$HERE/build/jna-platform.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \ From a28bb6ac3c9fde58a0cdceb969e9eb97196b831a Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 20 Mar 2022 02:41:09 -0400 Subject: [PATCH 10/33] Fix package imports, copy over the elevator functions --- java/net/i2p/router/Elevator.java | 29 +++++++++++++++++++++++++++++ java/net/i2p/router/Shell32X.java | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 java/net/i2p/router/Elevator.java diff --git a/java/net/i2p/router/Elevator.java b/java/net/i2p/router/Elevator.java new file mode 100644 index 0000000..3f69327 --- /dev/null +++ b/java/net/i2p/router/Elevator.java @@ -0,0 +1,29 @@ +package net.i2p.router; + +import com.sun.jna.WString; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.Kernel32Util; + +public class Elevator { + public static void main(String... args) { + executeAsAdministrator("c:\\windows\\system32\\notepad.exe", ""); + } + + public static void executeAsAdministrator(String command, String args) { + Shell32X.SHELLEXECUTEINFO execInfo = new Shell32X.SHELLEXECUTEINFO(); + execInfo.lpFile = new WString(command); + if (args != null) + execInfo.lpParameters = new WString(args); + execInfo.nShow = Shell32X.SW_SHOWDEFAULT; + execInfo.fMask = Shell32X.SEE_MASK_NOCLOSEPROCESS; + execInfo.lpVerb = new WString("runas"); + boolean result = Shell32X.INSTANCE.ShellExecuteEx(execInfo); + + if (!result) { + int lastError = Kernel32.INSTANCE.GetLastError(); + String errorMessage = Kernel32Util.formatMessageFromLastErrorCode(lastError); + throw new RuntimeException("Error performing elevation: " + lastError + ": " + errorMessage + " (apperror=" + + execInfo.hInstApp + ")"); + } + } +} diff --git a/java/net/i2p/router/Shell32X.java b/java/net/i2p/router/Shell32X.java index 63f7c7a..c7906eb 100644 --- a/java/net/i2p/router/Shell32X.java +++ b/java/net/i2p/router/Shell32X.java @@ -1,3 +1,5 @@ +package net.i2p.router; + import java.util.*; import com.sun.jna.Native; From 9da43b39610c05734f9c49b0cc272125e9dd7830 Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 21 Mar 2022 11:04:27 -0400 Subject: [PATCH 11/33] Try a way of determining required rights for the installer --- java/net/i2p/router/Elevator.java | 4 ++ java/net/i2p/router/WinUpdateProcess.java | 31 +++++++++----- .../router/WindowsUpdatePostProcessor.java | 42 ++++++++++--------- 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/java/net/i2p/router/Elevator.java b/java/net/i2p/router/Elevator.java index 3f69327..2715a15 100644 --- a/java/net/i2p/router/Elevator.java +++ b/java/net/i2p/router/Elevator.java @@ -10,6 +10,10 @@ public class Elevator { } public static void executeAsAdministrator(String command, String args) { + if (command == "" || command == null) { + System.out.println("No command specified"); + return; + } Shell32X.SHELLEXECUTEINFO execInfo = new Shell32X.SHELLEXECUTEINFO(); execInfo.lpFile = new WString(command); if (args != null) diff --git a/java/net/i2p/router/WinUpdateProcess.java b/java/net/i2p/router/WinUpdateProcess.java index 46dadcc..9dc6071 100644 --- a/java/net/i2p/router/WinUpdateProcess.java +++ b/java/net/i2p/router/WinUpdateProcess.java @@ -42,20 +42,29 @@ class WinUpdateProcess implements Runnable { var workingDir = workDir(); var logFile = new File(workingDir, "log-" + version + ".txt"); - ProcessBuilder pb = new ProcessBuilder(file.getAbsolutePath()); - var env = pb.environment(); - env.put("OLD_I2P_VERSION", version); - env.remove("RESTART_I2P"); + if (logFile.canWrite()) { + // check if we can write to the log file. If we can, use the ProcessBuilder to + // run the installer. + ProcessBuilder pb = new ProcessBuilder(file.getAbsolutePath(), "/S", "/D=" + workingDir.getAbsolutePath()); + var env = pb.environment(); + env.put("OLD_I2P_VERSION", version); + env.remove("RESTART_I2P"); - int exitCode = ctx.router().scheduledGracefulExitCode(); - if (exitCode == Router.EXIT_HARD_RESTART || exitCode == Router.EXIT_GRACEFUL_RESTART) - env.put("RESTART_I2P", "true"); + int exitCode = ctx.router().scheduledGracefulExitCode(); + if (exitCode == Router.EXIT_HARD_RESTART || exitCode == Router.EXIT_GRACEFUL_RESTART) + env.put("RESTART_I2P", "true"); - try { - pb.directory(workingDir).redirectErrorStream(true).redirectOutput(logFile).start(); - } catch (IOException ex) { - System.out.println("Unable to run update-program in background. Update will fail."); + try { + pb.directory(workingDir).redirectErrorStream(true).redirectOutput(logFile).start(); + } catch (IOException ex) { + System.out.println("Unable to run update-program in background. Update will fail."); + } + } else { + // If we cant write to the log file and we're on Windows, use the elevator to + // execute the installer instead of the ProcessBuilder. + Elevator.executeAsAdministrator(file.getAbsolutePath(), " /S /D=" + workingDir.getAbsolutePath()); } + } @Override diff --git a/java/net/i2p/router/WindowsUpdatePostProcessor.java b/java/net/i2p/router/WindowsUpdatePostProcessor.java index 45dc450..badad32 100644 --- a/java/net/i2p/router/WindowsUpdatePostProcessor.java +++ b/java/net/i2p/router/WindowsUpdatePostProcessor.java @@ -43,28 +43,30 @@ public class WindowsUpdatePostProcessor implements UpdatePostProcessor { public void updateDownloadedandVerified(UpdateType type, int fileType, String version, File file) throws IOException { _log.info("Got an update to post-process"); + if (SystemVersion.isWindows()) { - if (type != UpdateType.ROUTER_SIGNED_SU3 && type != UpdateType.ROUTER_DEV_SU3) { - _log.warn("Unsupported update type " + type); - return; + if (type != UpdateType.ROUTER_SIGNED_SU3 && type != UpdateType.ROUTER_DEV_SU3) { + _log.warn("Unsupported update type " + type); + return; + } + + if (fileType != SU3File.TYPE_EXE) { + _log.warn("Unsupported file type " + fileType); + return; + } + + this.positionedFile = moveUpdateInstaller(file); + this.version = version; + + if (!hook.compareAndSet(false, true)) { + _log.info("shutdown hook was already set"); + return; + } + + _log.info("adding shutdown hook"); + + ctx.addFinalShutdownTask(new WinUpdateProcess(ctx, this::getVersion, this::getFile)); } - - if (fileType != SU3File.TYPE_EXE) { - _log.warn("Unsupported file type " + fileType); - return; - } - - this.positionedFile = moveUpdateInstaller(file); - this.version = version; - - if (!hook.compareAndSet(false, true)) { - _log.info("shutdown hook was already set"); - return; - } - - _log.info("adding shutdown hook"); - ctx.addFinalShutdownTask(new WinUpdateProcess(ctx, this::getVersion, this::getFile)); - } private File moveUpdateInstaller(File file) throws IOException { From bb7dcaa907f23ee70003c333032955d71f30a9b7 Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 21 Mar 2022 11:32:10 -0400 Subject: [PATCH 12/33] Add elevator.java to build.sh --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 1a9c7e9..b0f67c6 100755 --- a/build.sh +++ b/build.sh @@ -62,6 +62,7 @@ fi cd java "$JAVA_HOME"/bin/javac -d ../build -classpath "$HERE/build/jna.jar":"$HERE/build/jna-platform.jar":"$HERE/build/i2p.jar":"$HERE/build/router.jar":"$HERE/build/routerconsole.jar" \ + net/i2p/router/Elevator.java \ net/i2p/router/Shell32X.java \ net/i2p/router/WinLauncher.java \ net/i2p/router/WindowsUpdatePostProcessor.java \ From 51dca79a76550cd84a549e9f1ad6e840811e93e2 Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 21 Mar 2022 11:36:28 -0400 Subject: [PATCH 13/33] remove the RequestExecutionLevel line --- src/nsis/i2pbrowser-installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index d14d04c..9938829 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -39,7 +39,7 @@ Name "${COMPANYNAME} - ${APPNAME}" Icon ui2pbrowser_icon.ico OutFile "I2P-Profile-Installer-${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.exe" -RequestExecutionLevel admin +# RequestExecutionLevel admin !include LogicLib.nsh !include x64.nsh From cf394be3526f5827d3881f79895f7dacbde5a725 Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 21 Mar 2022 11:41:29 -0400 Subject: [PATCH 14/33] Add choco to the Windows README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b3ab32..da366ea 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,8 @@ with `sudo service i2p start` then you can run the script: /usr/local/bin/i2p-config-service-setup -Including a jpackaged I2P Router(EXPERIMENTAL) ----------------------------------------------- +Including a jpackaged I2P Router +-------------------------------- In order to include a jpackaged(dependency-free) I2P router in the Profile Bundle you will need to build the jpackaged I2P router as an "App Image" on @@ -159,6 +159,9 @@ you should select "Checkout as is, commit as is" and leave line-endings alone. End-to-End Windows build process using Cygwin --------------------------------------------- +I highly recommend you look into the Chocolatey package manager, which makes it much +easier to configure these tools and keep them up to date. + **Prerequisites:** You need to have OpenJDK 14 or greater installed and configured with your `%JAVA_HOME%` environment variable configured and `%JAVA_HOME%/bin` on your `%PATH%`. You need to have Apache Ant installed and configured with `%ANT_HOME%` From 1f980fb016a9b06d3d3ae80a7096a0cf150522ea Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 21 Mar 2022 11:43:34 -0400 Subject: [PATCH 15/33] Add choco to the Windows README --- README.md | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index da366ea..5221d2c 100644 --- a/README.md +++ b/README.md @@ -4,33 +4,32 @@ I2P Browsing Profile for Firefox Features: --------- - - Automatically select an up-to-date, secure Firefox or Tor Browser(On Windows) variant - - Automatically configure a profile for I2P - - Automatically block-list all non-I2P local destinations - - Enable first-party isolation, anti-fingerprinting, letterboxing - - Automatically sandbox I2P, Non-I2P, and I2P-Application cookiestores +- Automatically select an up-to-date, secure Firefox or Tor Browser(On Windows) variant +- Automatically configure a profile for I2P +- Automatically block-list all non-I2P local destinations +- Enable first-party isolation, anti-fingerprinting, letterboxing +- Automatically sandbox I2P, Non-I2P, and I2P-Application cookiestores Build Dependencies: ------------------- To build this, you will need the following software packages (all available in Debian) : - * make - * nsis - * dos2unix - * curl - * jq +- make +- nsis +- dos2unix +- curl +- jq to build a Debian package, you'll also need - * checkinstall +- checkinstall Preparation ----------- Before you build, run the targets - make clean-extensions make extensions @@ -172,27 +171,26 @@ select "Checkout as is, commit as is" and leave line-endings alone. TODO: Add links to the respective instructions for each of these. - 1. Run the Cygwin `setup-$arch.exe` for your platform to set up new packages. - Select the `make` `jq` `dos2unix` and `curl` packages. - 2. Open a cygwin terminal. - 3. Clone `i2p.i2p` and `i2p.firefox` +1. Run the Cygwin `setup-$arch.exe` for your platform to set up new packages. Select the `make` `jq` `dos2unix` and `curl` packages. +2. Open a cygwin terminal. +3. Clone `i2p.i2p` and `i2p.firefox` git clone https://github.com/i2p/i2p.i2p git clone https://github.com/i2p/i2p.firefox - 3. Move to the i2p.i2p directory. Build the .jar files required to build the App Image +4. Move to the i2p.i2p directory. Build the .jar files required to build the App Image inside i2p.i2p. Return to home. cd i2p.i2p ant clean pkg cd .. - 4. Move into the i2p.firefox directory. Run the `./build.sh` script. +5. Move into the i2p.firefox directory. Run the `./build.sh` script. cd i2p.firefox ./build.sh - 5. Run `make` to build the installer. +6. Run `make` to build the installer. Doing a Release --------------- From 9a34008c484e6f4a15df05e5c2f79ffd4860a0d9 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 12:05:57 -0400 Subject: [PATCH 16/33] Makefile wasn't producing licenses at the right step, try and detect if elevated from the NSIS installer from the start of the script, for now, fail if we aren't --- Makefile | 2 +- src/nsis/i2pbrowser-installer.nsi | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 246fdf4..5b1d2e1 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ prep: profile.tgz app-profile.tgz profile build/licenses build/I2P build/I2P/con cp src/nsis/*.nsh build cp src/icons/*.ico build -install.exe: +install.exe: build/licenses cd build && makensis i2pbrowser-installer.nsi && cp I2P-Profile-Installer-*.exe ../ && echo "built windows installer" export RES_DIR="../i2p.i2p.jpackage-build/installer/resources" diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index 9938829..d3a32b2 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -144,6 +144,13 @@ Page instfiles !include i2pbrowser-mozcompat.nsi Function .onInit + UserInfo::GetAccountType + pop $0 + ${If} $0 != "admin" + MessageBox mb_iconstop "Administrator rights required!" + SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED + Quit + ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY Call ShouldInstall64Bit ${If} $0 == 1 From 6651a16fb2d4693b4800fc466bcf3f305ebd2828 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 12:17:28 -0400 Subject: [PATCH 17/33] don't accidentally dupe values in router.config when running src/I2P/config target twice --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5b1d2e1..ee340db 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ src/I2P/config: build/I2P cp -v $(RES_DIR)/i2ptunnel.config src/I2P/config/ cp -v $(RES_DIR)/wrapper.config src/I2P/config/ #grep -v 'router.updateURL' $(RES_DIR)/router.config > src/I2P/config/router.config - cat router.config >> src/I2P/config/router.config + cat router.config > src/I2P/config/router.config cp -v $(RES_DIR)/hosts.txt src/I2P/config/hosts.txt cp -R $(RES_DIR)/certificates src/I2P/config/certificates cp -R $(RES_DIR)/eepsite src/I2P/config/eepsite From 87f9cc063baa0cd61e77522781eef15c54278584 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 12:22:46 -0400 Subject: [PATCH 18/33] update version number --- src/nsis/i2pbrowser-version.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-version.nsi b/src/nsis/i2pbrowser-version.nsi index 7a67fa8..4323c0a 100644 --- a/src/nsis/i2pbrowser-version.nsi +++ b/src/nsis/i2pbrowser-version.nsi @@ -1,3 +1,3 @@ !define VERSIONMAJOR 1 !define VERSIONMINOR 07 -!define VERSIONBUILD 1 +!define VERSIONBUILD 3 From 1f543c8db50c6f6c40f5346008ee7040cd4b9de9 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 13:31:57 -0400 Subject: [PATCH 19/33] Request only the highest execution level, not necessarily admin --- src/nsis/i2pbrowser-installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index d3a32b2..be336ec 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -39,7 +39,7 @@ Name "${COMPANYNAME} - ${APPNAME}" Icon ui2pbrowser_icon.ico OutFile "I2P-Profile-Installer-${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.exe" -# RequestExecutionLevel admin +RequestExecutionLevel highest !include LogicLib.nsh !include x64.nsh From 4aa673a9594ee146d3701da8dbf802570cee56a3 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 14:19:06 -0400 Subject: [PATCH 20/33] Request only the user execution level, highest will request admin if the user has permission to elevate and I want to avoid that --- src/nsis/i2pbrowser-installer.nsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index be336ec..f01a912 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -30,7 +30,7 @@ SetOverwrite on !define RAM_NEEDED_FOR_64BIT 0x80000000 -InstallDir "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}" +InstallDir "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" # rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n) LicenseData "licenses\LICENSE.index" @@ -150,6 +150,7 @@ Function .onInit MessageBox mb_iconstop "Administrator rights required!" SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED Quit + #StrCpy INSTDIR "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}" ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY Call ShouldInstall64Bit From 400b9d3edc4537272f217bc2bc1bdf081cb613a2 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 14:20:39 -0400 Subject: [PATCH 21/33] Set install dir to local app data if the user is not elevated --- src/nsis/i2pbrowser-installer.nsi | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index f01a912..1a36b9f 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -30,7 +30,7 @@ SetOverwrite on !define RAM_NEEDED_FOR_64BIT 0x80000000 -InstallDir "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" +InstallDir "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}" # rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n) LicenseData "licenses\LICENSE.index" @@ -147,10 +147,7 @@ Function .onInit UserInfo::GetAccountType pop $0 ${If} $0 != "admin" - MessageBox mb_iconstop "Administrator rights required!" - SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED - Quit - #StrCpy INSTDIR "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}" + InstallDir "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY Call ShouldInstall64Bit From 9282d22e7bbdb7776d20137692abdd05b3e8d520 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 14:23:50 -0400 Subject: [PATCH 22/33] Request only the user execution level, highest will request admin if the user has permission to elevate and I want to avoid that --- src/nsis/i2pbrowser-installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index 1a36b9f..36d706f 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -39,7 +39,7 @@ Name "${COMPANYNAME} - ${APPNAME}" Icon ui2pbrowser_icon.ico OutFile "I2P-Profile-Installer-${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.exe" -RequestExecutionLevel highest +RequestExecutionLevel user !include LogicLib.nsh !include x64.nsh From ef0b5c5cad3e44a033b3ab866e1a8b3b5ee930e4 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 14:32:05 -0400 Subject: [PATCH 23/33] Set install dir to local app data if the user is not elevated --- src/nsis/i2pbrowser-installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index 36d706f..7df5293 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -147,7 +147,7 @@ Function .onInit UserInfo::GetAccountType pop $0 ${If} $0 != "admin" - InstallDir "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" + StrCpy INSTDIR "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY Call ShouldInstall64Bit From cf3385cfd0c973216800c91245139448a5d0f7c6 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 14:50:11 -0400 Subject: [PATCH 24/33] Set install dir to local app data if the user is not elevated --- src/nsis/i2pbrowser-installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index 7df5293..8489d9f 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -147,7 +147,7 @@ Function .onInit UserInfo::GetAccountType pop $0 ${If} $0 != "admin" - StrCpy INSTDIR "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" + StrCpy $INSTDIR "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY Call ShouldInstall64Bit From c64f0fe632e3edfc9bb7c09606a8488d76c84bf9 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 15:04:15 -0400 Subject: [PATCH 25/33] enable a user-mode install of I2P jpackages --- src/nsis/i2pbrowser-installer.nsi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index 8489d9f..0ed1370 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -27,6 +27,8 @@ SetOverwrite on !define I2PINSTEXE !define I2PINSTEXE32 "$PROGRAMFILES32\i2p" !define I2PINSTEXE64 "$PROGRAMFILES64\i2p" +!define I2PINSTEXE_USERMODE "$LOCALAPPDATA\i2p" + !define RAM_NEEDED_FOR_64BIT 0x80000000 @@ -144,10 +146,12 @@ Page instfiles !include i2pbrowser-mozcompat.nsi Function .onInit + StrCpy $I2PINSTEXE "${I2PINSTEXE64}" UserInfo::GetAccountType pop $0 ${If} $0 != "admin" StrCpy $INSTDIR "$LOCALAPPDATA\${COMPANYNAME}\${APPNAME}" + StrCpy $I2PINSTEXE "${I2PINSTEXE_USERMODE}" ${EndIf} !insertmacro MUI_LANGDLL_DISPLAY Call ShouldInstall64Bit @@ -177,13 +181,16 @@ Function .onInit StrCpy $FFINSTEXE "$PROFILE\Desktop\Tor Browser\Browser\" ${EndIf} ${EndIf} - StrCpy $I2PINSTEXE "${I2PINSTEXE64}" ${If} ${FileExists} "${I2PINSTEXE32}\i2p.exe" StrCpy $I2PINSTEXE "${I2PINSTEXE32}" ${EndIf} ${If} ${FileExists} "${I2PINSTEXE64}\i2p.exe" StrCpy $I2PINSTEXE "${I2PINSTEXE64}" ${EndIf} + ${If} ${FileExists} "${I2PINSTEXE_USERMODE}\i2p.exe" + StrCpy $I2PINSTEXE "${I2PINSTEXE_USERMODE}" + ${EndIf} + # look for user installs FunctionEnd Function firefoxDetect From af44dd357ad7404124ebb99eb0befa34412df485 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 15:09:15 -0400 Subject: [PATCH 26/33] enable a user-mode install of I2P jpackages --- changelog.txt | 8 ++++++++ src/nsis/i2pbrowser-installer.nsi | 16 +++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/changelog.txt b/changelog.txt index 87229e6..335fbda 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,11 @@ +2022-03-25 idk + * This release adds support for user-mode, non-privileged installation of the + jpackaged router and the browser profile. Admin installation is still supported + and detected automatically, to support existing bundles. + * On restart to update, will detect if a router requires admin rights to install + and will ask the user to authorize the update. In user-mode, no prompt will ever + be seen. + 2022-02-10 idk * This release fixes automatic update using Bittorrent within the I2P network and the custom Update PostProcessor. diff --git a/src/nsis/i2pbrowser-installer.nsi b/src/nsis/i2pbrowser-installer.nsi index 0ed1370..9ad5188 100644 --- a/src/nsis/i2pbrowser-installer.nsi +++ b/src/nsis/i2pbrowser-installer.nsi @@ -181,14 +181,16 @@ Function .onInit StrCpy $FFINSTEXE "$PROFILE\Desktop\Tor Browser\Browser\" ${EndIf} ${EndIf} - ${If} ${FileExists} "${I2PINSTEXE32}\i2p.exe" - StrCpy $I2PINSTEXE "${I2PINSTEXE32}" - ${EndIf} - ${If} ${FileExists} "${I2PINSTEXE64}\i2p.exe" + UserInfo::GetAccountType + pop $0 + ${If} $0 == "admin" StrCpy $I2PINSTEXE "${I2PINSTEXE64}" - ${EndIf} - ${If} ${FileExists} "${I2PINSTEXE_USERMODE}\i2p.exe" - StrCpy $I2PINSTEXE "${I2PINSTEXE_USERMODE}" + ${If} ${FileExists} "${I2PINSTEXE32}\i2p.exe" + StrCpy $I2PINSTEXE "${I2PINSTEXE32}" + ${EndIf} + ${If} ${FileExists} "${I2PINSTEXE64}\i2p.exe" + StrCpy $I2PINSTEXE "${I2PINSTEXE64}" + ${EndIf} ${EndIf} # look for user installs FunctionEnd From 706a7a6fe27ac8798d5d7613bcce6502b7b3e13f Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 15:23:19 -0400 Subject: [PATCH 27/33] enable a user-mode run of I2P jpackages --- src/win/i2pbrowser-private.bat | 11 ++++++++--- src/win/i2pbrowser.bat | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/win/i2pbrowser-private.bat b/src/win/i2pbrowser-private.bat index d37a3fd..3baf3e4 100644 --- a/src/win/i2pbrowser-private.bat +++ b/src/win/i2pbrowser-private.bat @@ -9,7 +9,12 @@ if exist "%ProgramFiles(x86)%\I2P" ( set "I2PPath=%ProgramFiles(x86)%\I2P" ) -if exist "%ProgramFiles%\I2P\jpackaged" ( +set "I2PPath=%LocalAppData%\I2P\" +if exist "%LocalAppData%\I2P\I2P.exe" ( + set "I2PPath=%LocalAppData%\I2P\" +) + +if exist "%I2PPath%\jpackaged" ( start "i2p" /D "%LOCALAPPDATA%\I2P" "%I2PPath%\i2p.exe" ) else ( start "i2p" "%I2PPath%\i2p.exe" @@ -19,10 +24,10 @@ timeout /t 3 if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\" ( echo "profile is configured, updating extensions" - xcopy /s /i /y "%ProgramFiles%\I2P\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" ) else ( echo "configuring profile" - xcopy /s /i /y "%ProgramFiles%\I2P\I2PBrowser-Launcher\firefox.profile.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" ) if exist "%USERPROFILE%/Desktop/Tor Browser/Browser/firefox.exe" ( diff --git a/src/win/i2pbrowser.bat b/src/win/i2pbrowser.bat index 3156c57..f642149 100644 --- a/src/win/i2pbrowser.bat +++ b/src/win/i2pbrowser.bat @@ -9,7 +9,12 @@ if exist "%ProgramFiles(x86)%\I2P" ( set "I2PPath=%ProgramFiles(x86)%\I2P" ) -if exist "%ProgramFiles%\I2P\jpackaged" ( +set "I2PPath=%LocalAppData%\I2P\" +if exist "%LocalAppData%\I2P\I2P.exe" ( + set "I2PPath=%LocalAppData%\I2P\" +) + +if exist "%I2PPath%\jpackaged" ( start "i2p" /D "%LOCALAPPDATA%\I2P" "%I2PPath%\i2p.exe" ) else ( start "i2p" "%I2PPath%\i2p.exe" @@ -19,10 +24,10 @@ timeout /t 3 if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\" ( echo "profile is configured, updating extensions" - xcopy /s /i /y "%ProgramFiles%\I2P\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" ) else ( echo "configuring profile" - xcopy /s /i /y "%ProgramFiles%\I2P\I2PBrowser-Launcher\firefox.profile.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" ) if exist "%USERPROFILE%/Desktop/Tor Browser/Browser/firefox.exe" ( From ffb9efaab8a00fbd5e01d827fb276b4ec3887275 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 17:09:07 -0400 Subject: [PATCH 28/33] update browser profiles --- src/app-profile/user.js | 27 +++++++++++++-------------- src/profile/prefs.js | 4 +--- src/profile/user.js | 28 ++++++++++++++++------------ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/app-profile/user.js b/src/app-profile/user.js index c4bb768..8f5596f 100644 --- a/src/app-profile/user.js +++ b/src/app-profile/user.js @@ -1,19 +1,18 @@ -# Overrides for Extension Preferences -# Tor Browser Bundle -# Do not edit this file. -# -# This file is modified from a file included in the Tor Browser Bundle. -# -# Copyright 2017 The Tor Project. See LICENSE.tor for licensing information. +/* +Overrides# +for Extension Preferences# Tor Browser Bundle# Do not edit this file.##This file is modified from a file included in the Tor Browser Bundle.##Copyright 2017 The Tor Project.See LICENSE.tor# +for licensing information. -# HTTPS Everywhere Preferences: +HTTPS Everywhere Preferences: +*/ user_pref("extensions.https_everywhere._observatory.popup_shown", true); user_pref("extensions.https_everywhere.toolbar_hint_shown", true); -# NoScript Preferences: -# In order to disable all scripts by default, uncomment the following line... -# user_pref("capability.policy.maonoscript.javascript.enabled", "noAccess"); -# and comment out the following line +/* +NoScript Preferences: #In order to disable all scripts by +default, uncomment the following line...#user_pref("capability.policy.maonoscript.javascript.enabled", "noAccess");# +and comment out the following line +*/ user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); user_pref("capability.policy.maonoscript.sites", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache"); user_pref("noscript.default", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache"); @@ -106,7 +105,7 @@ user_pref("network.proxy.ftp_port", 4444); user_pref("network.proxy.socks", "127.0.0.1"); user_pref("network.proxy.socks_port", 4444); user_pref("network.proxy.share_proxy_settings", true); -user_pref("browser.startup.homepage", "about:blank"); +user_pref("browser.startup.homepage", "http://127.0.0.1:7657/home"); // Privacy-harden and disable irrelevant features. user_pref("app.normandy.api_url", ""); @@ -221,4 +220,4 @@ user_pref("webgl.disable-extensions", true); user_pref("webgl.min_capability_mode", true); user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); -user_pref("dom.w3c_touch_events.enabled", false); +user_pref("dom.w3c_touch_events.enabled", false); \ No newline at end of file diff --git a/src/profile/prefs.js b/src/profile/prefs.js index 7312217..48bf864 100644 --- a/src/profile/prefs.js +++ b/src/profile/prefs.js @@ -58,6 +58,4 @@ user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); user_pref("media.navigator.enabled", false); user_pref("dom.w3c_touch_events.enabled", false); -user_pref("fission.autostart", true); -user_pref("gfx.webrender.all", false); -user_pref("privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts", false); \ No newline at end of file +user_pref("browser.privatebrowsing.autostart", false); \ No newline at end of file diff --git a/src/profile/user.js b/src/profile/user.js index 0a945b8..a15ef1e 100644 --- a/src/profile/user.js +++ b/src/profile/user.js @@ -1,15 +1,18 @@ -//# Overrides -//for Extension Preferences# Tor Browser Bundle# Do not edit this file.##This file is modified from a file included in the Tor Browser Bundle.##Copyright 2017 The Tor Project.See LICENSE.tor -//for licensing information. +/* +Overrides# +for Extension Preferences# Tor Browser Bundle# Do not edit this file.##This file is modified from a file included in the Tor Browser Bundle.##Copyright 2017 The Tor Project.See LICENSE.tor# +for licensing information. -//# HTTPS Everywhere Preferences: +HTTPS Everywhere Preferences: +*/ user_pref("extensions.https_everywhere._observatory.popup_shown", true); user_pref("extensions.https_everywhere.toolbar_hint_shown", true); -//# NoScript Preferences: #In order to disable all scripts by -//default, uncomment the following line... -//#user_pref("capability.policy.maonoscript.javascript.enabled", "noAccess");# -//and comment out the following line +/* +NoScript Preferences: #In order to disable all scripts by +default, uncomment the following line...#user_pref("capability.policy.maonoscript.javascript.enabled", "noAccess");# +and comment out the following line +*/ user_pref("capability.policy.maonoscript.javascript.enabled", "allAccess"); user_pref("capability.policy.maonoscript.sites", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache"); user_pref("noscript.default", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache"); @@ -79,6 +82,9 @@ user_pref("extensions.torbutton.use_nontor_proxy", true); //user_pref("extensions.torlauncher.socks_port_use_ipc", ); //user_pref("extensions.torlauncher.socks_ipc_path", ""); +// TODO: this is a Tor Browser specific setting which is ignored on Firefox. If +// I make it true, the SOCKS outproxy will have something to connect to. But I +// need to test more to find out if that's prudent. user_pref("extensions.torlauncher.start_tor", false); //user_pref("extensions.torlauncher.default_bridge_type", ""); user_pref("extensions.torlauncher.prompt_at_startup", false); @@ -102,7 +108,7 @@ user_pref("network.proxy.ftp_port", 4444); user_pref("network.proxy.socks", "127.0.0.1"); user_pref("network.proxy.socks_port", 4444); user_pref("network.proxy.share_proxy_settings", true); -user_pref("browser.startup.homepage", "about:blank"); +user_pref("browser.startup.homepage", "http://127.0.0.1:7657/home"); // Privacy-harden and disable irrelevant features. user_pref("app.normandy.api_url", ""); @@ -218,6 +224,4 @@ user_pref("webgl.min_capability_mode", true); user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); user_pref("dom.w3c_touch_events.enabled", false); -user_pref("fission.autostart", true); -user_pref("gfx.webrender.all", false); -user_pref("privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts", false); \ No newline at end of file +user_pref("browser.privatebrowsing.autostart", false); \ No newline at end of file From 8135506213e25a8cf169152a5a9a414d0b857355 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 17:23:49 -0400 Subject: [PATCH 29/33] update config launcher script --- src/win/i2pconfig.bat | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/win/i2pconfig.bat b/src/win/i2pconfig.bat index 53916ad..744105f 100644 --- a/src/win/i2pconfig.bat +++ b/src/win/i2pconfig.bat @@ -1,11 +1,25 @@ -@echo off +@echo on + +set "I2PPath=%ProgramFiles%\I2P\" +if exist "%ProgramFiles%\I2P\" ( + set "I2PPath=%ProgramFiles%\I2P\" +) + +if exist "%ProgramFiles(x86)%\I2P" ( + set "I2PPath=%ProgramFiles(x86)%\I2P" +) + +set "I2PPath=%LocalAppData%\I2P\" +if exist "%LocalAppData%\I2P\I2P.exe" ( + set "I2PPath=%LocalAppData%\I2P\" +) if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p\" ( echo "profile is configured" - xcopy /s /i /y "%ProgramFiles%\I2P\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" ) else ( echo "configuring profile" - xcopy /s /i /y "%ProgramFiles%\I2P\I2PBrowser-Launcher\firefox.profile.config.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.config.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p" ) if exist "%ProgramFiles%\Mozilla Firefox\firefox.exe" ( From 714ef026f3a19af18b9e1439d509c6f010202107 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 17:49:39 -0400 Subject: [PATCH 30/33] always copy settings to profile directory --- src/win/i2pbrowser-private.bat | 3 +++ src/win/i2pbrowser.bat | 3 +++ src/win/i2pconfig.bat | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/win/i2pbrowser-private.bat b/src/win/i2pbrowser-private.bat index 3baf3e4..79a4bc0 100644 --- a/src/win/i2pbrowser-private.bat +++ b/src/win/i2pbrowser-private.bat @@ -30,6 +30,9 @@ if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\" ( xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" ) +xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\user.js" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\user.js" +xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\prefs.js" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\prefs.js" + if exist "%USERPROFILE%/Desktop/Tor Browser/Browser/firefox.exe" ( start "i2pbrowser" "%USERPROFILE%/Desktop/Tor Browser/Browser/firefox.exe" -no-remote -profile "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" -private-window about:blank exit diff --git a/src/win/i2pbrowser.bat b/src/win/i2pbrowser.bat index f642149..477e55a 100644 --- a/src/win/i2pbrowser.bat +++ b/src/win/i2pbrowser.bat @@ -30,6 +30,9 @@ if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\" ( xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" ) +xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\user.js" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\user.js" +xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\prefs.js" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\prefs.js" + if exist "%USERPROFILE%/Desktop/Tor Browser/Browser/firefox.exe" ( start "i2pbrowser" "%USERPROFILE%/Desktop/Tor Browser/Browser/firefox.exe" -no-remote -profile "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p" -url %1 exit diff --git a/src/win/i2pconfig.bat b/src/win/i2pconfig.bat index 744105f..b66e1c5 100644 --- a/src/win/i2pconfig.bat +++ b/src/win/i2pconfig.bat @@ -16,12 +16,15 @@ if exist "%LocalAppData%\I2P\I2P.exe" ( if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p\" ( echo "profile is configured" - xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\extensions" + xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.config.i2p\extensions" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p\extensions" ) else ( echo "configuring profile" xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.config.i2p" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p" ) +xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.config.i2p\user.js" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p\user.js" +xcopy /s /i /y "%I2PPath%\I2PBrowser-Launcher\firefox.profile.config.i2p\prefs.js" "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p\prefs.js" + if exist "%ProgramFiles%\Mozilla Firefox\firefox.exe" ( start "i2pbrowser" "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -profile "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.config.i2p" -url %1 exit From 4ce272765f171e5baef82ff785fe93bdefd3a33f Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 18:47:48 -0400 Subject: [PATCH 31/33] check if the console is up before continuing --- changelog.txt | 1 + java/net/i2p/router/WinLauncher.java | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/changelog.txt b/changelog.txt index 335fbda..7c618b6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ * On restart to update, will detect if a router requires admin rights to install and will ask the user to authorize the update. In user-mode, no prompt will ever be seen. + * Updates to the Firefox profiles to improve compatibility with more Firefoxes 2022-02-10 idk * This release fixes automatic update using Bittorrent within the I2P network diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 61fe6c2..2f1f9f9 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -1,6 +1,8 @@ package net.i2p.router; import java.io.*; +import java.net.InetAddress; +import java.net.Socket; import java.util.*; import net.i2p.crypto.*; @@ -49,6 +51,12 @@ public class WinLauncher { System.out.println("\t" + System.getProperty("i2p.dir.base") + "\n\t" + System.getProperty("i2p.dir.config") + "\n\t" + System.getProperty("router.pid")); + // do a quick check to see of port 7657 is already occupied + if (i2pIsRunning()) { + System.err.println("I2P is already running"); + System.exit(0); + } + // wupp.i2pRouter = new Router(System.getProperties()); System.out.println("Router is configured"); @@ -61,6 +69,18 @@ public class WinLauncher { RouterLaunch.main(args); } + private static boolean i2pIsRunning() { + // check if there's something listening on port 7657 + try { + InetAddress localhost = InetAddress.getLocalHost(); + Socket s = new Socket(localhost, 7657); + s.close(); + return true; + } catch (IOException e) { + return false; + } + } + private static final Runnable REGISTER_UPP = () -> { // first wait for the RouterContext to appear From 74d5ccc47f40a1ce199fdbcd77e9b7fd80665177 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 25 Mar 2022 18:51:11 -0400 Subject: [PATCH 32/33] cd before starting a jpackaged router from the script in case the environment is overriding it --- src/win/i2pbrowser-private.bat | 1 + src/win/i2pbrowser.bat | 1 + 2 files changed, 2 insertions(+) diff --git a/src/win/i2pbrowser-private.bat b/src/win/i2pbrowser-private.bat index 79a4bc0..bbdd2b9 100644 --- a/src/win/i2pbrowser-private.bat +++ b/src/win/i2pbrowser-private.bat @@ -15,6 +15,7 @@ if exist "%LocalAppData%\I2P\I2P.exe" ( ) if exist "%I2PPath%\jpackaged" ( + cd "%LOCALAPPDATA%\I2P" start "i2p" /D "%LOCALAPPDATA%\I2P" "%I2PPath%\i2p.exe" ) else ( start "i2p" "%I2PPath%\i2p.exe" diff --git a/src/win/i2pbrowser.bat b/src/win/i2pbrowser.bat index 477e55a..aaca3f7 100644 --- a/src/win/i2pbrowser.bat +++ b/src/win/i2pbrowser.bat @@ -15,6 +15,7 @@ if exist "%LocalAppData%\I2P\I2P.exe" ( ) if exist "%I2PPath%\jpackaged" ( + cd "%LOCALAPPDATA%\I2P" start "i2p" /D "%LOCALAPPDATA%\I2P" "%I2PPath%\i2p.exe" ) else ( start "i2p" "%I2PPath%\i2p.exe" From e051d4095c87622e33ee0d73c8de467a41cb7c5e Mon Sep 17 00:00:00 2001 From: idk Date: Thu, 7 Apr 2022 20:34:51 -0400 Subject: [PATCH 33/33] add use_system_colors to the prefs.js and user.js files --- src/app-profile/prefs.js | 1 + src/app-profile/user.js | 3 ++- src/profile/prefs.js | 3 ++- src/profile/user.js | 3 ++- src/win/i2pbrowser.bat | 3 --- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app-profile/prefs.js b/src/app-profile/prefs.js index 11e8061..233e2d3 100644 --- a/src/app-profile/prefs.js +++ b/src/app-profile/prefs.js @@ -60,3 +60,4 @@ user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); user_pref("media.navigator.enabled", false); user_pref("dom.w3c_touch_events.enabled", false); +user_pref("browser.display.use_system_colors", false); \ No newline at end of file diff --git a/src/app-profile/user.js b/src/app-profile/user.js index 8f5596f..45fbbba 100644 --- a/src/app-profile/user.js +++ b/src/app-profile/user.js @@ -220,4 +220,5 @@ user_pref("webgl.disable-extensions", true); user_pref("webgl.min_capability_mode", true); user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); -user_pref("dom.w3c_touch_events.enabled", false); \ No newline at end of file +user_pref("dom.w3c_touch_events.enabled", false); +user_pref("browser.display.use_system_colors", false); \ No newline at end of file diff --git a/src/profile/prefs.js b/src/profile/prefs.js index 48bf864..8e4163e 100644 --- a/src/profile/prefs.js +++ b/src/profile/prefs.js @@ -58,4 +58,5 @@ user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); user_pref("media.navigator.enabled", false); user_pref("dom.w3c_touch_events.enabled", false); -user_pref("browser.privatebrowsing.autostart", false); \ No newline at end of file +user_pref("browser.privatebrowsing.autostart", false); +user_pref("browser.display.use_system_colors", false); \ No newline at end of file diff --git a/src/profile/user.js b/src/profile/user.js index a15ef1e..f6d2f77 100644 --- a/src/profile/user.js +++ b/src/profile/user.js @@ -224,4 +224,5 @@ user_pref("webgl.min_capability_mode", true); user_pref("webgl.disable-fail-if-major-performance-caveat", true); user_pref("webgl.enable-webgl2", false); user_pref("dom.w3c_touch_events.enabled", false); -user_pref("browser.privatebrowsing.autostart", false); \ No newline at end of file +user_pref("browser.privatebrowsing.autostart", false); +user_pref("browser.display.use_system_colors", false); \ No newline at end of file diff --git a/src/win/i2pbrowser.bat b/src/win/i2pbrowser.bat index 511e6f3..aaca3f7 100644 --- a/src/win/i2pbrowser.bat +++ b/src/win/i2pbrowser.bat @@ -21,9 +21,6 @@ if exist "%I2PPath%\jpackaged" ( start "i2p" "%I2PPath%\i2p.exe" ) - - - timeout /t 3 if exist "%LOCALAPPDATA%\I2PBrowser-Launcher\firefox.profile.i2p\" (