forked from I2P_Developers/i2p.i2p
Compare commits
11 Commits
i2p.i2p.2.
...
i2p.i2p.2.
Author | SHA1 | Date | |
---|---|---|---|
8376d2afc8 | |||
97f8c6a930 | |||
728762d4fd | |||
10022fb5d5 | |||
faddfb96ac | |||
56a89adb20 | |||
39910497cc | |||
c622688f31 | |||
cbd7b7aeee | |||
d88a69a2e3 | |||
8e2d99cfee |
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Git";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 0;
|
||||
public final static long BUILD = 1;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
@ -34,11 +34,12 @@ class CapacityCalculator {
|
||||
private static final double PENALTY_NO_R_CAP = 1;
|
||||
private static final double PENALTY_U_CAP = 2;
|
||||
private static final double PENALTY_LAST_SEND_FAIL = 4;
|
||||
// congestion cap penalty not yet applied
|
||||
//private static final double PENALTY_D_CAP = 0;
|
||||
// congestion cap penalty not yet applied
|
||||
//private static final double PENALTY_E_CAP = 0;
|
||||
//private static final double PENALTY_G_CAP = 0;
|
||||
private static final String PROP_D_CAP = "router.penaltyCapD";
|
||||
private static final double PENALTY_CAP_D = 0.5;
|
||||
private static final String PROP_E_CAP = "router.penaltyCapE";
|
||||
private static final double PENALTY_CAP_E = 0.9;
|
||||
// private static final String PROP_G_CAP = "router.gcapPenalty";
|
||||
// private static final double PENALTY_G_CAP = 0;
|
||||
private static final double PENALTY_RECENT_SEND_FAIL = 4;
|
||||
private static final double BONUS_LAST_SEND_SUCCESS = 1;
|
||||
private static final double BONUS_RECENT_SEND_SUCCESS = 1;
|
||||
@ -129,16 +130,27 @@ class CapacityCalculator {
|
||||
capacity -= PENALTY_U_CAP;
|
||||
if (caps.indexOf(Router.CAPABILITY_BW32) >= 0)
|
||||
capacity -= PENALTY_L_CAP;
|
||||
/* TODO */
|
||||
/*if (caps.indexOf(Router.CAPABILITY_CONGESTION_MODERATE) >= 0)
|
||||
capacity -= PENALTY_D_CAP;
|
||||
else if (caps.indexOf(Router.CAPABILITY_CONGESTION_SEVERE) >= 0)
|
||||
capacity -= PENALTY_E_CAP;*/
|
||||
/* TODO: G caps can be excluded in TunnelPeerSelector by adding it to DEFAULT_EXCLUDE_CAPS
|
||||
decide what other handling if any is needed here.
|
||||
else if (caps.indexOf(Router.CAPABILITY_NO_TUNNELS) >= 0)
|
||||
capacity -= PENALTY_G_CAP;
|
||||
*/
|
||||
if (caps.indexOf(Router.CAPABILITY_CONGESTION_MODERATE) >= 0) {
|
||||
String dcapPenalty = context.getProperty(PROP_D_CAP);
|
||||
if (dcapPenalty != null) {
|
||||
double dcap = Double.parseDouble(dcapPenalty);
|
||||
capacity -= dcap;
|
||||
} else {
|
||||
capacity -= PENALTY_CAP_D;
|
||||
}
|
||||
} else if (caps.indexOf(Router.CAPABILITY_CONGESTION_SEVERE) >= 0){
|
||||
String ecapPenalty = context.getProperty(PROP_E_CAP);
|
||||
if (ecapPenalty != null) {
|
||||
double ecap = Double.parseDouble(ecapPenalty);
|
||||
capacity -= ecap;
|
||||
} else {
|
||||
capacity -= PENALTY_CAP_E;
|
||||
}
|
||||
}
|
||||
/* TODO: G caps can be excluded in TunnelPeerSelector by adding it to DEFAULT_EXCLUDE_CAPS */
|
||||
// decide what other handling if any is needed here.
|
||||
//else if (caps.indexOf(Router.CAPABILITY_NO_TUNNELS) >= 0)
|
||||
// capacity -= PENALTY_G_CAP;
|
||||
} else {
|
||||
capacity -= PENALTY_NO_RI;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import net.i2p.data.Base64;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.EmptyProperties;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.i2np.DatabaseStoreMessage;
|
||||
import net.i2p.data.router.RouterIdentity;
|
||||
import net.i2p.data.router.RouterInfo;
|
||||
import net.i2p.data.TunnelId;
|
||||
@ -30,6 +31,7 @@ import net.i2p.router.HandlerJobBuilder;
|
||||
import net.i2p.router.Job;
|
||||
import net.i2p.router.JobImpl;
|
||||
import net.i2p.router.OutNetMessage;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.networkdb.kademlia.MessageWrapper;
|
||||
import net.i2p.router.peermanager.TunnelHistory;
|
||||
@ -41,6 +43,7 @@ import net.i2p.router.util.CoDelBlockingQueue;
|
||||
import net.i2p.stat.Rate;
|
||||
import net.i2p.stat.RateStat;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.VersionComparator;
|
||||
|
||||
/**
|
||||
* Handle the received tunnel build message requests and replies,
|
||||
@ -74,6 +77,7 @@ class BuildHandler implements Runnable {
|
||||
private volatile boolean _isRunning;
|
||||
private final Object _startupLock = new Object();
|
||||
private ExplState _explState = ExplState.NONE;
|
||||
private final String MIN_VERSION_HONOR_CAPS = "0.9.58";
|
||||
|
||||
private enum ExplState { NONE, IB, OB, BOTH }
|
||||
|
||||
@ -470,6 +474,52 @@ class BuildHandler implements Runnable {
|
||||
_context.commSystem().mayDisconnect(from);
|
||||
return -1;
|
||||
}
|
||||
// get my own RouterInfo
|
||||
RouterInfo myRI = _context.router().getRouterInfo();
|
||||
if (myRI != null) {
|
||||
String caps = myRI.getCapabilities();
|
||||
if (caps != null) {
|
||||
if (caps.indexOf(Router.CAPABILITY_NO_TUNNELS) >= 0){
|
||||
_context.statManager().addRateData("tunnel.dropTunnelFromCongestionCapability", 1);
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Drop request, we are denying tunnels due to congestion: " + from);
|
||||
RouterInfo fromRI = _context.netDb().lookupRouterInfoLocally(from);
|
||||
if (fromRI != null){
|
||||
String fromVersion = fromRI.getVersion();
|
||||
// if fromVersion is greater than 0.9.58, then then ban the router due to it disrespecting our
|
||||
// congestion flags
|
||||
if (fromVersion != null){
|
||||
if (VersionComparator.comp(fromVersion, MIN_VERSION_HONOR_CAPS) >= 0) {
|
||||
_context.statManager().addRateData("tunnel.dropTunnelFromCongestionCapability"+from, 1);
|
||||
_context.statManager().addRateData("tunnel.dropTunnelFromCongestionCapability"+fromVersion, 1);
|
||||
/*
|
||||
TODO: Determine if it's at all reasonable to do something about routers that are forwarding tunnel
|
||||
builds to us from other people who are spamming tunnel builds.
|
||||
long knocks = _context.statManager().getRate("tunnel.dropTunnelFromVersion"+from).getLifetimeEventCount();
|
||||
if (knocks > 10) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Banning peer: " + fromRI.getHash() + " due to it disrespecting our congestion flags");
|
||||
_context.banlist().banlistRouter(from, "disrespected our tunnel flags", null, false);
|
||||
} else if (knocks <= 1) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Replying with our RouterInfo to peer:" +fromRI.getHash() +
|
||||
" to give it a chance to update their own netDb and stop asking for new tunnels");
|
||||
// send the peer our RouterInfo
|
||||
int TIMEOUT = 10*1000;
|
||||
DatabaseStoreMessage dsm = new DatabaseStoreMessage(_context);
|
||||
dsm.setMessageExpiration(_context.clock().now() + TIMEOUT);
|
||||
dsm.setEntry(myRI);
|
||||
OutNetMessage outMsg = new OutNetMessage(_context, dsm, _context.clock().now() + TIMEOUT, PRIORITY, fromRI);
|
||||
_context.outNetMessagePool().add(outMsg);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timeSinceReceived > (BuildRequestor.REQUEST_TIMEOUT*3)) {
|
||||
// don't even bother, since we are so overloaded locally
|
||||
|
@ -42,7 +42,7 @@ import net.i2p.util.VersionComparator;
|
||||
*/
|
||||
public abstract class TunnelPeerSelector extends ConnectChecker {
|
||||
|
||||
private static final String DEFAULT_EXCLUDE_CAPS = String.valueOf(Router.CAPABILITY_BW12)+String.valueOf(Router.CAPABILITY_CONGESTION_SEVERE);
|
||||
private static final String DEFAULT_EXCLUDE_CAPS = String.valueOf(Router.CAPABILITY_BW12)+String.valueOf(Router.CAPABILITY_CONGESTION_SEVERE);//+String.valueOf(Router.CAPABILITY_CONGESTION_MODERATE);
|
||||
|
||||
protected TunnelPeerSelector(RouterContext context) {
|
||||
super(context);
|
||||
|
Reference in New Issue
Block a user