From 46ef089acc26db71efcfbf294d8b4e2c469c1bb7 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 20 May 2022 18:42:35 -0400 Subject: [PATCH] check for router.ping to determine if there's another I2P running --- java/net/i2p/router/WinLauncher.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index efdce42..bc1597b 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -64,6 +64,16 @@ public class WinLauncher { logger.warning(home + " exists but is not a directory. Please get it out of the way"); System.exit(1); } + // check for the existence of router.ping file, if it's less then 2 minutes old, + // exit + File ping = new File(home, "router.ping"); + if (ping.exists()) { + long diff = System.currentTimeMillis() - ping.lastModified(); + if (diff < 2 * 60 * 1000) { + logger.info("router.ping exists and is less than 2 minutes old, I2P appears to be running already."); + System.exit(0); + } + } System.setProperty("i2p.dir.base", programs.getAbsolutePath()); System.setProperty("i2p.dir.config", home.getAbsolutePath());