mirror of
https://github.com/wownero/i2p-zero.git
synced 2026-10-17 15:21:40 +02:00
save server keys file as <base32addr>.keys
copy i2p.base dir to ~/.i2p-zero and use the copy, since files in that dir will be modified and the installation dir may not be writable
This commit is contained in:
@@ -191,8 +191,6 @@ public class Controller {
|
||||
var params = Gui.instance.getParameters().getNamed();
|
||||
|
||||
Properties routerProperties = new Properties();
|
||||
routerProperties.put("i2p.dir.base", params.get("i2p.dir.base"));
|
||||
routerProperties.put("i2p.dir.config", params.get("i2p.dir.config"));
|
||||
routerProperties.put("i2np.inboundKBytesPerSecond", getBandwidthLimitKBPerSec());
|
||||
routerProperties.put("i2np.outboundKBytesPerSecond", getBandwidthLimitKBPerSec());
|
||||
routerProperties.put("router.sharePercentage", 80);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.getmonero.i2p.zero;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -12,11 +11,6 @@ public class Main {
|
||||
"Press Ctrl-C to gracefully shut down the router (or send the SIGINT signal to the process).");
|
||||
|
||||
Properties p = new Properties();
|
||||
// add your configuration settings, directories, etc.
|
||||
// where to find the I2P installation files
|
||||
p.put("i2p.dir.base", "/usr/share/i2p");
|
||||
// where to find the I2P data files
|
||||
p.put("i2p.dir.config", System.getProperty("user.home") + File.separator + ".i2p-zero");
|
||||
// bandwidth limits in K bytes per second
|
||||
p.put("i2np.inboundKBytesPerSecond","50");
|
||||
p.put("i2np.outboundKBytesPerSecond","50");
|
||||
|
||||
@@ -10,6 +10,9 @@ import net.i2p.router.transport.FIFOBandwidthRefiller;
|
||||
import net.i2p.router.transport.TransportUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
@@ -20,12 +23,33 @@ public class RouterWrapper {
|
||||
private boolean started = false;
|
||||
private Properties routerProperties;
|
||||
private TunnelControl tunnelControl;
|
||||
private File configDir;
|
||||
private File i2PConfigDir;
|
||||
private File i2PBaseDir;
|
||||
|
||||
public RouterWrapper(Properties p) {
|
||||
this.routerProperties = p;
|
||||
configDir = new File(routerProperties.getProperty("i2p.dir.config"));
|
||||
if(!configDir.exists()) configDir.mkdir();
|
||||
|
||||
p.put("i2p.dir.base", System.getProperty("user.home") + File.separator + ".i2p-zero" + File.separator + "base");
|
||||
p.put("i2p.dir.config", System.getProperty("user.home") + File.separator + ".i2p-zero" + File.separator + "config");
|
||||
|
||||
i2PConfigDir = new File(routerProperties.getProperty("i2p.dir.config"));
|
||||
if(!i2PConfigDir.exists()) i2PConfigDir.mkdirs();
|
||||
|
||||
i2PBaseDir = new File(routerProperties.getProperty("i2p.dir.base"));
|
||||
if(!i2PBaseDir.exists()) {
|
||||
i2PBaseDir.mkdirs();
|
||||
copyFolderRecursively(Path.of(routerProperties.getProperty("i2p.dir.base.template")), i2PBaseDir.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
public void copyFolderRecursively(Path src, Path dest) {
|
||||
try {
|
||||
Files.walk(src).forEach(source -> {
|
||||
try { Files.copy(source, dest.resolve(src.relativize(source)), StandardCopyOption.REPLACE_EXISTING); } catch (Exception e) { throw new RuntimeException(e); }
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
@@ -57,7 +81,7 @@ public class RouterWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
tunnelControl = new TunnelControl(router, new File(configDir, "tunnelTemp"));
|
||||
tunnelControl = new TunnelControl(router, new File(i2PConfigDir, "tunnelTemp"));
|
||||
new Thread(tunnelControl).start();
|
||||
|
||||
}
|
||||
|
||||
@@ -189,15 +189,17 @@ public class TunnelControl implements Runnable {
|
||||
String destHost = args[1];
|
||||
int destPort = Integer.parseInt(args[2]);
|
||||
File serverTunnelConfigDir = new File(args[3]);
|
||||
if(!serverTunnelConfigDir.exists()) serverTunnelConfigDir.mkdir();
|
||||
File serverKeyFile = new File(serverTunnelConfigDir, "serverTunnelSecretKey");
|
||||
File serverKeyFile;
|
||||
KeyPair keyPair;
|
||||
if(serverKeyFile.exists()) {
|
||||
keyPair = KeyPair.read(serverKeyFile.getPath());
|
||||
if(!serverTunnelConfigDir.exists() || serverTunnelConfigDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".keys")).length==0) {
|
||||
serverTunnelConfigDir.mkdir();
|
||||
keyPair = KeyPair.gen();
|
||||
serverKeyFile = new File(serverTunnelConfigDir, keyPair.b32Dest + ".keys");
|
||||
keyPair.write(serverKeyFile.getPath());
|
||||
}
|
||||
else {
|
||||
keyPair = KeyPair.gen();
|
||||
keyPair.write(serverKeyFile.getPath());
|
||||
serverKeyFile = serverTunnelConfigDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".keys"))[0];
|
||||
keyPair = KeyPair.read(serverKeyFile.getPath());
|
||||
}
|
||||
var tunnel = new ServerTunnel(destHost, destPort, keyPair, getTunnelControlTempDir());
|
||||
tunnels.add(tunnel);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
wd=${0%/*}
|
||||
cd "$wd"
|
||||
basedir="$wd/../../../.."
|
||||
./java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.zero.gui --i2p.dir.base=$basedir/i2p.base --i2p.dir.config=$basedir/i2p.config
|
||||
./java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.zero.gui --i2p.dir.base.template=$basedir/i2p.base
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
@echo off
|
||||
set DIR=%~dp0
|
||||
"%DIR%\java" -cp %DIR%\..\i2p.base\jbigi.jar -m org.getmonero.i2p.zero.gui --i2p.dir.base=%DIR%\..\i2p.base %*
|
||||
"%DIR%\java" -cp %DIR%\..\i2p.base\jbigi.jar -m org.getmonero.i2p.zero.gui --i2p.dir.base.template=%DIR%\..\i2p.base %*
|
||||
@@ -6,4 +6,4 @@ else
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
fi
|
||||
|
||||
$basedir/bin/java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.zero.gui --i2p.dir.base=$basedir/i2p.base
|
||||
$basedir/bin/java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.zero.gui --i2p.dir.base.template=$basedir/i2p.base
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
@echo off
|
||||
set DIR=%~dp0
|
||||
"%DIR%\java" -cp %DIR%\..\i2p.base\jbigi.jar -m org.getmonero.i2p.zero --i2p.dir.base=%DIR%\..\i2p.base --i2p.dir.config=%DIR%\..\i2p.config %*
|
||||
"%DIR%\java" -cp %DIR%\..\i2p.base\jbigi.jar -m org.getmonero.i2p.zero --i2p.dir.base.template=%DIR%\..\i2p.base %*
|
||||
+1
-1
@@ -6,4 +6,4 @@ else
|
||||
basedir=$(dirname $(dirname $(readlink -fm $0)))
|
||||
fi
|
||||
|
||||
$basedir/bin/java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.zero --i2p.dir.base=$basedir/i2p.base
|
||||
$basedir/bin/java -cp $basedir/i2p.base/jbigi.jar -m org.getmonero.i2p.zero --i2p.dir.base.template=$basedir/i2p.base
|
||||
|
||||
Reference in New Issue
Block a user