forked from I2P_Developers/i2p.i2p
SSU: Limit range for valid clock skew
Reduce log level for ignored clock adjustment
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
2015-02-07 zzz
|
||||
* SSU: Limit range for valid clock skew
|
||||
* Transport: Ban routers if they are too old and we are non-DSA
|
||||
|
||||
2015-02-06 zzz
|
||||
* NetDB: Reduce max job lag for floodfill
|
||||
* NTCP: Block IP for a while when incoming connection is dropped before
|
||||
|
@ -102,8 +102,8 @@ public class RouterClock extends Clock {
|
||||
// only allow substantial modifications before the first 10 minutes
|
||||
if (_alreadyChanged && (System.currentTimeMillis() - _startedOn > 10 * 60 * 1000)) {
|
||||
if ( (delta > MAX_LIVE_OFFSET) || (delta < 0 - MAX_LIVE_OFFSET) ) {
|
||||
getLog().log(Log.CRIT, "The clock has already been updated, but you want to change it by "
|
||||
+ delta + " to " + offsetMs + "? Did something break?");
|
||||
getLog().log(Log.WARN, "The clock has already been updated, ignoring request to change it by "
|
||||
+ delta + " to " + offsetMs, new Exception());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -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 = 22;
|
||||
public final static long BUILD = 23;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
@ -47,6 +47,7 @@ class PacketHandler {
|
||||
private static final int MAX_NUM_HANDLERS = 1;
|
||||
/** let packets be up to 30s slow */
|
||||
private static final long GRACE_PERIOD = Router.CLOCK_FUDGE_FACTOR + 30*1000;
|
||||
private static final long MAX_SKEW = 90*24*60*60*1000L;
|
||||
|
||||
private enum AuthType { NONE, INTRO, BOBINTRO, SESSION }
|
||||
|
||||
@ -610,17 +611,21 @@ class PacketHandler {
|
||||
long recvOn = packet.getBegin();
|
||||
long sendOn = reader.readTimestamp() * 1000;
|
||||
long skew = recvOn - sendOn;
|
||||
int type = reader.readPayloadType();
|
||||
// if it's a bad type, the whole packet is probably corrupt
|
||||
boolean typeOK = type <= UDPPacket.MAX_PAYLOAD_TYPE;
|
||||
boolean skewOK = skew < MAX_SKEW && skew > (0 - MAX_SKEW) && typeOK;
|
||||
|
||||
// update skew whether or not we will be dropping the packet for excessive skew
|
||||
if (state != null) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Received packet from " + state.getRemoteHostId().toString() + " with skew " + skew);
|
||||
if (auth == AuthType.SESSION)
|
||||
if (auth == AuthType.SESSION && typeOK && (skewOK || state.getMessagesReceived() <= 0))
|
||||
state.adjustClockSkew(skew);
|
||||
}
|
||||
_context.statManager().addRateData("udp.receivePacketSkew", skew, packet.getLifetime());
|
||||
_context.statManager().addRateData("udp.receivePacketSkew", skew);
|
||||
|
||||
if (!_context.clock().getUpdatedSuccessfully()) {
|
||||
if (skewOK && !_context.clock().getUpdatedSuccessfully()) {
|
||||
// adjust the clock one time in desperation
|
||||
// this doesn't seem to work for big skews, we never get anything back,
|
||||
// so we have to wait for NTCP to do it
|
||||
@ -648,7 +653,6 @@ class PacketHandler {
|
||||
RemoteHostId from = packet.getRemoteHost();
|
||||
_state = 46;
|
||||
|
||||
int type = reader.readPayloadType();
|
||||
switch (type) {
|
||||
case UDPPacket.PAYLOAD_TYPE_SESSION_REQUEST:
|
||||
_state = 47;
|
||||
|
@ -761,6 +761,8 @@ class PeerState {
|
||||
|
||||
/** we received the message specified completely */
|
||||
public void messageFullyReceived(Long messageId, int bytes) { messageFullyReceived(messageId, bytes, false); }
|
||||
|
||||
/** FIXME synch */
|
||||
public void messageFullyReceived(Long messageId, int bytes, boolean isForACK) {
|
||||
if (bytes > 0) {
|
||||
_receiveBytes += bytes;
|
||||
|
@ -84,6 +84,7 @@ class UDPPacket implements CDQEntry {
|
||||
public static final int PAYLOAD_TYPE_RELAY_INTRO = 5;
|
||||
public static final int PAYLOAD_TYPE_DATA = 6;
|
||||
public static final int PAYLOAD_TYPE_TEST = 7;
|
||||
public static final int MAX_PAYLOAD_TYPE = PAYLOAD_TYPE_TEST;
|
||||
/** @since 0.8.1 */
|
||||
public static final int PAYLOAD_TYPE_SESSION_DESTROY = 8;
|
||||
|
||||
|
Reference in New Issue
Block a user