* NetDb: Fix the totally broken "check new routers against blocklist"
code from 3 checkins ago * tunnels.jsp: Sort participating tunnels by usage, display rate
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
2008-09-20 zzz
|
||||
* NetDb: Fix the totally broken "check new routers against blocklist"
|
||||
code from 3 checkins ago
|
||||
* tunnels.jsp: Sort participating tunnels by usage, display rate
|
||||
|
||||
2008-09-19 zzz
|
||||
* Tunnels:
|
||||
- Add missing message accounting for inbound gateways,
|
||||
|
@ -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 = 7;
|
||||
public final static long BUILD = 8;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@ -81,13 +81,31 @@ public class HandleFloodfillDatabaseStoreMessageJob extends JobImpl {
|
||||
}
|
||||
} else if (_message.getValueType() == DatabaseStoreMessage.KEY_TYPE_ROUTERINFO) {
|
||||
getContext().statManager().addRateData("netDb.storeRouterInfoHandled", 1, 0);
|
||||
Hash key = _message.getKey();
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Handling dbStore of router " + _message.getKey() + " with publishDate of "
|
||||
_log.info("Handling dbStore of router " + key + " with publishDate of "
|
||||
+ new Date(_message.getRouterInfo().getPublished()));
|
||||
try {
|
||||
prevNetDb = getContext().netDb().store(_message.getKey(), _message.getRouterInfo());
|
||||
prevNetDb = getContext().netDb().store(key, _message.getRouterInfo());
|
||||
wasNew = ((null == prevNetDb) || (prevNetDb.getPublished() < _message.getRouterInfo().getPublished()));
|
||||
getContext().profileManager().heardAbout(_message.getKey());
|
||||
// Check new routerinfo address against blocklist
|
||||
if (wasNew) {
|
||||
if (prevNetDb == null) {
|
||||
if ((!getContext().shitlist().isShitlistedForever(key)) &&
|
||||
getContext().blocklist().isBlocklisted(key) &&
|
||||
_log.shouldLog(Log.ERROR))
|
||||
_log.error("Blocklisting new peer " + key);
|
||||
} else {
|
||||
Set oldAddr = prevNetDb.getAddresses();
|
||||
Set newAddr = _message.getRouterInfo().getAddresses();
|
||||
if (newAddr != null && (!newAddr.equals(oldAddr)) &&
|
||||
(!getContext().shitlist().isShitlistedForever(key)) &&
|
||||
getContext().blocklist().isBlocklisted(key) &&
|
||||
_log.shouldLog(Log.ERROR))
|
||||
_log.error("New address received, Blocklisting old peer " + key);
|
||||
}
|
||||
}
|
||||
getContext().profileManager().heardAbout(key);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
invalidMessage = iae.getMessage();
|
||||
}
|
||||
@ -127,23 +145,6 @@ public class HandleFloodfillDatabaseStoreMessageJob extends JobImpl {
|
||||
}
|
||||
}
|
||||
|
||||
// Check new routerinfo address against blocklist
|
||||
if (wasNew) {
|
||||
if (prevNetDb == null) {
|
||||
if ((!getContext().shitlist().isShitlistedForever(_fromHash)) &&
|
||||
getContext().blocklist().isBlocklisted(_fromHash) &&
|
||||
_log.shouldLog(Log.ERROR))
|
||||
_log.error("Blocklisting new peer " + _fromHash);
|
||||
} else {
|
||||
Set oldAddr = prevNetDb.getAddresses();
|
||||
Set newAddr = _message.getRouterInfo().getAddresses();
|
||||
if (newAddr != null && (!newAddr.equals(oldAddr)) &&
|
||||
(!getContext().shitlist().isShitlistedForever(_fromHash)) &&
|
||||
getContext().blocklist().isBlocklisted(_fromHash) &&
|
||||
_log.shouldLog(Log.ERROR))
|
||||
_log.error("New address received, Blocklisting old peer " + _fromHash);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Peer " + _fromHash.toBase64() + " sent bad data: " + invalidMessage);
|
||||
|
@ -3,10 +3,13 @@ package net.i2p.router.tunnel.pool;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Destination;
|
||||
@ -444,18 +447,19 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
renderPool(out, in, outPool);
|
||||
}
|
||||
|
||||
List participating = _context.tunnelDispatcher().listParticipatingTunnels();
|
||||
Set participating = new TreeSet(new TunnelComparator());
|
||||
participating.addAll(_context.tunnelDispatcher().listParticipatingTunnels());
|
||||
out.write("<h2><a name=\"participating\">Participating tunnels</a>:</h2><table border=\"1\">\n");
|
||||
out.write("<tr><td><b>Receive on</b></td><td><b>From</b></td><td>"
|
||||
+ "<b>Send on</b></td><td><b>To</b></td><td><b>Expiration</b></td>"
|
||||
+ "<td><b>Usage</b></td><td><b>Role</b></td></tr>\n");
|
||||
+ "<td><b>Usage</b></td><td><b>Rate</b></td><td><b>Role</b></td></tr>\n");
|
||||
long processed = 0;
|
||||
RateStat rs = _context.statManager().getRate("tunnel.participatingMessageCount");
|
||||
if (rs != null)
|
||||
processed = (long)rs.getRate(10*60*1000).getLifetimeTotalValue();
|
||||
int inactive = 0;
|
||||
for (int i = 0; i < participating.size(); i++) {
|
||||
HopConfig cfg = (HopConfig)participating.get(i);
|
||||
for (Iterator iter = participating.iterator(); iter.hasNext(); ) {
|
||||
HopConfig cfg = (HopConfig)iter.next();
|
||||
if (cfg.getProcessedMessagesCount() <= 0) {
|
||||
inactive++;
|
||||
continue;
|
||||
@ -483,6 +487,13 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
else
|
||||
out.write("<td align=right>(grace period)</td>");
|
||||
out.write("<td align=right>" + cfg.getProcessedMessagesCount() + "KB</td>");
|
||||
int lifetime = (int) ((_context.clock().now() - cfg.getCreation()) / 1000);
|
||||
if (lifetime <= 0)
|
||||
lifetime = 1;
|
||||
if (lifetime > 10*60)
|
||||
lifetime = 10*60;
|
||||
int bps = 1024 * (int) cfg.getProcessedMessagesCount() / lifetime;
|
||||
out.write("<td align=right>" + bps + "Bps</td>");
|
||||
if (cfg.getSendTo() == null)
|
||||
out.write("<td>Outbound Endpoint</td>");
|
||||
else if (cfg.getReceiveFrom() == null)
|
||||
@ -497,6 +508,12 @@ public class TunnelPoolManager implements TunnelManagerFacade {
|
||||
out.write("Lifetime bandwidth usage: " + processed + "KB<br />\n");
|
||||
}
|
||||
|
||||
class TunnelComparator implements Comparator {
|
||||
public int compare(Object l, Object r) {
|
||||
return (int) (((HopConfig)r).getProcessedMessagesCount() - ((HopConfig)l).getProcessedMessagesCount());
|
||||
}
|
||||
}
|
||||
|
||||
private void renderPool(Writer out, TunnelPool in, TunnelPool outPool) throws IOException {
|
||||
List tunnels = null;
|
||||
if (in == null)
|
||||
|
Reference in New Issue
Block a user