* Addressbook: Disallow '.-' and '-.' in host names

* NTCP: Don't drop a connection unless both directions are idle;
            Fix idle time for outbound connections
    * Outbound message: Make sure cached lease is in current leaseSet
    * Stats: Put all NetworkDatabase stats in same group
    * TunnelPool: Stop building tunnels and leaseSets after client shutdown
    * i2psnark: Add locking to prevent two I2CP connections
This commit is contained in:
zzz
2008-04-12 21:34:25 +00:00
parent 215eb14d38
commit 0b600669c7
11 changed files with 38 additions and 15 deletions

View File

@ -167,7 +167,8 @@ public class AddressBook {
host.length() <= 67 && // 63 + ".i2p"
(! host.startsWith(".")) &&
(! host.startsWith("-")) &&
(! host.endsWith("-.i2p")) &&
host.indexOf(".-") < 0 &&
host.indexOf("-.") < 0 &&
host.indexOf("..") < 0 &&
// IDN - basic check, not complete validation
(host.indexOf("--") < 0 || host.startsWith("xn--") || host.indexOf(".xn--") > 0) &&

View File

@ -97,7 +97,7 @@ public class I2PSnarkUtil {
/**
* Connect to the router, if we aren't already
*/
public boolean connect() {
synchronized public boolean connect() {
if (_manager == null) {
Properties opts = new Properties();
if (_opts != null) {

View File

@ -1,3 +1,12 @@
2008-04-12 zzz
* Addressbook: Disallow '.-' and '-.' in host names
* NTCP: Don't drop a connection unless both directions are idle;
Fix idle time for outbound connections
* Outbound message: Make sure cached lease is in current leaseSet
* Stats: Put all NetworkDatabase stats in same group
* TunnelPool: Stop building tunnels and leaseSets after client shutdown
* i2psnark: Add locking to prevent two I2CP connections
2008-04-07 zzz
* i2psnark:
- Implement upstream bandwidth limiting

View File

@ -33,8 +33,8 @@ public class DatabaseSearchReplyMessage extends I2NPMessageImpl {
public DatabaseSearchReplyMessage(I2PAppContext context) {
super(context);
_context.statManager().createRateStat("netDb.searchReplyMessageSend", "How many search reply messages we send", "Network Database", new long[] { 60*1000, 5*60*1000, 10*60*1000, 60*60*1000 });
_context.statManager().createRateStat("netDb.searchReplyMessageReceive", "How many search reply messages we receive", "Network Database", new long[] { 60*1000, 5*60*1000, 10*60*1000, 60*60*1000 });
_context.statManager().createRateStat("netDb.searchReplyMessageSend", "How many search reply messages we send", "NetworkDatabase", new long[] { 60*1000, 5*60*1000, 10*60*1000, 60*60*1000 });
_context.statManager().createRateStat("netDb.searchReplyMessageReceive", "How many search reply messages we receive", "NetworkDatabase", new long[] { 60*1000, 5*60*1000, 10*60*1000, 60*60*1000 });
setSearchKey(null);
_peerHashes = new ArrayList(3);
setFromHash(null);

View File

@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
public class RouterVersion {
public final static String ID = "$Revision: 1.548 $ $Date: 2008-02-10 15:00:00 $";
public final static String VERSION = "0.6.1.32";
public final static long BUILD = 15;
public final static long BUILD = 16;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -228,8 +228,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
* simultaneously talking to the same dest is probably rare enough
* to not bother separating out.
*
* We're going to use the lease until it expires, not even looking for a newer lease.
* So if the inbound tunnel fails and the dest publishes a new lease, we won't know about it.
* We're going to use the lease until it expires, as long as it remains in the current leaseSet.
*
* If not found,
* fetch the next lease that we should try sending through, randomly chosen
@ -259,9 +258,16 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
if (_lease != null) {
// if outbound tunnel length == 0 && lease.firsthop.isBacklogged() don't use it ??
if (!_lease.isExpired(Router.CLOCK_FUDGE_FACTOR)) {
if (_log.shouldLog(Log.INFO))
_log.info("Found in cache - lease for " + _toString);
return true;
// see if the current leaseSet contains the old lease, so that if the dest removes
// it (due to failure for example) we won't continue to use it.
for (int i = 0; i < _leaseSet.getLeaseCount(); i++) {
Lease lease = _leaseSet.getLease(i);
if (_lease.equals(lease)) {
if (_log.shouldLog(Log.INFO))
_log.info("Found in cache - lease for " + _toString);
return true;
}
}
}
if (_log.shouldLog(Log.WARN))
_log.warn("Expired from cache - lease for " + _toString);

View File

@ -46,8 +46,8 @@ class PersistentDataStore extends TransientDataStore {
_dbDir = dbDir;
_facade = facade;
_context.jobQueue().addJob(new ReadJob());
ctx.statManager().createRateStat("netDb.writeClobber", "How often we clobber a pending netDb write", "Network Database", new long[] { 60*1000, 10*60*1000 });
ctx.statManager().createRateStat("netDb.writePending", "How many pending writes are there", "Network Database", new long[] { 60*1000, 10*60*1000 });
ctx.statManager().createRateStat("netDb.writeClobber", "How often we clobber a pending netDb write", "NetworkDatabase", new long[] { 60*1000, 10*60*1000 });
ctx.statManager().createRateStat("netDb.writePending", "How many pending writes are there", "NetworkDatabase", new long[] { 60*1000, 10*60*1000 });
_writer = new Writer();
I2PThread writer = new I2PThread(_writer, "DBWriter");
writer.setDaemon(true);

View File

@ -143,8 +143,9 @@ public class EventPumper implements Runnable {
failsafeWrites++;
}
if ( con.getTimeSinceSend() > expireIdleWriteTime) {
// we haven't sent anything in a really long time, so lets just close 'er up
if ( con.getTimeSinceSend() > expireIdleWriteTime &&
con.getTimeSinceReceive() > expireIdleWriteTime) {
// we haven't sent or received anything in a really long time, so lets just close 'er up
con.close();
failsafeCloses++;
}

View File

@ -141,6 +141,8 @@ public class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener {
_context = ctx;
_log = ctx.logManager().getLog(getClass());
_created = System.currentTimeMillis();
_lastSendTime = _created;
_lastReceiveTime = _created;
_transport = transport;
_remAddr = remAddr;
_readBufs = new ArrayList(4);

View File

@ -246,6 +246,8 @@ class BuildExecutor implements Runnable {
_manager.listPools(pools);
for (int i = 0; i < pools.size(); i++) {
TunnelPool pool = (TunnelPool)pools.get(i);
if (!pool.isAlive())
continue;
int howMany = pool.countHowManyToBuild();
for (int j = 0; j < howMany; j++)
wanted.add(pool);

View File

@ -294,7 +294,7 @@ public class TunnelPool {
for (int i = 0; i < info.getLength(); i++)
_context.profileManager().tunnelLifetimePushed(info.getPeer(i), lifetime, lifetimeConfirmed);
if (_settings.isInbound() && (_settings.getDestination() != null) ) {
if (_alive && _settings.isInbound() && (_settings.getDestination() != null) ) {
if (ls != null) {
_context.clientManager().requestLeaseSet(_settings.getDestination(), ls);
} else {
@ -406,6 +406,8 @@ public class TunnelPool {
*
*/
private LeaseSet locked_buildNewLeaseSet() {
if (!_alive)
return null;
long expireAfter = _context.clock().now(); // + _settings.getRebuildPeriod();
LeaseSet ls = new LeaseSet();