forked from Qortal/qortal
Don't save arbitrary peer data if it's a local address
This commit is contained in:
parent
75c51aa61b
commit
3394543705
@ -5,6 +5,9 @@ import org.qortal.crypto.Crypto;
|
||||
import org.qortal.network.Peer;
|
||||
import org.qortal.utils.NTP;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class ArbitraryPeerData {
|
||||
|
||||
private final byte[] hash;
|
||||
@ -51,6 +54,17 @@ public class ArbitraryPeerData {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure that it's not a local address
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByName(host);
|
||||
if (addr.isLoopbackAddress() || addr.isLinkLocalAddress() || addr.isSiteLocalAddress()) {
|
||||
// Ignore local addresses
|
||||
return false;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Valid host/port combination
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user