diff --git a/browser.config b/browser.config index f45ab65..ebf70c7 100644 --- a/browser.config +++ b/browser.config @@ -1,5 +1,5 @@ -#Chromium Configuration Section -#Sat Oct 22 20:12:30 EDT 2022 +#Firefox Configuration Section +#Sat Oct 22 20:54:51 EDT 2022 chromium.bins.osx=ungoogled-chromium,chromium,brave,edge,ungoogled-chromium,chrome chromium.bins.windows=ungoogled-chromium.exe,chromium.exe,brave.exe,edge.exe,ungoogled-chromium.exe,chrome.exe firefox.bins.windows=firefox.exe,firefox-bin.exe,firefox-esr.exe,waterfox.exe,waterfox-bin.exe,librewolf.exe @@ -11,4 +11,5 @@ chromium.bins.linux=ungoogled-chromium,chromium,brave,edge,ungoogled-chromium,ch firefox.bins.osx=firefox,firefox-bin,firefox-esr,waterfox,waterfox-bin,librewolf chromium.paths.osx=/Applications/Chromium.app/Contents/MacOS,/Applications/Chrome.app/Contents/MacOS,/Applications/Brave.app/Contents/MacOS chromium.paths.linux=/usr/bin,/usr/local/bin,/opt/chromium/bin,/snap/bin +generic.bins.unix=sensible-browser,xdg-open,x-www-browser,gnome-www-browser,defaultbrowser,dillo,seamonkey,konqueror,galeon,surf,www-browser,links,lynx firefox.paths.linux=/usr/bin,/usr/local/bin,/opt/firefox/bin,/snap/bin diff --git a/src/java/net/i2p/i2pfirefox/I2PBrowser.java b/src/java/net/i2p/i2pfirefox/I2PBrowser.java index e7235bd..55693dc 100644 --- a/src/java/net/i2p/i2pfirefox/I2PBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PBrowser.java @@ -30,7 +30,7 @@ public class I2PBrowser extends I2PCommonBrowser { public boolean generic = false; public boolean chromiumFirst = false; public boolean usability = false; - static private boolean outputConfig = false; + static private boolean outputConfig = true; private void launchFirefox(int privateWindow, String[] url) { logger.info("I2PFirefox" + privateWindow); @@ -50,6 +50,8 @@ public class I2PBrowser extends I2PCommonBrowser { boolean privateWindow = false; if (privateWindowInt == 1) privateWindow = true; + if (outputConfig) + i2pGeneral.storeGenericDefaults(); logger.info("I2PGeneric" + privateWindowInt); i2pGeneral.launch(privateWindow, url); } @@ -209,6 +211,9 @@ public class I2PBrowser extends I2PCommonBrowser { if (arg.equals("-usability")) { i2pBrowser.usability = true; } + if (arg.equals("-generic")) { + i2pBrowser.generic = true; + } if (arg.equals("-app")) { i2pBrowser.usability = true; privateBrowsing = 2; diff --git a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java index e9c689b..364668a 100644 --- a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java @@ -9,6 +9,7 @@ import java.io.OutputStream; import java.net.Socket; import java.nio.file.Files; import java.nio.file.StandardCopyOption; +import java.util.Arrays; import java.util.Properties; import java.util.logging.FileHandler; import java.util.logging.Logger; diff --git a/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java b/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java index ae9c608..4431294 100644 --- a/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java @@ -1,10 +1,15 @@ package net.i2p.i2pfirefox; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.net.Socket; import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Scanner; +import java.util.stream.Collectors; /** * I2PChromiumProfileChecker.java @@ -57,6 +62,20 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { "www-browser", "links", "lynx"}; } + public static void storeGenericDefaults() { + List list = new ArrayList(); + + list = Arrays.asList(browsers()); + prop.setProperty("generic.bins.unix", + list.stream().collect(Collectors.joining(","))); + try (OutputStream fos = new FileOutputStream( + new File(runtimeDirectory(""), "browser.config"))) { + prop.store(fos, "Chromium Configuration Section"); + } catch (IOException ioe) { + logger.warning(ioe.toString()); + } + } + /** * Obtains the default browser for the Windows platform, which by now should * be Edgium in the worst-case scenario but in case it isn't, we can use this diff --git a/test.sh b/test.sh index 8ae65ea..bb267bb 100755 --- a/test.sh +++ b/test.sh @@ -82,15 +82,15 @@ sleep 2s rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile echo "Testing UNSAFE auto-selector with no private and no URL parameters." -java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PGenericUnsafeBrowser 2> gen.0.err 1> gen.0.log +java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PBrowser -generic 2> gen.0.err 1> gen.0.log echo "Testing UNSAFE auto-selector with local URL parameter." -java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PGenericUnsafeBrowser "http://127.0.0.1:7657" 2> gen.1.err 1> gen.1.log +java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PBrowser -generic "http://127.0.0.1:7657" 2> gen.1.err 1> gen.1.log echo "Testing UNSAFE auto-selector with remote URL parameter." -java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PGenericUnsafeBrowser "http://idk.i2p" 2> gen.2.err 1> gen.2.log +java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PBrowser -generic "http://idk.i2p" 2> gen.2.err 1> gen.2.log echo "Testing UNSAFE auto-selector with remote AND local URL parameter." -java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PGenericUnsafeBrowser "http://127.0.0.1:7657" "http://idk.i2p" 2> gen.3.err 1> gen.3.log +java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PBrowser -generic "http://127.0.0.1:7657" "http://idk.i2p" 2> gen.3.err 1> gen.3.log echo "Testing UNSAFE auto-selector with private browsing parameter" -java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PGenericUnsafeBrowser -private "http://127.0.0.1:7657" 2> gen.4.err 1> gen.4.log +java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PBrowser -generic -private "http://127.0.0.1:7657" 2> gen.4.err 1> gen.4.log echo "UNSAFE browser tests complete"