forked from I2P_Developers/i2p.i2p
* HarvesterJob: Don't instantiate if disabled
* NetDb: Add netDb.exploreKeySet stat * netdb.jsp: Add parameter ?r=xxxxxx to view a single routerinfo, and ?r=. to view our own; change links on other pages too
This commit is contained in:
@@ -61,6 +61,7 @@ public abstract class NetworkDatabaseFacade implements Service {
|
||||
|
||||
public int getKnownRouters() { return 0; }
|
||||
public int getKnownLeaseSets() { return 0; }
|
||||
public void renderRouterInfoHTML(Writer out, String s) throws IOException {}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
|
||||
public final static String VERSION = "0.6.3";
|
||||
public final static long BUILD = 3;
|
||||
public final static long BUILD = 4;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@@ -280,7 +280,7 @@ public class Shitlist {
|
||||
Hash key = (Hash)iter.next();
|
||||
Entry entry = (Entry)entries.get(key);
|
||||
buf.append("<li><b>").append(key.toBase64()).append("</b>");
|
||||
buf.append(" (<a href=\"netdb.jsp#").append(key.toBase64().substring(0, 6)).append("\">netdb</a>)");
|
||||
buf.append(" (<a href=\"netdb.jsp?r=").append(key.toBase64().substring(0, 6)).append("\">netdb</a>)");
|
||||
buf.append(" expiring in ");
|
||||
buf.append(DataHelper.formatDuration(entry.expireOn-_context.clock().now()));
|
||||
Set transports = entry.transports;
|
||||
|
@@ -41,7 +41,7 @@ class HarvesterJob extends JobImpl {
|
||||
/** background job, who cares */
|
||||
private static final int PRIORITY = 100;
|
||||
|
||||
private static final String PROP_ENABLED = "netDb.shouldHarvest";
|
||||
public static final String PROP_ENABLED = "netDb.shouldHarvest";
|
||||
|
||||
private boolean harvestDirectly() {
|
||||
return Boolean.valueOf(getContext().getProperty("netDb.harvestDirectly", "false")).booleanValue();
|
||||
|
@@ -130,6 +130,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
_activeRequests = new HashMap(8);
|
||||
_enforceNetId = DEFAULT_ENFORCE_NETID;
|
||||
context.statManager().createRateStat("netDb.lookupLeaseSetDeferred", "how many lookups are deferred for a single leaseSet lookup?", "NetworkDatabase", new long[] { 60*1000, 5*60*1000 });
|
||||
context.statManager().createRateStat("netDb.exploreKeySet", "how many keys are queued for exploration?", "NetworkDatabase", new long[] { 10*60*1000 });
|
||||
}
|
||||
|
||||
protected PeerSelector createPeerSelector() { return new PeerSelector(_context); }
|
||||
@@ -203,12 +204,14 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
if (!_initialized) return;
|
||||
synchronized (_exploreKeys) {
|
||||
_exploreKeys.removeAll(toRemove);
|
||||
_context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
|
||||
}
|
||||
}
|
||||
public void queueForExploration(Set keys) {
|
||||
if (!_initialized) return;
|
||||
synchronized (_exploreKeys) {
|
||||
_exploreKeys.addAll(keys);
|
||||
_context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +300,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
// fire off a group of searches from the explore pool
|
||||
_context.jobQueue().addJob(_exploreJob);
|
||||
// if configured to do so, periodically try to get newer routerInfo stats
|
||||
if (_harvestJob == null)
|
||||
if (_harvestJob == null && "true".equals(_context.getProperty(HarvesterJob.PROP_ENABLED)))
|
||||
_harvestJob = new HarvesterJob(_context, this);
|
||||
_context.jobQueue().addJob(_harvestJob);
|
||||
} else {
|
||||
@@ -943,9 +946,32 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
}
|
||||
}
|
||||
|
||||
public void renderRouterInfoHTML(Writer out, String routerPrefix) throws IOException {
|
||||
StringBuffer buf = new StringBuffer(4*1024);
|
||||
buf.append("<h2>Network Database RouterInfo Lookup</h2>\n");
|
||||
if (".".equals(routerPrefix)) {
|
||||
renderRouterInfo(buf, _context.router().getRouterInfo(), true);
|
||||
} else {
|
||||
boolean notFound = true;
|
||||
Set routers = getRouters();
|
||||
for (Iterator iter = routers.iterator(); iter.hasNext(); ) {
|
||||
RouterInfo ri = (RouterInfo)iter.next();
|
||||
Hash key = ri.getIdentity().getHash();
|
||||
if (key.toBase64().startsWith(routerPrefix)) {
|
||||
renderRouterInfo(buf, ri, false);
|
||||
notFound = false;
|
||||
}
|
||||
}
|
||||
if (notFound)
|
||||
buf.append("Router ").append(routerPrefix).append(" not found in network database");
|
||||
}
|
||||
out.write(buf.toString());
|
||||
out.flush();
|
||||
}
|
||||
|
||||
public void renderStatusHTML(Writer out) throws IOException {
|
||||
StringBuffer buf = new StringBuffer(10*1024);
|
||||
buf.append("<h2>Kademlia Network DB Contents</h2>\n");
|
||||
StringBuffer buf = new StringBuffer(getKnownRouters() * 2048);
|
||||
buf.append("<h2>Network Database Contents</h2>\n");
|
||||
if (!_initialized) {
|
||||
buf.append("<i>Not initialized</i>\n");
|
||||
out.write(buf.toString());
|
||||
|
@@ -163,7 +163,7 @@ class ProfileOrganizerRenderer {
|
||||
buf.append(" </td>");
|
||||
//buf.append("<td><a href=\"/profile/").append(prof.getPeer().toBase64().substring(0, 32)).append("\">profile.txt</a> ");
|
||||
//buf.append(" <a href=\"#").append(prof.getPeer().toBase64().substring(0, 32)).append("\">netDb</a></td>");
|
||||
buf.append("<td nowrap><a href=\"netdb.jsp#").append(peer.toBase64().substring(0,6)).append("\">netDb</a>");
|
||||
buf.append("<td nowrap><a href=\"netdb.jsp?r=").append(peer.toBase64().substring(0,6)).append("\">netDb</a>");
|
||||
buf.append("/<a href=\"dumpprofile.jsp?peer=").append(peer.toBase64().substring(0,6)).append("\">profile</a>");
|
||||
buf.append("/<a href=\"configpeer.jsp?peer=").append(peer.toBase64()).append("\">+-</a></td>\n");
|
||||
buf.append("</tr>");
|
||||
|
@@ -600,7 +600,7 @@ public class NTCPTransport extends TransportImpl {
|
||||
for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
|
||||
NTCPConnection con = (NTCPConnection)iter.next();
|
||||
String name = con.getRemotePeer().calculateHash().toBase64().substring(0,6);
|
||||
buf.append("<tr><td><code><a href=\"netdb.jsp#").append(name).append("\">").append(name);
|
||||
buf.append("<tr><td><code><a href=\"netdb.jsp?r=").append(name).append("\">").append(name);
|
||||
buf.append("</code></td><td align=\"center\"><code>");
|
||||
if (con.isInbound())
|
||||
buf.append("in");
|
||||
|
@@ -1687,7 +1687,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
|
||||
String name = peer.getRemotePeer().toBase64().substring(0,6);
|
||||
buf.append("<td valign=\"top\" nowrap=\"nowrap\"><code>");
|
||||
buf.append("<a href=\"netdb.jsp#");
|
||||
buf.append("<a href=\"netdb.jsp?r=");
|
||||
buf.append(name);
|
||||
buf.append("\">");
|
||||
buf.append(name);
|
||||
|
Reference in New Issue
Block a user