From 3930c6750d56c15db7e780eb85ea0c2f9325c575 Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 7 Aug 2022 21:58:57 -0400 Subject: [PATCH] make the java launcher handle the Firefox launch automatically if the router is already running --- i2pversion | 4 ++-- java/net/i2p/router/WinLauncher.java | 20 ++++++++++++++------ license/I2P.txt | 8 ++------ license/NOTICE-Tomcat.txt | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/i2pversion b/i2pversion index ad66ff2..5998b80 100644 --- a/i2pversion +++ b/i2pversion @@ -10,8 +10,8 @@ VERSIONMINOR=8 VERSIONBUILD=1 I2P_VERSION="$VERSIONMAJOR.$VERSIONMINOR.$VERSIONBUILD" export I2P_VERSION="$VERSIONMAJOR.$VERSIONMINOR.$VERSIONBUILD" -VERSION=i2p-1.8.1 -export VERSION=i2p-1.8.1 +VERSION=i2p-1.8.8 +export VERSION=i2p-1.8.0 #Uncomment this to build from the tip of the master. #I2P_VERSION=1.8.0 diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 71321ed..639ec5d 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -2,6 +2,7 @@ package net.i2p.router; import java.io.*; import java.net.InetAddress; +import java.net.ServerSocket; import java.net.Socket; import java.util.*; import java.util.logging.FileHandler; @@ -92,15 +93,21 @@ public class WinLauncher { RouterLaunch.main(args); } + // see https://stackoverflow.com/questions/434718/sockets-discover-port-availability-using-java + public static boolean isAvailable(int portNr) { + boolean portFree; + try (var ignored = new ServerSocket(portNr)) { + portFree = true; + } catch (IOException e) { + portFree = false; + } + return portFree; + } + 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(); + if (!isAvailable(7657)) { return true; - } catch (IOException e) { - return false; } // check for the existence of router.ping file, if it's less then 2 minutes old, // exit @@ -113,6 +120,7 @@ public class WinLauncher { return true; } } + return false; } private static final Runnable REGISTER_UPP = () -> { diff --git a/license/I2P.txt b/license/I2P.txt index fe6b5cf..1e94e57 100644 --- a/license/I2P.txt +++ b/license/I2P.txt @@ -212,10 +212,6 @@ Applications: Copyright (c) 2006, Matthew Estes See licenses/LICENSE-BlockFile.txt - BOB (BOB.jar): - Copyright (C) sponge - See licenses/COPYING-BOB.txt - Desktopgui (desktopgui.jar): Copyright (c) Mathias De Maré See licenses/LICENSE-DesktopGUI.txt @@ -339,9 +335,9 @@ Applications: Systray (systray.jar): Public domain. - Tomcat 9.0.54 (jasper-runtime.jar): + Tomcat 9.0.62 (jasper-runtime.jar): (not included in most distribution packages) - Copyright 1999-2021 The Apache Software Foundation + Copyright 1999-2022 The Apache Software Foundation See licenses/LICENSE-Apache2.0.txt See licenses/NOTICE-Tomcat.txt diff --git a/license/NOTICE-Tomcat.txt b/license/NOTICE-Tomcat.txt index 43bc6be..74fd3c4 100644 --- a/license/NOTICE-Tomcat.txt +++ b/license/NOTICE-Tomcat.txt @@ -1,5 +1,5 @@ Apache Tomcat -Copyright 1999-2021 The Apache Software Foundation +Copyright 1999-2022 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (https://www.apache.org/).