- Append I2CP Version information to the Get/Set Date Messages,
        so that both the router and client are aware of the other side's version,
        and future protocol changes will be easier to implement.
        Previously, router version information was not available to the client,
        so when router and client were in different JVMs,
        old clients would work with new routers
        but new clients would not work with old routers.
        After this change, we can design future changes so that new clients
        will work with old routers.
        This is an enhancement to the old protocol version byte sent by the client,
        which we have never changed and probably never will.
      - Prevent a client from setting the router's clock
      - Javadocs
This commit is contained in:
zzz
2011-05-30 16:31:09 +00:00
parent acb4bac5e6
commit d4bf2523a6
10 changed files with 163 additions and 18 deletions

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 11;
public final static long BUILD = 12;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -10,6 +10,7 @@ package net.i2p.router.client;
import java.util.Properties;
import net.i2p.CoreVersion;
import net.i2p.data.Payload;
import net.i2p.data.i2cp.BandwidthLimitsMessage;
import net.i2p.data.i2cp.CreateLeaseSetMessage;
@ -120,22 +121,30 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
// Is this is a little drastic for an unknown message type?
_runner.stopRunning();
}
public void disconnected(I2CPMessageReader reader) {
if (_runner.isDead()) return;
_runner.disconnected();
}
private void handleGetDate(I2CPMessageReader reader, GetDateMessage message) {
// sent by clients >= 0.8.7
String clientVersion = message.getVersion();
// TODO - save client's version string for future reference
try {
_runner.doSend(new SetDateMessage());
// only send version if the client can handle it (0.8.7 or greater)
_runner.doSend(new SetDateMessage(clientVersion != null ? CoreVersion.VERSION : null));
} catch (I2CPMessageException ime) {
if (_log.shouldLog(Log.ERROR))
_log.error("Error writing out the setDate message", ime);
}
}
/**
* As of 0.8.7, does nothing. Do not allow a client to set the router's clock.
*/
private void handleSetDate(I2CPMessageReader reader, SetDateMessage message) {
_context.clock().setNow(message.getDate().getTime());
//_context.clock().setNow(message.getDate().getTime());
}