I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Unverified Commit a86ab694 authored by zzz's avatar zzz
Browse files

SSU2: NAT fixes part 2

Fix rare peer test NPE if we did not set charlie's hash
parent 90088933
Branches
Tags
No related merge requests found
...@@ -1964,6 +1964,7 @@ class PeerTestManager { ...@@ -1964,6 +1964,7 @@ class PeerTestManager {
// More sanity checks here. // More sanity checks here.
// we compare to the test address, // we compare to the test address,
// however our address may have changed during the test // however our address may have changed during the test
Hash charlieHash = test.getCharlieHash();
boolean portok = addrBlockPort == test.getAlicePort(); boolean portok = addrBlockPort == test.getAlicePort();
boolean IPok = DataHelper.eq(addrBlockIP, test.getAliceIP().getAddress()); boolean IPok = DataHelper.eq(addrBlockIP, test.getAliceIP().getAddress());
if (!portok || !IPok) { if (!portok || !IPok) {
...@@ -1979,7 +1980,8 @@ class PeerTestManager { ...@@ -1979,7 +1980,8 @@ class PeerTestManager {
// Port different. Charlie probably symmetric natted. // Port different. Charlie probably symmetric natted.
// The result will be OK // The result will be OK
// Note that charlie is probably not reachable // Note that charlie is probably not reachable
_transport.markUnreachable(test.getCharlieHash()); if (charlieHash != null)
_transport.markUnreachable(charlieHash);
// Reset port so testComplete() will return success. // Reset port so testComplete() will return success.
test.setAlicePortFromCharlie(test.getAlicePort()); test.setAlicePortFromCharlie(test.getAlicePort());
// set bad so we don't call externalAddressReceived() // set bad so we don't call externalAddressReceived()
...@@ -1992,7 +1994,8 @@ class PeerTestManager { ...@@ -1992,7 +1994,8 @@ class PeerTestManager {
// Both IP and port changed, don't trust it // Both IP and port changed, don't trust it
// The result will be OK // The result will be OK
// Note that charlie is probably not reachable // Note that charlie is probably not reachable
_transport.markUnreachable(test.getCharlieHash()); if (charlieHash != null)
_transport.markUnreachable(charlieHash);
// Reset IP and port so testComplete() will return success. // Reset IP and port so testComplete() will return success.
test.setAliceIPFromCharlie(test.getAliceIP()); test.setAliceIPFromCharlie(test.getAliceIP());
test.setAlicePortFromCharlie(test.getAlicePort()); test.setAlicePortFromCharlie(test.getAlicePort());
...@@ -2009,8 +2012,8 @@ class PeerTestManager { ...@@ -2009,8 +2012,8 @@ class PeerTestManager {
} }
// We already call externalAddressReceived() for every outbound connection from EstablishmentManager // We already call externalAddressReceived() for every outbound connection from EstablishmentManager
// but we can use this also to update our address faster // but we can use this also to update our address faster
if (!bad) if (!bad && charlieHash != null)
_transport.externalAddressReceived(state.getCharlieHash(), addrBlockIP, addrBlockPort); _transport.externalAddressReceived(charlieHash, addrBlockIP, addrBlockPort);
} }
testComplete(); testComplete();
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment