1
0
mirror of https://github.com/coturn/coturn.git synced 2025-11-05 09:21:34 +01:00

mobile fixes

This commit is contained in:
mom040267 2014-09-28 09:37:52 +00:00
parent cbb37c645f
commit 01b0294bcf
3 changed files with 31 additions and 28 deletions

View File

@ -962,10 +962,16 @@ void stun_tid_generate_in_message_str(u08bits* buf, stun_tid* id) {
/////////////////// TIME //////////////////////////////////////////////////////// /////////////////// TIME ////////////////////////////////////////////////////////
u32bits stun_adjust_allocate_lifetime(u32bits lifetime) { turn_time_t stun_adjust_allocate_lifetime(turn_time_t lifetime, turn_time_t max_lifetime) {
if(!lifetime) return STUN_DEFAULT_ALLOCATE_LIFETIME;
else if(lifetime<STUN_MIN_ALLOCATE_LIFETIME) return STUN_MIN_ALLOCATE_LIFETIME; if(!lifetime) lifetime = STUN_DEFAULT_ALLOCATE_LIFETIME;
else if(lifetime>STUN_MAX_ALLOCATE_LIFETIME) return STUN_MAX_ALLOCATE_LIFETIME; else if(lifetime<STUN_MIN_ALLOCATE_LIFETIME) lifetime = STUN_MIN_ALLOCATE_LIFETIME;
else if(lifetime>STUN_MAX_ALLOCATE_LIFETIME) lifetime = STUN_MAX_ALLOCATE_LIFETIME;
if(max_lifetime && (max_lifetime < lifetime)) {
lifetime = max_lifetime;
}
return lifetime; return lifetime;
} }

View File

@ -90,7 +90,7 @@ u16bits stun_make_error_response(u16bits method);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
u32bits stun_adjust_allocate_lifetime(u32bits lifetime); turn_time_t stun_adjust_allocate_lifetime(turn_time_t lifetime, turn_time_t max_lifetime);
///////////// STR //////////////////////////////////////////////// ///////////// STR ////////////////////////////////////////////////

View File

@ -961,7 +961,7 @@ static int handle_turn_allocate(turn_turnserver *server,
} else { } else {
u08bits transport = 0; u08bits transport = 0;
u32bits lifetime = 0; turn_time_t lifetime = 0;
int even_port = -1; int even_port = -1;
int dont_fragment = 0; int dont_fragment = 0;
u64bits in_reservation_token = 0; u64bits in_reservation_token = 0;
@ -1158,10 +1158,7 @@ static int handle_turn_allocate(turn_turnserver *server,
} }
} }
lifetime = stun_adjust_allocate_lifetime(lifetime); lifetime = stun_adjust_allocate_lifetime(lifetime, ss->max_session_time_auth);
if(ss->max_session_time_auth && (ss->max_session_time_auth < lifetime)) {
lifetime = ss->max_session_time_auth;
}
u64bits out_reservation_token = 0; u64bits out_reservation_token = 0;
if(inc_quota(ss, username)<0) { if(inc_quota(ss, username)<0) {
@ -1399,7 +1396,7 @@ static int handle_turn_refresh(turn_turnserver *server,
} else { } else {
u32bits lifetime = 0; turn_time_t lifetime = 0;
int to_delete = 0; int to_delete = 0;
mobile_id_t mid = 0; mobile_id_t mid = 0;
char smid[sizeof(ss->s_mobile_id)] = "\0"; char smid[sizeof(ss->s_mobile_id)] = "\0";
@ -1552,6 +1549,7 @@ static int handle_turn_refresh(turn_turnserver *server,
//Check security: //Check security:
int postpone_reply = 0; int postpone_reply = 0;
if(!ss->hmackey_set) {
ns_bcopy(orig_ss->nonce,ss->nonce,sizeof(ss->nonce)); ns_bcopy(orig_ss->nonce,ss->nonce,sizeof(ss->nonce));
ss->nonce_expiration_time = orig_ss->nonce_expiration_time; 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->realm_options),&(ss->realm_options),sizeof(ss->realm_options));
@ -1563,6 +1561,7 @@ static int handle_turn_refresh(turn_turnserver *server,
ss->origin_set = orig_ss->origin_set; ss->origin_set = orig_ss->origin_set;
ns_bcopy(orig_ss->pwd,ss->pwd,sizeof(ss->pwd)); ns_bcopy(orig_ss->pwd,ss->pwd,sizeof(ss->pwd));
ss->max_session_time_auth = orig_ss->max_session_time_auth; ss->max_session_time_auth = orig_ss->max_session_time_auth;
}
if(check_stun_auth(server, ss, tid, resp_constructed, err_code, reason, in_buffer, nbh, 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) { STUN_METHOD_REFRESH, &message_integrity, &postpone_reply, can_resume)<0) {
@ -1582,10 +1581,7 @@ static int handle_turn_refresh(turn_turnserver *server,
if (to_delete) if (to_delete)
lifetime = 0; lifetime = 0;
else { else {
lifetime = stun_adjust_allocate_lifetime(lifetime); lifetime = stun_adjust_allocate_lifetime(lifetime, ss->max_session_time_auth);
if(ss->max_session_time_auth && (ss->max_session_time_auth < lifetime)) {
lifetime = ss->max_session_time_auth;
}
} }
if (af4c && refresh_relay_connection(server, orig_ss, lifetime, 0, 0, 0, if (af4c && refresh_relay_connection(server, orig_ss, lifetime, 0, 0, 0,
@ -1695,8 +1691,9 @@ static int handle_turn_refresh(turn_turnserver *server,
if (to_delete) if (to_delete)
lifetime = 0; lifetime = 0;
else else {
lifetime = stun_adjust_allocate_lifetime(lifetime); lifetime = stun_adjust_allocate_lifetime(lifetime, ss->max_session_time_auth);
}
if(!af4 && !af6) { if(!af4 && !af6) {
af4 = af4c; af4 = af4c;