|
|
|
|
@ -120,6 +120,7 @@ static int instance_init_common(struct UTUN_INSTANCE* instance, struct UASYNC* u
|
|
|
|
|
instance->client_type = config->global.client_type; |
|
|
|
|
instance->keepalive_interval = (uint16_t)(config->global.keepalive_interval > 0 ? config->global.keepalive_interval : 200); |
|
|
|
|
instance->client_activity = (instance->client_type == CLIENT_TYPE_MOBILE) ? CLIENT_ACTIVITY_STANDBY : CLIENT_ACTIVITY_ACTIVE; |
|
|
|
|
instance->client_activity_requested = instance->client_activity; |
|
|
|
|
|
|
|
|
|
// Set my keys
|
|
|
|
|
if (sc_init_local_keys(&instance->my_keys, config->global.my_public_key_hex, config->global.my_private_key_hex) != SC_OK) { |
|
|
|
|
@ -1155,20 +1156,26 @@ int utun_set_client_activity(struct UTUN_INSTANCE* instance, int active) {
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
if (instance->client_type == CLIENT_TYPE_SERVER) return 0; |
|
|
|
|
int state = active ? CLIENT_ACTIVITY_ACTIVE : CLIENT_ACTIVITY_STANDBY; |
|
|
|
|
int requested = active ? CLIENT_ACTIVITY_ACTIVE : CLIENT_ACTIVITY_STANDBY; |
|
|
|
|
int held = stream_service_needs_activity(instance); |
|
|
|
|
int state = held ? CLIENT_ACTIVITY_ACTIVE : requested; |
|
|
|
|
int previous = instance->client_activity; |
|
|
|
|
int previous_requested = instance->client_activity_requested; |
|
|
|
|
instance->client_activity_requested = requested; |
|
|
|
|
instance->client_activity = state; |
|
|
|
|
#ifdef UTUN_HAVE_STANDBY |
|
|
|
|
if (instance->client_type == CLIENT_TYPE_MOBILE && standby_set_enabled(instance, !active) < 0) { |
|
|
|
|
if (instance->client_type == CLIENT_TYPE_MOBILE && standby_set_enabled(instance, state != CLIENT_ACTIVITY_ACTIVE) < 0) { |
|
|
|
|
instance->client_activity = previous; |
|
|
|
|
instance->client_activity_requested = previous_requested; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "client_activity: standby transition failed node=%016llx requested=%d previous=%d", |
|
|
|
|
(unsigned long long)instance->node_id, state, previous); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
if (previous == state) return 0; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_BGP, "client_activity set %s until explicit change node=%016llx type=%u", |
|
|
|
|
active ? "ACTIVE" : "STANDBY", (unsigned long long)instance->node_id, instance->client_type); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_BGP, "client_activity effective=%s requested=%s stream_hold=%d node=%016llx type=%u", |
|
|
|
|
state ? "ACTIVE" : "STANDBY", requested ? "ACTIVE" : "STANDBY", held, |
|
|
|
|
(unsigned long long)instance->node_id, instance->client_type); |
|
|
|
|
utun_fire_activity_cbk(instance, state); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|