From d4637818be555634b5c2c2484e8af87b42a658a7 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Tue, 2 Feb 2010 15:18:22 +0000 Subject: [PATCH] - Show yellow star if no outbound tunnels --- .../src/net/i2p/router/web/SummaryHelper.java | 2 +- .../net/i2p/router/DummyTunnelManagerFacade.java | 1 + .../src/net/i2p/router/TunnelManagerFacade.java | 2 ++ .../i2p/router/tunnel/pool/TunnelPoolManager.java | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java index 53e71698db..f93bba3d57 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java @@ -390,7 +390,7 @@ public class SummaryHelper extends HelperBase { buf.append(name.substring(0,15)).append("…"); buf.append("</a></b></td>\n"); LeaseSet ls = _context.netDb().lookupLeaseSetLocally(h); - if (ls != null) { + if (ls != null && _context.tunnelManager().getOutboundClientTunnelCount(h) > 0) { long timeToExpire = ls.getEarliestLeaseDate() - _context.clock().now(); if (timeToExpire < 0) { // red or yellow light diff --git a/router/java/src/net/i2p/router/DummyTunnelManagerFacade.java b/router/java/src/net/i2p/router/DummyTunnelManagerFacade.java index 2adc9ac338..aef58c3589 100644 --- a/router/java/src/net/i2p/router/DummyTunnelManagerFacade.java +++ b/router/java/src/net/i2p/router/DummyTunnelManagerFacade.java @@ -37,6 +37,7 @@ class DummyTunnelManagerFacade implements TunnelManagerFacade { public int getInboundClientTunnelCount() { return 0; } public double getShareRatio() { return 0d; } public int getOutboundClientTunnelCount() { return 0; } + public int getOutboundClientTunnelCount(Hash destination) { return 0; } public long getLastParticipatingExpiration() { return -1; } public void buildTunnels(Destination client, ClientTunnelSettings settings) {} public TunnelPoolSettings getInboundSettings() { return null; } diff --git a/router/java/src/net/i2p/router/TunnelManagerFacade.java b/router/java/src/net/i2p/router/TunnelManagerFacade.java index b1cfd5c289..433624779c 100644 --- a/router/java/src/net/i2p/router/TunnelManagerFacade.java +++ b/router/java/src/net/i2p/router/TunnelManagerFacade.java @@ -51,6 +51,8 @@ public interface TunnelManagerFacade extends Service { public int getInboundClientTunnelCount(); /** how many outbound client tunnels do we have available? */ public int getOutboundClientTunnelCount(); + /** how many outbound client tunnels in this pool? */ + public int getOutboundClientTunnelCount(Hash destination); public double getShareRatio(); /** When does the last tunnel we are participating in expire? */ diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java index fbb2bc77f0..db68b507d1 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java +++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java @@ -190,6 +190,21 @@ public class TunnelPoolManager implements TunnelManagerFacade { } return count; } + + /** + * Use to verify a tunnel pool is alive + * @since 0.7.11 + */ + public int getOutboundClientTunnelCount(Hash destination) { + TunnelPool pool = null; + synchronized (_clientOutboundPools) { + pool = _clientOutboundPools.get(destination); + } + if (pool != null) + return pool.getTunnelCount(); + return 0; + } + public int getParticipatingCount() { return _context.tunnelDispatcher().getParticipatingCount(); } public long getLastParticipatingExpiration() { return _context.tunnelDispatcher().getLastParticipatingExpiration(); } -- GitLab