* 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:
@ -10,6 +10,8 @@ import net.i2p.router.RouterContext;
|
||||
public class NetDbHelper {
|
||||
private RouterContext _context;
|
||||
private Writer _out;
|
||||
private String _routerPrefix;
|
||||
|
||||
/**
|
||||
* Configure this bean to query a particular router context
|
||||
*
|
||||
@ -27,15 +29,22 @@ public class NetDbHelper {
|
||||
public NetDbHelper() {}
|
||||
|
||||
public void setWriter(Writer writer) { _out = writer; }
|
||||
public void setRouter(String r) { _routerPrefix = r; }
|
||||
|
||||
public String getNetDbSummary() {
|
||||
try {
|
||||
if (_out != null) {
|
||||
_context.netDb().renderStatusHTML(_out);
|
||||
if (_routerPrefix != null)
|
||||
_context.netDb().renderRouterInfoHTML(_out, _routerPrefix);
|
||||
else
|
||||
_context.netDb().renderStatusHTML(_out);
|
||||
return "";
|
||||
} else {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(32*1024);
|
||||
_context.netDb().renderStatusHTML(new OutputStreamWriter(baos));
|
||||
if (_routerPrefix != null)
|
||||
_context.netDb().renderRouterInfoHTML(new OutputStreamWriter(baos), _routerPrefix);
|
||||
else
|
||||
_context.netDb().renderStatusHTML(new OutputStreamWriter(baos));
|
||||
return new String(baos.toByteArray());
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
<jsp:useBean class="net.i2p.router.web.NetDbHelper" id="netdbHelper" scope="request" />
|
||||
<jsp:setProperty name="netdbHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
|
||||
<jsp:setProperty name="netdbHelper" property="writer" value="<%=out%>" />
|
||||
<jsp:setProperty name="netdbHelper" property="router" value="<%=request.getParameter("r")%>" />
|
||||
<jsp:getProperty name="netdbHelper" property="netDbSummary" />
|
||||
</div>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
<div class="routersummary">
|
||||
<u><b>General</b></u><br />
|
||||
<b>Ident:</b> (<a title="Your router identity is <jsp:getProperty name="helper" property="ident" />, never reveal it to anyone" href="netdb.jsp#our-info">view</a>)<br />
|
||||
<b>Ident:</b> (<a title="Your router identity is <jsp:getProperty name="helper" property="ident" />, never reveal it to anyone" href="netdb.jsp?r=.">view</a>)<br />
|
||||
<b>Version:</b> <jsp:getProperty name="helper" property="version" /><br />
|
||||
<b>Uptime:</b> <jsp:getProperty name="helper" property="uptime" /><br />
|
||||
<b>Now:</b> <jsp:getProperty name="helper" property="time" /><br />
|
||||
|
15
history.txt
15
history.txt
@ -1,3 +1,18 @@
|
||||
2008-09-11 zzz
|
||||
* Blocklist: Fix a log message format
|
||||
* HarvesterJob: Don't instantiate if disabled
|
||||
* i2psnark:
|
||||
- Add config i2psnark.linkPrefix to enable access to completed
|
||||
torrents from a different machine - examples:
|
||||
i2psnark.linkPrefix=file://///localserver/path/to/files/
|
||||
i2psnark.linkPrefix=http://localwebserver/path/
|
||||
(Stop i2psnark, add to i2psnark.config, restart)
|
||||
- Remove Galen and NickyB trackers
|
||||
* 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
|
||||
* Transport: Make 0.0.0.0/8 and 169.254.0.0/16 private
|
||||
|
||||
2008-09-06 zzz
|
||||
* EepGet command line: Fix byte counts after a failed resume
|
||||
* NTCP: Mark unreachable on outbound connection timeout
|
||||
|
@ -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