mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-14 04:54:49 +00:00
[mod_verto] add exptime to ping and pong and log any hangups as a result of auth expiring
This commit is contained in:
parent
8666cb504e
commit
852000f3f3
@ -1117,6 +1117,8 @@ static switch_bool_t check_auth(jsock_t *jsock, cJSON *params, int *code, char *
|
|||||||
switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, var, val);
|
switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, var, val);
|
||||||
switch_mutex_unlock(jsock->flag_mutex);
|
switch_mutex_unlock(jsock->flag_mutex);
|
||||||
|
|
||||||
|
switch_clear_flag(jsock, JPFLAG_AUTH_EXPIRED);
|
||||||
|
|
||||||
if (!strcmp(var, "login-expires")) {
|
if (!strcmp(var, "login-expires")) {
|
||||||
uint32_t tmp = atol(val);
|
uint32_t tmp = atol(val);
|
||||||
|
|
||||||
@ -1348,7 +1350,16 @@ static void drop_detached(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tech_pvt->detach_time && (now - tech_pvt->detach_time) > verto_globals.detach_timeout) {
|
if (tech_pvt->detach_time && (now - tech_pvt->detach_time) > verto_globals.detach_timeout) {
|
||||||
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);
|
jsock_t *jsock = NULL;
|
||||||
|
|
||||||
|
if ((jsock = get_jsock(tech_pvt->jsock_uuid))) {
|
||||||
|
if (switch_test_flag(jsock, JPFLAG_AUTH_EXPIRED)) {
|
||||||
|
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH);
|
||||||
|
}
|
||||||
|
switch_thread_rwlock_unlock(jsock->rwlock);
|
||||||
|
} else {
|
||||||
|
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_thread_rwlock_unlock(verto_globals.tech_rwlock);
|
switch_thread_rwlock_unlock(verto_globals.tech_rwlock);
|
||||||
@ -1985,6 +1996,7 @@ static void client_run(jsock_t *jsock)
|
|||||||
now = switch_epoch_time_now(NULL);
|
now = switch_epoch_time_now(NULL);
|
||||||
|
|
||||||
if (now >= jsock->exptime) {
|
if (now >= jsock->exptime) {
|
||||||
|
switch_set_flag(jsock, JPFLAG_AUTH_EXPIRED);
|
||||||
die("%s Authentication Expired\n", jsock->uid);
|
die("%s Authentication Expired\n", jsock->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1998,6 +2010,10 @@ static void client_run(jsock_t *jsock)
|
|||||||
cJSON *params = NULL;
|
cJSON *params = NULL;
|
||||||
cJSON *msg = jrpc_new_req("verto.ping", 0, ¶ms);
|
cJSON *msg = jrpc_new_req("verto.ping", 0, ¶ms);
|
||||||
|
|
||||||
|
if (jsock->exptime) {
|
||||||
|
cJSON_AddItemToObject(params, "auth-expires", cJSON_CreateNumber(jsock->exptime));
|
||||||
|
}
|
||||||
|
|
||||||
cJSON_AddItemToObject(params, "serno", cJSON_CreateNumber(switch_epoch_time_now(NULL)));
|
cJSON_AddItemToObject(params, "serno", cJSON_CreateNumber(switch_epoch_time_now(NULL)));
|
||||||
jsock_queue_event(jsock, &msg, SWITCH_TRUE);
|
jsock_queue_event(jsock, &msg, SWITCH_TRUE);
|
||||||
idle = 0;
|
idle = 0;
|
||||||
@ -3700,6 +3716,11 @@ static void parse_user_vars(cJSON *obj, switch_core_session_t *session)
|
|||||||
static switch_bool_t verto__ping_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response)
|
static switch_bool_t verto__ping_func(const char *method, cJSON *params, jsock_t *jsock, cJSON **response)
|
||||||
{
|
{
|
||||||
*response = cJSON_CreateObject();
|
*response = cJSON_CreateObject();
|
||||||
|
|
||||||
|
if (jsock->exptime) {
|
||||||
|
cJSON_AddItemToObject(*response, "auth-expires", cJSON_CreateNumber(jsock->exptime));
|
||||||
|
}
|
||||||
|
|
||||||
cJSON_AddItemToObject(*response, "message", cJSON_CreateString("PONG"));
|
cJSON_AddItemToObject(*response, "message", cJSON_CreateString("PONG"));
|
||||||
return SWITCH_TRUE;
|
return SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,8 @@ typedef enum {
|
|||||||
JPFLAG_CHECK_ATTACH = (1 << 2),
|
JPFLAG_CHECK_ATTACH = (1 << 2),
|
||||||
JPFLAG_EVENTS = (1 << 3),
|
JPFLAG_EVENTS = (1 << 3),
|
||||||
JPFLAG_AUTH_EVENTS = (1 << 4),
|
JPFLAG_AUTH_EVENTS = (1 << 4),
|
||||||
JPFLAG_ALL_EVENTS_AUTHED = (1 << 5)
|
JPFLAG_ALL_EVENTS_AUTHED = (1 << 5),
|
||||||
|
JPFLAG_AUTH_EXPIRED = (1 << 6)
|
||||||
} jpflag_t;
|
} jpflag_t;
|
||||||
|
|
||||||
struct verto_profile_s;
|
struct verto_profile_s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user