check if the console is up before continuing
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package net.i2p.router;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.*;
|
||||
|
||||
import net.i2p.crypto.*;
|
||||
@ -49,6 +51,12 @@ public class WinLauncher {
|
||||
System.out.println("\t" + System.getProperty("i2p.dir.base") + "\n\t" + System.getProperty("i2p.dir.config")
|
||||
+ "\n\t" + System.getProperty("router.pid"));
|
||||
|
||||
// do a quick check to see of port 7657 is already occupied
|
||||
if (i2pIsRunning()) {
|
||||
System.err.println("I2P is already running");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// wupp.i2pRouter = new Router(System.getProperties());
|
||||
System.out.println("Router is configured");
|
||||
|
||||
@ -61,6 +69,18 @@ public class WinLauncher {
|
||||
RouterLaunch.main(args);
|
||||
}
|
||||
|
||||
private static boolean i2pIsRunning() {
|
||||
// check if there's something listening on port 7657
|
||||
try {
|
||||
InetAddress localhost = InetAddress.getLocalHost();
|
||||
Socket s = new Socket(localhost, 7657);
|
||||
s.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Runnable REGISTER_UPP = () -> {
|
||||
|
||||
// first wait for the RouterContext to appear
|
||||
|
Reference in New Issue
Block a user