Add standby indication to i2ptunnel page
This commit is contained in:
@ -75,7 +75,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
private static long __tunnelId = 0;
|
||||
private long _tunnelId;
|
||||
private Properties _clientOptions;
|
||||
private final List _sessions;
|
||||
private final List<I2PSession> _sessions;
|
||||
|
||||
public static final int PACKET_DELAY = 100;
|
||||
|
||||
@ -179,7 +179,7 @@ public class I2PTunnel implements Logging, EventDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
List getSessions() {
|
||||
List<I2PSession> getSessions() {
|
||||
synchronized (_sessions) {
|
||||
return new ArrayList(_sessions);
|
||||
}
|
||||
|
@ -434,6 +434,16 @@ public class TunnelController implements Logging {
|
||||
|
||||
public boolean getIsRunning() { return _running; }
|
||||
public boolean getIsStarting() { return _starting; }
|
||||
/** if running but no open sessions, we are in standby */
|
||||
public boolean getIsStandby() {
|
||||
if (!_running)
|
||||
return false;
|
||||
for (I2PSession sess : _tunnel.getSessions()) {
|
||||
if (!sess.isClosed())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void getSummary(StringBuffer buf) {
|
||||
String type = getType();
|
||||
|
@ -77,6 +77,7 @@ public class IndexBean {
|
||||
public static final int RUNNING = 1;
|
||||
public static final int STARTING = 2;
|
||||
public static final int NOT_RUNNING = 3;
|
||||
public static final int STANDBY = 4;
|
||||
|
||||
public static final String PROP_TUNNEL_PASSPHRASE = "i2ptunnel.passphrase";
|
||||
static final String PROP_NONCE = IndexBean.class.getName() + ".nonce";
|
||||
@ -412,8 +413,12 @@ public class IndexBean {
|
||||
public int getTunnelStatus(int tunnel) {
|
||||
TunnelController tun = getController(tunnel);
|
||||
if (tun == null) return NOT_RUNNING;
|
||||
if (tun.getIsRunning()) return RUNNING;
|
||||
else if (tun.getIsStarting()) return STARTING;
|
||||
if (tun.getIsRunning()) {
|
||||
if (isClient(tunnel) && tun.getIsStandby())
|
||||
return STANDBY;
|
||||
else
|
||||
return RUNNING;
|
||||
} else if (tun.getIsStarting()) return STARTING;
|
||||
else return NOT_RUNNING;
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,11 @@
|
||||
case IndexBean.STARTING:
|
||||
%><div class="statusStarting text">Starting...</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.STANDBY:
|
||||
%><div class="statusStarting text">Standby</div>
|
||||
<a class="control" title="Stop this Tunnel" href="index.jsp?nonce=<%=indexBean.getNextNonce()%>&action=stop&tunnel=<%=curClient%>">Stop</a>
|
||||
<%
|
||||
break;
|
||||
case IndexBean.RUNNING:
|
||||
|
Reference in New Issue
Block a user