fix a NPE

This commit is contained in:
dev
2009-04-11 20:28:15 +00:00
parent 0cfbe9c28b
commit 429280e416

View File

@ -549,17 +549,21 @@ public class EstablishState {
Signature sig = new Signature(s); Signature sig = new Signature(s);
_verified = _context.dsa().verifySignature(sig, toVerify, alice.getSigningPublicKey()); _verified = _context.dsa().verifySignature(sig, toVerify, alice.getSigningPublicKey());
if (_verified) { if (_verified) {
byte[] ip = _con.getChannel().socket().getInetAddress().getAddress(); // get inet-addr
InetAddress addr = this._con.getChannel().socket().getInetAddress();
byte[] ip = (addr == null) ? null : addr.getAddress();
if (_context.shitlist().isShitlistedForever(alice.calculateHash())) { if (_context.shitlist().isShitlistedForever(alice.calculateHash())) {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Dropping inbound connection from permanently shitlisted peer: " + alice.calculateHash().toBase64()); _log.warn("Dropping inbound connection from permanently shitlisted peer: " + alice.calculateHash().toBase64());
// 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
_context.blocklist().add(ip); if(ip != null)
_context.blocklist().add(ip);
fail("Peer is shitlisted forever: " + alice.calculateHash().toBase64()); fail("Peer is shitlisted forever: " + alice.calculateHash().toBase64());
return; return;
} }
_transport.setIP(alice.calculateHash(), ip); if(ip != null)
_transport.setIP(alice.calculateHash(), ip);
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug(prefix() + "verification successful for " + _con); _log.debug(prefix() + "verification successful for " + _con);