Alter TBB less when it's discovered

This commit is contained in:
eyedeekay
2024-10-18 23:59:30 -04:00
parent b7bbcf4e4b
commit 1bc9894616
5 changed files with 69 additions and 27 deletions

View File

@ -9,11 +9,11 @@ i2p-in-private-browsing
2.7.0 2.7.0
https://addons.mozilla.org/firefox/downloads/file/4364373/i2p_in_private_browsing-2.7.0.xpi https://addons.mozilla.org/firefox/downloads/file/4364373/i2p_in_private_browsing-2.7.0.xpi
noscript noscript
11.4.40 11.4.42
https://addons.mozilla.org/firefox/downloads/file/4357325/noscript-11.4.40.xpi https://addons.mozilla.org/firefox/downloads/file/4363712/noscript-11.4.42.xpi
localcdn-fork-of-decentraleyes localcdn-fork-of-decentraleyes
2.6.73 2.6.74
https://addons.mozilla.org/firefox/downloads/file/4349721/localcdn_fork_of_decentraleyes-2.6.73.xpi https://addons.mozilla.org/firefox/downloads/file/4364493/localcdn_fork_of_decentraleyes-2.6.74.xpi
onion-in-container-browsing onion-in-container-browsing
0.82 0.82
https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Mon Oct 07 14:09:22 EDT 2024 #Fri Oct 18 23:29:32 EDT 2024
build.number=769 build.number=792

View File

@ -391,12 +391,6 @@ public class I2PCommonBrowser {
} }
} }
protected void makeDirectory(File destDir) {
logger.info("creating directory");
if (!destDir.exists())
destDir.mkdir();
}
/** /**
* Copy a directory in compatibility mode. * Copy a directory in compatibility mode.
* *
@ -440,7 +434,7 @@ public class I2PCommonBrowser {
* copied to * copied to
* @throws IOException if an I/O error occurs during the file copy process * @throws IOException if an I/O error occurs during the file copy process
*/ */
private void copyFile(File sourceFile, File destinationFile) public void copyFile(File sourceFile, File destinationFile)
throws IOException { throws IOException {
try (InputStream in = new FileInputStream(sourceFile); try (InputStream in = new FileInputStream(sourceFile);
OutputStream out = new FileOutputStream(destinationFile)) { OutputStream out = new FileOutputStream(destinationFile)) {

View File

@ -375,7 +375,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
if (firefoxFile.exists()) { if (firefoxFile.exists()) {
logger.info("Found valid firefox at " + firefox); logger.info("Found valid firefox at " + firefox);
validFirefoxes.add(firefox); validFirefoxes.add(firefox);
}else{ } else {
logger.info("firefox at " + firefox + "does not exist"); logger.info("firefox at " + firefox + "does not exist");
} }
} }

View File

@ -1,6 +1,7 @@
package net.i2p.i2pfirefox; package net.i2p.i2pfirefox;
import java.io.File; import java.io.File;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
@ -27,8 +28,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
private boolean strict; private boolean strict;
private String userChromeCSS() { private String userChromeCSS() {
String ret = String ret = "@namespace url(\"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\")\n";
"@namespace url(\"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\")\n";
/* only needed once */ /* only needed once */
@ -104,7 +104,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
// } // }
private String baseProfileDir(String file, String base, private String baseProfileDir(String file, String base,
boolean isTorBrowser) { boolean isTorBrowser) {
File profileDir = new File(file, "i2p.firefox." + base + ".profile"); File profileDir = new File(file, "i2p.firefox." + base + ".profile");
// make sure the directory exists // make sure the directory exists
if (profileDir.exists()) { if (profileDir.exists()) {
@ -113,9 +113,11 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
// create the directory // create the directory
if (!isTorBrowser) { if (!isTorBrowser) {
if (!this.unpackProfile(profileDir.getAbsolutePath(), "firefox", if (!this.unpackProfile(profileDir.getAbsolutePath(), "firefox",
base)) { base)) {
return null; return null;
} }
} else {
makeTBBDirectory(profileDir, profileDir);
} }
return profileDir.getAbsolutePath(); return profileDir.getAbsolutePath();
} }
@ -181,7 +183,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
* @since 0.0.1 * @since 0.0.1
*/ */
public boolean copyBaseProfiletoProfile(String base, boolean app, public boolean copyBaseProfiletoProfile(String base, boolean app,
boolean isTorBrowser) { boolean isTorBrowser) {
String baseProfile = baseProfileDirectory(base, isTorBrowser); String baseProfile = baseProfileDirectory(base, isTorBrowser);
String profile = profileDirectory(app, base); String profile = profileDirectory(app, base);
if (baseProfile.isEmpty() || profile.isEmpty()) { if (baseProfile.isEmpty() || profile.isEmpty()) {
@ -194,11 +196,11 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
try { try {
if (!isTorBrowser) { if (!isTorBrowser) {
logger.info("Copying base profile to profile directory: " + logger.info("Copying base profile to profile directory: " +
baseProfile + " -> " + profile); baseProfile + " -> " + profile);
copyDirectory(baseProfileDir, profileDir, "firefox", base); copyDirectory(baseProfileDir, profileDir, "firefox", base);
} else { } else {
logger.info("Creating base directory for use with Tor Browser"); logger.info("Creating base directory for use with Tor Browser");
makeDirectory(profileDir); makeTBBDirectory(baseProfileDir, profileDir);
} }
logger.info("Copied base profile to profile directory"); logger.info("Copied base profile to profile directory");
return true; return true;
@ -250,7 +252,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
* @since 0.0.1 * @since 0.0.1
*/ */
public boolean copyStrictOptions(String base, boolean app, public boolean copyStrictOptions(String base, boolean app,
boolean isTorBrowser) { boolean isTorBrowser) {
logger.info("Checking strict options"); logger.info("Checking strict options");
String baseProfile = baseProfileDirectory(base, isTorBrowser); String baseProfile = baseProfileDirectory(base, isTorBrowser);
String profile = profileDirectory(app, base); String profile = profileDirectory(app, base);
@ -261,8 +263,8 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
File baseProfileDir = new File(baseProfile); File baseProfileDir = new File(baseProfile);
File profileDir = new File(profile); File profileDir = new File(profile);
setupUserChrome(profileDir, app); setupUserChrome(profileDir, app);
if (!baseProfileDir.exists() || !profileDir.exists()) { if (!baseProfileDir.exists()) {
logger.info("Empty directories"); logger.info("Empty base directories: " + baseProfileDir);
return false; return false;
} }
File baseOverrides = new File(baseProfile, "strict-overrides.js"); File baseOverrides = new File(baseProfile, "strict-overrides.js");
@ -272,7 +274,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
if (strict) { if (strict) {
logger.info("Enabling strict options"); logger.info("Enabling strict options");
Files.copy(baseOverrides.toPath(), userOverrides.toPath(), Files.copy(baseOverrides.toPath(), userOverrides.toPath(),
StandardCopyOption.REPLACE_EXISTING); StandardCopyOption.REPLACE_EXISTING);
return true; return true;
} }
} }
@ -329,12 +331,56 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
} }
} }
private String TBB_BASE = "user_pref(\"extensions.torbutton.use_nontor_proxy\", true);\n"
+ "user_pref(\"extensions.torlauncher.start_tor\", false);\n"
+ "user_pref(\"extensions.torlauncher.prompt_at_startup\", false);\n"
+ "user_pref(\"network.proxy.no_proxies_on\", \"127.0.0.1:7657,localhost:7657,127.0.0.1:7662,localhost:7662,127.0.0.1:7669,localhost:7669\");\n"
+ "user_pref(\"network.proxy.type\", 1);\n"
+ "user_pref(\"network.proxy.http\", \"127.0.0.1\");\n"
+ "user_pref(\"network.proxy.http_port\", 4444);\n"
+ "user_pref(\"network.proxy.ssl\", \"127.0.0.1\");\n"
+ "user_pref(\"network.proxy.ssl_port\", 4444);\n"
+ "user_pref(\"network.proxy.ftp\", \"127.0.0.1\");"
+ "user_pref(\"network.proxy.ftp_port\", 4444);\n"
+ "user_pref(\"network.proxy.socks\", \"127.0.0.1\");\n"
+ "user_pref(\"network.proxy.socks_port\", 4444);\n"
+ "user_pref(\"network.proxy.share_proxy_settings\", true);\n"
+ "user_pref(\"browser.startup.homepage\", \"about:blank\");\n"
+ "user_pref(\"keyword.enabled\", false);\n"
+ "user_pref(\"extensions.allowPrivateBrowsingByDefault\", true);\n"
+ "user_pref(\"extensions.PrivateBrowsing.notification\", false);\n"
+ "user_pref(\"extensions.pocket.enabled\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.showSponsoredTopSites\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.showSponsored\", false);\n"
+ "user_pref(\"services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsored\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.feeds.section.highlights\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.feeds.section.topstories\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.default.sites\", \"http://planet.i2p/,http://legwork.i2p/,http://i2pwiki.i2p/,http://i2pforums.i2p/,http://zzz.i2p/\");\n"
+ "user_pref(\"browser.newtabpage.activity-stream.feeds.topsites\", true);\n"
+ "user_pref(\"browser.fixup.domainsuffixwhitelist.i2p\", true);\n";
protected void makeTBBDirectory(File sourceDir, File destDir) {
logger.info("creating TBB directory");
if (!destDir.exists())
destDir.mkdir();
File workUserJs = new File(destDir, "user.js");
// Write the value of TBB_BASE to the file workUserJs
try (FileWriter writer = new FileWriter(workUserJs)) {
logger.info("writing TBB user.js");
writer.write(TBB_BASE);
} catch (IOException e) {
logger.info("Error writing to file: " + e.getMessage());
}
}
/** /**
* Construct a new Profile Builder * Construct a new Profile Builder
* *
* @since 0.0.1 * @since 0.0.1
*/ */
public I2PFirefoxProfileBuilder() { this.strict = false; } public I2PFirefoxProfileBuilder() {
this.strict = false;
}
/** /**
* Construct a new Profile Builder * Construct a new Profile Builder
@ -343,5 +389,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
* *
* @since 0.0.1 * @since 0.0.1
*/ */
public I2PFirefoxProfileBuilder(boolean strict) { this.strict = strict; } public I2PFirefoxProfileBuilder(boolean strict) {
this.strict = strict;
}
} }