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

to branch 'i2p.i2p' (head 5551e9b0487e14e901cd1081ce3e1ffd33c4a354)
This commit is contained in:
zzz
2009-05-26 15:02:52 +00:00
12 changed files with 77 additions and 62 deletions

View File

@ -27,27 +27,27 @@
System.setProperty("net.i2p.router.web.ConfigLoggingHandler.nonce", new java.util.Random().nextLong()+""); %>
<input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigLoggingHandler.nonce")%>" />
<input type="hidden" name="action" value="blah" />
<b>Logging filename:</b>
<input type="text" name="logfilename" size="40" value="<jsp:getProperty name="logginghelper" property="logFilePattern" />" /><br />
<i>(the symbol '@' will be replaced during log rotation)</i><br />
<b>Log record format:</b>
<input type="text" name="logformat" size="20" value="<jsp:getProperty name="logginghelper" property="recordPattern" />" /><br />
<i>(use 'd' = date, 'c' = class, 't' = thread, 'p' = priority, 'm' = message)</i><br />
<b>Log date format:</b>
<input type="text" name="logdateformat" size="20" value="<jsp:getProperty name="logginghelper" property="datePattern" />" /><br />
<i>('MM' = month, 'dd' = day, 'HH' = hour, 'mm' = minute, 'ss' = second, 'SSS' = millisecond)</i><br />
<b>Max log file size:</b>
<input type="text" name="logfilesize" size="4" value="<jsp:getProperty name="logginghelper" property="maxFileSize" />" /><br />
<hr />
<b>Log levels:</b> <br />
<b>Default log level:</b>
<jsp:getProperty name="logginghelper" property="defaultLogLevelBox" />
<i>(DEBUG and INFO are not recommended defaults, as they will drastically slow down your router)</i>
<br />
<jsp:getProperty name="logginghelper" property="logLevelTable" />
<hr />
<table border="0" cellspacing="5">
<tr><td valign="top"><b>Logging filename:</b>
<td><input type="text" name="logfilename" size="40" value="<jsp:getProperty name="logginghelper" property="logFilePattern" />" /><br />
<i>(the symbol '@' will be replaced during log rotation)</i>
<tr><td valign="top"><b>Log record format:</b>
<td><input type="text" name="logformat" size="20" value="<jsp:getProperty name="logginghelper" property="recordPattern" />" /><br />
<i>(use 'd' = date, 'c' = class, 't' = thread, 'p' = priority, 'm' = message)</i>
<tr><td valign="top"><b>Log date format:</b>
<td><input type="text" name="logdateformat" size="20" value="<jsp:getProperty name="logginghelper" property="datePattern" />" /><br />
<i>('MM' = month, 'dd' = day, 'HH' = hour, 'mm' = minute, 'ss' = second, 'SSS' = millisecond)</i>
<tr><td valign="top"><b>Max log file size:</b>
<td><input type="text" name="logfilesize" size="4" value="<jsp:getProperty name="logginghelper" property="maxFileSize" />" /><br />
<tr><td valign="top"><b>Default log level:</b>
<td><jsp:getProperty name="logginghelper" property="defaultLogLevelBox" />
<br /><i>(DEBUG and INFO are not recommended defaults, as they will drastically slow down your router)</i>
<tr><td valign="top"><b>Log level overrides:</b>
<td><jsp:getProperty name="logginghelper" property="logLevelTable" />
<tr><td><td>
<input type="submit" name="shouldsave" value="Save changes" />
<input type="reset" value="Cancel" />
</table>
</form>
</div>

View File

@ -171,7 +171,9 @@ class ConnectionHandler {
// Send it through the packet handler again
if (_log.shouldLog(Log.WARN))
_log.warn("Found con for queued non-syn packet: " + packet);
_manager.getPacketHandler().receivePacket(packet);
// false -> don't requeue, fixes a race where a SYN gets dropped
// between here and PacketHandler, causing the packet to loop forever....
_manager.getPacketHandler().receivePacketDirect(packet, false);
} else {
// goodbye
if (_log.shouldLog(Log.WARN))

View File

@ -90,10 +90,10 @@ public class PacketHandler {
void receivePacket(Packet packet) {
//boolean ok = choke(packet);
//if (ok)
receivePacketDirect(packet);
receivePacketDirect(packet, true);
}
private void receivePacketDirect(Packet packet) {
void receivePacketDirect(Packet packet, boolean queueIfNoConn) {
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("packet received: " + packet);
@ -105,7 +105,7 @@ public class PacketHandler {
if (_log.shouldLog(Log.INFO))
displayPacket(packet, "RECV", "wsize " + con.getOptions().getWindowSize() + " rto " + con.getOptions().getRTO());
} else {
receiveUnknownCon(packet, sendId);
receiveUnknownCon(packet, sendId, queueIfNoConn);
displayPacket(packet, "UNKN", null);
}
}
@ -228,7 +228,7 @@ public class PacketHandler {
_manager.getPacketQueue().enqueue(reply);
}
private void receiveUnknownCon(Packet packet, long sendId) {
private void receiveUnknownCon(Packet packet, long sendId, boolean queueIfNoConn) {
if (packet.isFlagSet(Packet.FLAG_ECHO)) {
if (packet.getSendStreamId() > 0) {
receivePing(packet);
@ -262,7 +262,7 @@ public class PacketHandler {
if (packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) {
_manager.getConnectionHandler().receiveNewSyn(packet);
} else {
} else if (queueIfNoConn) {
// We can get here on the 2nd+ packet if the 1st (SYN) packet
// is still on the _synQueue in the ConnectionHandler, and
// ConnectionManager.receiveConnection() hasn't run yet to put
@ -287,6 +287,10 @@ public class PacketHandler {
}
//packet.releasePayload();
_manager.getConnectionHandler().receiveNewSyn(packet);
} else {
// don't queue again (infinite loop!)
sendReset(packet);
packet.releasePayload();
}
}
}

View File

@ -8,7 +8,9 @@ package net.i2p.router.networkdb.kademlia;
*
*/
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.i2p.data.Hash;
import net.i2p.data.TunnelId;
@ -96,7 +98,13 @@ class ExploreJob extends SearchJob {
available = MAX_CLOSEST - msg.getDontIncludePeers().size();
if (available > 0) {
List peers = _peerSelector.selectNearestExplicit(getState().getTarget(), available, msg.getDontIncludePeers(), getFacade().getKBuckets());
// selectNearestExplicit adds our hash to the dontInclude set (3rd param) ...
// And we end up with MAX_CLOSEST+1 entries.
// We don't want our hash in the message's don't-include list though.
// We're just exploring, but this could give things away, and tie our exploratory tunnels to our router,
// so let's not put our hash in there.
Set dontInclude = new HashSet(msg.getDontIncludePeers());
List peers = _peerSelector.selectNearestExplicit(getState().getTarget(), available, dontInclude, getFacade().getKBuckets());
msg.getDontIncludePeers().addAll(peers);
}
@ -106,17 +114,6 @@ class ExploreJob extends SearchJob {
return msg;
}
/**
* We're looking for a router, so lets build the lookup message (no need to tunnel route either, so just have
* replies sent back to us directly). This uses the similar overrides as the other buildMessage above.
*
*/
@Override
protected DatabaseLookupMessage buildMessage(long expiration) {
return buildMessage(null, getContext().router().getRouterInfo().getIdentity().getHash(), expiration);
}
/** max # of concurrent searches */
@Override
protected int getBredth() { return EXPLORE_BREDTH; }

View File

@ -44,7 +44,7 @@ class FloodfillPeerSelector extends PeerSelector {
public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets, boolean preferConnected) {
if (peersToIgnore == null)
peersToIgnore = new HashSet(1);
peersToIgnore.add(_context.router().getRouterInfo().getIdentity().getHash());
peersToIgnore.add(_context.routerHash());
FloodfillSelectionCollector matches = new FloodfillSelectionCollector(key, peersToIgnore, maxNumRouters);
if (kbuckets == null) return new ArrayList();
kbuckets.getAll(matches);

View File

@ -61,7 +61,7 @@ public class PeerSelector {
if (peersToIgnore == null)
peersToIgnore = new HashSet(1);
peersToIgnore.add(_context.router().getRouterInfo().getIdentity().getHash());
peersToIgnore.add(_context.routerHash());
Set allHashes = kbuckets.getAll(peersToIgnore);
removeFailingPeers(allHashes);
Map diffMap = new HashMap(allHashes.size());
@ -94,7 +94,7 @@ public class PeerSelector {
public List selectNearestExplicitThin(Hash key, int maxNumRouters, Set peersToIgnore, KBucketSet kbuckets) { // LINT -- Exporting non-public type through public API
if (peersToIgnore == null)
peersToIgnore = new HashSet(1);
peersToIgnore.add(_context.router().getRouterInfo().getIdentity().getHash());
peersToIgnore.add(_context.routerHash());
MatchSelectionCollector matches = new MatchSelectionCollector(key, peersToIgnore);
kbuckets.getAll(matches);
List rv = matches.get(maxNumRouters);

View File

@ -106,8 +106,10 @@ class PersistentDataStore extends TransientDataStore {
*/
@Override
public DataStructure remove(Hash key, boolean persist) {
if (persist)
if (persist) {
_writer.remove(key);
_context.jobQueue().addJob(new RemoveJob(key));
}
return super.remove(key);
}
@ -183,6 +185,10 @@ class PersistentDataStore extends TransientDataStore {
return _keys.get(key);
}
public void remove(Hash key) {
_keys.remove(key);
}
public void run() {
_quit = false;
Hash key = null;

View File

@ -452,6 +452,7 @@ class SearchJob extends JobImpl {
}
/** we're searching for a router, so we can just send direct */
/******* always send through the lease
protected void sendRouterSearch(RouterInfo router) {
int timeout = _facade.getPeerTimeout(router.getIdentity().getHash());
long expiration = getContext().clock().now() + timeout;
@ -471,6 +472,7 @@ class SearchJob extends JobImpl {
j.runJob();
//getContext().jobQueue().addJob(j);
}
**********/
/**
* what tunnel will we send the search out through?
@ -513,6 +515,7 @@ class SearchJob extends JobImpl {
* replies sent back to us directly)
*
*/
/******* always send through the lease
protected DatabaseLookupMessage buildMessage(long expiration) {
DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext(), true);
msg.setSearchKey(_state.getTarget());
@ -522,6 +525,7 @@ class SearchJob extends JobImpl {
msg.setReplyTunnel(null);
return msg;
}
*********/
void replyFound(DatabaseSearchReplyMessage message, Hash peer) {
long duration = _state.replyFound(peer);

View File

@ -58,9 +58,10 @@ class ProfileOrganizerRenderer {
int failing = 0;
StringBuffer buf = new StringBuffer(16*1024);
buf.append("<h2>Peer Profiles</h2>\n");
buf.append("<p>Showing ").append(order.size()).append(" recent profiles, hiding ").append(peers.size()-order.size()).append(" older profiles</p>");
buf.append("<table border=\"1\">");
buf.append("<tr>");
buf.append("<td><b>Peer</b> (").append(order.size()).append(", hiding ").append(peers.size()-order.size()).append(")</td>");
buf.append("<td><b>Peer</b></td>");
buf.append("<td><b>Groups (Caps)</b></td>");
buf.append("<td><b>Speed</b></td>");
buf.append("<td><b>Capacity</b></td>");
@ -97,7 +98,7 @@ class ProfileOrganizerRenderer {
buf.append("<tr><td colspan=\"7\"><hr /></td></tr>\n");
prevTier = tier;
buf.append("<tr><td>");
buf.append("<tr><td nowrap>");
buf.append(_context.commSystem().renderPeerHTML(peer));
buf.append("</td><td>");
@ -179,7 +180,7 @@ class ProfileOrganizerRenderer {
PeerProfile prof = (PeerProfile)iter.next();
Hash peer = prof.getPeer();
buf.append("<tr><td>");
buf.append("<tr><td nowrap>");
buf.append(_context.commSystem().renderPeerHTML(peer));
buf.append("</td>");
RouterInfo info = _context.netDb().lookupRouterInfoLocally(peer);

View File

@ -128,6 +128,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
}
int getTransportCount() { return _manager.getTransportCount(); }
/** Send the message out */
public void processMessage(OutNetMessage msg) {
//GetBidsJob j = new GetBidsJob(_context, this, msg);
//j.runJob();
@ -436,6 +437,16 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
public String renderPeerHTML(Hash peer) {
String h = peer.toBase64().substring(0, 4);
StringBuffer buf = new StringBuffer(128);
String c = getCountry(peer);
if (c != null) {
buf.append("<img alt=\"").append(c.toUpperCase()).append("\" title=\"");
String n = _geoIP.fullName(c);
if (n != null)
buf.append(n);
else
buf.append(c);
buf.append("\" src=\"/flags.jsp?c=").append(c).append("\"> ");
}
buf.append("<tt><font size=\"+1\">");
boolean found = _context.netDb().lookupRouterInfoLocally(peer) != null;
if (found)
@ -444,16 +455,6 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
if (found)
buf.append("</a>");
buf.append("</font></tt>");
String c = getCountry(peer);
if (c != null) {
buf.append(" <img alt=\"").append(c.toUpperCase()).append("\" title=\"");
String n = _geoIP.fullName(c);
if (n != null)
buf.append(n);
else
buf.append(c);
buf.append("\" src=\"/flags.jsp?c=").append(c).append("\">");
}
return buf.toString();
}
}

View File

@ -265,7 +265,7 @@ public class NTCPTransport extends TransportImpl {
boolean established = isEstablished(toAddress.getIdentity());
if (established) { // should we check the queue size? nah, if its valid, use it
if (_log.shouldLog(Log.DEBUG))
_log.debug("fast bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + " as its already established");
_log.debug("fast bid when trying to send to " + peer.toBase64() + " as its already established");
return _fastBid;
}
RouterAddress addr = toAddress.getTargetAddress(STYLE);
@ -275,7 +275,7 @@ public class NTCPTransport extends TransportImpl {
_context.statManager().addRateData("ntcp.bidRejectedNoNTCPAddress", 1, 0);
//_context.shitlist().shitlistRouter(toAddress.getIdentity().calculateHash(), "No NTCP address", STYLE);
if (_log.shouldLog(Log.DEBUG))
_log.debug("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + " as they don't have an ntcp address");
_log.debug("no bid when trying to send to " + peer.toBase64() + " as they don't have an ntcp address");
return null;
}
NTCPAddress naddr = new NTCPAddress(addr);
@ -284,7 +284,7 @@ public class NTCPTransport extends TransportImpl {
markUnreachable(peer);
//_context.shitlist().shitlistRouter(toAddress.getIdentity().calculateHash(), "Invalid NTCP address", STYLE);
if (_log.shouldLog(Log.DEBUG))
_log.debug("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + " as they don't have a valid ntcp address");
_log.debug("no bid when trying to send to " + peer.toBase64() + " as they don't have a valid ntcp address");
return null;
}
if (!naddr.isPubliclyRoutable()) {
@ -292,14 +292,14 @@ public class NTCPTransport extends TransportImpl {
_context.statManager().addRateData("ntcp.bidRejectedLocalAddress", 1, 0);
markUnreachable(peer);
if (_log.shouldLog(Log.DEBUG))
_log.debug("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + " as they have a private ntcp address");
_log.debug("no bid when trying to send to " + peer.toBase64() + " as they have a private ntcp address");
return null;
}
}
if (!allowConnection()) {
if (_log.shouldLog(Log.WARN))
_log.warn("no bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64() + ", max connection limit reached");
_log.warn("no bid when trying to send to " + peer.toBase64() + ", max connection limit reached");
return _transientFail;
}
@ -307,7 +307,7 @@ public class NTCPTransport extends TransportImpl {
// return null; // dont talk to yourself
if (_log.shouldLog(Log.DEBUG))
_log.debug("slow bid when trying to send to " + toAddress.getIdentity().calculateHash().toBase64());
_log.debug("slow bid when trying to send to " + peer.toBase64());
return _slowBid;
}
@ -655,7 +655,7 @@ public class NTCPTransport extends TransportImpl {
buf.setLength(0);
for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
NTCPConnection con = (NTCPConnection)iter.next();
buf.append("<tr><td>");
buf.append("<tr><td nowrap>");
buf.append(_context.commSystem().renderPeerHTML(con.getRemotePeer().calculateHash()));
//byte[] ip = getIP(con.getRemotePeer().calculateHash());
//if (ip != null)

View File

@ -1807,7 +1807,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
buf.append("<tr>");
buf.append("<td>");
buf.append("<td nowrap>");
buf.append(_context.commSystem().renderPeerHTML(peer.getRemotePeer()));
//byte ip[] = peer.getRemoteIP();
//if (ip != null)