From e1d808a284815515b49d616f43f1bb8affd4e4ae Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Fri, 4 Oct 2013 16:50:37 +0000
Subject: [PATCH] add msg when stopping tunnel on idle

---
 .../java/src/org/klomp/snark/IdleChecker.java         | 11 +++++++----
 .../java/src/org/klomp/snark/SnarkManager.java        |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/apps/i2psnark/java/src/org/klomp/snark/IdleChecker.java b/apps/i2psnark/java/src/org/klomp/snark/IdleChecker.java
index adfc42833c..ff6454ee23 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/IdleChecker.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/IdleChecker.java
@@ -22,6 +22,7 @@ import net.i2p.util.SimpleTimer2;
  */
 class IdleChecker extends SimpleTimer2.TimedEvent {
 
+    private final SnarkManager _mgr;
     private final I2PSnarkUtil _util;
     private final PeerCoordinatorSet _pcs;
     private final Log _log;
@@ -36,10 +37,11 @@ class IdleChecker extends SimpleTimer2.TimedEvent {
     /**
      *  Caller must schedule
      */
-    public IdleChecker(I2PSnarkUtil util, PeerCoordinatorSet pcs) {
-        super(util.getContext().simpleTimer2());
-        _log = util.getContext().logManager().getLog(IdleChecker.class);
-        _util = util;
+    public IdleChecker(SnarkManager mgr, PeerCoordinatorSet pcs) {
+        super(mgr.util().getContext().simpleTimer2());
+        _util = mgr.util();
+        _log = _util.getContext().logManager().getLog(IdleChecker.class);
+        _mgr = mgr;
         _pcs = pcs;
     }
 
@@ -64,6 +66,7 @@ class IdleChecker extends SimpleTimer2.TimedEvent {
                     if (_log.shouldLog(Log.WARN))
                         _log.warn("Closing tunnels on idle");
                     _util.disconnect();
+                    _mgr.addMessage(_util.getString("I2P tunnel closed."));
                     schedule(3 * CHECK_TIME);
                     return;
                 }
diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
index 38ea1c094d..b5e10b9401 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
@@ -180,7 +180,7 @@ public class SnarkManager implements CompleteListener {
             _context.simpleScheduler().addEvent(new Register(), 4*60*1000);
         // Not required, Jetty has a shutdown hook
         //_context.addShutdownTask(new SnarkManagerShutdown());
-        _idleChecker = new IdleChecker(_util, _peerCoordinatorSet);
+        _idleChecker = new IdleChecker(this, _peerCoordinatorSet);
         _idleChecker.schedule(5*60*1000);
     }
 
-- 
GitLab