Changeset ae0bcc49


Ignore:
Timestamp:
Jan 24, 2009 8:07:41 PM (12 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6ed17c1
Parents:
d8298c6
Message:
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/NetDbHelper.java

    rd8298c6 rae0bcc49  
    1212    private Writer _out;
    1313    private String _routerPrefix;
     14    private boolean _full = false;
    1415
    1516    /**
     
    3132    public void setWriter(Writer writer) { _out = writer; }
    3233    public void setRouter(String r) { _routerPrefix = r; }
     34    public void setFull(String f) { _full = "1".equals(f); };
    3335   
    3436    public String getNetDbSummary() {
     
    3840                    _context.netDb().renderRouterInfoHTML(_out, _routerPrefix);
    3941                else
    40                     _context.netDb().renderStatusHTML(_out);
     42                    _context.netDb().renderStatusHTML(_out, _full);
    4143                return "";
    4244            } else {
     
    4547                    _context.netDb().renderRouterInfoHTML(new OutputStreamWriter(baos), _routerPrefix);
    4648                else
    47                     _context.netDb().renderStatusHTML(new OutputStreamWriter(baos));
     49                    _context.netDb().renderStatusHTML(new OutputStreamWriter(baos), _full);
    4850                return new String(baos.toByteArray());
    4951            }
  • apps/routerconsole/jsp/netdb.jsp

    rd8298c6 rae0bcc49  
    1515 <jsp:setProperty name="netdbHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    1616 <jsp:setProperty name="netdbHelper" property="writer" value="<%=out%>" />
     17 <jsp:setProperty name="netdbHelper" property="full" value="<%=request.getParameter("f")%>" />
    1718 <jsp:setProperty name="netdbHelper" property="router" value="<%=request.getParameter("r")%>" />
    1819 <jsp:getProperty name="netdbHelper" property="netDbSummary" />
  • router/java/src/net/i2p/router/NetworkDatabaseFacade.java

    rd8298c6 rae0bcc49  
    6363    public int getKnownLeaseSets() { return 0; }
    6464    public void renderRouterInfoHTML(Writer out, String s) throws IOException {}
     65    public void renderStatusHTML(Writer out, boolean b) throws IOException {}
    6566}
  • router/java/src/net/i2p/router/networkdb/PublishLocalRouterInfoJob.java

    rd8298c6 rae0bcc49  
    2121
    2222/**
    23  * Publish the local router's RouterInfo every 5 to 10 minutes
     23 * Publish the local router's RouterInfo periodically
    2424 *
    2525 */
    2626public class PublishLocalRouterInfoJob extends JobImpl {
    2727    private Log _log;
    28     final static long PUBLISH_DELAY = 5*60*1000; // every 5 to 10 minutes (since we randomize)
     28    final static long PUBLISH_DELAY = 20*60*1000;
    2929   
    3030    public PublishLocalRouterInfoJob(RouterContext ctx) {
     
    6868            _log.error("Error signing the updated local router info!", dfe);
    6969        }
    70         requeue(PUBLISH_DELAY + getContext().random().nextInt((int)PUBLISH_DELAY));
     70        requeue((PUBLISH_DELAY/2) + getContext().random().nextInt((int)PUBLISH_DELAY));
    7171    }
    7272}
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    rd8298c6 rae0bcc49  
    126126   
    127127    private final static long EXPLORE_JOB_DELAY = 10*60*1000l;
     128    private final static long PUBLISH_JOB_DELAY = 5*60*1000l;
    128129
    129130    public KademliaNetworkDatabaseFacade(RouterContext context) {
     
    327328        // periodically update and resign the router's 'published date', which basically
    328329        // serves as a version
    329         _context.jobQueue().addJob(new PublishLocalRouterInfoJob(_context));
     330        Job plrij = new PublishLocalRouterInfoJob(_context);
     331        plrij.getTiming().setStartAfter(_context.clock().now() + PUBLISH_JOB_DELAY);
     332        _context.jobQueue().addJob(plrij);
    330333        try {
    331334            publish(ri);
     
    971974        buf.append("<h2>Network Database RouterInfo Lookup</h2>\n");
    972975        if (".".equals(routerPrefix)) {
    973             renderRouterInfo(buf, _context.router().getRouterInfo(), true);
     976            renderRouterInfo(buf, _context.router().getRouterInfo(), true, true);
    974977        } else {
    975978            boolean notFound = true;
     
    979982                Hash key = ri.getIdentity().getHash();
    980983                if (key.toBase64().startsWith(routerPrefix)) {
    981                     renderRouterInfo(buf, ri, false);
     984                    renderRouterInfo(buf, ri, false, true);
    982985                    notFound = false;
    983986                }
     
    991994
    992995    public void renderStatusHTML(Writer out) throws IOException {
    993         StringBuffer buf = new StringBuffer(getKnownRouters() * 2048);
     996        renderStatusHTML(out, true);
     997    }
     998
     999    public void renderStatusHTML(Writer out, boolean full) throws IOException {
     1000        int size = getKnownRouters() * 512;
     1001        if (full)
     1002            size *= 4;
     1003        StringBuffer buf = new StringBuffer(size);
    9941004        buf.append("<h2>Network Database Contents</h2>\n");
    9951005        if (!_initialized) {
     
    10451055       
    10461056        Hash us = _context.routerHash();
    1047         out.write("<h3>Routers</h3>\n");
     1057        out.write("<a name=\"routers\" /><h3>Routers (<a href=\"netdb.jsp");
     1058        if (full)
     1059            out.write("#routers\" >view without");
     1060        else
     1061            out.write("?f=1#routers\" >view with");
     1062        out.write(" stats</a>)</h3>\n");
    10481063       
    10491064        RouterInfo ourInfo = _context.router().getRouterInfo();
    1050         renderRouterInfo(buf, ourInfo, true);
     1065        renderRouterInfo(buf, ourInfo, true, true);
    10511066        out.write(buf.toString());
    10521067        buf.setLength(0);
     
    10621077            boolean isUs = key.equals(us);
    10631078            if (!isUs) {
    1064                 renderRouterInfo(buf, ri, false);
     1079                renderRouterInfo(buf, ri, false, full);
    10651080                out.write(buf.toString());
    10661081                buf.setLength(0);
     
    11031118    }
    11041119   
    1105     private void renderRouterInfo(StringBuffer buf, RouterInfo info, boolean isUs) {
     1120    private void renderRouterInfo(StringBuffer buf, RouterInfo info, boolean isUs, boolean full) {
    11061121        String hash = info.getIdentity().getHash().toBase64();
    11071122        buf.append("<a name=\"").append(hash.substring(0, 6)).append("\" />");
     
    11301145        }
    11311146        buf.append("</i><br />\n");
    1132         buf.append("Stats: <br /><i><code>\n");
    1133         for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
    1134             String key = (String)iter.next();
    1135             String val = info.getOption(key);
    1136             buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br />\n");
    1137         }
    1138         buf.append("</code></i><hr />\n");
     1147        if (full) {
     1148            buf.append("Stats: <br /><i><code>\n");
     1149            for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
     1150                String key = (String)iter.next();
     1151                String val = info.getOption(key);
     1152                buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br />\n");
     1153            }
     1154            buf.append("</code></i>\n");
     1155        } else {
     1156            buf.append("<a href=\"netdb.jsp?r=").append(hash.substring(0, 6)).append("\" >Full entry</a>\n");
     1157        }
     1158        buf.append("<hr />\n");
    11391159    }
    11401160   
  • router/java/src/net/i2p/router/startup/RebuildRouterInfoJob.java

    rd8298c6 rae0bcc49  
    2929
    3030/**
     31 * This used be called from StartAcceptingClientsJob but is now disabled.
     32 * It is still called once from LoadRouterInfoJob (but not run as a Job).
     33 *
     34 * The following comments appear to be incorrect...
     35 * it rebuilds if the router.info file does not exist.
     36 * There is no check for a router.info.rebuild file.
     37 *
    3138 * If the file router.info.rebuild exists, rebuild the router info and republish.
    3239 * This is useful for dhcp or other situations where the router addresses change -
  • router/java/src/net/i2p/router/startup/StartAcceptingClientsJob.java

    rd8298c6 rae0bcc49  
    2929
    3030        getContext().jobQueue().addJob(new ReadConfigJob(getContext()));
    31         getContext().jobQueue().addJob(new RebuildRouterInfoJob(getContext()));
     31        // pointless
     32        //getContext().jobQueue().addJob(new RebuildRouterInfoJob(getContext()));
    3233        getContext().jobQueue().allowParallelOperation();
    3334    }
Note: See TracChangeset for help on using the changeset viewer.