forked from I2P_Developers/i2p.i2p
I2CP: Disconnect client on attempt to publish invalid leaseset
This commit is contained in:
@ -289,14 +289,22 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
|
||||
if ( (message.getLeaseSet() == null) || (message.getPrivateKey() == null) || (message.getSigningPrivateKey() == null) ) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Null lease set granted: " + message);
|
||||
_runner.disconnectClient("Invalid CreateLeaseSetMessage");
|
||||
return;
|
||||
}
|
||||
|
||||
_context.keyManager().registerKeys(message.getLeaseSet().getDestination(), message.getSigningPrivateKey(), message.getPrivateKey());
|
||||
try {
|
||||
_context.netDb().publish(message.getLeaseSet());
|
||||
} catch (IllegalArgumentException iae) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("Invalid leaseset from client", iae);
|
||||
_runner.disconnectClient("Invalid leaseset: " + iae);
|
||||
return;
|
||||
}
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("New lease set granted for destination "
|
||||
+ message.getLeaseSet().getDestination().calculateHash().toBase64());
|
||||
_context.keyManager().registerKeys(message.getLeaseSet().getDestination(), message.getSigningPrivateKey(), message.getPrivateKey());
|
||||
_context.netDb().publish(message.getLeaseSet());
|
||||
|
||||
// leaseSetCreated takes care of all the LeaseRequestState stuff (including firing any jobs)
|
||||
_runner.leaseSetCreated(message.getLeaseSet());
|
||||
|
@ -527,14 +527,17 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
|
||||
private static final long PUBLISH_DELAY = 3*1000;
|
||||
|
||||
public void publish(LeaseSet localLeaseSet) {
|
||||
/**
|
||||
* @throws IllegalArgumentException if the leaseSet is not valid
|
||||
*/
|
||||
public void publish(LeaseSet localLeaseSet) throws IllegalArgumentException {
|
||||
if (!_initialized) return;
|
||||
Hash h = localLeaseSet.getDestination().calculateHash();
|
||||
try {
|
||||
store(h, localLeaseSet);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
_log.error("wtf, locally published leaseSet is not valid?", iae);
|
||||
return;
|
||||
throw iae;
|
||||
}
|
||||
if (!_context.clientManager().shouldPublishLeaseSet(h))
|
||||
return;
|
||||
|
Reference in New Issue
Block a user