Router: Consistent logging for network ID check

Log level change for peer test IP
This commit is contained in:
zzz
2020-07-11 14:19:01 +00:00
parent e05545ab7c
commit 12e2dabaa8
6 changed files with 11 additions and 7 deletions

View File

@ -1062,7 +1062,7 @@ public abstract class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacad
if (routerInfo.getNetworkId() != _networkID){ if (routerInfo.getNetworkId() != _networkID){
_context.banlist().banlistRouterForever(key, "Not in our network: " + routerInfo.getNetworkId()); _context.banlist().banlistRouterForever(key, "Not in our network: " + routerInfo.getNetworkId());
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Bad network: " + routerInfo); _log.warn("Not in our network: " + routerInfo, new Exception());
return "Not in our network"; return "Not in our network";
} }
FamilyKeyCrypto fkc = _context.router().getFamilyKeyCrypto(); FamilyKeyCrypto fkc = _context.router().getFamilyKeyCrypto();

View File

@ -591,7 +591,7 @@ class InboundEstablishState extends EstablishBase implements NTCP2Payload.Payloa
if (!rv) { if (!rv) {
Hash aliceHash = alice.getHash(); Hash aliceHash = alice.getHash();
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Dropping inbound connection from wrong network: " + aliceID + ' ' + aliceHash); _log.warn("Not in our network: " + alice, new Exception());
// So next time we will not accept the con from this IP, // So next time we will not accept the con from this IP,
// rather than doing the whole handshake // rather than doing the whole handshake
InetAddress addr = _con.getChannel().socket().getInetAddress(); InetAddress addr = _con.getChannel().socket().getInetAddress();

View File

@ -531,6 +531,8 @@ public class NTCPTransport extends TransportImpl {
} }
if (toAddress.getNetworkId() != _networkID) { if (toAddress.getNetworkId() != _networkID) {
_context.banlist().banlistRouterForever(peer, "Not in our network: " + toAddress.getNetworkId()); _context.banlist().banlistRouterForever(peer, "Not in our network: " + toAddress.getNetworkId());
if (_log.shouldWarn())
_log.warn("Not in our network: " + toAddress, new Exception());
markUnreachable(peer); markUnreachable(peer);
return null; return null;
} }

View File

@ -253,8 +253,10 @@ class EstablishmentManager {
Hash toHash = toIdentity.calculateHash(); Hash toHash = toIdentity.calculateHash();
if (toRouterInfo.getNetworkId() != _networkID) { if (toRouterInfo.getNetworkId() != _networkID) {
_context.banlist().banlistRouterForever(toHash, "Not in our network: " + toRouterInfo.getNetworkId()); _context.banlist().banlistRouterForever(toHash, "Not in our network: " + toRouterInfo.getNetworkId());
if (_log.shouldWarn())
_log.warn("Not in our network: " + toRouterInfo, new Exception());
_transport.markUnreachable(toHash); _transport.markUnreachable(toHash);
_transport.failed(msg, "Remote peer is on the wrong network, cannot establish"); _transport.failed(msg, "Not in our network");
return; return;
} }
UDPAddress addr = new UDPAddress(ra); UDPAddress addr = new UDPAddress(ra);

View File

@ -393,8 +393,8 @@ class PeerTestManager {
if (test.getReceiveBobTime() > 0) if (test.getReceiveBobTime() > 0)
testComplete(true); testComplete(true);
} catch (UnknownHostException uhe) { } catch (UnknownHostException uhe) {
if (_log.shouldLog(Log.ERROR)) if (_log.shouldWarn())
_log.error("Charlie @ " + from + " said we were an invalid IP address: " + uhe.getMessage(), uhe); _log.warn("Charlie @ " + from + " said we were an invalid IP address: " + uhe.getMessage(), uhe);
_context.statManager().addRateData("udp.testBadIP", 1); _context.statManager().addRateData("udp.testBadIP", 1);
} }
} else { } else {

View File

@ -1542,9 +1542,9 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
//_context.banlist().banlistRouter(peerHash, "Part of the wrong network", STYLE); //_context.banlist().banlistRouter(peerHash, "Part of the wrong network", STYLE);
if (peer != null) if (peer != null)
sendDestroy(peer); sendDestroy(peer);
dropPeer(peerHash, false, "wrong network"); dropPeer(peerHash, false, "Not in our network");
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Dropping the peer " + peerHash + " because they are in the wrong net: " + entry); _log.warn("Not in our network: " + entry, new Exception());
return; return;
} else { } else {
if (entry.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) { if (entry.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {