* Console cleanups
* Router: Don't do some things when we are shutting down * VMCommSystem fixups
This commit is contained in:
@ -35,16 +35,13 @@ public class ConfigStatsHelper extends HelperBase {
|
||||
/**
|
||||
* Configure this bean to query a particular router context
|
||||
*
|
||||
* @param contextId begging few characters of the routerHash, or null to pick
|
||||
* @param contextId beginning few characters of the routerHash, or null to pick
|
||||
* the first one we come across.
|
||||
*/
|
||||
@Override
|
||||
public void setContextId(String contextId) {
|
||||
try {
|
||||
_context = ContextHelper.getContext(contextId);
|
||||
_log = _context.logManager().getLog(ConfigStatsHelper.class);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
super.setContextId(contextId);
|
||||
_log = _context.logManager().getLog(ConfigStatsHelper.class);
|
||||
|
||||
_stats = new ArrayList();
|
||||
Map groups = _context.statManager().getStatsByGroup();
|
||||
|
@ -14,7 +14,7 @@ public abstract class HelperBase {
|
||||
/**
|
||||
* Configure this bean to query a particular router context
|
||||
*
|
||||
* @param contextId begging few characters of the routerHash, or null to pick
|
||||
* @param contextId beginning few characters of the routerHash, or null to pick
|
||||
* the first one we come across.
|
||||
*/
|
||||
public void setContextId(String contextId) {
|
||||
@ -25,5 +25,8 @@ public abstract class HelperBase {
|
||||
}
|
||||
}
|
||||
|
||||
/** might be useful in the jsp's */
|
||||
//public RouterContext getContext() { return _context; }
|
||||
|
||||
public void setWriter(Writer out) { _out = out; }
|
||||
}
|
||||
|
@ -205,6 +205,7 @@ public class RouterConsoleRunner {
|
||||
}
|
||||
}
|
||||
|
||||
/*******
|
||||
public void stopConsole() {
|
||||
try {
|
||||
_server.stop();
|
||||
@ -212,6 +213,7 @@ public class RouterConsoleRunner {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
}
|
||||
********/
|
||||
|
||||
public static Properties webAppProperties() {
|
||||
Properties rv = new Properties();
|
||||
|
@ -64,7 +64,9 @@ public abstract class CommSystemFacade implements Service {
|
||||
public void queueLookup(byte[] ip) {}
|
||||
public String getCountry(Hash peer) { return null; }
|
||||
public String getCountryName(String code) { return code; }
|
||||
public String renderPeerHTML(Hash peer) { return null; }
|
||||
public String renderPeerHTML(Hash peer) {
|
||||
return peer.toBase64().substring(0, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell other transports our address changed
|
||||
|
@ -481,6 +481,8 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
private static final long PUBLISH_DELAY = 3*1000;
|
||||
public void publish(LeaseSet localLeaseSet) {
|
||||
if (!_initialized) return;
|
||||
if (_context.router().gracefulShutdownInProgress())
|
||||
return;
|
||||
Hash h = localLeaseSet.getDestination().calculateHash();
|
||||
try {
|
||||
store(h, localLeaseSet);
|
||||
@ -517,6 +519,8 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
*/
|
||||
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException {
|
||||
if (!_initialized) return;
|
||||
if (_context.router().gracefulShutdownInProgress())
|
||||
return;
|
||||
// This isn't really used for anything
|
||||
// writeMyInfo(localRouterInfo);
|
||||
if (_context.router().isHidden()) return; // DE-nied!
|
||||
@ -1072,6 +1076,10 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Be careful to use stripHTML for any displayed routerInfo data
|
||||
* to prevent vulnerabilities
|
||||
*/
|
||||
private void renderRouterInfo(StringBuilder buf, RouterInfo info, boolean isUs, boolean full) {
|
||||
String hash = info.getIdentity().getHash().toBase64();
|
||||
buf.append("<a name=\"").append(hash.substring(0, 6)).append("\" ></a>");
|
||||
@ -1096,7 +1104,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
|
||||
RouterAddress addr = (RouterAddress)iter.next();
|
||||
buf.append(addr.getTransportStyle()).append(": ");
|
||||
buf.append(DataHelper.stripHTML(addr.getTransportStyle())).append(": ");
|
||||
for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) {
|
||||
String name = (String)optIter.next();
|
||||
String val = addr.getOptions().getProperty(name);
|
||||
|
@ -42,7 +42,8 @@ class StartExplorersJob extends JobImpl {
|
||||
|
||||
public String getName() { return "Start Explorers Job"; }
|
||||
public void runJob() {
|
||||
if (! ((FloodfillNetworkDatabaseFacade)_facade).floodfillEnabled()) {
|
||||
if (! (((FloodfillNetworkDatabaseFacade)_facade).floodfillEnabled() ||
|
||||
getContext().router().gracefulShutdownInProgress())) {
|
||||
Set toExplore = selectKeysToExplore();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Keys to explore during this run: " + toExplore);
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.i2p.router.transport;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -150,5 +152,7 @@ public class VMCommSystem extends CommSystemFacade {
|
||||
_commSystemFacades.put(_context.routerHash(), this);
|
||||
}
|
||||
|
||||
public void renderStatusHTML(OutputStream out) {}
|
||||
public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException {
|
||||
out.write("Dummy! i2p.vmCommSystem=true!");
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,9 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
|
||||
// no need to explore too wildly at first
|
||||
if (ctx.router().getUptime() <= 5*60*1000)
|
||||
return true;
|
||||
// or at the end
|
||||
if (ctx.router().gracefulShutdownInProgress())
|
||||
return true;
|
||||
// ok, if we aren't explicitly asking for it, we should try to pick peers
|
||||
// randomly from the 'not failing' pool. However, if we are having a
|
||||
// hard time building exploratory tunnels, lets fall back again on the
|
||||
|
Reference in New Issue
Block a user