forked from I2P_Developers/i2p.i2p
Several connect-to-self checks
This commit is contained in:
@@ -227,6 +227,8 @@ public class I2PSnarkUtil {
|
||||
Destination addr = peer.getAddress();
|
||||
if (addr == null)
|
||||
throw new IOException("Null address");
|
||||
if (addr.equals(getMyDestination()))
|
||||
throw new IOException("Attempt to connect to myself");
|
||||
Hash dest = addr.calculateHash();
|
||||
if (_shitlist.contains(dest))
|
||||
throw new IOException("Not trying to contact " + dest.toBase64() + ", as they are shitlisted");
|
||||
@@ -300,17 +302,25 @@ public class I2PSnarkUtil {
|
||||
}
|
||||
|
||||
String getOurIPString() {
|
||||
if (_manager == null)
|
||||
return "unknown";
|
||||
I2PSession sess = _manager.getSession();
|
||||
if (sess != null) {
|
||||
Destination dest = sess.getMyDestination();
|
||||
if (dest != null)
|
||||
return dest.toBase64();
|
||||
}
|
||||
Destination dest = getMyDestination();
|
||||
if (dest != null)
|
||||
return dest.toBase64();
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return dest or null
|
||||
* @since 0.8.4
|
||||
*/
|
||||
Destination getMyDestination() {
|
||||
if (_manager == null)
|
||||
return null;
|
||||
I2PSession sess = _manager.getSession();
|
||||
if (sess != null)
|
||||
return sess.getMyDestination();
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Base64 only - static (no naming service) */
|
||||
static Destination getDestinationFromBase64(String ip) {
|
||||
if (ip == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user