Compare commits

...

7 Commits
1.1.0 ... 1.2.0

19 changed files with 501 additions and 513 deletions

View File

@ -9,20 +9,20 @@ i2p-in-private-browsing
1.48
https://addons.mozilla.org/firefox/downloads/file/4123613/i2p_in_private_browsing-1.48.xpi
noscript
11.4.24
https://addons.mozilla.org/firefox/downloads/file/4131645/noscript-11.4.24.xpi
11.4.28
https://addons.mozilla.org/firefox/downloads/file/4178438/noscript-11.4.28.xpi
localcdn-fork-of-decentraleyes
2.6.52
https://addons.mozilla.org/firefox/downloads/file/4129532/localcdn_fork_of_decentraleyes-2.6.52.xpi
2.6.59
https://addons.mozilla.org/firefox/downloads/file/4197044/localcdn_fork_of_decentraleyes-2.6.59.xpi
onion-in-container-browsing
0.82
https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi
javascript-restrictor
0.13
https://addons.mozilla.org/firefox/downloads/file/4131644/javascript_restrictor-0.13.xpi
0.17
https://addons.mozilla.org/firefox/downloads/file/4190089/javascript_restrictor-0.17.xpi
ublock-origin
1.50.0
https://addons.mozilla.org/firefox/downloads/file/4121906/ublock_origin-1.50.0.xpi
1.54.0
https://addons.mozilla.org/firefox/downloads/file/4198829/ublock_origin-1.54.0.xpi
```
## Chromium
@ -35,12 +35,12 @@ NoScript
11.4.18
https://clients2.google.com/service/update2/crx
LocalCDN
2.6.52
2.6.59
https://clients2.google.com/service/update2/crx
uBlock Origin
1.50.0
1.54.0
https://clients2.google.com/service/update2/crx
JShelter
0.13
__MSG_extensionName__
0.17
https://clients2.google.com/service/update2/crx
```

Binary file not shown.

View File

@ -1,6 +1,6 @@
#Build Number for ANT. Do not edit!
#Thu Jul 06 15:11:32 EDT 2023
build.number=500
>>>>>>>=7cdf84bb265e7fda5b98d2386dab1855de8383eb
#Mon Dec 11 13:13:24 EST 2023
=\=\=\=\=\=\=
build.number=555
>>>>>>>=7cdf84bb265e7fda5b98d2386dab1855de8383eb
<<<<<<<=HEAD

View File

@ -9,6 +9,7 @@
<pathelement location="${i2plib}/i2ptunnel.jar" />
<pathelement location="${i2plib}/i2psnark.jar" />
<pathelement location="${i2plib}/mstreaming.jar" />
<pathelement location="${i2plib}/desktopgui.jar" />
<pathelement location="${ant.home}/lib/ant.jar"/>
<pathelement location="${jettylib}/org.mortbay.jetty.jar"/>
<pathelement location="${jettylib}/jasper-runtime.jar" />
@ -40,7 +41,7 @@
debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
destdir="./build/obj"
includeAntRuntime="false"
classpath="${i2plib}/i2p.jar:${i2plib}/i2ptunnel.jar:${i2plib}/i2psnark.jar:${i2plib}/mstreaming.jar:${i2plib}/systray.jar:${jettylib}/org.mortbay.jetty.jar:${jettylib}/jetty-util.jar:${jettylib}/jetty-xml.jar" >
classpath="${i2plib}/i2p.jar:${i2plib}/i2ptunnel.jar:${i2plib}/i2psnark.jar:${i2plib}/mstreaming.jar:${i2plib}/systray.jar:${i2plib}/desktopgui.jar:${jettylib}/org.mortbay.jetty.jar:${jettylib}/jetty-util.jar:${jettylib}/jetty-xml.jar" >
<compilerarg line="${javac.compilerargs}" />
</javac>
</target>

View File

@ -1,6 +1,6 @@
package net.i2p.i2pfirefox;
import java.awt.AWTException;
/*import java.awt.AWTException;
import java.awt.Component;
import java.awt.Image;
import java.awt.Menu;
@ -13,7 +13,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseListener;*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@ -46,26 +46,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
private final I2PChromium i2pChromium = new I2PChromium();
private final I2PGenericUnsafeBrowser i2pGeneral =
new I2PGenericUnsafeBrowser();
private final Toolkit toolkit = Toolkit.getDefaultToolkit();
private final SystemTray tray = initTray();
private final Image image = toolkit.getImage("icon.png");
private final TrayIcon icon = initIcon();
private final PopupMenu menu = initMenu();
private final Menu submenuStrict = new Menu("Strict Mode");
private final MenuItem launchRegularBrowserStrict =
new MenuItem("Launch I2P Browser");
private final MenuItem launchPrivateBrowserStrict =
new MenuItem("Launch I2P Browser - Throwaway Session");
private final Menu submenuUsability = new Menu("Usability Mode");
private final MenuItem launchRegularBrowserUsability =
new MenuItem("Launch I2P Browser");
private final MenuItem launchPrivateBrowserUsability =
new MenuItem("Launch I2P Browser - Throwaway Session");
private final MenuItem launchConfigBrowserUsability =
new MenuItem("Launch I2P Console");
private final MenuItem closeItem = new MenuItem("Close");
public boolean firefox = false;
public boolean chromium = false;
public boolean generic = false;
@ -105,7 +85,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
*
* @since 0.0.16
*/
public I2PBrowser() { initIconFile(); }
public I2PBrowser() { }
/**
* Construct an I2PBrowser class which automatically determines which browser
@ -115,7 +95,6 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
*/
public I2PBrowser(String browserPath) {
this.BROWSER = browserPath;
initIconFile();
}
public void setBrowser(String browserPath) { this.BROWSER = browserPath; }
@ -164,7 +143,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
* @since 0.0.17
*/
public void launch(int privateWindow, String[] url) {
validateUserDir();
validateUserDirectory();
if (generic) {
this.launchGeneric(privateWindow, url);
return;
@ -239,7 +218,7 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
i2pBrowser.startup(args);
}
public ArrayList<String> parseArgs(String[] args) {
validateUserDir();
validateUserDirectory();
logger.info("I2PBrowser");
ArrayList<String> visitURL = new ArrayList<String>();
if (args != null) {
@ -289,12 +268,9 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
ArrayList<String> visitURL = parseArgs(args);
try {
if (useSystray) {
startupSystray();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
shutdownSystray();
}
});
}
@ -331,138 +307,4 @@ public class I2PBrowser extends I2PGenericUnsafeBrowser {
logger.info("Systray does not appear to be running");
return false;
}
private SystemTray initTray() {
if (systrayRunningExternally()) {
return null;
}
if (!SystemTray.isSupported()) {
logger.warning("SystemTray is not supported");
return null;
}
return SystemTray.getSystemTray();
}
private PopupMenu initMenu() {
PopupMenu menu = new PopupMenu();
return menu;
}
private File initIconFile() {
File iconFile = new File(runtimeDirectory(""), "icon.png");
if (!iconFile.exists()) {
InputStream resources =
I2PBrowser.class.getClassLoader().getResourceAsStream("icon.png");
try {
OutputStream fos = new FileOutputStream(iconFile);
copy(resources, fos);
} catch (IOException e) {
logger.warning(e.toString());
}
}
return iconFile;
}
private TrayIcon initIcon() {
TrayIcon icon = new TrayIcon(image, "I2P Browser Profile Controller", menu);
icon.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
String[] args = {"-usability", "-app", "http://127.0.0.1:7657"};
main(args);
}
}
});
icon.setImageAutoSize(true);
return icon;
}
protected void startupSystray() {
if (!systrayRunningExternally()) {
logger.info("Setting up systray");
try {
if (useSystray) {
logger.info("Starting systray");
try {
if (systray()) {
logger.info("Systray started");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!createSystrayRunningFile()) {
logger.warning("Failed to create systray running file");
}
}
logger.info("Adding icon to systray");
tray.add(icon);
} catch (AWTException e) {
logger.warning(e.toString());
}
} else {
logger.warning("Systray is already running externally");
}
}
protected void shutdownSystray() {
if (tray != null)
tray.remove(icon);
if (systrayRunningExternally()) {
File systrayIsRunningFile =
new File(runtimeDirectory(""), "systray.running");
systrayIsRunningFile.delete();
}
}
public boolean systray() throws Exception {
if (tray == null)
throw new Exception("System Tray is Null Exception");
launchRegularBrowserStrict.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] args = {"-strict"};
main(args);
}
});
submenuStrict.add(launchRegularBrowserStrict);
logger.info("Added strict mode browser");
launchPrivateBrowserStrict.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] args = {"-private", "-strict"};
main(args);
}
});
submenuStrict.add(launchPrivateBrowserStrict);
logger.info("Added strict+private mode browser");
menu.add(submenuStrict);
logger.info("Added strict mode submenu");
launchRegularBrowserUsability.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] args = {"-usability"};
main(args);
}
});
submenuUsability.add(launchRegularBrowserUsability);
logger.info("Added usability mode browser");
launchPrivateBrowserUsability.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] args = {"-private", "-strict"};
main(args);
}
});
submenuUsability.add(launchPrivateBrowserUsability);
logger.info("Added usability+private mode browser");
launchConfigBrowserUsability.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] args = {"-usability", "-app", "http://127.0.0.1:7657"};
main(args);
}
});
menu.add(submenuUsability);
menu.add(launchConfigBrowserUsability);
logger.info("Added config-only browser");
logger.info("Added usability mode submenu");
closeItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { shutdownSystray(); }
});
menu.add(closeItem);
icon.setPopupMenu(menu);
logger.info("Added close menu item");
return true;
}
}

View File

@ -10,6 +10,12 @@ import net.i2p.app.ClientApp;
import net.i2p.app.ClientAppManager;
import net.i2p.app.ClientAppState;
import net.i2p.util.EepGet;
import net.i2p.app.MenuCallback;
import net.i2p.app.MenuHandle;
import net.i2p.app.MenuService;
import net.i2p.util.I2PAppThread;
import net.i2p.desktopgui.ExternalMain;
public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
private final I2PAppContext context;
@ -27,8 +33,25 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
cam.notify(this, ClientAppState.INITIALIZED,
"Profile Manager Systray Plugin Initialized", null);
}
private MenuService startTrayApp() {
try {
//if (isSystrayEnabled(context)) {
System.setProperty("java.awt.headless", "false");
ExternalMain dtg = new ExternalMain(context, cam, null);
//MenuService dtg = new MenuService(context, cam, null);
dtg.startup();
return dtg;
//}
} catch (Throwable t) {
t.printStackTrace();
}
return null;
}
private File threadLogFile() {
validateUserDir();
validateUserDirectory();
String userDir = System.getProperty("user.dir");
File log = new File(userDir, "logs");
if (!log.exists())
@ -38,7 +61,7 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
public String getDisplayName() { return "Browser Profile Manager"; }
public String getName() { return "browserProfileManager"; }
public void shutdown(String[] args) {
this.shutdownSystray();
//this.shutdownSystray();
cam.notify(this, ClientAppState.STOPPING,
"Shutting down up profile manager systray", null);
got = true;
@ -85,6 +108,7 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
}
public void startup() {
shutdown = false;
MenuService dtg = startTrayApp();
cam.notify(this, ClientAppState.STARTING,
"Starting up profile manager systray", null);
Runnable r = new Runnable() {
@ -98,16 +122,8 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
}
};
new Thread(r).start();
try {
this.startup(args);
cam.register(this);
cam.notify(this, ClientAppState.RUNNING,
"Starting up profile manager systray", null);
} catch (Exception e) {
logger.info(e.toString());
cam.notify(this, ClientAppState.START_FAILED,
"Error starting profile manager systray", e);
}
if (dtg != null)
dtg.addMenu("Shutdown I2PBrowser", new StandaloneStopper(dtg));
}
private File torrentDir() throws IOException {
@ -185,4 +201,32 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
}
return ClientAppState.FORKED; // Used as a euphemism for unknown here.
}
/**
* Callback when shutdown is clicked in systray
* @since 0.9.60
*/
public class StandaloneStopper implements MenuCallback {
private final MenuService _ms;
public StandaloneStopper(MenuService ms) { _ms = ms; }
public void clicked(MenuHandle menu) {
_ms.disableMenu(menu);
_ms.updateMenu("I2P Browser shutting down", menu);
Thread t = new I2PAppThread(new StopperThread(), "Browser Stopper", true);
t.start();
}
}
/**
* Threaded shutdown
* @since 0.9.60
*/
public class StopperThread implements Runnable {
public void run() {
//shutdown(null);
}
}
}

View File

@ -60,34 +60,34 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
public void storeChromiumDefaults() {
List<String> list = new ArrayList<String>();
list = Arrays.asList(chromiumPathsWindows());
prop.setProperty("chromium.paths.windows",
getProperties().setProperty("chromium.paths.windows",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(chromiumPathsUnix());
prop.setProperty("chromium.paths.linux",
getProperties().setProperty("chromium.paths.linux",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(chromiumPathsOSX());
prop.setProperty("chromium.paths.osx",
getProperties().setProperty("chromium.paths.osx",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(chromiumBinsWindows());
prop.setProperty("chromium.bins.windows",
getProperties().setProperty("chromium.bins.windows",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(chromiumBinsUnix());
prop.setProperty("chromium.bins.linux",
getProperties().setProperty("chromium.bins.linux",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(chromiumBinsUnix());
prop.setProperty("chromium.bins.osx",
getProperties().setProperty("chromium.bins.osx",
list.stream().collect(Collectors.joining(",")));
try (OutputStream fos = new FileOutputStream(
new File(runtimeDirectory(""), "browser.config"))) {
prop.store(fos, "Chromium Configuration Section");
getProperties().store(fos, "Chromium Configuration Section");
} catch (IOException ioe) {
logger.warning(ioe.toString());
}
}
private String[] chromiumPathsUnix() {
String chromiumPathsProp = prop.getProperty("chromium.paths.unix");
String chromiumPathsProp = getProperties().getProperty("chromium.paths.unix");
if (chromiumPathsProp != null)
if (!chromiumPathsProp.equals(""))
return chromiumPathsProp.split(",");
@ -98,12 +98,12 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
private String[] chromiumBinsUnix() {
String chromiumPathsProp;
if (isOSX()) {
chromiumPathsProp = prop.getProperty("chromium.bins.osx");
chromiumPathsProp = getProperties().getProperty("chromium.bins.osx");
if (chromiumPathsProp != null)
if (!chromiumPathsProp.equals(""))
return chromiumPathsProp.split(",");
}
chromiumPathsProp = prop.getProperty("chromium.bins.unix");
chromiumPathsProp = getProperties().getProperty("chromium.bins.unix");
if (chromiumPathsProp != null)
if (!chromiumPathsProp.equals(""))
return chromiumPathsProp.split(",");
@ -126,7 +126,7 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
return exePath;
}
private String[] chromiumPathsOSX() {
String chromiumPathsProp = prop.getProperty("chromium.paths.osx");
String chromiumPathsProp = getProperties().getProperty("chromium.paths.osx");
if (chromiumPathsProp != null)
if (!chromiumPathsProp.equals(""))
return chromiumPathsProp.split(",");
@ -149,7 +149,7 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
}
private String[] chromiumPathsWindows() {
String chromiumPathsProp = prop.getProperty("chromium.paths.windows");
String chromiumPathsProp = getProperties().getProperty("chromium.paths.windows");
if (chromiumPathsProp != null)
if (!chromiumPathsProp.equals(""))
return chromiumPathsProp.split(",");
@ -182,7 +182,7 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
};
}
private String[] chromiumBinsWindows() {
String chromiumPathsProp = prop.getProperty("chromium.bins.windows");
String chromiumPathsProp = getProperties().getProperty("chromium.bins.windows");
if (chromiumPathsProp != null)
if (!chromiumPathsProp.equals(""))
return chromiumPathsProp.split(",");
@ -667,7 +667,7 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
}
public Process launchAndDetatch(int privateWindow, String[] url) {
validateUserDir();
validateUserDirectory();
if (waitForProxy()) {
String profileDirectory = this.profileDirectory(this.usabilityMode());
if (this.validateProfileDirectory(profileDirectory)) {
@ -777,7 +777,7 @@ public class I2PChromium extends I2PChromiumProfileUnpacker {
public static void main(String[] args) {
int privateBrowsing = 0;
I2PChromium i2pChromium = new I2PChromium();
i2pChromium.validateUserDir();
i2pChromium.validateUserDirectory();
i2pChromium.logger.info("I2PChromium");
i2pChromium.logger.info("checking for private browsing");
ArrayList<String> visitURL = new ArrayList<String>();

View File

@ -33,10 +33,10 @@ import java.util.zip.ZipInputStream;
*/
public class I2PCommonBrowser {
public Properties prop = new Properties();
private Properties prop = new Properties();
public Logger logger = Logger.getLogger("browserlauncher");
private FileHandler fh;
static int CONFIGURED_TIMEOUT = 200;
int CONFIGURED_TIMEOUT = 200;
public I2PCommonBrowser() {
try {
@ -55,27 +55,47 @@ public class I2PCommonBrowser {
loadPropertiesFile(new File(runtimeDirectory(""), "browser.config"));
}
public void loadPropertiesFile(File props) {
try (InputStream propsInput = new FileInputStream(props)) {
/**
* Loads a properties file.
*
* @param propertiesFile the file to load
*/
public void loadPropertiesFile(File propertiesFile) {
try (InputStream inputStream = new FileInputStream(propertiesFile)) {
prop = new Properties();
prop.load(propsInput);
System.out.println(prop);
} catch (IOException io) {
logger.warning(io.toString());
prop.load(inputStream);
} catch (IOException exception) {
logger.warning(exception.toString());
}
}
public void validateUserDir() {
/**
* Retrieves the properties of the object.
*
* @return the properties of the object
*/
public Properties getProperties() {
return prop;
}
/**
* Validates the user directory.
*
* @param None No parameters.
* @return None No return value.
*/
public void validateUserDirectory() {
logger.info("Validating user directory");
String userDir = System.getProperty("user.dir");
String userHome = System.getProperty("user.home");
File userDirFile = new File(userDir);
File userHomeFile = new File(userHome);
logger.info("user.dir testing !" + userHomeFile.getAbsolutePath() +
".equals(" + userDirFile.getAbsolutePath() + ")");
logger.info("user.dir: " + userDirFile.getAbsolutePath());
logger.info("user.home: " + userHomeFile.getAbsolutePath());
if (!userDirFile.getAbsolutePath().contains("Program Files")) {
if (!userDirFile.getAbsolutePath().equals(
userHomeFile.getAbsolutePath())) {
if (!userDirFile.getAbsolutePath().equals(userHomeFile.getAbsolutePath())) {
logger.info("user.dir is not inconvenient");
if (userDirFile.exists()) {
logger.info("user.dir exists");
@ -87,8 +107,9 @@ public class I2PCommonBrowser {
} else {
logger.info("user.dir is not writable");
}
} else {
logger.info("user.dir is not actually a directory");
}
{ logger.info("user.dir is not actually a directory"); }
} else {
logger.info("user.dir does not exist");
}
@ -98,178 +119,213 @@ public class I2PCommonBrowser {
} else {
logger.info("user.dir cannot run from inside Program Files");
}
if (isWindows())
if (isWindows()) {
userHome = new File(userHome, "AppData/Local/I2P").getAbsolutePath();
}
File defaultPathFile = new File(userHome, "i2p/i2pbrowser");
if (!defaultPathFile.exists())
if (!defaultPathFile.exists()) {
defaultPathFile.mkdirs();
}
if (!defaultPathFile.isDirectory()) {
logger.info(
"default path exists and is not a directory, get it out of the way");
logger.info("default path exists and is not a directory, get it out of the way");
logger.info(defaultPathFile.getAbsolutePath());
}
System.setProperty("user.dir", defaultPathFile.getAbsolutePath());
}
/**
* Get the operating system.
*
* @return the name of the operating system (Windows, Linux, BSD, Mac, or
* Unknown)
*/
public String getOperatingSystem() {
String os = System.getProperty("os.name");
if (os.startsWith("Windows")) {
if (isWindows()) {
return "Windows";
} else if (os.contains("Linux")) {
} else if (isLinux()) {
return "Linux";
} else if (os.contains("BSD")) {
} else if (isBSD()) {
return "BSD";
} else if (os.contains("Mac")) {
} else if (isOSX()) {
return "Mac";
}
return "Unknown";
}
/**
* Determines if the current operating system is Windows.
*
* @return true if the current operating system is Windows, false otherwise
*/
protected boolean isWindows() {
String osName = System.getProperty("os.name");
logger.info("os.name" + osName);
if (osName.contains("windows"))
return true;
if (osName.contains("Windows"))
return true;
if (osName.contains("WINDOWS"))
return true;
return false;
String osName = System.getProperty("os.name").toLowerCase();
return osName.contains("windows");
}
/**
* Determines if the current operating system is macOS.
*
* @return true if the operating system is macOS, false otherwise
*/
protected boolean isOSX() {
String osName = System.getProperty("os.name");
logger.info("os.name" + osName);
if (osName.contains("OSX"))
return true;
if (osName.contains("osx"))
return true;
if (osName.contains("mac"))
return true;
if (osName.contains("Mac"))
return true;
if (osName.contains("apple"))
return true;
if (osName.contains("Apple"))
return true;
if (osName.contains("Darwin"))
return true;
if (osName.contains("darwin"))
return true;
return false;
String osName = System.getProperty("os.name").toLowerCase();
return osName.contains("osx") || osName.contains("mac") || osName.contains("apple") || osName.contains("darwin");
}
/**
* Determines whether the current operating system is Linux.
*
* @return true if the operating system is Linux, false otherwise
*/
protected boolean isLinux() {
String osName = System.getProperty("os.name").toLowerCase();
return osName.contains("linux");
}
/**
* Checks if the current operating system is a BSD variant.
*
* @return true if the operating system is a BSD variant, false otherwise
*/
protected boolean isBSD() {
String osName = System.getProperty("os.name").toLowerCase();
return osName.contains("bsd");
}
// public void logger.info(String line) { logger.info(line); }
/**
* Returns the log file for the browser launcher.
*
* @return the log file for the browser launcher
*/
private File logFile() {
validateUserDir();
String userDir = System.getProperty("user.dir");
File log = new File(userDir, "logs");
if (!log.exists())
log.mkdirs();
return new File(log, "browserlauncher.log");
validateUserDirectory();
String userDirectory = System.getProperty("user.dir");
File logDirectory = new File(userDirectory, "logs");
if (!logDirectory.exists()) {
logDirectory.mkdirs();
}
return new File(logDirectory, "browserlauncher.log");
}
/**
* get the runtime directory, creating it if create=true
* Get the runtime directory, creating it if create=true.
*
* @param create if true, create the runtime directory if it does not exist
* @return the runtime directory, or null if it could not be created
* @param create If true, create the runtime directory if it does not exist.
* @param override The runtime directory override.
* @return The runtime directory, or null if it could not be created.
* @since 0.0.19
*/
protected File runtimeDirectory(boolean create, String override) {
String rtd = runtimeDirectory(override);
File rtdFile = new File(rtd);
if (create) {
if (!rtdFile.exists()) {
rtdFile.mkdir();
String runtimeDir = runtimeDirectory(override);
File runtimeDirFile = new File(runtimeDir);
if (create && !runtimeDirFile.exists()) {
runtimeDirFile.mkdir();
}
}
return new File(rtd);
return runtimeDirFile;
}
/**
* get the correct runtime directory
* Returns the runtime directory path based on the given override parameter.
*
* @return the runtime directory, or null if it could not be created or found
* @since 0.0.19
* @param override the name of the environment variable to override the runtime
* directory
* @return the runtime directory path as a string
*/
protected String runtimeDirectory(String override) {
// get the I2P_BROWSER_DIR environment variable
String rtd = System.getenv(override);
// 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 runtimeDir = System.getenv(override);
if (isDirectoryValid(runtimeDir)) {
return runtimeDir;
}
String pluginDir = System.getenv("PLUGIN");
if (isDirectoryValid(pluginDir)) {
return pluginDir;
}
String userDir = System.getProperty("user.dir");
if (userDir != null && !userDir.isEmpty()) {
File userDir1 = new File(userDir);
if (userDir1.exists()) {
return userDir1.toString();
}
if (isDirectoryValid(userDir)) {
return userDir;
}
String homeDir = System.getProperty("user.home");
if (homeDir != null && !homeDir.isEmpty()) {
File homeDir1 = new File(homeDir + "/.i2p");
if (homeDir1.exists()) {
return homeDir.toString();
if (isDirectoryValid(homeDir)) {
String i2pDir = homeDir + "/.i2p";
if (isDirectoryValid(i2pDir)) {
return homeDir;
}
File homeDir2 = new File(homeDir + "/i2p");
if (homeDir2.exists()) {
return homeDir2.toString();
String altI2pDir = homeDir + "/i2p";
if (isDirectoryValid(altI2pDir)) {
return altI2pDir;
}
}
return "";
}
/**
* get the profile directory, creating it if necessary
* Checks if the given directory is valid.
*
* @param directory the directory to check
* @return true if the directory is valid, false otherwise
*/
private boolean isDirectoryValid(String directory) {
return directory != null && !directory.isEmpty() && new File(directory).exists();
}
/**
* Retrieves the profile directory, creating it if necessary.
*
* @param envVar the environment variable name
* @param browser the browser name
* @param base the base directory
* @param app indicates if it is an app directory
* @return the profile directory, or null if it could not be created
* @since 0.0.19
*/
protected String profileDirectory(String envVar, String browser, String base,
boolean app) {
String pd = System.getenv(envVar);
if (pd != null && !pd.isEmpty()) {
File pdf = new File(pd);
if (pdf.exists() && pdf.isDirectory()) {
return pd;
protected String profileDirectory(String envVar, String browser, String base, boolean app) {
String profileDir = System.getenv(envVar);
if (profileDir != null && !profileDir.isEmpty()) {
File profileDirFile = new File(profileDir);
if (profileDirFile.exists() && profileDirFile.isDirectory()) {
return profileDir;
}
}
String rtd = runtimeDirectory("");
return profileDir(rtd, browser, base, app);
String runtimeDir = runtimeDirectory("");
return profileDir(runtimeDir, browser, base, app);
}
protected String profileDir(String file, String browser, String base,
boolean app) {
String appString = "";
if (app) {
appString = ".app";
}
File profileDir =
new File(file, "i2p." + browser + ".profile." + base + appString);
/**
* A description of the entire Java function.
*
* @param file description of parameter
* @param browser description of parameter
* @param base description of parameter
* @param app description of parameter
* @return description of return value
*/
protected String profileDir(String file, String browser, String base, boolean app) {
String appString = app ? ".app" : "";
String profileDirName = String.format("i2p.%s.profile.%s%s", browser, base, appString);
File profileDir = new File(file, profileDirName);
return profileDir.getAbsolutePath();
}
/**
* Unpacks the base profile to a specified directory.
*
* @param profileDirectory the directory where the profile will be unpacked
* @param browser the browser type
* @param base the base profile
* @return true if the profile was successfully unpacked, false otherwise
*/
protected boolean unpackProfile(String profileDirectory, String browser,
String base) {
logger.info("Unpacking base profile to " + profileDirectory);
try {
final InputStream resources =
this.getClass().getClassLoader().getResourceAsStream(
final InputStream resources = this.getClass().getClassLoader().getResourceAsStream(
"i2p." + browser + "." + base + ".profile.zip");
if (resources == null) {
logger.info("Could not find resources");
@ -309,64 +365,95 @@ public class I2PCommonBrowser {
return true;
}
protected void copyDirectory(File sourceDirectory, File destinationDirectory,
String browser, String base) throws IOException {
destinationDirectory = new File(destinationDirectory.toString().replace(
"i2p." + browser + "." + base + ".profile", ""));
if (!destinationDirectory.exists()) {
destinationDirectory.mkdir();
/**
* Copy a directory from sourceDir to destDir, excluding certain files based on
* browser and base.
*
* @param sourceDir directory to be copied from
* @param destDir directory to be copied to
* @param browser the browser name
* @param base the base name
* @throws IOException if an I/O error occurs during copying
*/
protected void copyDirectory(File sourceDir, File destDir, String browser, String base) throws IOException {
destDir = new File(destDir.toString().replace("i2p." + browser + "." + base + ".profile", ""));
if (!destDir.exists()) {
destDir.mkdir();
}
for (String f : sourceDirectory.list()) {
copyDirectoryCompatibilityMode(new File(sourceDirectory, f),
new File(destinationDirectory, f), browser,
base);
for (String file : sourceDir.list()) {
copyDirectoryCompatibilityMode(new File(sourceDir, file), new File(destDir, file), browser, base);
}
}
private void copyDirectoryCompatibilityMode(File source, File destination,
String browser, String base)
throws IOException {
if (source.isDirectory()) {
copyDirectory(source, destination, browser, base);
/**
* Copy a directory in compatibility mode.
*
* @param sourceDirectory the source directory to copy
* @param destinationDirectory the destination directory to copy to
* @param browser the browser
* @param base the base
* @throws IOException if an I/O error occurs
*/
private void copyDirectoryCompatibilityMode(File sourceDirectory, File destinationDirectory, String browser,
String base) throws IOException {
if (sourceDirectory.isDirectory()) {
copyDirectory(sourceDirectory, destinationDirectory, browser, base);
} else {
copyFile(source, destination);
copyFile(sourceDirectory, destinationDirectory);
}
}
/**
* Copies the content from the source InputStream to the target OutputStream.
*
* @param source the InputStream to copy from
* @param target the OutputStream to copy to
* @throws IOException if an I/O error occurs during the copying process
*/
public void copy(InputStream source, OutputStream target) throws IOException {
byte[] buf = new byte[8192];
int length;
while ((length = source.read(buf)) != -1) {
target.write(buf, 0, length);
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = source.read(buffer)) != -1) {
target.write(buffer, 0, bytesRead);
}
}
private void copyFile(File sourceFile, File destinationFile)
throws IOException {
/**
* Copies a file from the source file to the destination file.
*
* @param sourceFile the source file to be copied
* @param destinationFile the destination file where the source file will be
* copied to
* @throws IOException if an I/O error occurs during the file copy process
*/
private void copyFile(File sourceFile, File destinationFile) throws IOException {
try (InputStream in = new FileInputStream(sourceFile);
OutputStream out = new FileOutputStream(destinationFile)) {
byte[] buf = new byte[1024];
byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buf)) > 0) {
out.write(buf, 0, length);
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
}
}
}
/**
* Validates the profile for the first run.
*
* @param profileDirectory the directory of the profile
* @return true if the profile is valid for the first run, false otherwise
*/
public boolean validateProfileFirstRun(String profileDirectory) {
File profileDir = new File(profileDirectory);
if (!profileDir.exists()) {
logger.info("Profile directory does not exist");
return false;
}
if (!profileDir.isDirectory()) {
logger.info("Profile directory is not a directory");
return false;
}
File frf = new File(profileDir, "first-run");
if (frf.exists()) {
frf.delete();
// is a first run
File firstRunFile = new File(profileDir, "first-run");
if (firstRunFile.exists()) {
firstRunFile.delete();
return true;
}
return false;
@ -379,7 +466,9 @@ public class I2PCommonBrowser {
* @return true if the proxy is ready, false if it is not.
* @since 0.0.1
*/
public boolean waitForProxy() { return waitForProxy(CONFIGURED_TIMEOUT); }
public boolean waitForProxy() {
return waitForProxy(CONFIGURED_TIMEOUT);
}
/**
* Waits for an HTTP proxy on port 4444 to be ready.
@ -392,6 +481,7 @@ public class I2PCommonBrowser {
public boolean waitForProxy(int timeout) {
return waitForProxy(timeout, 4444);
}
/**
* Waits for an HTTP proxy on the specified port to be ready.
* Returns false on timeout of the specified number of seconds.
@ -404,6 +494,7 @@ public class I2PCommonBrowser {
public boolean waitForProxy(int timeout, int port) {
return waitForProxy(timeout, port, "localhost");
}
/**
* Waits for an HTTP proxy on the specified port to be ready.
* Returns false on timeout of the specified number of seconds.
@ -417,13 +508,11 @@ public class I2PCommonBrowser {
* @since 0.0.1
*/
public boolean waitForProxy(int timeout, int port, String host) {
logger.info("waiting up to " + timeout + "seconds for a proxy");
if (timeout <= 0) {
return true;
}
for (int i = 0; i < timeout; i++) {
logger.info("Waiting for proxy");
if (checkifPortIsOccupied(port, host)) {
if (isPortOccupied(port, host)) {
return true;
}
try {
@ -434,54 +523,78 @@ public class I2PCommonBrowser {
}
return false;
}
public boolean checkifPortIsOccupied(int port, String host) {
/**
* Determines if a given port on a specified host is occupied.
*
* @param port the port number to check
* @param host the host address to check
* @return true if the port is occupied, false otherwise
*/
public boolean isPortOccupied(int port, String host) {
try {
Socket socket = new Socket(host, port);
socket.close();
new Socket(host, port).close();
return true;
} catch (IOException e) {
return false;
}
}
/**
* Alters the proxy timeout to customized value time, in seconds.
* May be zero.
*
* @param time
*/
public void setProxyTimeoutTime(int time) { CONFIGURED_TIMEOUT = time; }
public void setProxyTimeoutTime(int time) {
CONFIGURED_TIMEOUT = time;
}
/**
* Joins the elements of the given string array into a single string.
*
* @param arr the string array to be joined
* @return the joined string
*/
protected String join(String[] arr) {
StringBuilder val = new StringBuilder("");
for (int x = 0; x < arr.length; x++) {
val.append(" \"");
val.append(arr[x]);
val.append("\"");
StringBuilder result = new StringBuilder();
for (String item : arr) {
result.append(" \"").append(item).append("\"");
}
return val.toString();
return result.toString();
}
/**
* Sleeps for a specified number of milliseconds.
*
* @param millis the number of milliseconds to sleep
*/
public void sleep(int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException bad) {
bad.printStackTrace();
throw new RuntimeException(bad);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
public File searchFile(File file, String search) {
if (file.isDirectory()) {
File[] arr = file.listFiles();
for (File f : arr) {
File found = searchFile(f, search);
if (found != null)
return found;
/**
* Searches for a file in a given directory and its subdirectories.
*
* @param directory the directory to search in
* @param search the name of the file to search for
* @return the found file or null if not found
*/
public File searchFile(File directory, String search) {
if (directory.isDirectory()) {
File[] files = directory.listFiles();
for (File file : files) {
File foundFile = searchFile(file, search);
if (foundFile != null)
return foundFile;
}
} else {
if (file.getName().equals(search)) {
return file;
if (directory.getName().equals(search)) {
return directory;
}
}
return null;

View File

@ -58,34 +58,34 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
public void storeFirefoxDefaults() {
List<String> list = new ArrayList<String>();
list = Arrays.asList(firefoxPathsWindows());
prop.setProperty("firefox.paths.windows",
getProperties().setProperty("firefox.paths.windows",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(firefoxPathsUnix());
prop.setProperty("firefox.paths.linux",
getProperties().setProperty("firefox.paths.linux",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(firefoxPathsOSX());
prop.setProperty("firefox.paths.osx",
getProperties().setProperty("firefox.paths.osx",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(firefoxBinsWindows());
prop.setProperty("firefox.bins.windows",
getProperties().setProperty("firefox.bins.windows",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(firefoxBinsUnix());
prop.setProperty("firefox.bins.linux",
getProperties().setProperty("firefox.bins.linux",
list.stream().collect(Collectors.joining(",")));
list = Arrays.asList(firefoxBinsUnix());
prop.setProperty("firefox.bins.osx",
getProperties().setProperty("firefox.bins.osx",
list.stream().collect(Collectors.joining(",")));
try (OutputStream fos = new FileOutputStream(
new File(runtimeDirectory(""), "browser.config"))) {
prop.store(fos, "Firefox Configuration Section");
getProperties().store(fos, "Firefox Configuration Section");
} catch (IOException ioe) {
logger.warning(ioe.toString());
}
}
public String[] firefoxPathsUnix() {
String firefoxPathsProp = prop.getProperty("firefox.paths.unix");
String firefoxPathsProp = getProperties().getProperty("firefox.paths.unix");
if (firefoxPathsProp != null)
if (!firefoxPathsProp.equals(""))
return firefoxPathsProp.split(",");
@ -96,12 +96,12 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
public String[] firefoxBinsUnix() {
String firefoxPathsProp;
if (isOSX()) {
firefoxPathsProp = prop.getProperty("firefox.bins.osx");
firefoxPathsProp = getProperties().getProperty("firefox.bins.osx");
if (firefoxPathsProp != null)
if (!firefoxPathsProp.equals(""))
return firefoxPathsProp.split(",");
}
firefoxPathsProp = prop.getProperty("firefox.bins.unix");
firefoxPathsProp = getProperties().getProperty("firefox.bins.unix");
if (firefoxPathsProp != null)
if (!firefoxPathsProp.equals(""))
return firefoxPathsProp.split(",");
@ -124,7 +124,7 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
return exePath;
}
public String[] firefoxPathsOSX() {
String firefoxPathsProp = prop.getProperty("firefox.paths.osx");
String firefoxPathsProp = getProperties().getProperty("firefox.paths.osx");
if (firefoxPathsProp != null)
if (!firefoxPathsProp.equals(""))
return firefoxPathsProp.split(",");
@ -147,7 +147,7 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
return exePath;
}
public String[] firefoxPathsWindows() {
String firefoxPathsProp = prop.getProperty("firefox.paths.windows");
String firefoxPathsProp = getProperties().getProperty("firefox.paths.windows");
if (firefoxPathsProp != null)
if (!firefoxPathsProp.equals(""))
return firefoxPathsProp.split(",");
@ -180,7 +180,7 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
};
}
private String[] firefoxBinsWindows() {
String firefoxPathsProp = prop.getProperty("firefox.bins.windows");
String firefoxPathsProp = getProperties().getProperty("firefox.bins.windows");
if (firefoxPathsProp != null)
if (!firefoxPathsProp.equals(""))
return firefoxPathsProp.split(",");
@ -692,7 +692,7 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
return launchAndDetatch(privateWindowInt, url);
}
public Process launchAndDetatch(int privateWindow, String[] url) {
validateUserDir();
validateUserDirectory();
boolean app = false;
if (privateWindow == 2)
app = true;
@ -841,7 +841,7 @@ public class I2PFirefox extends I2PFirefoxProfileUnpacker {
public static void main(String[] args) {
int privateBrowsing = 0;
I2PFirefox i2pFirefox = new I2PFirefox();
i2pFirefox.validateUserDir();
i2pFirefox.validateUserDirectory();
i2pFirefox.logger.info("checking for private browsing");
i2pFirefox.logger.info("I2PFirefox");
ArrayList<String> visitURL = new ArrayList<String>();

View File

@ -27,21 +27,23 @@ import java.util.Scanner;
public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
/**
* @param args unused
* The main method for executing the Java program.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
I2PFirefoxProfileChecker pc = new I2PFirefoxProfileChecker();
String profileDirectory = pc.profileDirectory(false, "base");
I2PFirefoxProfileChecker profileChecker = new I2PFirefoxProfileChecker();
String profileDirectory = profileChecker.profileDirectory(false, "base");
if (profileDirectory == null) {
pc.logger.info("No profile directory found");
profileChecker.logger.info("No profile directory found");
return;
}
pc.logger.info("Profile directory: " + profileDirectory);
boolean ok = pc.validateProfileDirectory(profileDirectory);
if (ok) {
pc.logger.info("Profile directory is valid");
profileChecker.logger.info("Profile directory: " + profileDirectory);
boolean isProfileValid = profileChecker.validateProfileDirectory(profileDirectory);
if (isProfileValid) {
profileChecker.logger.info("Profile directory is valid");
} else {
pc.logger.info("Profile directory is invalid");
profileChecker.logger.info("Profile directory is invalid");
}
}
@ -63,80 +65,76 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
*/
public boolean validateProfileDirectory(String profileDirectory) {
File profileDir = new File(profileDirectory);
if (!profileDir.exists()) {
logger.info("Profile directory does not exist");
return false;
}
if (!profileDir.isDirectory()) {
logger.info("Profile directory is not a directory");
return false;
}
if (!profileDir.canRead()) {
logger.info("Profile directory is not readable");
return false;
}
if (!profileDir.canWrite()) {
logger.info("Profile directory is not writable");
if (!profileDir.exists() || !profileDir.isDirectory() || !profileDir.canRead() || !profileDir.canWrite()) {
return false;
}
if (!validateFile(profileDir + "/prefs.js")) {
logger.info("prefs.js is not valid");
return false;
}
if (!validateFile(profileDir + "/user.js")) {
logger.info("user.js is not valid");
return false;
}
if (!validateExtensionDirectory(profileDir + "/extensions")) {
logger.info("extensions directory is invalid");
return false;
}
return deRestrictHTTPSAndSetupHomepage(profileDir.toString());
}
/**
* Verify essential values in prefs.js, user.js, and user-overrides.js
*
* @param profile profile
* @return true if successful
*/
private boolean deRestrictHTTPSAndSetupHomepage(String profile) {
// String profile = profileDirectory();
File profileDir = new File(profile);
if (profileDir.exists()) {
File prefOverrides = new File(profile, "prefs.js");
if (prefOverrides.exists()) {
undoHttpsOnlyMode(prefOverrides);
undoHomepage(prefOverrides);
}
File userSettings = new File(profile, "user.js");
if (userSettings.exists()) {
undoHttpsOnlyMode(userSettings);
undoHomepage(userSettings);
}
File userOverrides = new File(profile, "user-overrides.js");
if (userOverrides.exists()) {
undoHttpsOnlyMode(userOverrides);
undoHomepage(userOverrides);
}
cleanUpFile(new File(profile, "prefs.js"));
cleanUpFile(new File(profile, "user.js"));
cleanUpFile(new File(profile, "user-overrides.js"));
return true;
}
return false;
}
/**
* Cleans up a file by undoing specific modifications if the file exists.
*
* @param file the file to be cleaned up
*/
private void cleanUpFile(File file) {
if (file.exists()) {
undoHttpsOnlyMode(file);
undoHomepage(file);
}
}
/**
* Undo the HTTPS-only mode by modifying a file.
*
* @param fileToBeModified the file to be modified
* @return true if the undo operation is successful, false otherwise
*/
private boolean undoHttpsOnlyMode(File fileToBeModified) {
String oldString = "\"dom.security.https_only_mode\", true";
String newString = "\"dom.security.https_only_mode\", false";
return undoValue(oldString, newString, fileToBeModified);
}
/**
* Undo the modification of the homepage in a file.
*
* @param fileToBeModified the file to be modified
* @return true if the modification was successful, otherwise false
*/
private boolean undoHomepage(File fileToBeModified) {
String oldString = "\"browser.startup.homepage\", true";
File file = new File("Student.txt");
String newString =
"\"browser.startup.homepage\", \"http://127.0.0.1:7657\"";
try {
try (Scanner scanner = new Scanner(file)) {
// now read the file line by line...
String oldStringToFind = "\"browser.startup.homepage\", true";
String newStringToReplace = "\"browser.startup.homepage\", \"http://127.0.0.1:7657\"";
try (Scanner scanner = new Scanner(fileToBeModified)) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.contains("browser.startup.homepage")) {
oldString = line.toString();
return undoValue(oldString, newString, fileToBeModified);
}
if (line.contains(oldStringToFind)) {
return undoValue(line, newStringToReplace, fileToBeModified);
}
}
} catch (FileNotFoundException e) {
@ -145,6 +143,15 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
return true;
}
/**
* Undo the value by replacing the occurrences of the old string with the new
* string in the given file.
*
* @param oldString the string to be replaced
* @param newString the string to replace the old string with
* @param fileToBeModified the file to be modified
* @return true if the value was successfully undone, false otherwise
*/
public boolean undoValue(String oldString, String newString,
File fileToBeModified) {
String oldContent = "";
@ -173,58 +180,37 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
}
return false;
}
/**
* Return true if the file is valid.
*
* @param file the file to check
* @param filePath the path of the file to check
* @return true if the file is valid, false otherwise
* @since 0.0.1
*/
public boolean validateFile(String file) {
File f = new File(file);
if (!f.exists()) {
logger.info("User JavaScript file does not exist");
return false;
}
if (!f.isFile()) {
logger.info("User JavaScript file is not a file");
return false;
}
if (!f.canRead()) {
logger.info("User JavaScript file is not readable");
return false;
}
if (!f.canWrite()) {
logger.info("User JavaScript file is not writable");
public boolean validateFile(String filePath) {
File file = new File(filePath);
if (!file.exists() || !file.isFile() || !file.canRead() || !file.canWrite()) {
return false;
}
return true;
}
/**
* Return true if the extension directory is valid.
* Validates the extension directory.
*
* @param extensionDirectory the extension directory to check
* @param extensionDirectory the extension directory to validate
* @return true if the extension directory is valid, false otherwise
* @since 0.0.1
*/
public boolean validateExtensionDirectory(String extensionDirectory) {
File extensionDir = new File(extensionDirectory);
if (!extensionDir.exists()) {
logger.info("Extension directory does not exist");
return false;
}
if (!extensionDir.isDirectory()) {
logger.info("Extension directory is not a directory");
return false;
}
if (!extensionDir.canRead()) {
logger.info("Extension directory is not readable");
return false;
}
if (!extensionDir.canWrite()) {
logger.info("Extension directory is not writable");
if (!extensionDir.exists() || !extensionDir.isDirectory() ||
!extensionDir.canRead() || !extensionDir.canWrite()) {
return false;
}
return true;
}
}

View File

@ -40,7 +40,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
// For now, we're just assuming. So don't use this until I understand the
// situation better, unless you think you know better.
private String[] browsers() {
String genericPathsProp = prop.getProperty("generic.bins.unix");
String genericPathsProp = getProperties().getProperty("generic.bins.unix");
if (genericPathsProp != null)
return genericPathsProp.split(",");
return new String[] {
@ -66,11 +66,11 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
List<String> list = new ArrayList<String>();
list = Arrays.asList(browsers());
prop.setProperty("generic.bins.unix",
getProperties().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");
getProperties().store(fos, "Chromium Configuration Section");
} catch (IOException ioe) {
logger.warning(ioe.toString());
}
@ -366,7 +366,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
}
public Process launchAndDetatch(boolean privateWindow, String[] url) {
validateUserDir();
validateUserDirectory();
if (waitForProxy()) {
ProcessBuilder pb;
if (privateWindow) {
@ -418,7 +418,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
public static void main(String[] args) {
I2PGenericUnsafeBrowser i2pBrowser = new I2PGenericUnsafeBrowser();
i2pBrowser.validateUserDir();
i2pBrowser.validateUserDirectory();
boolean privateBrowsing = false;
i2pBrowser.logger.info("checking for private browsing");
ArrayList<String> visitURL = new ArrayList<String>();

View File

@ -20,6 +20,5 @@ import javax.script.*;
* @since 1.0.6
*/
public class I2PLibreWolf {
private static final ScriptEngineManager sem = new ScriptEngineManager();
private final ScriptEngine ee = sem.getEngineByName("Nashorn");
//TODO: provide a librewolf updater here.
}

View File

@ -1,5 +1,8 @@
#! /usr/bin/env sh
ant distclean
ant jar
./test/test.sh
./test/test-chromium.sh
./test/test-firefox.sh

View File

@ -1,7 +1,7 @@
#! /usr/bin/env sh
ant distclean
cd src && ant jar && cd ..
ant jar
rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US

View File

@ -1,7 +1,7 @@
#! /usr/bin/env sh
ant distclean
cd src && ant jar && cd ..
ant jar
rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US

View File

@ -1,7 +1,7 @@
#! /usr/bin/env sh
ant distclean
cd src && ant jar && cd ..
ant jar
rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US

View File

@ -1,7 +1,7 @@
#! /usr/bin/env sh
ant distclean
cd src && ant jar && cd ..
ant jar
rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile

View File

@ -1,7 +1,7 @@
#! /usr/bin/env sh
ant distclean
cd src && ant jar && cd ..
ant jar
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

View File

@ -1,7 +1,7 @@
#! /usr/bin/env sh
ant distclean
cd src && ant jar && cd ..
ant jar
rm -rf i2p.chromium.base.profile i2p.chromium.profile i2p.firefox.base.profile i2p.firefox.profile i2p.firefox.usability.profile tor-browser_en-US