Fix TTL scaling in cert.

This commit is contained in:
Adam Ierymenko 2016-11-15 14:26:05 -08:00
parent 15c6e2ec70
commit 07b2a3818c

View File

@ -1399,16 +1399,18 @@ void EmbeddedNetworkController::_request(
_NetworkMemberInfo nmi; _NetworkMemberInfo nmi;
_getNetworkMemberInfo(now,nwid,nmi); _getNetworkMemberInfo(now,nwid,nmi);
// Compute credential TTL. This is the "moving window" for COM agreement and uint64_t credentialtmd = ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MAX_MAX_DELTA;
// the global TTL for Capability and Tag objects. (The same value is used if (now > nmi.mostRecentDeauthTime) {
// for both.) This is computed by reference to the last time we deauthorized // If we recently de-authorized a member, shrink credential TTL/max delta to
// a member, since within the time period since this event any temporal // be below the threshold required to exclude it. Cap this to a min/max to
// differences are not particularly relevant. // prevent jitter or absurdly large values.
uint64_t credentialtmd = ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MIN_MAX_DELTA; const uint64_t deauthWindow = now - nmi.mostRecentDeauthTime;
if (now > nmi.mostRecentDeauthTime) if (deauthWindow < ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MIN_MAX_DELTA) {
credentialtmd += (now - nmi.mostRecentDeauthTime); credentialtmd = ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MIN_MAX_DELTA;
if (credentialtmd > ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MAX_MAX_DELTA) } else if (deauthWindow < (ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MAX_MAX_DELTA + 5000ULL)) {
credentialtmd = ZT_NETWORKCONFIG_DEFAULT_CREDENTIAL_TIME_MAX_MAX_DELTA; credentialtmd = deauthWindow - 5000ULL;
}
}
nc.networkId = nwid; nc.networkId = nwid;
nc.type = _jB(network["private"],true) ? ZT_NETWORK_TYPE_PRIVATE : ZT_NETWORK_TYPE_PUBLIC; nc.type = _jB(network["private"],true) ? ZT_NETWORK_TYPE_PRIVATE : ZT_NETWORK_TYPE_PUBLIC;