log to stdout when I2P has warmed up

pull/35/head
knaccc 5 years ago
parent 8c310b5df9
commit b9a5baef78

@ -18,7 +18,7 @@ public class Main {
System.exit(1);
}
System.out.println("I2P router launched.\n" +
System.out.println("I2P router launched. Note that it will take several minutes for I2P to warm up before it is ready.\n" +
"Press Ctrl-C to gracefully shut down the router (or send the SIGINT signal to the process).");
Properties p = new Properties();
@ -38,13 +38,18 @@ public class Main {
+ p.entrySet().stream().map(e->"--"+e.getKey()+"="+e.getValue()).collect(Collectors.joining(" ")));
RouterWrapper routerWrapper = new RouterWrapper(p, ()->{
Main.consoleOut.println("**** A new version of I2P-zero is available at https://github.com/i2p-zero/i2p-zero - Please keep your software up-to-date, as it will enhance your privacy and keep you safe from vulnerabilities");
consoleOut.println("**** A new version of I2P-zero is available at https://github.com/i2p-zero/i2p-zero - Please keep your software up-to-date, as it will enhance your privacy and keep you safe from vulnerabilities");
});
routerWrapper.start(()->Main.consoleOut.println("For best performance, please open port " + routerWrapper.routerExternalPort + " on your firewall for incoming UDP and TCP connections. This port has been randomly assigned to you. For privacy reasons, please do not share this port with others."));
routerWrapper.start(()->consoleOut.println("For best performance, please open port " + routerWrapper.routerExternalPort + " on your firewall for incoming UDP and TCP connections. This port has been randomly assigned to you. For privacy reasons, please do not share this port with others."));
Runtime.getRuntime().addShutdownHook(new Thread(()->routerWrapper.stop(true)));
new Thread(()->{
routerWrapper.waitForRouterRunning();
consoleOut.println("I2P router now ready to create tunnels");
}).start();
}
}

@ -332,6 +332,9 @@ public class RouterWrapper {
if(router==null) return false;
return router.isRunning();
}
public void waitForRouterRunning() {
while(!isRouterRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) {} }
}
public RouterContext getRouterContext() {
return router.getContext();

@ -202,9 +202,6 @@ public class TunnelControl implements Runnable {
}
}).start();
}
public void waitForRouterRunning() {
while(!routerWrapper.isRouterRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) {} }
}
}
public static class ClientTunnel extends Tunnel {
@ -220,7 +217,7 @@ public class TunnelControl implements Runnable {
@Override
public Tunnel start() {
new Thread(()->{
waitForRouterRunning();
routerWrapper.waitForRouterRunning();
tunnel = new I2PTunnel(new String[]{"-die", "-nocli", "-e", "config localhost 7654", "-e", "client " + port + " " + dest});
}).start();
return this;
@ -242,7 +239,7 @@ public class TunnelControl implements Runnable {
@Override
public Tunnel start() {
new Thread(()->{
waitForRouterRunning();
routerWrapper.waitForRouterRunning();
tunnel = new I2PTunnel(new String[]{"-die", "-nocli", "-e", "config localhost 7654", "-e", "httpclient " + port});
}).start();
return this;
@ -276,7 +273,7 @@ public class TunnelControl implements Runnable {
@Override
public Tunnel start() {
new Thread(() -> {
waitForRouterRunning();
routerWrapper.waitForRouterRunning();
try {
String uuid = new BigInteger(128, new Random()).toString(16);
String seckeyPath = tunnelControlTempDir.getAbsolutePath() + File.separator + "seckey." + uuid + ".dat";
@ -419,7 +416,7 @@ public class TunnelControl implements Runnable {
@Override
public Tunnel start() {
new Thread(()->{
waitForRouterRunning();
routerWrapper.waitForRouterRunning();
tunnel = new I2PTunnel(new String[]{"-die", "-nocli", "-e", "sockstunnel " + port});
}).start();
return this;

Loading…
Cancel
Save