diff --git a/history.txt b/history.txt index 76f1f37a6..226095f71 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,14 @@ +2014-10-10 zzz + * Banlist: Remove unused banlist tracking in the profile + causing deadlock (ticket #1394) + * GeoIP: + - Don't rate peers in some countries as high capacity + - Don't enable auto-floodfill in some countries + - Don't prefer floodfills in some countries + +2014-10-08 zzz + * UPnP: Comment out unused parsers + 2014-10-07 zzz * CPUID: Remove Intel model 2 again, this is spoofed in the VM * Graphs: Catch an error caused by missing fonts diff --git a/router/java/src/net/i2p/router/CommSystemFacade.java b/router/java/src/net/i2p/router/CommSystemFacade.java index b81f5bfff..fa970fc27 100644 --- a/router/java/src/net/i2p/router/CommSystemFacade.java +++ b/router/java/src/net/i2p/router/CommSystemFacade.java @@ -14,6 +14,7 @@ import java.util.Collections; import java.util.List; import net.i2p.data.Hash; import net.i2p.data.router.RouterAddress; +import net.i2p.data.router.RouterInfo; import net.i2p.router.transport.Transport; import net.i2p.router.transport.crypto.DHSessionKeyBuilder; @@ -73,6 +74,12 @@ public abstract class CommSystemFacade implements Service { /** @since 0.8.13 */ public boolean isInBadCountry() { return false; } + /** @since 0.9.16 */ + public boolean isInBadCountry(Hash peer) { return false; } + + /** @since 0.9.16 */ + public boolean isInBadCountry(RouterInfo ri) { return false; } + public String getCountry(Hash peer) { return null; } public String getCountryName(String code) { return code; } public String renderPeerHTML(Hash peer) { diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index fecba78d6..a6204817e 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/networkdb/kademlia/FloodfillMonitorJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java index d94475ff2..2dae6fdd7 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillMonitorJob.java @@ -85,6 +85,9 @@ class FloodfillMonitorJob extends JobImpl { if (SystemVersion.isARM()) return false; + if (getContext().commSystem().isInBadCountry()) + return false; + // Only if up a while... if (getContext().router().getUptime() < MIN_UPTIME) return false; diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java index 6870edcd5..3504e4644 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java @@ -245,6 +245,10 @@ class FloodfillPeerSelector extends PeerSelector { badff.add(entry); if (_log.shouldLog(Log.DEBUG)) _log.debug("Old: " + entry); + } else if (info != null && _context.commSystem().isInBadCountry(info)) { + badff.add(entry); + if (_log.shouldLog(Log.DEBUG)) + _log.debug("Bad country: " + entry); } else { PeerProfile prof = _context.profileOrganizer().getProfile(entry); double maxGoodRespTime = MAX_GOOD_RESP_TIME; diff --git a/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java b/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java index 7e89cab25..60bfab128 100644 --- a/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java +++ b/router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java @@ -1404,7 +1404,8 @@ public class ProfileOrganizer { // if not selectable for a tunnel (banlisted for example), // don't allow them in the high-cap pool, what would the point of that be? if (_thresholdCapacityValue <= profile.getCapacityValue() && - isSelectable(peer)) { + isSelectable(peer) && + !_context.commSystem().isInBadCountry(peer)) { _highCapacityPeers.put(peer, profile); if (_log.shouldLog(Log.DEBUG)) _log.debug("High capacity: \t" + peer); diff --git a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java index 0c7cd430f..88374cf49 100644 --- a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java +++ b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java @@ -343,15 +343,42 @@ public class CommSystemFacadeImpl extends CommSystemFacade { * Are we in a bad place * @since 0.8.13 */ + @Override public boolean isInBadCountry() { String us = getOurCountry(); - return us != null && (BadCountries.contains(us) || _context.getBooleanProperty("router.forceBadCountry")); + return (us != null && BadCountries.contains(us)) || _context.getBooleanProperty("router.forceBadCountry"); + } + + /** + * Are they in a bad place + * @param peer non-null + * @since 0.9.16 + */ + @Override + public boolean isInBadCountry(Hash peer) { + String c = getCountry(peer); + return c != null && BadCountries.contains(c); + } + + /** + * Are they in a bad place + * @param ri non-null + * @since 0.9.16 + */ + @Override + public boolean isInBadCountry(RouterInfo ri) { + byte[] ip = getIP(ri); + if (ip == null) + return false; + String c = _geoIP.get(ip); + return c != null && BadCountries.contains(c); } /** * Uses the transport IP first because that lookup is fast, * then the IP from the netDb. * + * @param peer not ourselves - use getOurCountry() for that * @return two-letter lower-case country code or null */ @Override