more javadoc
Former-commit-id: 2c608ccbc5
Former-commit-id: 0253f02816b4bc27b170a0d840cdd7c2ff34c170
This commit is contained in:
16
README.md
16
README.md
@ -84,4 +84,20 @@ if (i2pIsRunning()) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
|
||||||
|
// Auto-Select Example, chooses Firefox first, then Chromium
|
||||||
|
if (i2pIsRunning()) {
|
||||||
|
logger.warning("I2P is already running");
|
||||||
|
System.out.println("I2PBrowser");
|
||||||
|
I2PBrowser i2pBrowser = new I2PBrowser();
|
||||||
|
/*
|
||||||
|
* toggle chromium to the top of the order by doing:
|
||||||
|
I2PBrowser.chromiumFirst = true;
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
i2pBrowser.launch(privateBrowsing);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
to add a browser management tool to it.
|
to add a browser management tool to it.
|
||||||
|
@ -1,11 +1,30 @@
|
|||||||
package net.i2p.i2pfirefox;
|
package net.i2p.i2pfirefox;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PBrowser.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PBrowser is a class that is used to open a browser window to the I2P network.
|
||||||
|
* It automatically detects the operating system and available browsers, and selects
|
||||||
|
* the best one to use, with Tor Browser at the top for Firefox and Brave at the top
|
||||||
|
* for Chrome.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.16
|
||||||
|
*/
|
||||||
public class I2PBrowser {
|
public class I2PBrowser {
|
||||||
private final I2PFirefox i2pFirefox = new I2PFirefox();
|
private final I2PFirefox i2pFirefox = new I2PFirefox();
|
||||||
private final I2PChromium i2pChromium = new I2PChromium();
|
private final I2PChromium i2pChromium = new I2PChromium();
|
||||||
public static boolean firefox = false;
|
public boolean firefox = false;
|
||||||
public static boolean chromium = false;
|
public boolean chromium = false;
|
||||||
|
public boolean chromiumFirst = false;
|
||||||
|
|
||||||
private void launchFirefox(boolean privateWindow) {
|
private void launchFirefox(boolean privateWindow) {
|
||||||
System.out.println("I2PFirefox");
|
System.out.println("I2PFirefox");
|
||||||
@ -17,9 +36,7 @@ public class I2PBrowser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct an I2PBrowser class which manages an instance of Chromium and
|
* Construct an I2PBrowser class which automatically determines which browser to use.
|
||||||
* an accompanying Chromium profile. This version includes Chromium variants
|
|
||||||
* and forks.
|
|
||||||
*
|
*
|
||||||
* @since 0.0.16
|
* @since 0.0.16
|
||||||
*/
|
*/
|
||||||
@ -63,7 +80,7 @@ public class I2PBrowser {
|
|||||||
/*
|
/*
|
||||||
* Populates a profile directory with a proxy configuration.
|
* Populates a profile directory with a proxy configuration.
|
||||||
* Waits for an HTTP proxy on the port 4444 to be ready.
|
* Waits for an HTTP proxy on the port 4444 to be ready.
|
||||||
* Launches Chromium with the profile directory.
|
* Launches either Firefox or Chromium with the profile directory.
|
||||||
*
|
*
|
||||||
* @param bool if true, the profile will be ephemeral(i.e. a --private-window profile).
|
* @param bool if true, the profile will be ephemeral(i.e. a --private-window profile).
|
||||||
* @since 0.0.16
|
* @since 0.0.16
|
||||||
@ -75,21 +92,28 @@ public class I2PBrowser {
|
|||||||
} else if (this.hasChromium()) {
|
} else if (this.hasChromium()) {
|
||||||
this.launchChromium(privateWindow);
|
this.launchChromium(privateWindow);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chromiumFirst){
|
||||||
|
if (chromium) {
|
||||||
|
this.launchChromium(privateWindow);
|
||||||
|
}else if (firefox) {
|
||||||
|
this.launchFirefox(privateWindow);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (firefox) {
|
if (firefox) {
|
||||||
this.launchFirefox(privateWindow);
|
this.launchFirefox(privateWindow);
|
||||||
return;
|
}else if (chromium) {
|
||||||
}
|
|
||||||
if (chromium) {
|
|
||||||
this.launchChromium(privateWindow);
|
this.launchChromium(privateWindow);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Populates a profile directory with a proxy configuration.
|
* Populates a profile directory with a proxy configuration.
|
||||||
* Waits for an HTTP proxy on the port 4444 to be ready.
|
* Waits for an HTTP proxy on the port 4444 to be ready.
|
||||||
* Launches Chromium with the profile directory.
|
* Launches either Firefox or Chromium with the profile directory.
|
||||||
*
|
*
|
||||||
* @since 0.0.16
|
* @since 0.0.16
|
||||||
*/
|
*/
|
||||||
@ -99,22 +123,22 @@ public class I2PBrowser {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
boolean privateBrowsing = false;
|
boolean privateBrowsing = false;
|
||||||
|
System.out.println("I2PBrowser");
|
||||||
|
I2PBrowser i2pBrowser = new I2PBrowser();
|
||||||
if (args != null && args.length > 0) {
|
if (args != null && args.length > 0) {
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (arg.equals("-private")) {
|
if (arg.equals("-private")) {
|
||||||
privateBrowsing = true;
|
privateBrowsing = true;
|
||||||
}
|
}
|
||||||
if (arg.equals("-chromium")) {
|
if (arg.equals("-chromium")) {
|
||||||
chromium = true;
|
i2pBrowser.chromium = true;
|
||||||
}
|
}
|
||||||
if (arg.equals("-firefox")) {
|
if (arg.equals("-firefox")) {
|
||||||
firefox = true;
|
i2pBrowser.firefox = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("I2PBrowser");
|
i2pBrowser.launch(privateBrowsing);
|
||||||
I2PBrowser I2PBrowser = new I2PBrowser();
|
|
||||||
I2PBrowser.launch(privateBrowsing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,7 +5,20 @@ import java.io.IOException;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PChromium.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PChromium {
|
public class I2PChromium {
|
||||||
private final String[] CHROMIUM_SEARCH_PATHS = CHROMIUM_FINDER();
|
private final String[] CHROMIUM_SEARCH_PATHS = CHROMIUM_FINDER();
|
||||||
private final int DEFAULT_TIMEOUT = 200;
|
private final int DEFAULT_TIMEOUT = 200;
|
||||||
|
@ -9,6 +9,24 @@ import java.io.OutputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PChromiumProfileBuilder.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PChromiumProfileBuilder is a class that builds a profile directory which
|
||||||
|
* contains the I2P browser profile for the Chromium browser family. It manages
|
||||||
|
* the base profile directory and copies it's contents to the active profile
|
||||||
|
* directory, which is actually used by Chromium.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PChromiumProfileBuilder {
|
public class I2PChromiumProfileBuilder {
|
||||||
private static boolean strict;
|
private static boolean strict;
|
||||||
|
|
||||||
|
@ -2,6 +2,22 @@ package net.i2p.i2pfirefox;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PChromiumProfileChecker.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PChromiumProfileChecker is a class that checks if the Chromium profile directory
|
||||||
|
* exists and is valid.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PChromiumProfileChecker {
|
public class I2PChromiumProfileChecker {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
String profileDirectory = I2PChromiumProfileBuilder.profileDirectory();
|
||||||
|
@ -7,6 +7,23 @@ import java.nio.file.StandardCopyOption;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PChromiumProfileUnpacker.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PChromiumProfileUnpacker is a class that unpacks the Chromium profile zip file
|
||||||
|
* into the Chromium base profile directory. This is not used by the Chromium browser
|
||||||
|
* instance, it's unpacked to the disk to be copied to the active profile directory.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PChromiumProfileUnpacker {
|
public class I2PChromiumProfileUnpacker {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -5,6 +5,20 @@ import java.io.IOException;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PFirefox.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PFirefox {
|
public class I2PFirefox {
|
||||||
private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER();
|
private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER();
|
||||||
private final int DEFAULT_TIMEOUT = 200;
|
private final int DEFAULT_TIMEOUT = 200;
|
||||||
|
@ -9,6 +9,24 @@ import java.io.OutputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PFirefoxProfileBuilder.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PFirefoxProfileBuilder is a class that builds a profile directory which
|
||||||
|
* contains the I2P browser profile for the Firefox browser family. It manages
|
||||||
|
* the base profile directory and copies it's contents to the active profile
|
||||||
|
* directory, which is actually used by Firefox.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PFirefoxProfileBuilder {
|
public class I2PFirefoxProfileBuilder {
|
||||||
private static boolean strict;
|
private static boolean strict;
|
||||||
|
|
||||||
|
@ -2,6 +2,22 @@ package net.i2p.i2pfirefox;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PFirefoxProfileChecker.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PFirefoxProfileChecker is a class that checks if the Firefox profile directory
|
||||||
|
* exists and is valid.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PFirefoxProfileChecker {
|
public class I2PFirefoxProfileChecker {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||||
|
@ -7,6 +7,24 @@ import java.nio.file.StandardCopyOption;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2PFirefoxProfileUnpacker.java
|
||||||
|
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the MIT License. See LICENSE.md for details.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* I2PFirefoxProfileUnpacker is a class that unpacks the I2P Firefox profile
|
||||||
|
* from a zip file embedded in the `jar` file. The zip is unpacked to a base
|
||||||
|
* directory where it is left untouched, and the base profile is copied to the
|
||||||
|
* active profile directory.
|
||||||
|
*
|
||||||
|
* @author idk
|
||||||
|
* @since 0.0.1
|
||||||
|
*/
|
||||||
public class I2PFirefoxProfileUnpacker {
|
public class I2PFirefoxProfileUnpacker {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#! /usr/bin/env sh
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
GITHUB_USER=eyedeekay
|
|
||||||
GITHUB_REPO=i2p.plugins.firefox
|
|
||||||
ant distclean
|
ant distclean
|
||||||
ant jar
|
ant jar
|
||||||
java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PChromium
|
java -cp ./src/build/i2pfirefox.jar net.i2p.i2pfirefox.I2PBrowser -private -chromium
|
Reference in New Issue
Block a user