propagate from branch 'i2p.i2p.zzz.test' (head f402c08d0b2796653b559711cb1ea8c3c0204372)

to branch 'i2p.i2p' (head 4d0babb75e3c5237b10ff49f57599c53c581bb83)
This commit is contained in:
zzz
2009-05-17 12:20:34 +00:00
14 changed files with 190 additions and 102 deletions

View File

@ -121,7 +121,6 @@ Applications:
Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
See licenses/LICENSE-Apache1.1.txt
See licenses/LICENSE-Apache2.0.txt
See licenses/NOTICE-Ant.txt
See licenses/NOTICE-Commons-Logging.txt
JRobin 1.4.0:

View File

@ -55,7 +55,7 @@
<mkdir dir="../jsp/WEB-INF/" />
<mkdir dir="../jsp/WEB-INF/classes" />
<!-- there are various jspc ant tasks, but they all seem a bit flakey -->
<java classname="org.apache.jasper.JspC" fork="true" >
<java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
<classpath>
<pathelement location="../../jetty/jettylib/jasper-compiler.jar" />
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />

View File

@ -86,7 +86,7 @@
<mkdir dir="../jsp/WEB-INF/" />
<mkdir dir="../jsp/WEB-INF/classes" />
<!-- there are various jspc ant tasks, but they all seem a bit flakey -->
<java classname="org.apache.jasper.JspC" fork="true">
<java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
<classpath>
<pathelement location="../../jetty/jettylib/jasper-compiler.jar" />
<pathelement location="../../jetty/jettylib/jasper-runtime.jar" />

View File

@ -63,6 +63,11 @@ public class ConfigTunnelsHelper extends HelperBase {
out.getLength() <= 0 ||
out.getLength() + out.getLengthVariance() <= 0)
buf.append("<tr><td colspan=\"3\"><font color=\"red\">ANONYMITY WARNING - Settings include 0-hop tunnels</font></td></tr>");
else if (in.getLength() <= 1 ||
in.getLength() + in.getLengthVariance() <= 1 ||
out.getLength() <= 1 ||
out.getLength() + out.getLengthVariance() <= 1)
buf.append("<tr><td colspan=\"3\"><font color=\"red\">ANONYMITY WARNING - Settings include 1-hop tunnels</font></td></tr>");
if (in.getLength() + Math.abs(in.getLengthVariance()) >= WARN_LENGTH ||
out.getLength() + Math.abs(out.getLengthVariance()) >= WARN_LENGTH)
buf.append("<tr><td colspan=\"3\"><font color=\"red\">PERFORMANCE WARNING - Settings include very long tunnels</font></td></tr>");

View File

@ -26,7 +26,7 @@ jbigi <%=net.i2p.util.NativeBigInteger.loadStatus()%><br />
<h4>Critical logs:</h4><a name="criticallogs"> </a>
<jsp:getProperty name="logsHelper" property="criticalLogs" />
<hr />
<h4>Router logs:</h4>
<h4>Router logs (<a href="configlogging.jsp">configure</a>):</h4>
<jsp:getProperty name="logsHelper" property="logs" />
<hr />
<h4>Service (Wrapper) logs:</h4><a name="servicelogs"> </a>

View File

@ -35,7 +35,7 @@
<delete file="WEB-INF/web-out.xml" />
<mkdir dir="${tmp}" />
<echo message="Ignore any warning about /WEB-INF/web.xml not found" />
<java classname="org.apache.jasper.JspC" fork="true" classpathref="cp">
<java classname="org.apache.jasper.JspC" fork="true" classpathref="cp" failonerror="true">
<arg value="-d" />
<arg value="${tmp}" />
<arg value="-v" />

View File

@ -37,10 +37,12 @@ import java.util.Properties;
public class AddressbookBean
{
private String book, action, serial, lastSerial, filter, search, hostname, destination;
private int beginIndex, endIndex;
private Properties properties, addressbook;
private int trClass;
private LinkedList deletionMarks;
private static Comparator sorter;
private static final int DISPLAY_SIZE=100;
static {
sorter = new AddressByNameSorter();
@ -74,6 +76,8 @@ public class AddressbookBean
{
properties = new Properties();
deletionMarks = new LinkedList();
beginIndex = 0;
endIndex = DISPLAY_SIZE - 1;
}
private long configLastLoaded = 0;
private static final String PRIVATE_BOOK = "private_addressbook";
@ -106,6 +110,8 @@ public class AddressbookBean
{
loadConfig();
String filename = properties.getProperty( getBook() + "_addressbook" );
if (filename.startsWith("../"))
return filename.substring(3);
return ConfigBean.addressbookPrefix + filename;
}
private Object[] entries;
@ -174,17 +180,45 @@ public class AddressbookBean
}
list.addLast( new AddressBean( name, destination ) );
}
// Format a message about filtered addressbook size, and the number of displayed entries
if( filter != null && filter.length() > 0 )
message = "Filtered l";
else
message = "L";
message += "ist contains " + list.size() + " entries";
if (list.size() > 300) message += ", displaying the first 300."; else message += ".";
Object array[] = list.toArray();
Arrays.sort( array, sorter );
entries = array;
// Format a message about filtered addressbook size, and the number of displayed entries
// addressbook.jsp catches the case where the whole book is empty.
String filterArg = "";
if( search != null && search.length() > 0 ) {
message = "Search ";
}
if( filter != null && filter.length() > 0 ) {
if( search != null && search.length() > 0 )
message += "within ";
message += "Filtered list ";
filterArg = "&filter=" + filter;
}
if (entries.length == 0) {
message += "- no matches";
} else if (getBeginInt() == 0 && getEndInt() == entries.length - 1) {
if (message.length() == 0)
message = "Addressbook ";
message += "contains " + entries.length + " entries";
} else {
if (getBeginInt() > 0) {
int newBegin = Math.max(0, getBeginInt() - DISPLAY_SIZE);
int newEnd = Math.max(0, getBeginInt() - 1);
message += "<a href=\"addressbook.jsp?book=" + getBook() + filterArg +
"&begin=" + newBegin + "&end=" + newEnd + "\">" + newBegin +
'-' + newEnd + "</a> | ";
}
message += "Showing " + getBegin() + '-' + getEnd() + " of " + entries.length;
if (getEndInt() < entries.length - 1) {
int newBegin = Math.min(entries.length - 1, getEndInt() + 1);
int newEnd = Math.min(entries.length, getEndInt() + DISPLAY_SIZE);
message += " | <a href=\"addressbook.jsp?book=" + getBook() + filterArg +
"&begin=" + newBegin + "&end=" + newEnd + "\">" + newBegin +
'-' + newEnd + "</a>";
}
}
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
@ -302,4 +336,26 @@ public class AddressbookBean
public void setHostname(String hostname) {
this.hostname = hostname;
}
private int getBeginInt() {
return Math.max(0, Math.min(entries.length - 1, beginIndex));
}
public String getBegin() {
return "" + getBeginInt();
}
public void setBegin(String s) {
try {
beginIndex = Integer.parseInt(s);
} catch (NumberFormatException nfe) {}
}
private int getEndInt() {
return Math.max(0, Math.max(getBeginInt(), Math.min(entries.length - 1, endIndex)));
}
public String getEnd() {
return "" + getEndInt();
}
public void setEnd(String s) {
try {
endIndex = Integer.parseInt(s);
} catch (NumberFormatException nfe) {}
}
}

View File

@ -46,10 +46,10 @@
<div id="navi">
<p>addressbooks
<a href="addressbook.jsp?book=master">master</a> |
<a href="addressbook.jsp?book=router">router</a> |
<a href="addressbook.jsp?book=published">published</a> |
<a href="addressbook.jsp?book=private">private</a> *
<a href="addressbook.jsp?book=master&filter=none&begin=0&end=99">master</a> |
<a href="addressbook.jsp?book=router&filter=none&begin=0&end=99">router</a> |
<a href="addressbook.jsp?book=published&filter=none&begin=0&end=99">published</a> |
<a href="addressbook.jsp?book=private&filter=none&begin=0&end=99">private</a> *
<a href="subscriptions.jsp">subscriptions</a> *
<a href="config.jsp">configuration</a> *
<a href="index.jsp">overview</a>
@ -64,42 +64,46 @@
<span>${book.loadBookMessages}</span>
<c:if test="${book.notEmpty}">
<div id="filter">
<p>Filter: <a href="addressbook.jsp?filter=a">a</a>
<a href="addressbook.jsp?filter=b">b</a>
<a href="addressbook.jsp?filter=c">c</a>
<a href="addressbook.jsp?filter=d">d</a>
<a href="addressbook.jsp?filter=e">e</a>
<a href="addressbook.jsp?filter=f">f</a>
<a href="addressbook.jsp?filter=g">g</a>
<a href="addressbook.jsp?filter=h">h</a>
<a href="addressbook.jsp?filter=i">i</a>
<a href="addressbook.jsp?filter=j">j</a>
<a href="addressbook.jsp?filter=k">k</a>
<a href="addressbook.jsp?filter=l">l</a>
<a href="addressbook.jsp?filter=m">m</a>
<a href="addressbook.jsp?filter=n">n</a>
<a href="addressbook.jsp?filter=o">o</a>
<a href="addressbook.jsp?filter=p">p</a>
<a href="addressbook.jsp?filter=q">q</a>
<a href="addressbook.jsp?filter=r">r</a>
<a href="addressbook.jsp?filter=s">s</a>
<a href="addressbook.jsp?filter=t">t</a>
<a href="addressbook.jsp?filter=u">u</a>
<a href="addressbook.jsp?filter=v">v</a>
<a href="addressbook.jsp?filter=w">w</a>
<a href="addressbook.jsp?filter=x">x</a>
<a href="addressbook.jsp?filter=y">y</a>
<a href="addressbook.jsp?filter=z">z</a>
<a href="addressbook.jsp?filter=0-9">0-9</a>
<a href="addressbook.jsp?filter=none">all</a></p>
<p>Filter:
<a href="addressbook.jsp?filter=a&begin=0&end=99">a</a>
<a href="addressbook.jsp?filter=b&begin=0&end=99">b</a>
<a href="addressbook.jsp?filter=c&begin=0&end=99">c</a>
<a href="addressbook.jsp?filter=d&begin=0&end=99">d</a>
<a href="addressbook.jsp?filter=e&begin=0&end=99">e</a>
<a href="addressbook.jsp?filter=f&begin=0&end=99">f</a>
<a href="addressbook.jsp?filter=g&begin=0&end=99">g</a>
<a href="addressbook.jsp?filter=h&begin=0&end=99">h</a>
<a href="addressbook.jsp?filter=i&begin=0&end=99">i</a>
<a href="addressbook.jsp?filter=j&begin=0&end=99">j</a>
<a href="addressbook.jsp?filter=k&begin=0&end=99">k</a>
<a href="addressbook.jsp?filter=l&begin=0&end=99">l</a>
<a href="addressbook.jsp?filter=m&begin=0&end=99">m</a>
<a href="addressbook.jsp?filter=n&begin=0&end=99">n</a>
<a href="addressbook.jsp?filter=o&begin=0&end=99">o</a>
<a href="addressbook.jsp?filter=p&begin=0&end=99">p</a>
<a href="addressbook.jsp?filter=q&begin=0&end=99">q</a>
<a href="addressbook.jsp?filter=r&begin=0&end=99">r</a>
<a href="addressbook.jsp?filter=s&begin=0&end=99">s</a>
<a href="addressbook.jsp?filter=t&begin=0&end=99">t</a>
<a href="addressbook.jsp?filter=u&begin=0&end=99">u</a>
<a href="addressbook.jsp?filter=v&begin=0&end=99">v</a>
<a href="addressbook.jsp?filter=w&begin=0&end=99">w</a>
<a href="addressbook.jsp?filter=x&begin=0&end=99">x</a>
<a href="addressbook.jsp?filter=y&begin=0&end=99">y</a>
<a href="addressbook.jsp?filter=z&begin=0&end=99">z</a>
<a href="addressbook.jsp?filter=0-9&begin=0&end=99">0-9</a>
<a href="addressbook.jsp?filter=none&begin=0&end=99">all</a></p>
<c:if test="${book.hasFilter}">
<p>Current filter: ${book.filter}
(<a href="addressbook.jsp?filter=none">clear filter</a>)</p>
(<a href="addressbook.jsp?filter=none&begin=0&end=99">clear filter</a>)</p>
</c:if>
</div>
<form method="POST" action="addressbook.jsp">
<input type="hidden" name="begin" value="0"/>
<input type="hidden" name="end" value="99"/>
<div id="search">
<table><tr>
<td class="search">Search: <input type="text" name="search" value="${book.search}" size="20" /></td>
@ -109,9 +113,12 @@
</div>
</form>
</c:if>
<form method="POST" action="addressbook.jsp">
<input type="hidden" name="serial" value="${book.serial}"/>
<input type="hidden" name="begin" value="0"/>
<input type="hidden" name="end" value="99"/>
<c:if test="${book.notEmpty}">
@ -127,8 +134,8 @@
<th>Name</th>
<th>Destination</th>
</tr>
<!-- limit iterator to 300, or "Form too large" may result on submit -->
<c:forEach items="${book.entries}" var="addr" begin="0" end="299">
<!-- limit iterator, or "Form too large" may result on submit, and is a huge web page if we don't -->
<c:forEach items="${book.entries}" var="addr" begin="${book.begin}" end="${book.end}">
<tr class="list${book.trClass}">
<c:if test="${book.master || book.router || book.published || book.private}">
<td class="checkbox"><input type="checkbox" name="checked" value="${addr.name}" alt="Mark for deletion"></td>
@ -136,7 +143,7 @@
<td class="names"><a href="http://${addr.name}/">${addr.name}</a> -
<span class="addrhlpr"><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}">(addrhlpr)</a></span>
</td>
<td class="destinations"><textarea rows="1" cols="20" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
<td class="destinations"><textarea rows="1" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
</tr>
</c:forEach>
</table>
@ -160,8 +167,9 @@
<div id="add">
<p class="add">
<h3>Add new destination:</h3>
Hostname: <input type="text" name="hostname" value="${book.hostname}" size="20">
Destination: <textarea name="destination" rows="1" cols="20" wrap="off" >${book.destination}</textarea><br/>
<b>Hostname:</b> <input type="text" name="hostname" value="${book.hostname}" size="20">
<b>Destination:</b> <textarea name="destination" rows="1" cols="40" wrap="off" >${book.destination}</textarea><br/>
</p><p>
<input type="image" name="action" value="add" src="images/add.png" alt="Add destination" />
</p>
</div>

View File

@ -72,7 +72,6 @@
<copy file="apps/routerconsole/java/build/routerconsole.jar" todir="build/" />
<copy file="apps/routerconsole/java/build/routerconsole.war" todir="build/" />
<copy file="apps/jetty/jettylib/org.mortbay.jetty.jar" todir="build/" />
<copy file="apps/jetty/jettylib/ant.jar" todir="build/" />
<copy file="apps/jetty/jettylib/jasper-compiler.jar" todir="build/" />
<copy file="apps/jetty/jettylib/jasper-runtime.jar" todir="build/" />
<copy file="apps/jetty/jettylib/commons-logging.jar" todir="build/" />
@ -103,7 +102,7 @@
<jar destfile="./build/launchi2p.jar">
<manifest>
<attribute name="Main-Class" value="net.i2p.router.RouterLaunch" />
<attribute name="Class-Path" value="lib/i2p.jar lib/router.jar lib/jbigi.jar lib/BOB.jar lib/sam.jar lib/mstreaming.jar lib/streaming.jar lib/routerconsole.jar lib/i2ptunnel.jar lib/org.mortbay.jetty.jar lib/javax.servlet.jar lib/jasper-compiler.jar lib/jasper-runtime.jar lib/commons-logging.jar lib/commons-el.jar lib/ant.jar lib/wrapper.jar lib/systray.jar lib/systray4j.jar" />
<attribute name="Class-Path" value="lib/i2p.jar lib/router.jar lib/jbigi.jar lib/BOB.jar lib/sam.jar lib/mstreaming.jar lib/streaming.jar lib/routerconsole.jar lib/i2ptunnel.jar lib/org.mortbay.jetty.jar lib/javax.servlet.jar lib/jasper-compiler.jar lib/jasper-runtime.jar lib/commons-logging.jar lib/commons-el.jar lib/wrapper.jar lib/systray.jar lib/systray4j.jar" />
</manifest>
</jar>
<!-- now the standalone launcher exe -->
@ -210,7 +209,6 @@
</target>
<target name="preppkg" depends="build, buildexe">
<delete dir="pkg-temp" />
<copy file="build/ant.jar" todir="pkg-temp/lib/" />
<copy file="build/i2p.jar" todir="pkg-temp/lib/" />
<copy file="build/i2ptunnel.jar" todir="pkg-temp/lib/" />
<copy file="build/jasper-compiler.jar" todir="pkg-temp/lib/" />
@ -396,7 +394,6 @@
<copy file="build/router.jar" todir="pkg-temp/lib/" />
</target>
<target name="prepjupdate" depends="prepupdate, buildWEB">
<copy file="build/ant.jar" todir="pkg-temp/lib/" />
<copy file="build/jasper-compiler.jar" todir="pkg-temp/lib/" />
<copy file="build/jasper-runtime.jar" todir="pkg-temp/lib/" />
<copy file="build/commons-logging.jar" todir="pkg-temp/lib/" />
@ -491,7 +488,7 @@
<arg value="-output"/>
<arg value="findbugs.xml"/>
<arg value="-auxclasspath"/>
<arg value="build/ant.jar:build/commons-el.jar:build/commons-logging.jar:build/jasper-compiler.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:apps/jrobin/jrobin-1.4.0.jar:apps/systray/java/lib/systray4j.jar:installer/lib/wrapper/linux/wrapper.jar"/>
<arg value="build/commons-el.jar:build/commons-logging.jar:build/jasper-compiler.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:apps/jrobin/jrobin-1.4.0.jar:apps/systray/java/lib/systray4j.jar:installer/lib/wrapper/linux/wrapper.jar"/>
<arg value="-sourcepath"/>
<arg value="apps/BOB/src/:apps/addressbook/java/src/:apps/i2psnark/java/src/:apps/i2ptunnel/java/src/:apps/ministreaming/java/src/:apps/routerconsole/java/src/:apps/sam/java/src/:apps/streaming/java/src/:apps/susidns/src/java/src/:apps/susimail/src/src/:apps/systray/java/src/:core/java/src/:router/java/src/"/>
<!-- start of the files to be analyzed -->

View File

@ -46,18 +46,17 @@ wrapper.java.classpath.11=lib/jasper-compiler.jar
wrapper.java.classpath.12=lib/jasper-runtime.jar
wrapper.java.classpath.13=lib/commons-logging.jar
wrapper.java.classpath.14=lib/commons-el.jar
wrapper.java.classpath.15=lib/ant.jar
# java service wrapper, BSD
wrapper.java.classpath.16=lib/wrapper.jar
wrapper.java.classpath.15=lib/wrapper.jar
# systray, LGPL
wrapper.java.classpath.17=lib/systray.jar
wrapper.java.classpath.18=lib/systray4j.jar
wrapper.java.classpath.16=lib/systray.jar
wrapper.java.classpath.17=lib/systray4j.jar
# BOB
wrapper.java.classpath.19=lib/BOB.jar
wrapper.java.classpath.18=lib/BOB.jar
# desktopgui
wrapper.java.classpath.20=lib/appframework.jar
wrapper.java.classpath.21=lib/swing-worker.jar
wrapper.java.classpath.22=lib/desktopgui.jar
wrapper.java.classpath.19=lib/appframework.jar
wrapper.java.classpath.20=lib/swing-worker.jar
wrapper.java.classpath.21=lib/desktopgui.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=.

View File

@ -1,15 +0,0 @@
=========================================================================
== NOTICE file corresponding to the section 4 d of ==
== the Apache License, Version 2.0, ==
== in this case for the Apache Ant distribution. ==
=========================================================================
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
This product includes also software developed by :
- the W3C consortium (http://www.w3c.org) ,
- the SAX project (http://www.saxproject.org)
Please read the different LICENSE files present in the root directory of
this distribution.

View File

@ -12,6 +12,8 @@ import java.util.Set;
import net.i2p.data.DataStructure;
import net.i2p.data.Hash;
import net.i2p.data.LeaseSet;
import net.i2p.data.RouterInfo;
import net.i2p.router.Job;
import net.i2p.router.RouterContext;
@ -45,8 +47,21 @@ class FloodfillStoreJob extends StoreJob {
@Override
protected void succeed() {
super.succeed();
if (_state != null)
getContext().jobQueue().addJob(new FloodfillVerifyStoreJob(getContext(), _state.getTarget(), _facade));
if (_state != null) {
// Get the time stamp from the data we sent, so the Verify job can meke sure that
// it finds something stamped with that time or newer.
long published = 0;
boolean isRouterInfo = false;
DataStructure data = _state.getData();
if (data instanceof RouterInfo) {
published = ((RouterInfo) data).getPublished();
isRouterInfo = true;
} else if (data instanceof LeaseSet) {
published = ((LeaseSet) data).getEarliestLeaseDate();
}
getContext().jobQueue().addJob(new FloodfillVerifyStoreJob(getContext(), _state.getTarget(),
published, isRouterInfo, _facade));
}
}
@Override

View File

@ -5,6 +5,8 @@ import java.util.List;
import net.i2p.data.DataStructure;
import net.i2p.data.Hash;
import net.i2p.data.LeaseSet;
import net.i2p.data.RouterInfo;
import net.i2p.data.i2np.DatabaseLookupMessage;
import net.i2p.data.i2np.DatabaseSearchReplyMessage;
import net.i2p.data.i2np.DatabaseStoreMessage;
@ -29,21 +31,33 @@ public class FloodfillVerifyStoreJob extends JobImpl {
private FloodfillNetworkDatabaseFacade _facade;
private long _expiration;
private long _sendTime;
private long _published;
private boolean _isRouterInfo;
private static final int VERIFY_TIMEOUT = 10*1000;
public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, FloodfillNetworkDatabaseFacade facade) {
public FloodfillVerifyStoreJob(RouterContext ctx, Hash key, long published, boolean isRouterInfo, FloodfillNetworkDatabaseFacade facade) {
super(ctx);
_key = key;
_published = published;
_isRouterInfo = isRouterInfo;
_log = ctx.logManager().getLog(getClass());
_facade = facade;
// wait 10 seconds before trying to verify the store
getTiming().setStartAfter(ctx.clock().now() + VERIFY_TIMEOUT);
getContext().statManager().createRateStat("netDb.floodfillVerifyOK", "How long a floodfill verify takes when it succeeds", "NetworkDatabase", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
getContext().statManager().createRateStat("netDb.floodfillVerifyFail", "How long a floodfill verify takes when it fails", "NetworkDatabase", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
getContext().statManager().createRateStat("netDb.floodfillVerifyTimeout", "How long a floodfill verify takes when it times out", "NetworkDatabase", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
getContext().statManager().createRateStat("netDb.floodfillVerifyOK", "How long a floodfill verify takes when it succeeds", "NetworkDatabase", new long[] { 60*60*1000 });
getContext().statManager().createRateStat("netDb.floodfillVerifyFail", "How long a floodfill verify takes when it fails", "NetworkDatabase", new long[] { 60*60*1000 });
getContext().statManager().createRateStat("netDb.floodfillVerifyTimeout", "How long a floodfill verify takes when it times out", "NetworkDatabase", new long[] { 60*60*1000 });
}
public String getName() { return "Verify netdb store"; }
/**
* Wait 10 seconds, then query a random floodfill for the leaseset or routerinfo
* that we just stored to a (hopefully different) floodfill peer.
*
* If it fails (after waiting up to another 10 seconds), resend the data.
* If the queried data is older than what we stored, that counts as a fail.
**/
public void runJob() {
_target = pickTarget();
if (_target == null) return;
@ -118,21 +132,30 @@ public class FloodfillVerifyStoreJob extends JobImpl {
public void runJob() {
long delay = getContext().clock().now() - _sendTime;
if (_message instanceof DatabaseStoreMessage) {
// Verify it's as recent as the one we sent
boolean success = false;
DatabaseStoreMessage dsm = (DatabaseStoreMessage)_message;
if (_isRouterInfo && dsm.getValueType() == DatabaseStoreMessage.KEY_TYPE_ROUTERINFO)
success = dsm.getRouterInfo().getPublished() >= _published;
else if ((!_isRouterInfo) && dsm.getValueType() == DatabaseStoreMessage.KEY_TYPE_LEASESET)
success = dsm.getLeaseSet().getEarliestLeaseDate() >= _published;
if (success) {
// store ok, w00t!
// Hmm should we verify it's as recent as the one we sent???
getContext().profileManager().dbLookupSuccessful(_target, delay);
getContext().statManager().addRateData("netDb.floodfillVerifyOK", delay, 0);
} else {
// store failed, boo, hiss!
if (_message instanceof DatabaseSearchReplyMessage) {
return;
}
if (_log.shouldLog(Log.WARN))
_log.warn("Verify failed - older");
} else if (_message instanceof DatabaseSearchReplyMessage) {
// assume 0 old, all new, 0 invalid, 0 dup
getContext().profileManager().dbLookupReply(_target, 0,
((DatabaseSearchReplyMessage)_message).getNumReplies(), 0, 0, delay);
}
// store failed, boo, hiss!
getContext().statManager().addRateData("netDb.floodfillVerifyFail", delay, 0);
resend();
}
}
public void setMessage(I2NPMessage message) { _message = message; }
}

View File

@ -627,9 +627,9 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
String validate(Hash key, RouterInfo routerInfo) throws IllegalArgumentException {
long now = _context.clock().now();
boolean upLongEnough = _context.router().getUptime() > 60*60*1000;
// Once we're over 300 routers, reduce the expiration time down from the default,
// Once we're over 150 routers, reduce the expiration time down from the default,
// as a crude way of limiting memory usage.
// i.e. at 600 routers the expiration time will be about half the default, etc.
// i.e. at 300 routers the expiration time will be about half the default, etc.
// And if we're floodfill, we can keep the expiration really short, since
// we are always getting the latest published to us.
// As the net grows this won't be sufficient, and we'll have to implement
@ -638,9 +638,10 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
if (FloodfillNetworkDatabaseFacade.floodfillEnabled(_context))
adjustedExpiration = ROUTER_INFO_EXPIRATION_FLOODFILL;
else
// _kb.size() includes leasesets but that's ok
adjustedExpiration = Math.min(ROUTER_INFO_EXPIRATION,
ROUTER_INFO_EXPIRATION_MIN +
((ROUTER_INFO_EXPIRATION - ROUTER_INFO_EXPIRATION_MIN) * 300 / (_kb.size() + 1)));
((ROUTER_INFO_EXPIRATION - ROUTER_INFO_EXPIRATION_MIN) * 150 / (_kb.size() + 1)));
if (!key.equals(routerInfo.getIdentity().getHash())) {
if (_log.shouldLog(Log.WARN))