do away with clunky logging thing
Former-commit-id: 0a9b7f0678
Former-commit-id: 927ed542e0c6aa26735f6be4c1e021b414479f5f
This commit is contained in:
@ -32,17 +32,17 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
public boolean usability = false;
|
public boolean usability = false;
|
||||||
|
|
||||||
private void launchFirefox(boolean privateWindow, String[] url) {
|
private void launchFirefox(boolean privateWindow, String[] url) {
|
||||||
println("I2PFirefox");
|
logger.info("I2PFirefox");
|
||||||
I2PFirefox.usability = usability;
|
I2PFirefox.usability = usability;
|
||||||
i2pFirefox.launch(privateWindow, url);
|
i2pFirefox.launch(privateWindow, url);
|
||||||
}
|
}
|
||||||
private void launchChromium(boolean privateWindow, String[] url) {
|
private void launchChromium(boolean privateWindow, String[] url) {
|
||||||
println("I2PChromium");
|
logger.info("I2PChromium");
|
||||||
I2PChromiumProfileBuilder.usability = usability;
|
I2PChromiumProfileBuilder.usability = usability;
|
||||||
i2pChromium.launch(privateWindow, url);
|
i2pChromium.launch(privateWindow, url);
|
||||||
}
|
}
|
||||||
private void launchGeneric(boolean privateWindow, String[] url) {
|
private void launchGeneric(boolean privateWindow, String[] url) {
|
||||||
println("I2PChromium");
|
logger.info("I2PChromium");
|
||||||
i2pGeneral.launch(privateWindow, url);
|
i2pGeneral.launch(privateWindow, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
validateUserDir();
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("I2PBrowser");
|
logger.info("I2PBrowser");
|
||||||
I2PBrowser i2pBrowser = new I2PBrowser();
|
I2PBrowser i2pBrowser = new I2PBrowser();
|
||||||
ArrayList<String> visitURL = new ArrayList<String>();
|
ArrayList<String> visitURL = new ArrayList<String>();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
@ -197,7 +197,7 @@ public class I2PBrowser extends I2PCommonBrowser {
|
|||||||
i2pBrowser.usability = true;
|
i2pBrowser.usability = true;
|
||||||
}
|
}
|
||||||
if (arg.equals("-noproxycheck")) {
|
if (arg.equals("-noproxycheck")) {
|
||||||
println("zeroing out proxy check");
|
logger.info("zeroing out proxy check");
|
||||||
i2pBrowser.setProxyTimeoutTime(0);
|
i2pBrowser.setProxyTimeoutTime(0);
|
||||||
}
|
}
|
||||||
if (!arg.startsWith("-")) {
|
if (!arg.startsWith("-")) {
|
||||||
|
@ -32,7 +32,7 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
for (String path : CHROMIUM_SEARCH_PATHS) {
|
for (String path : CHROMIUM_SEARCH_PATHS) {
|
||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
println("Found Chromium at " + path);
|
logger.info("Found Chromium at " + path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
for (String path : CHROMIUM_SEARCH_PATHS) {
|
for (String path : CHROMIUM_SEARCH_PATHS) {
|
||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
println("Found Chromium at " + path);
|
logger.info("Found Chromium at " + path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,10 +247,10 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
for (String chrome : chromees) {
|
for (String chrome : chromees) {
|
||||||
File chromeFile = new File(chrome);
|
File chromeFile = new File(chrome);
|
||||||
if (chromeFile.exists()) {
|
if (chromeFile.exists()) {
|
||||||
println("Found valid chromium at " + chrome);
|
logger.info("Found valid chromium at " + chrome);
|
||||||
validChromiums.add(chrome);
|
validChromiums.add(chrome);
|
||||||
}
|
}
|
||||||
println("chrome at " + chrome + "does not exist");
|
logger.info("chrome at " + chrome + "does not exist");
|
||||||
}
|
}
|
||||||
return validChromiums.toArray(new String[validChromiums.size()]);
|
return validChromiums.toArray(new String[validChromiums.size()]);
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
return new ProcessBuilder(newArgs).directory(
|
return new ProcessBuilder(newArgs).directory(
|
||||||
I2PChromiumProfileBuilder.runtimeDirectory(true));
|
I2PChromiumProfileBuilder.runtimeDirectory(true));
|
||||||
} else {
|
} else {
|
||||||
println("No Chromium found.");
|
logger.info("No Chromium found.");
|
||||||
return new ProcessBuilder(args);
|
return new ProcessBuilder(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,15 +486,16 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||||
if (I2PChromiumProfileChecker.validateProfileDirectory(
|
if (I2PChromiumProfileChecker.validateProfileDirectory(
|
||||||
profileDirectory)) {
|
profileDirectory)) {
|
||||||
println("Valid profile directory: " + profileDirectory);
|
logger.info("Valid profile directory: " + profileDirectory);
|
||||||
} else {
|
} else {
|
||||||
println("Invalid profile directory: " + profileDirectory +
|
logger.info("Invalid profile directory: " + profileDirectory +
|
||||||
" rebuilding...");
|
" rebuilding...");
|
||||||
if (!I2PChromiumProfileBuilder.copyBaseProfiletoProfile()) {
|
if (!I2PChromiumProfileBuilder.copyBaseProfiletoProfile()) {
|
||||||
println("Failed to rebuild profile directory: " + profileDirectory);
|
logger.info("Failed to rebuild profile directory: " +
|
||||||
|
profileDirectory);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
println("Rebuilt profile directory: " + profileDirectory);
|
logger.info("Rebuilt profile directory: " + profileDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (validateProfileFirstRun(profileDirectory))
|
if (validateProfileFirstRun(profileDirectory))
|
||||||
@ -506,12 +507,12 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
pb = this.defaultProcessBuilder(url);
|
pb = this.defaultProcessBuilder(url);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
System.out.println(pb.command());
|
logger.info(pb.command().toString());
|
||||||
p = pb.start();
|
p = pb.start();
|
||||||
sleep(2000);
|
sleep(2000);
|
||||||
return p;
|
return p;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
System.out.println(e);
|
logger.info(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -532,13 +533,13 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
p = launchAndDetatch(privateWindow, url);
|
p = launchAndDetatch(privateWindow, url);
|
||||||
if (p == null)
|
if (p == null)
|
||||||
return;
|
return;
|
||||||
println("I2PChromium");
|
logger.info("I2PChromium");
|
||||||
try {
|
try {
|
||||||
println("Waiting for I2PChromium to close...");
|
logger.info("Waiting for I2PChromium to close...");
|
||||||
int exit = p.waitFor();
|
int exit = p.waitFor();
|
||||||
println("I2PChromium exited with value: " + exit);
|
logger.info("I2PChromium exited with value: " + exit);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error: " + e.getMessage());
|
logger.info("Error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,23 +577,23 @@ public class I2PChromium extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
validateUserDir();
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("I2PChromium");
|
logger.info("I2PChromium");
|
||||||
I2PChromium i2pChromium = new I2PChromium();
|
I2PChromium i2pChromium = new I2PChromium();
|
||||||
println("checking for private browsing");
|
logger.info("checking for private browsing");
|
||||||
ArrayList<String> visitURL = new ArrayList<String>();
|
ArrayList<String> visitURL = new ArrayList<String>();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (arg.equals("-private")) {
|
if (arg.equals("-private")) {
|
||||||
privateBrowsing = true;
|
privateBrowsing = true;
|
||||||
println(
|
logger.info(
|
||||||
"private browsing is true, profile will be discarded at end of session");
|
"private browsing is true, profile will be discarded at end of session");
|
||||||
}
|
}
|
||||||
if (arg.equals("-usability")) {
|
if (arg.equals("-usability")) {
|
||||||
I2PChromiumProfileBuilder.usability = true;
|
I2PChromiumProfileBuilder.usability = true;
|
||||||
}
|
}
|
||||||
if (arg.equals("-noproxycheck")) {
|
if (arg.equals("-noproxycheck")) {
|
||||||
println("zeroing out proxy check");
|
logger.info("zeroing out proxy check");
|
||||||
i2pChromium.setProxyTimeoutTime(0);
|
i2pChromium.setProxyTimeoutTime(0);
|
||||||
}
|
}
|
||||||
if (!arg.startsWith("-")) {
|
if (!arg.startsWith("-")) {
|
||||||
|
@ -120,8 +120,8 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser {
|
|||||||
public static boolean copyBaseProfiletoProfile() {
|
public static boolean copyBaseProfiletoProfile() {
|
||||||
String baseProfile = baseProfileDirectory(usabilityMode());
|
String baseProfile = baseProfileDirectory(usabilityMode());
|
||||||
String profile = profileDirectory();
|
String profile = profileDirectory();
|
||||||
println("Copying base profile to profile directory: " + baseProfile +
|
logger.info("Copying base profile to profile directory: " + baseProfile +
|
||||||
" -> " + profile);
|
" -> " + profile);
|
||||||
if (baseProfile.isEmpty() || profile.isEmpty()) {
|
if (baseProfile.isEmpty() || profile.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -129,14 +129,14 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser {
|
|||||||
File profileDir = new File(profile);
|
File profileDir = new File(profile);
|
||||||
if (!profileDir.exists()) {
|
if (!profileDir.exists()) {
|
||||||
try {
|
try {
|
||||||
println("Copying base profile to profile directory");
|
logger.info("Copying base profile to profile directory");
|
||||||
copyDirectory(baseProfileDir, profileDir, "chromium", usabilityMode());
|
copyDirectory(baseProfileDir, profileDir, "chromium", usabilityMode());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error copying base profile to profile" + e);
|
logger.info("Error copying base profile to profile" + e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println("Copied base profile to profile directory");
|
logger.info("Copied base profile to profile directory");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,15 +29,15 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||||
if (profileDirectory == null) {
|
if (profileDirectory == null) {
|
||||||
println("No profile directory found");
|
logger.info("No profile directory found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println("Profile directory: " + profileDirectory);
|
logger.info("Profile directory: " + profileDirectory);
|
||||||
boolean ok = validateProfileDirectory(profileDirectory);
|
boolean ok = validateProfileDirectory(profileDirectory);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
println("Profile directory is valid");
|
logger.info("Profile directory is valid");
|
||||||
} else {
|
} else {
|
||||||
println("Profile directory is invalid");
|
logger.info("Profile directory is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -50,23 +50,23 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser {
|
|||||||
public static boolean validateProfileDirectory(String profileDirectory) {
|
public static boolean validateProfileDirectory(String profileDirectory) {
|
||||||
File profileDir = new File(profileDirectory);
|
File profileDir = new File(profileDirectory);
|
||||||
if (!profileDir.exists()) {
|
if (!profileDir.exists()) {
|
||||||
println("Profile directory does not exist");
|
logger.info("Profile directory does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.isDirectory()) {
|
if (!profileDir.isDirectory()) {
|
||||||
println("Profile directory is not a directory");
|
logger.info("Profile directory is not a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.canRead()) {
|
if (!profileDir.canRead()) {
|
||||||
println("Profile directory is not readable");
|
logger.info("Profile directory is not readable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.canWrite()) {
|
if (!profileDir.canWrite()) {
|
||||||
println("Profile directory is not writable");
|
logger.info("Profile directory is not writable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!validateExtensionDirectory(profileDir + "/extensions")) {
|
if (!validateExtensionDirectory(profileDir + "/extensions")) {
|
||||||
println("extensions directory is invalid");
|
logger.info("extensions directory is invalid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -81,19 +81,19 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser {
|
|||||||
public static boolean validateFile(String file) {
|
public static boolean validateFile(String file) {
|
||||||
File f = new File(file);
|
File f = new File(file);
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
println("User JavaScript file does not exist");
|
logger.info("User JavaScript file does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f.isFile()) {
|
if (!f.isFile()) {
|
||||||
println("User JavaScript file is not a file");
|
logger.info("User JavaScript file is not a file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f.canRead()) {
|
if (!f.canRead()) {
|
||||||
println("User JavaScript file is not readable");
|
logger.info("User JavaScript file is not readable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f.canWrite()) {
|
if (!f.canWrite()) {
|
||||||
println("User JavaScript file is not writable");
|
logger.info("User JavaScript file is not writable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -108,19 +108,19 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser {
|
|||||||
public static boolean validateExtensionDirectory(String extensionDirectory) {
|
public static boolean validateExtensionDirectory(String extensionDirectory) {
|
||||||
File extensionDir = new File(extensionDirectory);
|
File extensionDir = new File(extensionDirectory);
|
||||||
if (!extensionDir.exists()) {
|
if (!extensionDir.exists()) {
|
||||||
println("Extension directory does not exist");
|
logger.info("Extension directory does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!extensionDir.isDirectory()) {
|
if (!extensionDir.isDirectory()) {
|
||||||
println("Extension directory is not a directory");
|
logger.info("Extension directory is not a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!extensionDir.canRead()) {
|
if (!extensionDir.canRead()) {
|
||||||
println("Extension directory is not readable");
|
logger.info("Extension directory is not readable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!extensionDir.canWrite()) {
|
if (!extensionDir.canWrite()) {
|
||||||
println("Extension directory is not writable");
|
logger.info("Extension directory is not writable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,7 @@ public class I2PChromiumProfileUnpacker extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||||
if (profileDirectory == null) {
|
if (profileDirectory == null) {
|
||||||
println("No profile directory found");
|
logger.info("No profile directory found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ public class I2PChromiumProfileUnpacker extends I2PCommonBrowser {
|
|||||||
* @since 0.0.1
|
* @since 0.0.1
|
||||||
*/
|
*/
|
||||||
public boolean unpackProfile(String profileDirectory, String mode) {
|
public boolean unpackProfile(String profileDirectory, String mode) {
|
||||||
println("Unpacking base profile to " + profileDirectory);
|
logger.info("Unpacking base profile to " + profileDirectory);
|
||||||
return unpackProfile(profileDirectory, "chromium", mode);
|
return unpackProfile(profileDirectory, "chromium", mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class I2PCommonBrowser {
|
public class I2PCommonBrowser {
|
||||||
static Logger logger = Logger.getLogger("browserlauncher");
|
static public Logger logger = Logger.getLogger("browserlauncher");
|
||||||
static FileHandler fh;
|
static FileHandler fh;
|
||||||
// private final int DEFAULT_TIMEOUT = 200;
|
// private final int DEFAULT_TIMEOUT = 200;
|
||||||
private static int CONFIGURED_TIMEOUT = 200;
|
private static int CONFIGURED_TIMEOUT = 200;
|
||||||
@ -53,37 +53,37 @@ public class I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void validateUserDir() {
|
public static void validateUserDir() {
|
||||||
println("Validating user directory");
|
logger.info("Validating user directory");
|
||||||
String userDir = System.getProperty("user.dir");
|
String userDir = System.getProperty("user.dir");
|
||||||
String userHome = System.getProperty("user.home");
|
String userHome = System.getProperty("user.home");
|
||||||
File userDirFile = new File(userDir);
|
File userDirFile = new File(userDir);
|
||||||
File userHomeFile = new File(userHome);
|
File userHomeFile = new File(userHome);
|
||||||
println("user.dir testing !" + userHomeFile.getAbsolutePath() + ".equals(" +
|
logger.info("user.dir testing !" + userHomeFile.getAbsolutePath() +
|
||||||
userDirFile.getAbsolutePath() + ")");
|
".equals(" + userDirFile.getAbsolutePath() + ")");
|
||||||
if (!userDirFile.getAbsolutePath().contains("Program Files")) {
|
if (!userDirFile.getAbsolutePath().contains("Program Files")) {
|
||||||
if (!userDirFile.getAbsolutePath().equals(
|
if (!userDirFile.getAbsolutePath().equals(
|
||||||
userHomeFile.getAbsolutePath())) {
|
userHomeFile.getAbsolutePath())) {
|
||||||
println("user.dir is not inconvenient");
|
logger.info("user.dir is not inconvenient");
|
||||||
if (userDirFile.exists()) {
|
if (userDirFile.exists()) {
|
||||||
println("user.dir exists");
|
logger.info("user.dir exists");
|
||||||
if (userDirFile.isDirectory()) {
|
if (userDirFile.isDirectory()) {
|
||||||
println("user.dir is a directory");
|
logger.info("user.dir is a directory");
|
||||||
if (userDirFile.canWrite()) {
|
if (userDirFile.canWrite()) {
|
||||||
println("user.dir is writable");
|
logger.info("user.dir is writable");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
println("user.dir is not writable");
|
logger.info("user.dir is not writable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ println("user.dir is not actually a directory"); }
|
{ logger.info("user.dir is not actually a directory"); }
|
||||||
} else {
|
} else {
|
||||||
println("user.dir does not exist");
|
logger.info("user.dir does not exist");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println("user.dir should not be the same as user.home");
|
logger.info("user.dir should not be the same as user.home");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println("user.dir cannot run from inside Program Files");
|
logger.info("user.dir cannot run from inside Program Files");
|
||||||
}
|
}
|
||||||
if (isWindows())
|
if (isWindows())
|
||||||
userHome = new File(userHome, "AppData/Local/I2P").getAbsolutePath();
|
userHome = new File(userHome, "AppData/Local/I2P").getAbsolutePath();
|
||||||
@ -91,16 +91,16 @@ public class I2PCommonBrowser {
|
|||||||
if (!defaultPathFile.exists())
|
if (!defaultPathFile.exists())
|
||||||
defaultPathFile.mkdirs();
|
defaultPathFile.mkdirs();
|
||||||
if (!defaultPathFile.isDirectory()) {
|
if (!defaultPathFile.isDirectory()) {
|
||||||
println(
|
logger.info(
|
||||||
"default path exists and is not a directory, get it out of the way");
|
"default path exists and is not a directory, get it out of the way");
|
||||||
println(defaultPathFile.getAbsolutePath());
|
logger.info(defaultPathFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
System.setProperty("user.dir", defaultPathFile.getAbsolutePath());
|
System.setProperty("user.dir", defaultPathFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean isWindows() {
|
protected static boolean isWindows() {
|
||||||
String osName = System.getProperty("os.name");
|
String osName = System.getProperty("os.name");
|
||||||
println("os.name" + osName);
|
logger.info("os.name" + osName);
|
||||||
if (osName.contains("windows"))
|
if (osName.contains("windows"))
|
||||||
return true;
|
return true;
|
||||||
if (osName.contains("Windows"))
|
if (osName.contains("Windows"))
|
||||||
@ -110,7 +110,7 @@ public class I2PCommonBrowser {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void println(String line) { logger.info(line); }
|
// public static void logger.info(String line) { logger.info(line); }
|
||||||
|
|
||||||
private static File logFile() {
|
private static File logFile() {
|
||||||
validateUserDir();
|
validateUserDir();
|
||||||
@ -211,16 +211,16 @@ public class I2PCommonBrowser {
|
|||||||
|
|
||||||
protected boolean unpackProfile(String profileDirectory, String browser,
|
protected boolean unpackProfile(String profileDirectory, String browser,
|
||||||
String base) {
|
String base) {
|
||||||
println("Unpacking base profile to " + profileDirectory);
|
logger.info("Unpacking base profile to " + profileDirectory);
|
||||||
try {
|
try {
|
||||||
final InputStream resources =
|
final InputStream resources =
|
||||||
this.getClass().getClassLoader().getResourceAsStream(
|
this.getClass().getClassLoader().getResourceAsStream(
|
||||||
"i2p." + browser + "." + base + ".profile.zip");
|
"i2p." + browser + "." + base + ".profile.zip");
|
||||||
if (resources == null) {
|
if (resources == null) {
|
||||||
println("Could not find resources");
|
logger.info("Could not find resources");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
println(resources.toString());
|
logger.info(resources.toString());
|
||||||
// InputStream corresponds to a zip file. Unzip it.
|
// InputStream corresponds to a zip file. Unzip it.
|
||||||
// Files.copy(r, new File(profileDirectory).toPath(),
|
// Files.copy(r, new File(profileDirectory).toPath(),
|
||||||
// StandardCopyOption.REPLACE_EXISTING);
|
// StandardCopyOption.REPLACE_EXISTING);
|
||||||
@ -228,14 +228,14 @@ public class I2PCommonBrowser {
|
|||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
// while there are entries I process them
|
// while there are entries I process them
|
||||||
while ((entry = zis.getNextEntry()) != null) {
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
println("entry: " + entry.getName() + ", " + entry.getSize());
|
logger.info("entry: " + entry.getName() + ", " + entry.getSize());
|
||||||
// consume all the data from this entry
|
// consume all the data from this entry
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
println("Creating directory: " + entry.getName());
|
logger.info("Creating directory: " + entry.getName());
|
||||||
File dir = new File(profileDirectory + "/" + entry.getName());
|
File dir = new File(profileDirectory + "/" + entry.getName());
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
} else {
|
} else {
|
||||||
println("Creating file: " + entry.getName());
|
logger.info("Creating file: " + entry.getName());
|
||||||
File file = new File(profileDirectory + "/" + entry.getName());
|
File file = new File(profileDirectory + "/" + entry.getName());
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
Files.copy(zis, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(zis, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
@ -248,7 +248,7 @@ public class I2PCommonBrowser {
|
|||||||
// loop through the Enumeration
|
// loop through the Enumeration
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error copying profile files: " + e.getMessage());
|
logger.info("Error copying profile files: " + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -295,11 +295,11 @@ public class I2PCommonBrowser {
|
|||||||
public static boolean validateProfileFirstRun(String profileDirectory) {
|
public static boolean validateProfileFirstRun(String profileDirectory) {
|
||||||
File profileDir = new File(profileDirectory);
|
File profileDir = new File(profileDirectory);
|
||||||
if (!profileDir.exists()) {
|
if (!profileDir.exists()) {
|
||||||
println("Profile directory does not exist");
|
logger.info("Profile directory does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.isDirectory()) {
|
if (!profileDir.isDirectory()) {
|
||||||
println("Profile directory is not a directory");
|
logger.info("Profile directory is not a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File frf = new File(profileDir, "first-run");
|
File frf = new File(profileDir, "first-run");
|
||||||
@ -356,12 +356,12 @@ public class I2PCommonBrowser {
|
|||||||
* @since 0.0.1
|
* @since 0.0.1
|
||||||
*/
|
*/
|
||||||
public boolean waitForProxy(int timeout, int port, String host) {
|
public boolean waitForProxy(int timeout, int port, String host) {
|
||||||
println("waiting up to " + timeout + "seconds for a proxy");
|
logger.info("waiting up to " + timeout + "seconds for a proxy");
|
||||||
if (timeout <= 0) {
|
if (timeout <= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < timeout; i++) {
|
for (int i = 0; i < timeout; i++) {
|
||||||
println("Waiting for proxy");
|
logger.info("Waiting for proxy");
|
||||||
if (checkifPortIsOccupied(port, host)) {
|
if (checkifPortIsOccupied(port, host)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
for (String path : FIREFOX_SEARCH_PATHS) {
|
for (String path : FIREFOX_SEARCH_PATHS) {
|
||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
println("Found Firefox at " + path);
|
logger.info("Found Firefox at " + path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,10 +239,10 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
for (String firefox : firefoxes) {
|
for (String firefox : firefoxes) {
|
||||||
File firefoxFile = new File(firefox);
|
File firefoxFile = new File(firefox);
|
||||||
if (firefoxFile.exists()) {
|
if (firefoxFile.exists()) {
|
||||||
println("Found valid firefox at " + firefox);
|
logger.info("Found valid firefox at " + firefox);
|
||||||
validFirefoxes.add(firefox);
|
validFirefoxes.add(firefox);
|
||||||
}
|
}
|
||||||
println("firefox at " + firefox + "does not exist");
|
logger.info("firefox at " + firefox + "does not exist");
|
||||||
}
|
}
|
||||||
return validFirefoxes.toArray(new String[validFirefoxes.size()]);
|
return validFirefoxes.toArray(new String[validFirefoxes.size()]);
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
return new ProcessBuilder(newArgs).directory(
|
return new ProcessBuilder(newArgs).directory(
|
||||||
I2PFirefoxProfileBuilder.runtimeDirectory(true));
|
I2PFirefoxProfileBuilder.runtimeDirectory(true));
|
||||||
} else {
|
} else {
|
||||||
println("No Firefox found.");
|
logger.info("No Firefox found.");
|
||||||
return new ProcessBuilder(args);
|
return new ProcessBuilder(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,16 +422,17 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
if (waitForProxy()) {
|
if (waitForProxy()) {
|
||||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||||
if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) {
|
if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) {
|
||||||
println("Valid profile directory: " + profileDirectory);
|
logger.info("Valid profile directory: " + profileDirectory);
|
||||||
} else {
|
} else {
|
||||||
println("Invalid profile directory: " + profileDirectory +
|
logger.info("Invalid profile directory: " + profileDirectory +
|
||||||
" rebuilding...");
|
" rebuilding...");
|
||||||
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile(
|
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile(
|
||||||
usabilityMode())) {
|
usabilityMode())) {
|
||||||
println("Failed to rebuild profile directory: " + profileDirectory);
|
logger.info("Failed to rebuild profile directory: " +
|
||||||
|
profileDirectory);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
println("Rebuilt profile directory: " + profileDirectory);
|
logger.info("Rebuilt profile directory: " + profileDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (validateProfileFirstRun(profileDirectory)) {
|
if (validateProfileFirstRun(profileDirectory)) {
|
||||||
@ -441,22 +442,22 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
Process hp = hpb.start();
|
Process hp = hpb.start();
|
||||||
try {
|
try {
|
||||||
boolean hev = hp.waitFor(5, TimeUnit.SECONDS);
|
boolean hev = hp.waitFor(5, TimeUnit.SECONDS);
|
||||||
println("Headless browser run completed, exit: " + hev);
|
logger.info("Headless browser run completed, exit: " + hev);
|
||||||
if (!hev)
|
if (!hev)
|
||||||
hp.destroy();
|
hp.destroy();
|
||||||
hev = hp.waitFor(5, TimeUnit.SECONDS);
|
hev = hp.waitFor(5, TimeUnit.SECONDS);
|
||||||
if (hp.isAlive()) {
|
if (hp.isAlive()) {
|
||||||
int forcedExitCode = hp.destroyForcibly().waitFor();
|
int forcedExitCode = hp.destroyForcibly().waitFor();
|
||||||
println("Headless browser run forcibly terminated, exit: " +
|
logger.info("Headless browser run forcibly terminated, exit: " +
|
||||||
forcedExitCode);
|
forcedExitCode);
|
||||||
}
|
}
|
||||||
int exitCode = hp.exitValue();
|
int exitCode = hp.exitValue();
|
||||||
println("Headless browser run completed, exit: " + exitCode);
|
logger.info("Headless browser run completed, exit: " + exitCode);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
println("Headless browser error " + e.toString());
|
logger.info("Headless browser error " + e.toString());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
println("Headless browser error " + e.toString());
|
logger.info("Headless browser error " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,13 +469,13 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
pb = defaultProcessBuilder(url);
|
pb = defaultProcessBuilder(url);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
System.out.println(pb.command());
|
logger.info(pb.command().toString());
|
||||||
p = pb.start();
|
p = pb.start();
|
||||||
println("I2PFirefox");
|
logger.info("I2PFirefox");
|
||||||
sleep(2000);
|
sleep(2000);
|
||||||
return p;
|
return p;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
System.out.println(e);
|
logger.info(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -496,11 +497,11 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
if (p == null)
|
if (p == null)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
println("Waiting for I2PFirefox to close...");
|
logger.info("Waiting for I2PFirefox to close...");
|
||||||
int exit = p.waitFor();
|
int exit = p.waitFor();
|
||||||
println("I2PFirefox exited with value: " + exit);
|
logger.info("I2PFirefox exited with value: " + exit);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error: " + e.getMessage());
|
logger.info("Error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,7 +531,7 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
String[] schemes = {"http", "https"};
|
String[] schemes = {"http", "https"};
|
||||||
for (String scheme : schemes) {
|
for (String scheme : schemes) {
|
||||||
if (inUrl.startsWith(scheme)) {
|
if (inUrl.startsWith(scheme)) {
|
||||||
println("Valid URL: " + inUrl);
|
logger.info("Valid URL: " + inUrl);
|
||||||
return inUrl;
|
return inUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -540,8 +541,8 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
validateUserDir();
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("checking for private browsing");
|
logger.info("checking for private browsing");
|
||||||
println("I2PFirefox");
|
logger.info("I2PFirefox");
|
||||||
I2PFirefox i2pFirefox = new I2PFirefox();
|
I2PFirefox i2pFirefox = new I2PFirefox();
|
||||||
ArrayList<String> visitURL = new ArrayList<String>();
|
ArrayList<String> visitURL = new ArrayList<String>();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
@ -549,14 +550,14 @@ public class I2PFirefox extends I2PCommonBrowser {
|
|||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (arg.equals("-private")) {
|
if (arg.equals("-private")) {
|
||||||
privateBrowsing = true;
|
privateBrowsing = true;
|
||||||
println(
|
logger.info(
|
||||||
"private browsing is true, profile will be discarded at end of session");
|
"private browsing is true, profile will be discarded at end of session");
|
||||||
}
|
}
|
||||||
if (arg.equals("-usability")) {
|
if (arg.equals("-usability")) {
|
||||||
usability = true;
|
usability = true;
|
||||||
}
|
}
|
||||||
if (arg.equals("-noproxycheck")) {
|
if (arg.equals("-noproxycheck")) {
|
||||||
println("zeroing out proxy check");
|
logger.info("zeroing out proxy check");
|
||||||
i2pFirefox.setProxyTimeoutTime(0);
|
i2pFirefox.setProxyTimeoutTime(0);
|
||||||
}
|
}
|
||||||
if (!arg.startsWith("-")) {
|
if (!arg.startsWith("-")) {
|
||||||
|
@ -112,8 +112,8 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
|||||||
public static boolean copyBaseProfiletoProfile(String base) {
|
public static boolean copyBaseProfiletoProfile(String base) {
|
||||||
String baseProfile = baseProfileDirectory(base);
|
String baseProfile = baseProfileDirectory(base);
|
||||||
String profile = profileDirectory();
|
String profile = profileDirectory();
|
||||||
println("Copying base profile to profile directory: " + baseProfile +
|
logger.info("Copying base profile to profile directory: " + baseProfile +
|
||||||
" -> " + profile);
|
" -> " + profile);
|
||||||
if (baseProfile.isEmpty() || profile.isEmpty()) {
|
if (baseProfile.isEmpty() || profile.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -122,13 +122,13 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
|||||||
|
|
||||||
if (!profileDir.exists()) {
|
if (!profileDir.exists()) {
|
||||||
try {
|
try {
|
||||||
println("Copying base profile to profile directory");
|
logger.info("Copying base profile to profile directory");
|
||||||
copyDirectory(baseProfileDir, profileDir, "firefox", base);
|
copyDirectory(baseProfileDir, profileDir, "firefox", base);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error copying base profile to profile" + e);
|
logger.info("Error copying base profile to profile" + e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
println("Copied base profile to profile directory");
|
logger.info("Copied base profile to profile directory");
|
||||||
}
|
}
|
||||||
// if user.js does not exist yet, make an empty one.
|
// if user.js does not exist yet, make an empty one.
|
||||||
// if (!touch(profileDir.toString(), "user.js")) {
|
// if (!touch(profileDir.toString(), "user.js")) {
|
||||||
@ -171,7 +171,7 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
|||||||
Files.copy(baseOverrides.toPath(), userOverrides.toPath(),
|
Files.copy(baseOverrides.toPath(), userOverrides.toPath(),
|
||||||
StandardCopyOption.REPLACE_EXISTING);
|
StandardCopyOption.REPLACE_EXISTING);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error copying base profile to profile" + e);
|
logger.info("Error copying base profile to profile" + e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if user-overrides.js does not exist yet, make an empty one.
|
// if user-overrides.js does not exist yet, make an empty one.
|
||||||
|
@ -32,15 +32,15 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||||
if (profileDirectory == null) {
|
if (profileDirectory == null) {
|
||||||
println("No profile directory found");
|
logger.info("No profile directory found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
println("Profile directory: " + profileDirectory);
|
logger.info("Profile directory: " + profileDirectory);
|
||||||
boolean ok = validateProfileDirectory(profileDirectory);
|
boolean ok = validateProfileDirectory(profileDirectory);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
println("Profile directory is valid");
|
logger.info("Profile directory is valid");
|
||||||
} else {
|
} else {
|
||||||
println("Profile directory is invalid");
|
logger.info("Profile directory is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -53,31 +53,31 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
|
|||||||
public static boolean validateProfileDirectory(String profileDirectory) {
|
public static boolean validateProfileDirectory(String profileDirectory) {
|
||||||
File profileDir = new File(profileDirectory);
|
File profileDir = new File(profileDirectory);
|
||||||
if (!profileDir.exists()) {
|
if (!profileDir.exists()) {
|
||||||
println("Profile directory does not exist");
|
logger.info("Profile directory does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.isDirectory()) {
|
if (!profileDir.isDirectory()) {
|
||||||
println("Profile directory is not a directory");
|
logger.info("Profile directory is not a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.canRead()) {
|
if (!profileDir.canRead()) {
|
||||||
println("Profile directory is not readable");
|
logger.info("Profile directory is not readable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!profileDir.canWrite()) {
|
if (!profileDir.canWrite()) {
|
||||||
println("Profile directory is not writable");
|
logger.info("Profile directory is not writable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!validateFile(profileDir + "/prefs.js")) {
|
if (!validateFile(profileDir + "/prefs.js")) {
|
||||||
println("prefs.js is not valid");
|
logger.info("prefs.js is not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!validateFile(profileDir + "/user.js")) {
|
if (!validateFile(profileDir + "/user.js")) {
|
||||||
println("user.js is not valid");
|
logger.info("user.js is not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!validateExtensionDirectory(profileDir + "/extensions")) {
|
if (!validateExtensionDirectory(profileDir + "/extensions")) {
|
||||||
println("extensions directory is invalid");
|
logger.info("extensions directory is invalid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return deRestrictHTTPSAndSetupHomepage(profileDir.toString());
|
return deRestrictHTTPSAndSetupHomepage(profileDir.toString());
|
||||||
@ -172,19 +172,19 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
|
|||||||
public static boolean validateFile(String file) {
|
public static boolean validateFile(String file) {
|
||||||
File f = new File(file);
|
File f = new File(file);
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
println("User JavaScript file does not exist");
|
logger.info("User JavaScript file does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f.isFile()) {
|
if (!f.isFile()) {
|
||||||
println("User JavaScript file is not a file");
|
logger.info("User JavaScript file is not a file");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f.canRead()) {
|
if (!f.canRead()) {
|
||||||
println("User JavaScript file is not readable");
|
logger.info("User JavaScript file is not readable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f.canWrite()) {
|
if (!f.canWrite()) {
|
||||||
println("User JavaScript file is not writable");
|
logger.info("User JavaScript file is not writable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -199,19 +199,19 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser {
|
|||||||
public static boolean validateExtensionDirectory(String extensionDirectory) {
|
public static boolean validateExtensionDirectory(String extensionDirectory) {
|
||||||
File extensionDir = new File(extensionDirectory);
|
File extensionDir = new File(extensionDirectory);
|
||||||
if (!extensionDir.exists()) {
|
if (!extensionDir.exists()) {
|
||||||
println("Extension directory does not exist");
|
logger.info("Extension directory does not exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!extensionDir.isDirectory()) {
|
if (!extensionDir.isDirectory()) {
|
||||||
println("Extension directory is not a directory");
|
logger.info("Extension directory is not a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!extensionDir.canRead()) {
|
if (!extensionDir.canRead()) {
|
||||||
println("Extension directory is not readable");
|
logger.info("Extension directory is not readable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!extensionDir.canWrite()) {
|
if (!extensionDir.canWrite()) {
|
||||||
println("Extension directory is not writable");
|
logger.info("Extension directory is not writable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,7 @@ public class I2PFirefoxProfileUnpacker extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||||
if (profileDirectory == null) {
|
if (profileDirectory == null) {
|
||||||
println("No profile directory found");
|
logger.info("No profile directory found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
pb.environment().put("NO_PROXY", "http://127.0.0.1:7657");
|
pb.environment().put("NO_PROXY", "http://127.0.0.1:7657");
|
||||||
return pb;
|
return pb;
|
||||||
} else {
|
} else {
|
||||||
println("No Browser found.");
|
logger.info("No Browser found.");
|
||||||
return new ProcessBuilder(args);
|
return new ProcessBuilder(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,13 +335,13 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
pb = baseProcessBuilder(url);
|
pb = baseProcessBuilder(url);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
System.out.println(pb.command());
|
System.out.logger.info(pb.command());
|
||||||
p = pb.start();
|
p = pb.start();
|
||||||
println("I2PBrowser");
|
logger.info("I2PBrowser");
|
||||||
sleep(2000);
|
sleep(2000);
|
||||||
return p;
|
return p;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
System.out.println(e);
|
System.out.logger.info(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -351,15 +351,16 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
if (waitForProxy()) {
|
if (waitForProxy()) {
|
||||||
p = launchAndDetatch(privateWindow, url);
|
p = launchAndDetatch(privateWindow, url);
|
||||||
try {
|
try {
|
||||||
println("Waiting for I2PBrowser to close...");
|
logger.info("Waiting for I2PBrowser to close...");
|
||||||
int exit = p.waitFor();
|
int exit = p.waitFor();
|
||||||
if (privateWindow) {
|
if (privateWindow) {
|
||||||
if (deleteRuntimeDirectory())
|
if (deleteRuntimeDirectory())
|
||||||
println("Private browsing enforced, deleting runtime directory");
|
logger.info(
|
||||||
|
"Private browsing enforced, deleting runtime directory");
|
||||||
}
|
}
|
||||||
println("I2PBrowser exited with value: " + exit);
|
logger.info("I2PBrowser exited with value: " + exit);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
println("Error: " + e.getMessage());
|
logger.info("Error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +377,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
String[] schemes = {"http", "https"};
|
String[] schemes = {"http", "https"};
|
||||||
for (String scheme : schemes) {
|
for (String scheme : schemes) {
|
||||||
if (inUrl.startsWith(scheme)) {
|
if (inUrl.startsWith(scheme)) {
|
||||||
println("Valid URL: " + inUrl);
|
logger.info("Valid URL: " + inUrl);
|
||||||
return inUrl;
|
return inUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,14 +397,14 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
validateUserDir();
|
validateUserDir();
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
println("checking for private browsing");
|
logger.info("checking for private browsing");
|
||||||
ArrayList<String> visitURL = new ArrayList<String>();
|
ArrayList<String> visitURL = new ArrayList<String>();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (arg.equals("-private")) {
|
if (arg.equals("-private")) {
|
||||||
privateBrowsing = true;
|
privateBrowsing = true;
|
||||||
println(
|
logger.info(
|
||||||
"private browsing is true, profile will be discarded at end of session");
|
"private browsing is true, profile will be discarded at end of session");
|
||||||
}
|
}
|
||||||
if (!arg.startsWith("-")) {
|
if (!arg.startsWith("-")) {
|
||||||
@ -413,7 +414,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println("I2PGenericUnsafeBrowser");
|
logger.info("I2PGenericUnsafeBrowser");
|
||||||
I2PGenericUnsafeBrowser i2pBrowser = new I2PGenericUnsafeBrowser();
|
I2PGenericUnsafeBrowser i2pBrowser = new I2PGenericUnsafeBrowser();
|
||||||
i2pBrowser.launch(privateBrowsing,
|
i2pBrowser.launch(privateBrowsing,
|
||||||
visitURL.toArray(new String[visitURL.size()]));
|
visitURL.toArray(new String[visitURL.size()]));
|
||||||
|
Reference in New Issue
Block a user