diff --git a/src/apps/uclient/uclient.c b/src/apps/uclient/uclient.c index 8412cb1..4b70586 100644 --- a/src/apps/uclient/uclient.c +++ b/src/apps/uclient/uclient.c @@ -1440,8 +1440,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message) if(((method == STUN_METHOD_ALLOCATE) || (method == STUN_METHOD_REFRESH)) || !(clnet_info->key_set)) { - if(!mobility) - cok=(++(clnet_info->cok))%2; + cok=(++(clnet_info->cok))%2; clnet_info->cok = cok; encoded_oauth_token etoken; u08bits nonce[12]; diff --git a/src/server/ns_turn_server.c b/src/server/ns_turn_server.c index 38f5269..f1e9262 100644 --- a/src/server/ns_turn_server.c +++ b/src/server/ns_turn_server.c @@ -1548,8 +1548,24 @@ static int handle_turn_refresh(turn_turnserver *server, //Check security: int postpone_reply = 0; - check_stun_auth(server, orig_ss, tid, resp_constructed, err_code, reason, in_buffer, nbh, - STUN_METHOD_REFRESH, &message_integrity, &postpone_reply, can_resume); + + ns_bcopy(orig_ss->nonce,ss->nonce,sizeof(ss->nonce)); + ss->nonce_expiration_time = orig_ss->nonce_expiration_time; + ns_bcopy(&(orig_ss->realm_options),&(ss->realm_options),sizeof(ss->realm_options)); + ns_bcopy(orig_ss->username,ss->username,sizeof(ss->username)); + ss->hmackey_set = orig_ss->hmackey_set; + ns_bcopy(orig_ss->hmackey,ss->hmackey,sizeof(ss->hmackey)); + ss->oauth = orig_ss->oauth; + ns_bcopy(orig_ss->origin,ss->origin,sizeof(ss->origin)); + ss->origin_set = orig_ss->origin_set; + ns_bcopy(orig_ss->pwd,ss->pwd,sizeof(ss->pwd)); + + if(check_stun_auth(server, ss, tid, resp_constructed, err_code, reason, in_buffer, nbh, + STUN_METHOD_REFRESH, &message_integrity, &postpone_reply, can_resume)<0) { + if(!(*err_code)) { + *err_code = 401; + } + } if(postpone_reply) {