From 5559000ccc748528c0524acaa4f486ecfaadb85d Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 7 Aug 2022 02:00:32 -0400 Subject: [PATCH] screw batchfiles --- CHANGES.md | 0 LICENSE.md | 46 +++ README.md | 2 +- build.xml | 103 ++++++ plugin/LICENSE.txt | 0 plugin/clients.config | 8 + plugin/templates/contexts/base-context.xml | 23 ++ plugin/templates/contexts/cgi-context.xml | 36 ++ plugin/templates/etc/realm.properties | 21 ++ plugin/templates/etc/webdefault.xml | 408 +++++++++++++++++++++ plugin/templates/help.html | 360 ++++++++++++++++++ plugin/templates/index.html | 25 ++ plugin/templates/jetty.xml | 293 +++++++++++++++ scripts/build.number | 3 + scripts/favicon.png | Bin 0 -> 1705 bytes scripts/firefox-purple.css | 235 ++++++++++++ scripts/firefox.css | 247 +++++++++++++ scripts/i2pfirefox.config | 3 + scripts/i2ptunnel.config | 41 +++ scripts/makeplugin.sh | 147 ++++++++ scripts/plugin.config | 14 + scripts/robots.txt | 2 + src/build.xml | 102 ++++++ src/java/net/I2PFirefox.java | 246 +++++++++++++ src/java/net/I2PFirefoxProfileBuilder.java | 151 ++++++++ src/java/net/I2PFirefoxProfileChecker.java | 96 +++++ src/jsp/WEB-INF/web.xml | 50 +++ src/jsp/index.jsp | 23 ++ 28 files changed, 2684 insertions(+), 1 deletion(-) create mode 100644 CHANGES.md create mode 100644 LICENSE.md create mode 100644 build.xml create mode 100644 plugin/LICENSE.txt create mode 100644 plugin/clients.config create mode 100644 plugin/templates/contexts/base-context.xml create mode 100644 plugin/templates/contexts/cgi-context.xml create mode 100644 plugin/templates/etc/realm.properties create mode 100644 plugin/templates/etc/webdefault.xml create mode 100644 plugin/templates/help.html create mode 100644 plugin/templates/index.html create mode 100644 plugin/templates/jetty.xml create mode 100644 scripts/build.number create mode 100644 scripts/favicon.png create mode 100644 scripts/firefox-purple.css create mode 100644 scripts/firefox.css create mode 100644 scripts/i2pfirefox.config create mode 100644 scripts/i2ptunnel.config create mode 100755 scripts/makeplugin.sh create mode 100644 scripts/plugin.config create mode 100644 scripts/robots.txt create mode 100644 src/build.xml create mode 100644 src/java/net/I2PFirefox.java create mode 100644 src/java/net/I2PFirefoxProfileBuilder.java create mode 100644 src/java/net/I2PFirefoxProfileChecker.java create mode 100644 src/jsp/WEB-INF/web.xml create mode 100644 src/jsp/index.jsp diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7acbc21 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,46 @@ + Copyright 2022 idk (hankhill19580@gmail.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ======================================================================== + Includes code from zzzot: + + Copyright 2010 zzz (zzz@mail.i2p) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ======================================================================== + Includes code from Jetty 5.1.15: + + Copyright 199-2004 Mort Bay Consulting Pty. Ltd. + ------------------------------------------------------------------------ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.md b/README.md index 692d12b..5039c82 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Within a particular ecosystem, there may be a common way of installing things, s Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. ## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. +Tell people where they can go to for help. It can be any combination of an issue firefox, a chat room, an email address, etc. ## Roadmap If you have ideas for releases in the future, it is a good idea to list them in the README. diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..76b3450 --- /dev/null +++ b/build.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugin/LICENSE.txt b/plugin/LICENSE.txt new file mode 100644 index 0000000..e69de29 diff --git a/plugin/clients.config b/plugin/clients.config new file mode 100644 index 0000000..39d99e6 --- /dev/null +++ b/plugin/clients.config @@ -0,0 +1,8 @@ +clientApp.0.main=net.i2p.i2pfirefox.I2PFirefoxController +clientApp.0.name=I2PFirefox +clientApp.0.args=-d $PLUGIN start +clientApp.0.stopargs=-d $PLUGIN stop +clientApp.0.delay=0 +clientApp.0.startOnLoad=true +# we also use i2p.jar and i2ptunnel.jar, they are in the standard router classpath +clientApp.0.classpath=$PLUGIN/lib/i2pfirefox.jar,$I2P/lib/i2psnark.jar diff --git a/plugin/templates/contexts/base-context.xml b/plugin/templates/contexts/base-context.xml new file mode 100644 index 0000000..8fec760 --- /dev/null +++ b/plugin/templates/contexts/base-context.xml @@ -0,0 +1,23 @@ + + + + + + + / + $PLUGIN/eepsite/docroot/ + + cacheControl + max-age=3600,public + + + net.i2p.servlet.I2PDefaultServlet + / + + + diff --git a/plugin/templates/contexts/cgi-context.xml b/plugin/templates/contexts/cgi-context.xml new file mode 100644 index 0000000..33377db --- /dev/null +++ b/plugin/templates/contexts/cgi-context.xml @@ -0,0 +1,36 @@ + + + + + + + /cgi-bin + $PLUGIN/eepsite/cgi-bin/ + + Path + /usr/local/bin:/bin:/usr/bin + + + org.eclipse.jetty.servlets.CGI + / + + diff --git a/plugin/templates/etc/realm.properties b/plugin/templates/etc/realm.properties new file mode 100644 index 0000000..f9e4e7f --- /dev/null +++ b/plugin/templates/etc/realm.properties @@ -0,0 +1,21 @@ +# +# This file defines users passwords and roles for a HashUserRealm +# +# The format is +# : [, ...] +# +# Passwords may be clear text, obfuscated or checksummed. The class +# org.mortbay.util.Password should be used to generate obfuscated +# passwords or password checksums +# +# If DIGEST Authentication is used, the password must be in a recoverable +# format, either plain text or OBF:. +# +jetty: MD5:164c88b302622e17050af52c89945d44,user +admin: CRYPT:ad1ks..kc.1Ug,server-administrator,content-administrator,admin +other: OBF:1xmk1w261u9r1w1c1xmq +plain: plain +user: password + +# This entry is for digest auth. The credential is a MD5 hash of username:realmname:password +digest: MD5:6e120743ad67abfbc385bc2bb754e297 diff --git a/plugin/templates/etc/webdefault.xml b/plugin/templates/etc/webdefault.xml new file mode 100644 index 0000000..d0a6f4b --- /dev/null +++ b/plugin/templates/etc/webdefault.xml @@ -0,0 +1,408 @@ + + + + + + + + + + + + + + + + + + + + + + + Default web.xml file. + This file is applied to a Web application before it's own WEB_INF/web.xml file + + + + + + + + + + org.eclipse.jetty.webapp.NoTLDJarPattern + start.jar|ant-.*\.jar|dojo-.*\.jar|jetty-.*\.jar|jsp-api-.*\.jar|junit-.*\.jar|servlet-api-.*\.jar|dnsns\.jar|rt\.jar|jsse\.jar|tools\.jar|sunpkcs11\.jar|sunjce_provider\.jar|xerces.*\.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default + org.eclipse.jetty.servlet.DefaultServlet + + acceptRanges + true + + + dirAllowed + true + + + welcomeServlets + false + + + redirectWelcome + false + + + maxCacheSize + 256000000 + + + maxCachedFileSize + 10000000 + + + maxCachedFiles + 1000 + + + cacheType + both + + + gzip + true + + + useFileMappedBuffer + true + + + cacheControl + max-age=3600,public + + 0 + + + default / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jsp + org.apache.jasper.servlet.JspServlet + + logVerbosityLevel + DEBUG + + + fork + false + + + xpoweredBy + false + + + 0 + + + + jsp + *.jsp + *.jspf + *.jspx + *.xsp + *.JSP + *.JSPF + *.JSPX + *.XSP + + + + + + + + + + + + + + + + + + + + + + + + + + + + 30 + + + + + + + + + + + + + index.html + index.htm + index.jsp + + + + + arISO-8859-6 + beISO-8859-5 + bgISO-8859-5 + caISO-8859-1 + csISO-8859-2 + daISO-8859-1 + deISO-8859-1 + elISO-8859-7 + enISO-8859-1 + esISO-8859-1 + etISO-8859-1 + fiISO-8859-1 + frISO-8859-1 + hrISO-8859-2 + huISO-8859-2 + isISO-8859-1 + itISO-8859-1 + iwISO-8859-8 + jaShift_JIS + koEUC-KR + ltISO-8859-2 + lvISO-8859-2 + mkISO-8859-5 + nlISO-8859-1 + noISO-8859-1 + plISO-8859-2 + ptISO-8859-1 + roISO-8859-2 + ruISO-8859-5 + shISO-8859-5 + skISO-8859-2 + slISO-8859-2 + sqISO-8859-2 + srISO-8859-5 + svISO-8859-1 + trISO-8859-9 + ukISO-8859-5 + zhGB2312 + zh_TWBig5 + + + + + Disable TRACE + / + TRACE + + + + + + diff --git a/plugin/templates/help.html b/plugin/templates/help.html new file mode 100644 index 0000000..c001625 --- /dev/null +++ b/plugin/templates/help.html @@ -0,0 +1,360 @@ + + + + + + I2P Firefox | HELP + + + + + +
+ +
+ + + diff --git a/plugin/templates/index.html b/plugin/templates/index.html new file mode 100644 index 0000000..ddf6d83 --- /dev/null +++ b/plugin/templates/index.html @@ -0,0 +1,25 @@ + + + + + + + I2P Firefox + + + + + +
+
+ i2pfirefox + $B32 +
+
+ + + diff --git a/plugin/templates/jetty.xml b/plugin/templates/jetty.xml new file mode 100644 index 0000000..ad56ae7 --- /dev/null +++ b/plugin/templates/jetty.xml @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 20 + 3 + 60000 + + + 50 + + + 4 + 20 + 60000 + true + I2PFirefox Jetty + + + + + + + + + + + + + + + + + 1 + 0 + + + + + + + false + true + + + + + + + 127.0.0.1 + 7662 + 600000 + + + + + + + + + + + + + + + + + + + + true + false + requestedPath + + + + + /help + /help.html + + + + + /help/ + /help.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern + .*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$ + + + + + + + + + + + + + + + + + + + + + $PLUGIN/contexts + 120 + + + + + + + + + + + + + + + + + + + + + + + $PLUGIN/eepsite/webapps + false + false + $PLUGIN/etc/webdefault.xml + + + + + + + + + + + + + + + + + + + + + + + + + $PLUGIN/eepsite/logs/yyyy_mm_dd.request.log + yyyy_MM_dd + 90 + true + false + false + GMT + + + + + + + + true + 1000 + + diff --git a/scripts/build.number b/scripts/build.number new file mode 100644 index 0000000..0994948 --- /dev/null +++ b/scripts/build.number @@ -0,0 +1,3 @@ +#Build Number for ANT. Do not edit! +#Sun Aug 07 01:58:20 EDT 2022 +build.number=24 diff --git a/scripts/favicon.png b/scripts/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..ae712dc4ae7c1bce21c6d48e194ac83ad8a20d32 GIT binary patch literal 1705 zcmchY`#01H0L5p#hIyHp=KEz-Mxxln5P1~F?upH8Ve?8S?S?cS5t)o-d{=E^ZTnB`J?Gxfxj)|@ZjLv@1%uQ(2Pk_ri{1ZXH>5b#)Aq%KZ*4^|1M0XGI! z*787^5crb~JPybIRU?dHkI)Y_>f* z++5?kgK8g=fh7*`J_?x1AkIb-$5M8Uad!=K2$D1S9wxqniEs76l?Gz3x?o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1AB%WNL+a;@OvX&&v4rTKxESN7{xqLBJUt{G0ZhWW0Wt%8jRR+Lw#%fqF#(P8f0 rze2vL> $PCT +mv $PCT $PC || exit 1 + +# add our Base64 key +grep -v '^key=' $PC > $PCT +B64KEY=`cat $B64KEYFILE` +echo "key=$B64KEY" >> $PCT || exit 1 +mv $PCT $PC || exit 1 + +# zip it +zip -r $OPWD/plugin.zip * || exit 1 + +# get the version and use it for the sud header +VERSION=`grep '^version=' $PC | cut -f 2 -d '='` +# get the name and use it for the file name +NAME=`grep '^name=' $PC | cut -f 2 -d '='` +XPI2P=${NAME}.xpi2p +SU3=${NAME}.su3 +cd $OPWD + +# sign it +echo 'Signing. ...' +java -cp $I2P/lib/i2p.jar net.i2p.crypto.TrustedUpdate sign plugin.zip $XPI2P $PRIVKEYFILE $VERSION || exit 1 +java -cp $I2P/lib/i2p.jar net.i2p.crypto.SU3File sign -c PLUGIN -t $KEYTYPE plugin.zip $SU3 $PRIVKEYSTORE $VERSION $SIGNER || exit 1 +rm -f plugin.zip + +# verify +echo 'Verifying. ...' +java -cp $I2P/lib/i2p.jar net.i2p.crypto.TrustedUpdate showversion $XPI2P || exit 1 +java -cp $I2P/lib/i2p.jar -Drouter.trustedUpdateKeys=$B64KEY net.i2p.crypto.TrustedUpdate verifysig $XPI2P || exit 1 +java -cp $I2P/lib/i2p.jar net.i2p.crypto.SU3File showversion $SU3 || exit 1 +java -cp $I2P/lib/i2p.jar net.i2p.crypto.SU3File verifysig -k $PUBKEYSTORE $SU3 || exit 1 +rm -rf logs/ + +echo 'Plugin files created: ' +wc -c $XPI2P +wc -c $SU3 + +exit 0 diff --git a/scripts/plugin.config b/scripts/plugin.config new file mode 100644 index 0000000..0f6fcb6 --- /dev/null +++ b/scripts/plugin.config @@ -0,0 +1,14 @@ +name=i2pfirefox +signer=idki2p@mail.i2p +consoleLinkName=I2PFirefox +consoleLinkURL=http://127.0.0.1:7662/firefox/ +consoleLinkTooltip=Firefox process manager for I2P +icon-code=iVB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n5ZYHqG8WmER4GuN-dWhEYq4Ull7txXG2izdd3nobbZ8sF8LJBGZE4JcY6CrYavsAt98lcA0kLb8ZCofDw8sSor4DLqfbVutbZd76Nvrc~6P51tt~v97-t1i3~38A57d5M52iLPcAAAAASUVORK5CYII= +description=Firefox process manager for I2P +author=idk +updateURL=http://idk.i2p/i2p.plugins.firefox/plugins/i2pfirefox-update.xpi2p +updateURL.su3=http://idk.i2p/i2p.plugins.firefox/plugins/i2pfirefox-update.su3 +websiteURL=http://idk.i2p/i2p.plugins.firefox/ +license=Apache 2.0 +min-jetty-version=9 +min-i2p-version=0.9.31 diff --git a/scripts/robots.txt b/scripts/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/scripts/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/src/build.xml b/src/build.xml new file mode 100644 index 0000000..4ee0ad5 --- /dev/null +++ b/src/build.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/net/I2PFirefox.java b/src/java/net/I2PFirefox.java new file mode 100644 index 0000000..1feaa88 --- /dev/null +++ b/src/java/net/I2PFirefox.java @@ -0,0 +1,246 @@ +package net; + +import java.io.File; +import java.util.ArrayList; + +public class I2PFirefox { + private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER(); + + I2PFirefox() { + for (String path : FIREFOX_SEARCH_PATHS) { + File f = new File(path); + if (f.exists()) { + System.out.println("Found Firefox at " + path); + return; + } + } + + } + + private static String[] FIND_FIREFOX_SEARCH_PATHS_UNIX(){ + String[] path = new String[]{"/usr/bin", "/usr/local/bin", "/opt/firefox/bin","/snap/bin"}; + String[] exes = new String[]{"firefox", "firefox-bin", "firefox-esr", "waterfox", "waterfox-bin", "librewolf"}; + String[] exePath = new String[path.length * exes.length]; + int i = 0; + for (String s : path) { + for (String exe : exes) { + exePath[i] = s + "/" + exe; + i++; + } + } + return exePath; + } + private static String[] FIND_FIREFOX_SEARCH_PATHS_OSX() { + String[] path = new String[]{"/Applications/Firefox.app/Contents/MacOS/", "/Applications/Waterfox.app/Contents/MacOS/", "/Applications/Librewolf.app/Contents/MacOS/"}; + String[] exes = new String[]{"firefox", "firefox-bin", "firefox-esr", "waterfox", "waterfox-bin", "librewolf"}; + String[] exePath = new String[path.length * exes.length]; + int i = 0; + for (String s : path) { + for (String exe : exes) { + exePath[i] = s + "/" + exe; + i++; + } + } + return exePath; + } + private static String[] FIND_FIREFOX_SEARCH_PATHS_WINDOWS() { + String[] path = new String[]{"C:/Program Files/Mozilla Firefox/", "C:/Program Files (x86)/Mozilla Firefox/", "C:/Program Files/Waterfox/", "C:/Program Files (x86)/Waterfox/", "C:/Program Files/Librewolf/"}; + String[] exes = new String[]{"firefox.exe", "firefox-bin.exe", "firefox-esr.exe", "waterfox.exe", "waterfox-bin.exe", "librewolf.exe"}; + String[] exePath = new String[path.length * exes.length]; + int i = 0; + for (String s : path) { + for (String exe : exes) { + exePath[i] = s + exe; + i++; + } + } + return exePath; + } + + private static String[] FIND_ALL_FIREFOX_SEARCH_PATHS() { + String[] Unix = FIND_FIREFOX_SEARCH_PATHS_UNIX(); + String[] Windows = FIND_FIREFOX_SEARCH_PATHS_WINDOWS(); + String[] Mac = FIND_FIREFOX_SEARCH_PATHS_OSX(); + String[] exePath = new String[Unix.length + Windows.length + Mac.length]; + int i = 0; + for (String s : Unix) { + exePath[i] = s; + i++; + } + for (String s : Windows) { + exePath[i] = s; + i++; + } + for (String s : Mac) { + exePath[i] = s; + i++; + } + return exePath; + } + + private static String[] FIND_FIREFOX_SEARCH_PATHS() { + switch (getOperatingSystem()) { + case "Windows": + return FIND_FIREFOX_SEARCH_PATHS_WINDOWS(); + case "Linux": + return FIND_FIREFOX_SEARCH_PATHS_UNIX(); + case "Mac": + return FIND_FIREFOX_SEARCH_PATHS_OSX(); + case "BSD": + return FIND_FIREFOX_SEARCH_PATHS_UNIX(); + default: + return FIND_ALL_FIREFOX_SEARCH_PATHS(); + } + } + + private static String[] NEARBY_FIREFOX_SEARCH_PATHS() { + // obtain the PLUGIN environment variable + String plugin = System.getenv("PLUGIN"); + // search the plugin directory for anything named "firefox", "firefox-bin", "firefox-esr", "waterfox", "waterfox-bin", "librewolf" + // up to a depth of 2 directories deep. + // list the directories in the plugin directory + File pluginDir = new File(plugin); + if (pluginDir.exists()) { + File[] pluginDirs = pluginDir.listFiles(); + // list the files in the plugin directory + for (File pluginDir1 : pluginDirs) { + File[] pluginFiles = pluginDir1.listFiles(); + // list the files in the plugin directory + for (File pluginFile : pluginFiles) { + if (pluginFile.getName().equals("firefox") || pluginFile.getName().equals("firefox-bin") || pluginFile.getName().equals("firefox-esr") || pluginFile.getName().equals("waterfox") || pluginFile.getName().equals("waterfox-bin") || pluginFile.getName().equals("librewolf")) { + return new String[]{pluginFile.getAbsolutePath()}; + } + } + } + } + // now, do the same thing, but with user.dir instead of plugin + // list the directories in the user.dir directory + File userDir = new File(System.getProperty("user.dir")); + if (userDir.exists()) { + File[] userDirs = userDir.listFiles(); + // list the files in the user.dir directory + for (File userDir1 : userDirs) { + File[] userFiles = userDir1.listFiles(); + // list the files in the user.dir directory + for (File userFile : userFiles) { + if (userFile.getName().equals("firefox") || userFile.getName().equals("firefox-bin") || userFile.getName().equals("firefox-esr") || userFile.getName().equals("waterfox") || userFile.getName().equals("waterfox-bin") || userFile.getName().equals("librewolf")) { + return new String[]{userFile.getAbsolutePath()}; + } + } + } + } + return new String[]{}; + } + + private static String[] FIREFOX_FINDER() { + String[] nearby = NEARBY_FIREFOX_SEARCH_PATHS(); + String[] all = FIND_FIREFOX_SEARCH_PATHS(); + if (nearby.length > 0) { + return nearby; + } else if (all.length > 0) { + return all; + } else { + return new String[]{}; + } + } + + private static String getOperatingSystem() { + String os = System.getProperty("os.name"); + if (os.startsWith("Windows")) { + return "Windows"; + } else if (os.contains("Linux")) { + return "Linux"; + } else if (os.contains("BSD")) { + return "BSD"; + } else if (os.contains("Mac")) { + return "Mac"; + } + return "Unknown"; + } + + public String[] OnlyValidFirefoxes() { + String[] firefoxes = FIREFOX_FINDER(); + ArrayList validFirefoxes = new ArrayList(); + for (String firefox : firefoxes) { + File firefoxFile = new File(firefox); + if (firefoxFile.exists()) { + validFirefoxes.add(firefox); + } + } + return validFirefoxes.toArray(new String[validFirefoxes.size()]); + } + + public String TopFirefox() { + // get the FIREFOX environment variable + String firefox = System.getenv("FIREFOX"); + // if it is not null and not empty + if (firefox != null && !firefox.isEmpty()) { + // check if the file exists + File firefoxFile = new File(firefox); + if (firefoxFile.exists()) { + // if it does, return it + return firefox; + } + } + String[] firefoxes = OnlyValidFirefoxes(); + if (firefoxes.length > 0) { + return firefoxes[0]; + } else { + return ""; + } + } + public String TopFirefox(String overrideFirefox) { + if (overrideFirefox != null && !overrideFirefox.isEmpty()) { + File firefoxFile = new File(overrideFirefox); + if (firefoxFile.exists()) { + return overrideFirefox; + } + } + return TopFirefox(); + } + + public ProcessBuilder defaultProcessBuilder() { + return processBuilder(new String[]{}); + } + + public ProcessBuilder processBuilder(String[] args) { + String firefox = TopFirefox(); + if (!firefox.isEmpty()) { + String[] newArgs = new String[args.length+2]; + newArgs[0] = firefox; + newArgs[1] = "--profile"; + newArgs[2] = I2PFirefoxProfileBuilder.profileDirectory(); + for (int i = 0; i < args.length; i++) { + newArgs[i+3] = args[i]; + } + return new ProcessBuilder(newArgs).directory(I2PFirefoxProfileBuilder.RuntimeDirectory(true)); + } else { + return new ProcessBuilder(args); + } + } + + public static void main(String[] args) { + System.out.println("I2PFirefox"); + I2PFirefox i2pFirefox = new I2PFirefox(); + String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory(); + if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) { + System.out.println("Valid profile directory: "+profileDirectory); + } else { + System.out.println("Invalid profile directory: "+profileDirectory+" rebuilding..."); + if (!I2PFirefoxProfileBuilder.CopyBaseProfiletoProfile()) { + System.out.println("Failed to rebuild profile directory: "+profileDirectory); + return; + } else { + System.out.println("Rebuilt profile directory: "+profileDirectory); + } + } + ProcessBuilder pb = i2pFirefox.defaultProcessBuilder(); + try{ + pb.start(); + }catch(Exception e){ + System.out.println("Error: "+e.getMessage()); + }finally{ + System.out.println("I2PFirefox"); + } + } +} diff --git a/src/java/net/I2PFirefoxProfileBuilder.java b/src/java/net/I2PFirefoxProfileBuilder.java new file mode 100644 index 0000000..b7db2fc --- /dev/null +++ b/src/java/net/I2PFirefoxProfileBuilder.java @@ -0,0 +1,151 @@ +package net; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; + +public class I2PFirefoxProfileBuilder { + private static boolean strict; + + private static String profileDir(String file) { + File profileDir = new File(file, "i2p.firefox.profile"); + // make sure the directory exists + if (profileDir.exists()) { + return profileDir.getAbsolutePath(); + } else { + // create the directory + profileDir.mkdir(); + return profileDir.getAbsolutePath(); + } + } + + public static String profileDirectory() { + String rtd = RuntimeDirectory(); + return profileDir(rtd); + } + + private static String baseProfileDir(String file) { + File profileDir = new File(file, "i2p.firefox.base.profile"); + // make sure the directory exists + if (profileDir.exists()) { + return profileDir.getAbsolutePath(); + } else { + // create the directory + profileDir.mkdir(); + return profileDir.getAbsolutePath(); + } + } + + public static String baseProfileDirectory() { + String rtd = RuntimeDirectory(); + return baseProfileDir(rtd); + } + + public static File RuntimeDirectory(boolean create) { + String rtd = RuntimeDirectory(); + File rtdFile = new File(rtd); + if (create) { + if (!rtdFile.exists()) { + rtdFile.mkdir(); + } + } + return new File(rtd); + } + + public static String RuntimeDirectory() { + // get the I2P_FIREFOX_DIR environment variable + String rtd = System.getenv("I2P_FIREFOX_DIR"); + // if it is not null and not empty + if (rtd != null && !rtd.isEmpty()) { + // check if the file exists + File rtdFile = new File(rtd); + if (rtdFile.exists()) { + // if it does, return it + return rtd; + } + } + // obtain the PLUGIN environment variable + String plugin = System.getenv("PLUGIN"); + if (plugin != null && !plugin.isEmpty()) { + File pluginDir = new File(plugin); + if (pluginDir.exists()) { + return pluginDir.toString(); + } + } + String userDir = System.getProperty("user.dir"); + if (userDir != null && !userDir.isEmpty()) { + File userDir1 = new File(userDir); + if (userDir1.exists()) { + return userDir1.toString(); + } + } + String homeDir = System.getProperty("user.home"); + if (homeDir != null && !homeDir.isEmpty()) { + File homeDir1 = new File(homeDir+"/.i2p"); + if (homeDir1.exists()) { + return homeDir.toString(); + } + File homeDir2 = new File(homeDir+"/i2p"); + if (homeDir2.exists()) { + return homeDir2.toString(); + } + } + return ""; + } + public static boolean CopyBaseProfiletoProfile() { + String baseProfile = baseProfileDirectory(); + String profile = profileDirectory(); + if (baseProfile.isEmpty() || profile.isEmpty()) { + return false; + } + File baseProfileDir = new File(baseProfile); + File profileDir = new File(profile); + if (!baseProfileDir.exists() || !profileDir.exists()) { + return false; + } + try { + Files.copy(baseProfileDir.toPath(), profileDir.toPath(), StandardCopyOption.REPLACE_EXISTING); + } catch (Exception e) { + System.out.println("Error copying base profile to profile"+e); + return false; + } + if (!CopyStrictOptions()){ + return false; + } + return true; + } + public static boolean CopyStrictOptions() { + if (!strict){ + return true; + } + String baseProfile = baseProfileDirectory(); + String profile = profileDirectory(); + if (baseProfile.isEmpty() || profile.isEmpty()) { + return false; + } + File baseProfileDir = new File(baseProfile); + File profileDir = new File(profile); + if (!baseProfileDir.exists() || !profileDir.exists()) { + return false; + } + File baseOverrides = new File(baseProfile, "strict-overrides.js"); + File userOverrides = new File(baseProfile, "user-overrides.js"); + if (!baseOverrides.exists()) { + return false; + } + try { + Files.copy(baseOverrides.toPath(), userOverrides.toPath(), StandardCopyOption.REPLACE_EXISTING); + } catch (Exception e) { + System.out.println("Error copying base profile to profile"+e); + return false; + } + return true; + } + + I2PFirefoxProfileBuilder() { + I2PFirefoxProfileBuilder.strict = false; + } + I2PFirefoxProfileBuilder(boolean strict) { + I2PFirefoxProfileBuilder.strict = strict; + } +} diff --git a/src/java/net/I2PFirefoxProfileChecker.java b/src/java/net/I2PFirefoxProfileChecker.java new file mode 100644 index 0000000..59a66eb --- /dev/null +++ b/src/java/net/I2PFirefoxProfileChecker.java @@ -0,0 +1,96 @@ +package net; + +import java.io.File; + +public class I2PFirefoxProfileChecker { + public static void main(String[] args) { + String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory(); + if (profileDirectory == null) { + System.out.println("No profile directory found"); + return; + } + System.out.println("Profile directory: " + profileDirectory); + boolean ok = validateProfileDirectory(profileDirectory); + if (ok) { + System.out.println("Profile directory is valid"); + } else { + System.out.println("Profile directory is invalid"); + } + } + public static boolean validateProfileDirectory(String profileDirectory) { + File profileDir = new File(profileDirectory); + if (!profileDir.exists()) { + System.out.println("Profile directory does not exist"); + return false; + } + if (!profileDir.isDirectory()) { + System.out.println("Profile directory is not a directory"); + return false; + } + if (!profileDir.canRead()) { + System.out.println("Profile directory is not readable"); + return false; + } + if (!profileDir.canWrite()) { + System.out.println("Profile directory is not writable"); + return false; + } + if (!validateFile(profileDir+"/prefs.js")){ + System.out.println("prefs.js is not valid"); + return false; + } + if (!validateFile(profileDir+"/user.js")){ + System.out.println("user.js is not valid"); + return false; + } + if (!validateFile(profileDir+"/user-overrides.js")){ + System.out.println("user-overrides.js is not valid"); + return false; + } + if (!validateExtensionDirectory(profileDir+"/extensions")){ + System.out.println("extensions directory is invalid"); + return false; + } + return true; + } + public static boolean validateFile(String file) { + File f = new File(file); + if (!f.exists()) { + System.out.println("User JavaScript file does not exist"); + return false; + } + if (!f.isFile()) { + System.out.println("User JavaScript file is not a file"); + return false; + } + if (!f.canRead()) { + System.out.println("User JavaScript file is not readable"); + return false; + } + if (!f.canWrite()) { + System.out.println("User JavaScript file is not writable"); + return false; + } + return true; + } + public static boolean validateExtensionDirectory(String extensionDirectory) { + File extensionDir = new File(extensionDirectory); + if (!extensionDir.exists()) { + System.out.println("Extension directory does not exist"); + return false; + } + if (!extensionDir.isDirectory()) { + System.out.println("Extension directory is not a directory"); + return false; + } + if (!extensionDir.canRead()) { + System.out.println("Extension directory is not readable"); + return false; + } + if (!extensionDir.canWrite()) { + System.out.println("Extension directory is not writable"); + return false; + } + return true; + } +} diff --git a/src/jsp/WEB-INF/web.xml b/src/jsp/WEB-INF/web.xml new file mode 100644 index 0000000..69660db --- /dev/null +++ b/src/jsp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + + + + index.jsp + + + + net.i2p.i2pfirefox.index_jsp + / + + + + net.i2p.i2pfirefox.index_jsp + /index + + + + net.i2p.i2pfirefox.index_jsp + /index.html + + + + net.i2p.i2pfirefox.announce_jsp + /announce.php + + + + net.i2p.i2pfirefox.announce_jsp + /announce + + + + net.i2p.i2pfirefox.announce_jsp + /a + + + + net.i2p.i2pfirefox.scrape_jsp + /scrape + + + + net.i2p.i2pfirefox.scrape_jsp + /scrape.php + + + diff --git a/src/jsp/index.jsp b/src/jsp/index.jsp new file mode 100644 index 0000000..539887b --- /dev/null +++ b/src/jsp/index.jsp @@ -0,0 +1,23 @@ +<%@page trimDirectiveWhitespaces="true"%> + + + + + +I2P Browser Manager + + + + +
+
+I2P Browser Manager
+

+

+I2P Browser Manager +
+
+ + +