From ba9754ac591c4fc1bbc4fd1abf02094b7ec9d087 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Fri, 16 Sep 2011 14:34:52 +0000 Subject: [PATCH] * Router: Fix router changing client-side tunnel options, causing original tunnel quantity to not be restored (ticket #513) --- .../client/ClientMessageEventListener.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/router/java/src/net/i2p/router/client/ClientMessageEventListener.java b/router/java/src/net/i2p/router/client/ClientMessageEventListener.java index 653f46e235..c74b38d04b 100644 --- a/router/java/src/net/i2p/router/client/ClientMessageEventListener.java +++ b/router/java/src/net/i2p/router/client/ClientMessageEventListener.java @@ -29,6 +29,7 @@ import net.i2p.data.i2cp.ReceiveMessageEndMessage; import net.i2p.data.i2cp.ReconfigureSessionMessage; import net.i2p.data.i2cp.SendMessageMessage; import net.i2p.data.i2cp.SendMessageExpiresMessage; +import net.i2p.data.i2cp.SessionConfig; import net.i2p.data.i2cp.SessionId; import net.i2p.data.i2cp.SessionStatusMessage; import net.i2p.data.i2cp.SetDateMessage; @@ -156,7 +157,8 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi * So keep it simple. */ private void handleCreateSession(I2CPMessageReader reader, CreateSessionMessage message) { - if (message.getSessionConfig().verifySignature()) { + SessionConfig in = message.getSessionConfig(); + if (in.verifySignature()) { if (_log.shouldLog(Log.DEBUG)) _log.debug("Signature verified correctly on create session message"); } else { @@ -171,7 +173,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi String configUser = _context.getProperty("i2cp.username"); String configPW = _context.getProperty("i2cp.password"); if (configUser != null && configPW != null) { - Properties props = message.getSessionConfig().getOptions(); + Properties props = in.getOptions(); String user = props.getProperty("i2cp.username"); String pw = props.getProperty("i2cp.password"); if (user == null || pw == null) { @@ -193,7 +195,17 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi sessionId.setSessionId(getNextSessionId()); _runner.setSessionId(sessionId); sendStatusMessage(SessionStatusMessage.STATUS_CREATED); - _runner.sessionEstablished(message.getSessionConfig()); + + // Copy over the whole config structure so we don't later corrupt it on + // the client side if we change settings or later get a + // ReconfigureSessionMessage + SessionConfig cfg = new SessionConfig(in.getDestination()); + cfg.setSignature(in.getSignature()); + Properties props = new Properties(); + props.putAll(in.getOptions()); + cfg.setOptions(props); + _runner.sessionEstablished(cfg); + if (_log.shouldLog(Log.DEBUG)) _log.debug("after sessionEstablished for " + message.getSessionConfig().getDestination().calculateHash().toBase64()); @@ -285,7 +297,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi /** * Message's Session ID ignored. This doesn't support removing previously set options. * Nor do we bother with message.getSessionConfig().verifySignature() ... should we? - * + * Nor is the Date checked. */ private void handleReconfigureSession(I2CPMessageReader reader, ReconfigureSessionMessage message) { if (_log.shouldLog(Log.INFO)) -- GitLab