forked from Qortal/qortal
When making a direct connection to a peer, try using the default listen port along with the one specified in the ArbitraryPeers table.
This is a workaround to account for any ephemeral ports that may have made it into the dataset.
This commit is contained in:
parent
7df8381b8f
commit
391fa008d0
@ -253,7 +253,23 @@ public class ArbitraryDataFileManager {
|
||||
int index = new SecureRandom().nextInt(peers.size());
|
||||
ArbitraryPeerData arbitraryPeerData = peers.get(index);
|
||||
String peerAddressString = arbitraryPeerData.getPeerAddress();
|
||||
return Network.getInstance().requestDataFromPeer(peerAddressString, signature);
|
||||
boolean success = Network.getInstance().requestDataFromPeer(peerAddressString, signature);
|
||||
|
||||
// If using a non-standard port, try a second connection with the default listen port, since almost all nodes use that
|
||||
// This is a workaround to account for any ephemeral ports that may have made it into the dataset
|
||||
boolean success2 = false;
|
||||
String[] parts = peerAddressString.split(":");
|
||||
if (parts.length > 1) {
|
||||
String host = parts[0];
|
||||
int port = Integer.parseInt(parts[1]);
|
||||
int defaultPort = Settings.getInstance().getDefaultListenPort();
|
||||
if (port != defaultPort) {
|
||||
String newPeerAddressString = String.format("%s:%d", host, defaultPort);
|
||||
success2 = Network.getInstance().requestDataFromPeer(newPeerAddressString, signature);
|
||||
}
|
||||
}
|
||||
|
||||
return success || success2;
|
||||
|
||||
} catch (DataException e) {
|
||||
LOGGER.debug("Unable to fetch peer list from repository");
|
||||
|
Loading…
x
Reference in New Issue
Block a user