propagate from branch 'i2p.i2p' (head fd10b04ca3a6cf66e669bfad32d3011ed9f7e33c)

to branch 'i2p.i2p.zzz.ipv6' (head 6f6e16f14691f359322e665a7ad5ab65cbe1ca5e)
This commit is contained in:
zzz
2013-05-29 00:22:15 +00:00
48 changed files with 18131 additions and 28638 deletions

View File

@@ -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 = 21;
public final static long BUILD = 0;
/** for example "-test" */
public final static String EXTRA = "-ipv6";

View File

@@ -78,9 +78,10 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
return;
}
// TODO only look up once, then check type
LeaseSet ls = getContext().netDb().lookupLeaseSetLocally(_message.getSearchKey());
if (ls != null) {
// only lookup once, then cast to correct type
DatabaseEntry dbe = getContext().netDb().lookupLocally(_message.getSearchKey());
if (dbe != null && dbe.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
LeaseSet ls = (LeaseSet) dbe;
// We have to be very careful here to decide whether or not to send out the leaseSet,
// to avoid anonymity vulnerabilities.
// As this is complex, lots of comments follow...
@@ -105,7 +106,7 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
// so we don't check the answerAllQueries() flag.
// Local leasesets are not handled here
if (_log.shouldLog(Log.INFO))
_log.info("We have the published LS " + _message.getSearchKey().toBase64() + ", answering query");
_log.info("We have the published LS " + _message.getSearchKey() + ", answering query");
getContext().statManager().addRateData("netDb.lookupsMatchedReceivedPublished", 1, 0);
sendData(_message.getSearchKey(), ls, fromKey, _message.getReplyTunnel());
} else if (shouldPublishLocal && answerAllQueries()) {
@@ -118,13 +119,13 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
if (weAreClosest(closestHashes)) {
// It's in our keyspace, so give it to them
if (_log.shouldLog(Log.INFO))
_log.info("We have local LS " + _message.getSearchKey().toBase64() + ", answering query, in our keyspace");
_log.info("We have local LS " + _message.getSearchKey() + ", answering query, in our keyspace");
getContext().statManager().addRateData("netDb.lookupsMatchedLocalClosest", 1, 0);
sendData(_message.getSearchKey(), ls, fromKey, _message.getReplyTunnel());
} else {
// Lie, pretend we don't have it
if (_log.shouldLog(Log.INFO))
_log.info("We have local LS " + _message.getSearchKey().toBase64() + ", NOT answering query, out of our keyspace");
_log.info("We have local LS " + _message.getSearchKey() + ", NOT answering query, out of our keyspace");
getContext().statManager().addRateData("netDb.lookupsMatchedLocalNotClosest", 1, 0);
Set<Hash> routerHashSet = getNearestRouters();
sendClosest(_message.getSearchKey(), routerHashSet, fromKey, _message.getReplyTunnel());
@@ -135,16 +136,16 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
// or it's local and we don't publish it.
// Lie, pretend we don't have it
if (_log.shouldLog(Log.INFO))
_log.info("We have LS " + _message.getSearchKey().toBase64() +
_log.info("We have LS " + _message.getSearchKey() +
", NOT answering query - local? " + isLocal + " shouldPublish? " + shouldPublishLocal +
" RAP? " + ls.getReceivedAsPublished() + " RAR? " + ls.getReceivedAsReply());
getContext().statManager().addRateData("netDb.lookupsMatchedRemoteNotClosest", 1, 0);
Set<Hash> routerHashSet = getNearestRouters();
sendClosest(_message.getSearchKey(), routerHashSet, fromKey, _message.getReplyTunnel());
}
} else {
RouterInfo info = getContext().netDb().lookupRouterInfoLocally(_message.getSearchKey());
if ( (info != null) && (info.isCurrent(EXPIRE_DELAY)) ) {
} else if (dbe != null && dbe.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
RouterInfo info = (RouterInfo) dbe;
if (info.isCurrent(EXPIRE_DELAY)) {
if ( (info.getIdentity().isHidden()) || (isUnreachable(info) && !publishUnreachable()) ) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Not answering a query for a netDb peer who isn't reachable");
@@ -162,12 +163,12 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
} else {
// send that routerInfo to the _message.getFromHash peer
if (_log.shouldLog(Log.DEBUG))
_log.debug("We do have key " + _message.getSearchKey().toBase64()
+ " locally as a router info. sending to " + fromKey.toBase64());
_log.debug("We do have key " + _message.getSearchKey()
+ " locally as a router info. sending to " + fromKey);
sendData(_message.getSearchKey(), info, fromKey, _message.getReplyTunnel());
}
} else {
// not found locally - return closest peer hashes
// expired locally - return closest peer hashes
Set<Hash> routerHashSet = getNearestRouters();
// ERR: see above
@@ -180,10 +181,17 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
// }
if (_log.shouldLog(Log.DEBUG))
_log.debug("We do not have key " + _message.getSearchKey().toBase64() +
" locally. sending back " + routerHashSet.size() + " peers to " + fromKey.toBase64());
_log.debug("Expired " + _message.getSearchKey() +
" locally. sending back " + routerHashSet.size() + " peers to " + fromKey);
sendClosest(_message.getSearchKey(), routerHashSet, fromKey, _message.getReplyTunnel());
}
} else {
// not found locally - return closest peer hashes
Set<Hash> routerHashSet = getNearestRouters();
if (_log.shouldLog(Log.DEBUG))
_log.debug("We do not have key " + _message.getSearchKey() +
" locally. sending back " + routerHashSet.size() + " peers to " + fromKey);
sendClosest(_message.getSearchKey(), routerHashSet, fromKey, _message.getReplyTunnel());
}
}
@@ -230,7 +238,7 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
return;
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("Sending data matching key " + key.toBase64() + " to peer " + toPeer.toBase64()
_log.debug("Sending data matching key " + key + " to peer " + toPeer
+ " tunnel " + replyTunnel);
DatabaseStoreMessage msg = new DatabaseStoreMessage(getContext());
if (data.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
@@ -244,7 +252,7 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
protected void sendClosest(Hash key, Set<Hash> routerHashes, Hash toPeer, TunnelId replyTunnel) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Sending closest routers to key " + key.toBase64() + ": # peers = "
_log.debug("Sending closest routers to key " + key + ": # peers = "
+ routerHashes.size() + " tunnel " + replyTunnel);
DatabaseSearchReplyMessage msg = new DatabaseSearchReplyMessage(getContext());
msg.setFromHash(getContext().routerHash());

View File

@@ -25,7 +25,7 @@ class FloodfillMonitorJob extends JobImpl {
private static final int REQUEUE_DELAY = 60*60*1000;
private static final long MIN_UPTIME = 2*60*60*1000;
private static final long MIN_CHANGE_DELAY = 6*60*60*1000;
private static final int MIN_FF = 500;
private static final int MIN_FF = 1000;
private static final int MAX_FF = 999999;
private static final String PROP_FLOODFILL_PARTICIPANT = "router.floodfillParticipant";

View File

@@ -42,7 +42,6 @@ import net.i2p.util.SecureFileOutputStream;
*
*/
class PersistentDataStore extends TransientDataStore {
private final Log _log;
private final File _dbDir;
private final KademliaNetworkDatabaseFacade _facade;
private final Writer _writer;
@@ -60,7 +59,6 @@ class PersistentDataStore extends TransientDataStore {
*/
public PersistentDataStore(RouterContext ctx, String dbDir, KademliaNetworkDatabaseFacade facade) throws IOException {
super(ctx);
_log = ctx.logManager().getLog(PersistentDataStore.class);
_flat = ctx.getBooleanProperty(PROP_FLAT);
_dbDir = getDbDir(dbDir);
_facade = facade;

View File

@@ -22,14 +22,17 @@ import net.i2p.data.RouterInfo;
import net.i2p.router.RouterContext;
import net.i2p.util.Log;
/**
* Stores in-memory only. See extension.
*/
class TransientDataStore implements DataStore {
private Log _log;
private ConcurrentHashMap<Hash, DatabaseEntry> _data;
protected RouterContext _context;
protected final Log _log;
private final ConcurrentHashMap<Hash, DatabaseEntry> _data;
protected final RouterContext _context;
public TransientDataStore(RouterContext ctx) {
_context = ctx;
_log = ctx.logManager().getLog(TransientDataStore.class);
_log = ctx.logManager().getLog(getClass());
_data = new ConcurrentHashMap(1024);
if (_log.shouldLog(Log.INFO))
_log.info("Data Store initialized");
@@ -191,7 +194,7 @@ class TransientDataStore implements DataStore {
public DatabaseEntry remove(Hash key) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Removing key " + key.toBase64());
_log.debug("Removing key " + key);
return _data.remove(key);
}
}

View File

@@ -63,7 +63,7 @@ public class Reseeder {
public static final String DEFAULT_SEED_URL =
"http://netdb.i2p2.de/" + "," +
"http://reseed.i2p-projekt.de/" + "," +
"http://euve5653.vserver.de/netDb/" + "," +
//"http://euve5653.vserver.de/netDb/" + "," +
"http://cowpuncher.drollette.com/netdb/" + "," +
"http://i2p.mooo.com/netDb/" + "," +
"http://193.150.121.66/netDb/" + "," +
@@ -77,7 +77,7 @@ public class Reseeder {
public static final String DEFAULT_SSL_SEED_URL =
"https://netdb.i2p2.de/" + "," +
"https://reseed.i2p-projekt.de/" + "," +
"https://euve5653.vserver.de/netDb/" + "," +
//"https://euve5653.vserver.de/netDb/" + "," +
"https://cowpuncher.drollette.com/netdb/" + "," +
"https://i2p.mooo.com/netDb/" + "," +
"https://193.150.121.66/netDb/" + "," +

View File

@@ -74,6 +74,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
private Device _router;
private Service _service;
private boolean isDisabled = false; // We disable the plugin if more than one IGD is found
private volatile boolean _serviceLacksAPM;
private final Object lock = new Object();
// FIXME: detect it for real and deal with it! @see #2524
private volatile boolean thinksWeAreDoubleNatted = false;
@@ -121,6 +122,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
super.stop();
_router = null;
_service = null;
_serviceLacksAPM = false;
}
public DetectedIP[] getAddress() {
@@ -255,20 +257,21 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
_log.error(_router.getFriendlyName()+ " doesn't export WAN_IP_CONNECTION either: we won't be able to use it!");
}
_serviceLacksAPM = false;
return;
}
}
}
}
public boolean tryAddMapping(String protocol, int port, String description, ForwardPort fp) {
private boolean tryAddMapping(String protocol, int port, String description, ForwardPort fp) {
if (_log.shouldLog(Log.WARN))
_log.warn("Registering a port mapping for " + port + "/" + protocol);
int nbOfTries = 0;
boolean isPortForwarded = false;
while(nbOfTries++ < 5) {
while ((!_serviceLacksAPM) && nbOfTries++ < 5) {
isPortForwarded = addMapping(protocol, port, "I2P " + description, fp);
if(isPortForwarded)
if(isPortForwarded || _serviceLacksAPM)
break;
try {
Thread.sleep(5000);
@@ -307,6 +310,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
_log.warn("UP&P IGD device removed : " + dev.getFriendlyName());
_router = null;
_service = null;
_serviceLacksAPM = false;
}
}
}
@@ -565,7 +569,13 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
Action add = _service.getAction("AddPortMapping");
if(add == null) {
_log.error("Couldn't find AddPortMapping action!");
if (_serviceLacksAPM) {
if (_log.shouldLog(Log.WARN))
_log.warn("Couldn't find AddPortMapping action!");
} else {
_serviceLacksAPM = true;
_log.logAlways(Log.WARN, "UPnP device does not support port forwarding");
}
return false;
}
@@ -695,7 +705,8 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
Action remove = _service.getAction("DeletePortMapping");
if(remove == null) {
_log.error("Couldn't find DeletePortMapping action!");
if (_log.shouldLog(Log.WARN))
_log.warn("Couldn't find DeletePortMapping action!");
return false;
}
@@ -794,6 +805,18 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
* so throw this in a thread.
*/
private void registerPorts(Set<ForwardPort> portsToForwardNow) {
if (_serviceLacksAPM) {
if (_log.shouldLog(Log.WARN))
_log.warn("UPnP device does not support port forwarding");
for (ForwardPort port : portsToForwardNow) {
ForwardPortStatus fps = new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE,
"UPnP device does not support port forwarding",
port.portNumber);
Map map = Collections.singletonMap(port, fps);
forwardCallback.portForwardStatus(map);
}
return;
}
if (_log.shouldLog(Log.INFO))
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
Thread t = new Thread(new RegisterPortsThread(portsToForwardNow));

View File

@@ -693,7 +693,8 @@ class EventPumper implements Runnable {
}
} else {
// Nothing more to write
key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
if (key.isValid())
key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
break;
}
}

View File

@@ -160,7 +160,7 @@ abstract class BuildRequestor {
if (cfg.isInbound()) {
if (log.shouldLog(Log.INFO))
log.info("Sending the tunnel build request " + msg.getUniqueId() + " out the tunnel " + pairedTunnel + " to "
+ cfg.getPeer(0).toBase64() + " for " + cfg + " waiting for the reply of "
+ cfg.getPeer(0) + " for " + cfg + " waiting for the reply of "
+ cfg.getReplyMessageId());
// send it out a tunnel targetting the first hop
// TODO - would be nice to have a TunnelBuildFirstHopFailJob queued if the
@@ -168,7 +168,7 @@ abstract class BuildRequestor {
ctx.tunnelDispatcher().dispatchOutbound(msg, pairedTunnel.getSendTunnelId(0), cfg.getPeer(0));
} else {
if (log.shouldLog(Log.INFO))
log.info("Sending the tunnel build request directly to " + cfg.getPeer(1).toBase64()
log.info("Sending the tunnel build request directly to " + cfg.getPeer(1)
+ " for " + cfg + " waiting for the reply of " + cfg.getReplyMessageId()
+ " with msgId=" + msg.getUniqueId());
// send it directly to the first hop
@@ -183,8 +183,8 @@ abstract class BuildRequestor {
outMsg.setPriority(PRIORITY);
RouterInfo peer = ctx.netDb().lookupRouterInfoLocally(cfg.getPeer(1));
if (peer == null) {
if (log.shouldLog(Log.ERROR))
log.error("Could not find the next hop to send the outbound request to: " + cfg);
if (log.shouldLog(Log.WARN))
log.warn("Could not find the next hop to send the outbound request to: " + cfg);
exec.buildComplete(cfg, pool);
return;
}
@@ -300,7 +300,7 @@ abstract class BuildRequestor {
if (peerInfo == null) {
if (log.shouldLog(Log.WARN))
log.warn("Peer selected for hop " + i + "/" + hop + " was not found locally: "
+ peer.toBase64() + " for " + cfg);
+ peer + " for " + cfg);
return null;
} else {
key = peerInfo.getIdentity().getPublicKey();
@@ -343,9 +343,9 @@ abstract class BuildRequestor {
* Can't do this for inbound tunnels since the msg goes out an expl. tunnel.
*/
private static class TunnelBuildFirstHopFailJob extends JobImpl {
final TunnelPool _pool;
final PooledTunnelCreatorConfig _cfg;
final BuildExecutor _exec;
private final TunnelPool _pool;
private final PooledTunnelCreatorConfig _cfg;
private final BuildExecutor _exec;
private TunnelBuildFirstHopFailJob(RouterContext ctx, TunnelPool pool, PooledTunnelCreatorConfig cfg, BuildExecutor exec) {
super(ctx);
_cfg = cfg;