I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit d87d4eb2 authored by zzz's avatar zzz
Browse files

I2CP: Disconnect client on attempt to publish invalid leaseset

parent 88ea451f
No related branches found
No related tags found
No related merge requests found
...@@ -289,14 +289,22 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi ...@@ -289,14 +289,22 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
if ( (message.getLeaseSet() == null) || (message.getPrivateKey() == null) || (message.getSigningPrivateKey() == null) ) { if ( (message.getLeaseSet() == null) || (message.getPrivateKey() == null) || (message.getSigningPrivateKey() == null) ) {
if (_log.shouldLog(Log.ERROR)) if (_log.shouldLog(Log.ERROR))
_log.error("Null lease set granted: " + message); _log.error("Null lease set granted: " + message);
_runner.disconnectClient("Invalid CreateLeaseSetMessage");
return; 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)) if (_log.shouldLog(Log.INFO))
_log.info("New lease set granted for destination " _log.info("New lease set granted for destination "
+ message.getLeaseSet().getDestination().calculateHash().toBase64()); + 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) // leaseSetCreated takes care of all the LeaseRequestState stuff (including firing any jobs)
_runner.leaseSetCreated(message.getLeaseSet()); _runner.leaseSetCreated(message.getLeaseSet());
......
...@@ -527,14 +527,17 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { ...@@ -527,14 +527,17 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
private static final long PUBLISH_DELAY = 3*1000; 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; if (!_initialized) return;
Hash h = localLeaseSet.getDestination().calculateHash(); Hash h = localLeaseSet.getDestination().calculateHash();
try { try {
store(h, localLeaseSet); store(h, localLeaseSet);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
_log.error("wtf, locally published leaseSet is not valid?", iae); _log.error("wtf, locally published leaseSet is not valid?", iae);
return; throw iae;
} }
if (!_context.clientManager().shouldPublishLeaseSet(h)) if (!_context.clientManager().shouldPublishLeaseSet(h))
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment