From 3befe90007794c5072e0aa7ecfd6c8716b9119f9 Mon Sep 17 00:00:00 2001 From: zzz <zzz@i2pmail.org> Date: Fri, 10 Jun 2022 09:53:55 -0400 Subject: [PATCH] i2ptunnel: Add tunnel name to offline expiration log messages --- .../net/i2p/i2ptunnel/I2PTunnelServer.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index c18112908c..dab84d9e51 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -289,14 +289,14 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { if (remaining <= 10*60*1000) { String msg; if (remaining > 0) - msg = "Offline signature for tunnel alternate destination expires " + DataHelper.formatTime(exp); + msg = "Offline signature for tunnel " + name + " alternate destination expires in " + DataHelper.formatTime(exp); else - msg = "Offline signature for tunnel alternate destination expired " + DataHelper.formatTime(exp); + msg = "Offline signature for tunnel " + name + " alternate destination expired " + DataHelper.formatTime(exp); _log.log(Log.CRIT, msg); throw new IllegalArgumentException(msg); } if (remaining < 60*24*60*60*1000L) { - String msg = "Offline signature for tunnel alternate destination expires in " + DataHelper.formatDuration(remaining); + String msg = "Offline signature for tunnel " + name + " alternate destination expires in " + DataHelper.formatDuration(remaining); _log.logAlways(Log.WARN, msg); l.log("WARNING: " + msg); } @@ -327,18 +327,25 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { if (session.isOffline()) { long exp = session.getOfflineExpiration(); long remaining = exp - getTunnel().getContext().clock().now(); + Properties props = getTunnel().getClientOptions(); + String name = props.getProperty("inbound.nickname"); + if (name == null) { + name = props.getProperty("outbound.nickname"); + if (name == null) + name = ""; + } // if expires before the LS expires... if (remaining <= 10*60*1000) { String msg; if (remaining > 0) - msg = "Offline signature for tunnel expires " + DataHelper.formatTime(exp); + msg = "Offline signature for tunnel " + name + " expires in " + DataHelper.formatTime(exp); else - msg = "Offline signature for tunnel expired " + DataHelper.formatTime(exp); + msg = "Offline signature for tunnel " + name + " expired " + DataHelper.formatTime(exp); _log.log(Log.CRIT, msg); throw new IllegalArgumentException(msg); } if (remaining < 60*24*60*60*1000L) { - String msg = "Offline signature for tunnel expires in " + DataHelper.formatDuration(remaining); + String msg = "Offline signature for tunnel " + name + " expires in " + DataHelper.formatDuration(remaining); _log.logAlways(Log.WARN, msg); l.log("WARNING: " + msg); } -- GitLab