forked from I2P_Developers/i2p.i2p
SSU2: Peer Test fixes
Don't set AlicePortFromCharlie in msg 5, should be msg 7 only Assume success if no address block in msg 7 (i2pd) Require introducers for SNAT states Don't log no charlie port if no IP Add some TODO notes Log tweaks
This commit is contained in:
@ -586,6 +586,7 @@ class PeerTestManager {
|
||||
// we never received anything from bob - he is either down,
|
||||
// ignoring us, or unable to get a Charlie to respond
|
||||
status = Status.UNKNOWN;
|
||||
// TODO disconnect from Bob if version 2?
|
||||
}
|
||||
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
@ -959,8 +960,7 @@ class PeerTestManager {
|
||||
state = _activeTests.get(lNonce);
|
||||
|
||||
if (_log.shouldDebug())
|
||||
_log.debug("Got peer test" +
|
||||
" msg: " + msg +
|
||||
_log.debug("Got peer test msg " + msg +
|
||||
" status: " + status +
|
||||
" hash: " + h +
|
||||
" nonce: " + nonce +
|
||||
@ -1280,6 +1280,7 @@ class PeerTestManager {
|
||||
if (status != 0) {
|
||||
if (_log.shouldInfo())
|
||||
_log.info("Msg 4 status " + status + ' ' + test);
|
||||
// TODO validate sig anyway, mark charlie unreachable if status is 69 (banned)
|
||||
} else if (cps != null && cps.isIPv6() == isIPv6) {
|
||||
if (_log.shouldInfo())
|
||||
_log.info("Charlie is connected " + test);
|
||||
@ -1313,22 +1314,23 @@ class PeerTestManager {
|
||||
_log.info("Test fail ban/ip " + Addresses.toString(ip));
|
||||
} else {
|
||||
try {
|
||||
charlieIP = InetAddress.getByAddress(ip);
|
||||
charlieIP = InetAddress.getByAddress(ip);
|
||||
charliePort = ra.getPort();
|
||||
if (!TransportUtil.isValidPort(charliePort)) {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Charlie port " + charliePort + " bad: " + test + '\n' + ra);
|
||||
charliePort = 0;
|
||||
}
|
||||
} catch (UnknownHostException uhe) {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Charlie IP not found: " + test + '\n' + ra, uhe);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// i2pd Bob picks firewalled Charlie
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Charlie IP not found: " + test + '\n' + ra);
|
||||
}
|
||||
charliePort = ra.getPort();
|
||||
if (!TransportUtil.isValidPort(charliePort)) {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Charlie port bad: " + test + '\n' + ra);
|
||||
charliePort = 0;
|
||||
}
|
||||
} else {
|
||||
if (_log.shouldWarn())
|
||||
_log.warn("Charlie address not found" + test + '\n' + charlieRI);
|
||||
@ -1377,7 +1379,8 @@ class PeerTestManager {
|
||||
return;
|
||||
}
|
||||
test.setReceiveCharlieTime(now);
|
||||
test.setAlicePortFromCharlie(testPort);
|
||||
// Do NOT set this here, only for msg 7, this is how testComplete() knows we got msg 7
|
||||
//test.setAlicePortFromCharlie(testPort);
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByAddress(testIP);
|
||||
test.setAliceIPFromCharlie(addr);
|
||||
@ -1450,8 +1453,14 @@ class PeerTestManager {
|
||||
}
|
||||
// this is our second charlie, yay!
|
||||
test.setReceiveCharlieTime(now);
|
||||
// use the IP/port from the address block
|
||||
test.setAlicePortFromCharlie(addrBlockPort);
|
||||
// i2pd did not send address block in msg 7 until 0.9.57
|
||||
if (addrBlockPort != 0) {
|
||||
// use the IP/port from the address block
|
||||
test.setAlicePortFromCharlie(addrBlockPort);
|
||||
} else if (!_transport.isSnatted()) {
|
||||
// assume good if we aren't snatted
|
||||
test.setAlicePortFromCharlie(test.getAlicePort());
|
||||
}
|
||||
if (addrBlockIP != null) {
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByAddress(addrBlockIP);
|
||||
@ -1832,7 +1841,8 @@ class PeerTestManager {
|
||||
}
|
||||
|
||||
public void timeReached() {
|
||||
_activeTests.remove(_nonce);
|
||||
_activeTests.remove(_nonce);
|
||||
// TODO send code as bob if no response from charlie
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,14 +183,26 @@ class PeerTestState {
|
||||
.append(_isIPv6 ? " IPv6" : " IPv4")
|
||||
.append(" started ").append(DataHelper.formatTime(_beginTime))
|
||||
.append(" as ").append(_ourRole.toString());
|
||||
if (_aliceIP != null)
|
||||
buf.append("; Alice: ").append(_aliceIP).append(':').append(_alicePort);
|
||||
if (_aliceIP != null) {
|
||||
buf.append("; Alice: ");
|
||||
if (_ourRole == Role.ALICE)
|
||||
buf.append("me");
|
||||
else
|
||||
buf.append(_aliceIP).append(':').append(_alicePort);
|
||||
}
|
||||
if (_aliceIPFromCharlie != null)
|
||||
buf.append(" (fromCharlie ").append(_aliceIPFromCharlie).append(':').append(_alicePortFromCharlie).append(')');
|
||||
if (_bob != null)
|
||||
buf.append("; Bob: ").append(_bob.toString());
|
||||
if (_charlieIP != null)
|
||||
buf.append(" Charlie: ").append(_charlieIP).append(':').append(_charliePort);
|
||||
buf.append(" Bob: ").append(_bob.toString());
|
||||
else
|
||||
buf.append(" Bob: me");
|
||||
if (_charlieIP != null) {
|
||||
buf.append(" Charlie: ");
|
||||
if (_ourRole == Role.CHARLIE)
|
||||
buf.append("me");
|
||||
else
|
||||
buf.append(_charlieIP).append(':').append(_charliePort);
|
||||
}
|
||||
if (_lastSendTime > 0)
|
||||
buf.append("; last send after ").append(_lastSendTime - _beginTime);
|
||||
if (_receiveAliceTime > 0)
|
||||
|
@ -3233,6 +3233,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
case DIFFERENT:
|
||||
case IPV4_FIREWALLED_IPV6_OK:
|
||||
case IPV4_FIREWALLED_IPV6_UNKNOWN:
|
||||
case IPV4_SNAT_IPV6_OK:
|
||||
case IPV4_SNAT_IPV6_UNKNOWN:
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Require IPv4 introducers, status is " + status);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user