forked from I2P_Developers/i2p.i2p
SSU: Increase minimum peers if we have a IPv6 address
Check for 'B' cap for peer test Fix peer test ip length check logic
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2016-07-20 zzz
|
||||||
|
* SSU:
|
||||||
|
- Increase minimum peers if we have a IPv6 address
|
||||||
|
- Check for 'B' cap for peer test
|
||||||
|
- Fix peer test IP length check
|
||||||
|
|
||||||
2016-07-18 zzz
|
2016-07-18 zzz
|
||||||
* i2ptunnel: Block 'Proxy' header
|
* i2ptunnel: Block 'Proxy' header
|
||||||
* SU3File: Also look in config dir for signer certificate
|
* SU3File: Also look in config dir for signer certificate
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 6;
|
public final static long BUILD = 7;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
|||||||
@@ -1706,7 +1706,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** minimum active peers to maintain IP detection, etc. */
|
/** minimum active peers to maintain IP detection, etc. */
|
||||||
private static final int MIN_PEERS = 3;
|
private static final int MIN_PEERS = 5;
|
||||||
|
private static final int MIN_PEERS_IF_HAVE_V6 = 30;
|
||||||
/** minimum peers volunteering to be introducers if we need that */
|
/** minimum peers volunteering to be introducers if we need that */
|
||||||
private static final int MIN_INTRODUCER_POOL = 5;
|
private static final int MIN_INTRODUCER_POOL = 5;
|
||||||
|
|
||||||
@@ -1764,7 +1765,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("bidding on a message to an unestablished peer: " + to);
|
_log.debug("bidding on a message to an unestablished peer: " + to);
|
||||||
|
|
||||||
// Try to maintain at least 3 peers so we can determine our IP address and
|
// Try to maintain at least 5 peers (30 for v6) so we can determine our IP address and
|
||||||
// we have a selection to run peer tests with.
|
// we have a selection to run peer tests with.
|
||||||
// If we are firewalled, and we don't have enough peers that volunteered to
|
// If we are firewalled, and we don't have enough peers that volunteered to
|
||||||
// also introduce us, also bid aggressively so we are preferred over NTCP.
|
// also introduce us, also bid aggressively so we are preferred over NTCP.
|
||||||
@@ -1772,6 +1773,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
// never get any introducers)
|
// never get any introducers)
|
||||||
int count = _peersByIdent.size();
|
int count = _peersByIdent.size();
|
||||||
if (alwaysPreferUDP() || count < MIN_PEERS ||
|
if (alwaysPreferUDP() || count < MIN_PEERS ||
|
||||||
|
(_haveIPv6Address && count < MIN_PEERS_IF_HAVE_V6) ||
|
||||||
(introducersRequired() && _introManager.introducerCount() < MIN_INTRODUCER_POOL))
|
(introducersRequired() && _introManager.introducerCount() < MIN_INTRODUCER_POOL))
|
||||||
return _cachedBid[SLOW_PREFERRED_BID];
|
return _cachedBid[SLOW_PREFERRED_BID];
|
||||||
else if (preferUDP())
|
else if (preferUDP())
|
||||||
@@ -3223,9 +3225,13 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
// enforce IPv4/v6 connection if we are ALICE looking for a BOB
|
// enforce IPv4/v6 connection if we are ALICE looking for a BOB
|
||||||
byte[] ip = peer.getRemoteIP();
|
byte[] ip = peer.getRemoteIP();
|
||||||
if (peerRole == BOB) {
|
if (peerRole == BOB) {
|
||||||
if ((!isIPv6 && ip.length != 4) ||
|
if (isIPv6) {
|
||||||
(isIPv6 && ip.length != 16))
|
if (ip.length != 16)
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
if (ip.length != 4)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// enforce IPv4/v6 advertised for all
|
// enforce IPv4/v6 advertised for all
|
||||||
RouterInfo peerInfo = _context.netDb().lookupRouterInfoLocally(peer.getRemotePeer());
|
RouterInfo peerInfo = _context.netDb().lookupRouterInfoLocally(peer.getRemotePeer());
|
||||||
@@ -3239,13 +3245,23 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
ip = null;
|
ip = null;
|
||||||
List<RouterAddress> addrs = getTargetAddresses(peerInfo);
|
List<RouterAddress> addrs = getTargetAddresses(peerInfo);
|
||||||
for (RouterAddress addr : addrs) {
|
for (RouterAddress addr : addrs) {
|
||||||
ip = addr.getIP();
|
byte[] rip = addr.getIP();
|
||||||
if (ip != null) {
|
if (rip != null) {
|
||||||
if ((!isIPv6 && ip.length != 4) ||
|
if (isIPv6) {
|
||||||
(isIPv6 && ip.length != 16))
|
if (rip.length != 16)
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (rip.length != 4)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// as of 0.9.27, we trust the 'B' cap for IPv6
|
||||||
|
String caps = addr.getOption(UDPAddress.PROP_CAPACITY);
|
||||||
|
if (caps != null && caps.contains(CAP_TESTING)) {
|
||||||
|
ip = rip;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ip == null)
|
if (ip == null)
|
||||||
continue;
|
continue;
|
||||||
if (isTooClose(ip))
|
if (isTooClose(ip))
|
||||||
|
|||||||
Reference in New Issue
Block a user