diff --git a/history.txt b/history.txt index 3315f3c3c8..0a4adcb7b1 100644 --- a/history.txt +++ b/history.txt @@ -1,10 +1,18 @@ +2014-01-11 zzz + * NetDB: + - Reduce min part tunnels for ffs to 35 + - Use client tunnels for LS lookups from OCMOSJ (ticket #1166) + 2014-01-11 str4d * BOB: Pass through I2CP host/port (ticket #827) 2014-01-10 str4d * BOB: Implement ClientApp interface (ticket #347) -2014-01-09 +2014-01-09 zzz + * Kademila: Fix NPE in remove() + +2014-01-09 kytv * Translations - Updates to French, German, Romanian, and Russian - New Brazilian Portuguese translation @@ -17,6 +25,9 @@ - UTF-8 support from wockenfuss (ticket #508) * Console: Fixed overlapping text issue in midnight theme +2014-01-07 zzz + * Streaming: Fix StandardServerSocket.close() and isClosed() + 2014-01-04 zzz * Peermanager: Disable small same-country bonus * Tunnels: Change client default to 3 hops in router; diff --git a/router/java/src/net/i2p/router/NetworkDatabaseFacade.java b/router/java/src/net/i2p/router/NetworkDatabaseFacade.java index a488ff7fc7..7fc3c50826 100644 --- a/router/java/src/net/i2p/router/NetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/NetworkDatabaseFacade.java @@ -40,6 +40,14 @@ public abstract class NetworkDatabaseFacade implements Service { */ public abstract DatabaseEntry lookupLocally(Hash key); public abstract void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs); + + /** + * Lookup using the client's tunnels + * @param fromLocalDest use these tunnels for the lookup, or null for exploratory + * @since 0.9.10 + */ + public abstract void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest); + public abstract LeaseSet lookupLeaseSetLocally(Hash key); public abstract void lookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs); public abstract RouterInfo lookupRouterInfoLocally(Hash key); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index fecba78d69..a6204817e3 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 7; + public final static long BUILD = 8; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/dummy/DummyNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/dummy/DummyNetworkDatabaseFacade.java index 2005578140..a17cee9076 100644 --- a/router/java/src/net/i2p/router/dummy/DummyNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/dummy/DummyNetworkDatabaseFacade.java @@ -40,6 +40,7 @@ public class DummyNetworkDatabaseFacade extends NetworkDatabaseFacade { public DatabaseEntry lookupLocally(Hash key) { return null; } public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) {} + public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) {} public LeaseSet lookupLeaseSetLocally(Hash key) { return null; } public void lookupRouterInfo(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) { RouterInfo info = lookupRouterInfoLocally(key); diff --git a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java index 78ef6faa72..cb4f6daf7d 100644 --- a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java +++ b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java @@ -219,7 +219,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl { if (_log.shouldLog(Log.DEBUG)) _log.debug(getJobId() + ": Send outbound client message - sending off leaseSet lookup job for " + _toString); LookupLeaseSetFailedJob failed = new LookupLeaseSetFailedJob(getContext()); - getContext().netDb().lookupLeaseSet(key, success, failed, timeoutMs); + getContext().netDb().lookupLeaseSet(key, success, failed, timeoutMs, _from.calculateHash()); } } diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java index 282c11eae6..c61ed40f18 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java @@ -129,7 +129,7 @@ class FloodfillMonitorJob extends JobImpl { // Only if we're pretty well integrated... happy = happy && _facade.getKnownRouters() >= 200; happy = happy && getContext().commSystem().countActivePeers() >= 50; - happy = happy && getContext().tunnelManager().getParticipatingCount() >= 50; + happy = happy && getContext().tunnelManager().getParticipatingCount() >= 35; happy = happy && Math.abs(getContext().clock().getOffset()) < 10*1000; // We need an address and no introducers if (happy) { diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java index 0da4cf05e0..4661f5c361 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java @@ -299,6 +299,8 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad } /** + * Lookup using exploratory tunnels + * * Begin a kademlia style search for the key specified, which can take up to timeoutMs and * will fire the appropriate jobs on success or timeout (or if the kademlia search completes * without any match) @@ -307,6 +309,17 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad */ @Override SearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease) { + return search(key, onFindJob, onFailedLookupJob, timeoutMs, isLease, null); + } + + /** + * Lookup using the client's tunnels + * @param fromLocalDest use these tunnels for the lookup, or null for exploratory + * @return null always + * @since 0.9.10 + */ + SearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease, + Hash fromLocalDest) { //if (true) return super.search(key, onFindJob, onFailedLookupJob, timeoutMs, isLease); if (key == null) throw new IllegalArgumentException("searchin for nothin, eh?"); boolean isNew = false; @@ -316,7 +329,8 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad if (searchJob == null) { //if (SearchJob.onlyQueryFloodfillPeers(_context)) { //searchJob = new FloodOnlySearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, isLease); - searchJob = new IterativeSearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, isLease); + searchJob = new IterativeSearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, + isLease, fromLocalDest); //} else { // searchJob = new FloodSearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, isLease); //} diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/IterativeSearchJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/IterativeSearchJob.java index d55379d432..f8e7721d69 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/IterativeSearchJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/IterativeSearchJob.java @@ -25,6 +25,7 @@ import net.i2p.router.OutNetMessage; import net.i2p.router.ReplyJob; import net.i2p.router.RouterContext; import net.i2p.router.TunnelInfo; +import net.i2p.router.TunnelManagerFacade; import net.i2p.router.util.RandomIterator; import net.i2p.util.Log; @@ -63,6 +64,7 @@ class IterativeSearchJob extends FloodSearchJob { private final Hash _rkey; /** this is a marker to register with the MessageRegistry, it is never sent */ private OutNetMessage _out; + private final Hash _fromLocalDest; /** testing */ private static Hash _alwaysQueryHash; @@ -89,7 +91,21 @@ class IterativeSearchJob extends FloodSearchJob { /** testing */ private static final String PROP_ENCRYPT_RI = "router.encryptRouterLookups"; - public IterativeSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease) { + /** + * Lookup using exploratory tunnels + */ + public IterativeSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, + Job onFind, Job onFailed, int timeoutMs, boolean isLease) { + this(ctx, facade, key, onFind, onFailed, timeoutMs, isLease, null); + } + + /** + * Lookup using the client's tunnels + * @param fromLocalDest use these tunnels for the lookup, or null for exploratory + * @since 0.9.10 + */ + public IterativeSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, + Job onFind, Job onFailed, int timeoutMs, boolean isLease, Hash fromLocalDest) { super(ctx, facade, key, onFind, onFailed, timeoutMs, isLease); // these override the settings in super _timeoutMs = Math.min(timeoutMs, MAX_SEARCH_TIME); @@ -99,6 +115,7 @@ class IterativeSearchJob extends FloodSearchJob { _unheardFrom = new HashSet(CONCURRENT_SEARCHES); _failedPeers = new HashSet(TOTAL_SEARCH_LIMIT); _sentTime = new ConcurrentHashMap(TOTAL_SEARCH_LIMIT); + _fromLocalDest = fromLocalDest; } @Override @@ -232,8 +249,23 @@ class IterativeSearchJob extends FloodSearchJob { */ private void sendQuery(Hash peer) { DatabaseLookupMessage dlm = new DatabaseLookupMessage(getContext(), true); - TunnelInfo replyTunnel = getContext().tunnelManager().selectInboundExploratoryTunnel(peer); - TunnelInfo outTunnel = getContext().tunnelManager().selectOutboundExploratoryTunnel(peer); + TunnelManagerFacade tm = getContext().tunnelManager(); + TunnelInfo outTunnel; + TunnelInfo replyTunnel; + boolean isClientReplyTunnel; + if (_fromLocalDest != null) { + outTunnel = tm.selectOutboundTunnel(_fromLocalDest, peer); + if (outTunnel == null) + outTunnel = tm.selectOutboundExploratoryTunnel(peer); + replyTunnel = tm.selectInboundTunnel(_fromLocalDest, peer); + isClientReplyTunnel = replyTunnel != null; + if (!isClientReplyTunnel) + replyTunnel = tm.selectInboundExploratoryTunnel(peer); + } else { + outTunnel = tm.selectOutboundExploratoryTunnel(peer); + replyTunnel = tm.selectInboundExploratoryTunnel(peer); + isClientReplyTunnel = false; + } if ( (replyTunnel == null) || (outTunnel == null) ) { failed(); return; @@ -260,7 +292,8 @@ class IterativeSearchJob extends FloodSearchJob { synchronized(this) { tries = _unheardFrom.size() + _failedPeers.size(); } - _log.info(getJobId() + ": ISJ try " + tries + " for " + _key + " to " + peer); + _log.info(getJobId() + ": ISJ try " + tries + " for " + _key + " to " + peer + + " reply via client tunnel? " + isClientReplyTunnel); } long now = getContext().clock().now(); _sentTime.put(peer, Long.valueOf(now)); @@ -273,7 +306,11 @@ class IterativeSearchJob extends FloodSearchJob { if (ri != null) { // request encrypted reply if (DatabaseLookupMessage.supportsEncryptedReplies(ri)) { - MessageWrapper.OneTimeSession sess = MessageWrapper.generateSession(getContext()); + MessageWrapper.OneTimeSession sess; + if (isClientReplyTunnel) + sess = MessageWrapper.generateSession(getContext(), _fromLocalDest); + else + sess = MessageWrapper.generateSession(getContext()); if (_log.shouldLog(Log.INFO)) _log.info(getJobId() + ": Requesting encrypted reply from " + peer + ' ' + sess.key + ' ' + sess.tag); dlm.setReplySession(sess.key, sess.tag); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index 757cee9b8b..70702bcadd 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -479,7 +479,20 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { return _ds.get(key); } + /** + * Lookup using exploratory tunnels + */ public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) { + lookupLeaseSet(key, onFindJob, onFailedLookupJob, timeoutMs, null); + } + + /** + * Lookup using the client's tunnels + * @param fromLocalDest use these tunnels for the lookup, or null for exploratory + * @since 0.9.10 + */ + public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, + long timeoutMs, Hash fromLocalDest) { if (!_initialized) return; LeaseSet ls = lookupLeaseSetLocally(key); if (ls != null) { @@ -490,7 +503,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { } else { if (_log.shouldLog(Log.DEBUG)) _log.debug("leaseSet not found locally, running search"); - search(key, onFindJob, onFailedLookupJob, timeoutMs, true); + search(key, onFindJob, onFailedLookupJob, timeoutMs, true, fromLocalDest); } if (_log.shouldLog(Log.DEBUG)) _log.debug("after lookupLeaseSet"); @@ -1020,6 +1033,16 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { return searchJob; } + /** + * Unused - see FNDF + * @throws UnsupportedOperationException always + * @since 0.9.10 + */ + SearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease, + Hash fromLocalDest) { + throw new UnsupportedOperationException(); + } + /** public for NetDbRenderer in routerconsole */ @Override public Set getLeases() {