Commit 44173747 authored by Simon Morlat's avatar Simon Morlat

fix bug with turn/ice

parent f6e55b27
...@@ -2300,18 +2300,21 @@ static bool_t ice_handle_received_turn_allocate_success_response(IceCheckList *c ...@@ -2300,18 +2300,21 @@ static bool_t ice_handle_received_turn_allocate_success_response(IceCheckList *c
candidate = ice_add_local_candidate(cl, "srflx", ms_stun_family_to_af(srflx_addr.family), srflx_addr_str, srflx_port, componentID, candidate); candidate = ice_add_local_candidate(cl, "srflx", ms_stun_family_to_af(srflx_addr.family), srflx_addr_str, srflx_port, componentID, candidate);
ms_stun_address_to_printable_ip_address(&srflx_addr, srflx_addr_str, sizeof(srflx_addr_str)); ms_stun_address_to_printable_ip_address(&srflx_addr, srflx_addr_str, sizeof(srflx_addr_str));
ms_message("ice: Add candidate obtained by STUN/TURN: %s:srflx", srflx_addr_str); ms_message("ice: Add candidate obtained by STUN/TURN: %s:srflx", srflx_addr_str);
ms_stun_address_to_ip_address(&relay_addr, relay_addr_str, sizeof(relay_addr_str), &relay_port);
if (cl->session->turn_enabled) { if (cl->session->turn_enabled) {
request->turn_context->stats.nb_successful_allocate++; request->turn_context->stats.nb_successful_allocate++;
ice_schedule_turn_allocation_refresh(cl, componentID, ms_stun_message_get_lifetime(msg)); ice_schedule_turn_allocation_refresh(cl, componentID, ms_stun_message_get_lifetime(msg));
} }
if (relay_port != 0) { if (relay_addr.family != 0){
if (cl->session->turn_enabled) { ms_stun_address_to_ip_address(&relay_addr, relay_addr_str, sizeof(relay_addr_str), &relay_port);
ms_turn_context_set_allocated_relay_addr(request->turn_context, relay_addr); if (relay_port != 0) {
if (cl->session->turn_enabled) {
ms_turn_context_set_allocated_relay_addr(request->turn_context, relay_addr);
}
ice_add_local_candidate(cl, "relay", ms_stun_family_to_af(relay_addr.family), relay_addr_str, relay_port, componentID, NULL);
ms_stun_address_to_printable_ip_address(&relay_addr, relay_addr_str, sizeof(relay_addr_str));
ms_message("ice: Add candidate obtained by STUN/TURN: %s:relay", relay_addr_str);
} }
ice_add_local_candidate(cl, "relay", ms_stun_family_to_af(relay_addr.family), relay_addr_str, relay_port, componentID, NULL);
ms_stun_address_to_printable_ip_address(&relay_addr, relay_addr_str, sizeof(relay_addr_str));
ms_message("ice: Add candidate obtained by STUN/TURN: %s:relay", relay_addr_str);
} }
} }
} }
......
...@@ -585,8 +585,10 @@ MSStunAddress ms_ip_address_to_stun_address(int ai_family, int socktype, const c ...@@ -585,8 +585,10 @@ MSStunAddress ms_ip_address_to_stun_address(int ai_family, int socktype, const c
MSStunAddress stun_addr; MSStunAddress stun_addr;
struct addrinfo *res = bctbx_ip_address_to_addrinfo(ai_family, socktype, hostname, port); struct addrinfo *res = bctbx_ip_address_to_addrinfo(ai_family, socktype, hostname, port);
memset(&stun_addr, 0, sizeof(stun_addr)); memset(&stun_addr, 0, sizeof(stun_addr));
ms_sockaddr_to_stun_address(res->ai_addr, &stun_addr); if (res){
bctbx_freeaddrinfo(res); ms_sockaddr_to_stun_address(res->ai_addr, &stun_addr);
bctbx_freeaddrinfo(res);
}
return stun_addr; return stun_addr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment