Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from mozilla's repo #6

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9d857bc
Bug 1634145: Avoid leaking nr_ice_sockets due to various kinds of fai…
docfaraday May 4, 2020
7adfbbe
Bug 1639916: Clean up pstream if we don't end up using it. r=mjf
docfaraday May 21, 2020
2ba6f4a
Bug 1183145: Rename a function to better reflect what it does, and fi…
docfaraday May 26, 2020
a292f4f
Bug 1183145: Add a flags field to nr_local_addr so IPv6 addresses can…
docfaraday May 26, 2020
08b6a3c
Bug 1183145: Move platform-specific code from addrs.c into separate f…
vpoddubchak Mar 30, 2021
fc2452f
Bug 1183145: Teach platform-specific code to filter out inappropriate…
docfaraday May 26, 2020
21f56ea
Bug 1643169: Use ifr_ifru.ifru_flags6 instead of the ifr_flags macro,…
docfaraday Jun 4, 2020
7ab5c30
Bug 1644477: Make candidate pair insertion code easier to read/unders…
docfaraday Jun 9, 2020
f0e195e
Bug 1649678: Add include needed by OpenBSD. r=mjf
docfaraday Jul 7, 2020
5ec6033
Bug 1651601: Filter gathered candidates when their component is obsol…
docfaraday Jul 10, 2020
a220d51
Bug 1651601: Only do the minimum processing for STUN messages on an o…
docfaraday Jul 24, 2020
68ee2ba
Bug 1651601: Ignore remote trickle candidates for obsolete streams. r…
docfaraday Jul 31, 2020
d8ec558
Bug 1677759: Emit per-stream null candidates when the last candidate …
docfaraday Nov 19, 2020
22ef96f
Bug 1677759: Mark STUN/TURN client contexts failed when we encounter …
docfaraday Nov 19, 2020
30af813
Bug 1665161: Prefer IFA_LOCAL if present, and fall back to IFA_ADDRES…
docfaraday Nov 13, 2020
6e84c56
Bug 1678484: Start the grace period timer before pairing a candidate,…
docfaraday Dec 1, 2020
7631d3e
Bug 1626278: Stop requiring additional dispatches to STS for ICE ctx …
docfaraday Nov 19, 2020
9944ea4
Bug 1680771: Use a real LoadInfo for WebrtcTCPSocket, ensure we use t…
docfaraday Jan 5, 2021
8b33e12
Bug 1416220: Modify mtransport to delegate DNS lookups for TCP socket…
docfaraday Jan 14, 2021
cf69973
Bug 1416220: Add/improve some logging, and add an assertion. r=mjf
docfaraday Jan 14, 2021
576858e
Backed out 6 changesets (bug 1416220) for GTest failure on TestGather…
nbeleuzu Jan 14, 2021
868655f
Bug 1416220: Modify mtransport to delegate DNS lookups for TCP socket…
docfaraday Jan 28, 2021
1ea4428
Bug 1416220: Add/improve some logging, and add an assertion. r=mjf
docfaraday Jan 28, 2021
32d019d
Bug 1416220: Get ice_unittest working. r=mjf
vpoddubchak Mar 30, 2021
75065e0
Adapt CMakeFile to the the latest nicer.gyp
vpoddubchak Mar 30, 2021
c34b317
Fixed build
vpoddubchak Mar 30, 2021
ed7dad3
Bug 1702323: Fix bug where the tls bit was being stomped by conversio…
docfaraday Apr 5, 2021
a7b5749
Bug 857668: Remove some unneeded non-owning references to nr_socket. …
docfaraday May 27, 2021
a6fa3bd
Bug 1170299: Fix const-correctness on some functions. r=mjf
docfaraday May 27, 2021
5a753df
Bug 857668: Remove some fields that serve no purpose besides making t…
docfaraday May 27, 2021
2082b3c
Bug 857668: Add function for getting STUN multi-attributes. r=mjf
docfaraday May 27, 2021
c4c8c14
Bug 857668: Remove existing STUN/300 handling. r=mjf
docfaraday May 27, 2021
0669ac6
Bug 857668: Handle Allocate/300 with ALTERNATE-SERVER. r=mjf
docfaraday May 27, 2021
f15427c
Bug 857668: Fix handling of IPv6 literals. r=mjf
docfaraday May 27, 2021
dfae3e1
Bug 857668: Let Allocate/300 without MESSAGE-INTEGRITY slide. r=mjf
docfaraday May 27, 2021
a10d94d
Bug 857668: Stop ignoring error responses from STUN/TURN servers. r=mjf
docfaraday May 27, 2021
de78600
Bug 857668: Open a new TCP socket when we receive a redirect in the T…
docfaraday May 27, 2021
524ef67
Bug 857668: Implement redirect loop detection. r=mjf
docfaraday May 27, 2021
16fe857
Bug 857668: Remove this extra retry_ct field. r=mjf
docfaraday May 27, 2021
3dd888a
Bug 857668: Use IPPROTO_TCP here. r=mjf
docfaraday May 27, 2021
0341cc2
fixed build
Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ list(APPEND nicer__c_srcs
"${NICER_SOURCE}/src/net/local_addr.c"
"${NICER_SOURCE}/src/net/nr_interface_prioritizer.c"
"${NICER_SOURCE}/src/stun/addrs.c"
"${NICER_SOURCE}/src/stun/ifaddrs-android.c"
"${NICER_SOURCE}/src/stun/addrs-bsd.c"
"${NICER_SOURCE}/src/stun/addrs-netlink.c"
"${NICER_SOURCE}/src/stun/addrs-win32.c"
"${NICER_SOURCE}/src/stun/nr_socket_turn.c"
"${NICER_SOURCE}/src/stun/nr_socket_buffered_stun.c"
"${NICER_SOURCE}/src/stun/stun_build.c"
Expand Down Expand Up @@ -78,7 +80,9 @@ list(APPEND nicer__other_srcs
"${NICER_SOURCE}/src/net/local_addr.h"
"${NICER_SOURCE}/src/net/nr_interface_prioritizer.h"
"${NICER_SOURCE}/src/stun/addrs.h"
"${NICER_SOURCE}/src/stun/ifaddrs-android.h"
"${NICER_SOURCE}/src/stun/addrs-bsd.h"
"${NICER_SOURCE}/src/stun/addrs-netlink.h"
"${NICER_SOURCE}/src/stun/addrs-win32.h"
"${NICER_SOURCE}/src/stun/nr_socket_turn.h"
"${NICER_SOURCE}/src/stun/nr_socket_buffered_stun.h"
"${NICER_SOURCE}/src/stun/stun.h"
Expand Down
104 changes: 65 additions & 39 deletions src/ice/ice_candidate.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,11 @@ static const char *nr_tcp_type_name(nr_socket_tcp_type tcp_type) {

static int nr_ice_candidate_format_stun_label(char *label, size_t size, nr_ice_candidate *cand)
{
int _status;
*label = 0;
snprintf(label, size, "%s(%s|%s)", nr_ctype_name(cand->type),
cand->base.as_string, cand->stun_server->addr.as_string);

*label = 0;
switch(cand->stun_server->type) {
case NR_ICE_STUN_SERVER_TYPE_ADDR:
snprintf(label, size, "%s(%s|%s)", nr_ctype_name(cand->type), cand->base.as_string,
cand->stun_server->u.addr.as_string);
break;
case NR_ICE_STUN_SERVER_TYPE_DNSNAME:
snprintf(label, size, "%s(%s|%s:%u)", nr_ctype_name(cand->type), cand->base.as_string,
cand->stun_server->u.dnsname.host, cand->stun_server->u.dnsname.port);
break;
default:
assert(0);
ABORT(R_BAD_ARGS);
}

_status=0;
abort:
return(_status);
return (0);
}

int nr_ice_candidate_create(nr_ice_ctx *ctx,nr_ice_component *comp,nr_ice_socket *isock, nr_socket *osock, nr_ice_candidate_type ctype, nr_socket_tcp_type tcp_type, nr_ice_stun_server *stun_server, UCHAR component_id, nr_ice_candidate **candp)
Expand Down Expand Up @@ -271,7 +256,7 @@ int nr_ice_peer_peer_rflx_candidate_create(nr_ice_ctx *ctx,char *label, nr_ice_c

static void nr_ice_candidate_mark_done(nr_ice_candidate *cand, int state)
{
if (!cand || !cand->done_cb) {
if (!cand) {
assert(0);
return;
}
Expand All @@ -294,7 +279,9 @@ static void nr_ice_candidate_mark_done(nr_ice_candidate *cand, int state)
cand->done_cb=0;
cand->state=state;
/* This might destroy cand! */
done_cb(0,0,cand->cb_arg);
if (done_cb) {
done_cb(0,0,cand->cb_arg);
}
}

int nr_ice_candidate_destroy(nr_ice_candidate **candp)
Expand Down Expand Up @@ -579,6 +566,24 @@ static void nr_ice_candidate_fire_ready_cb(NR_SOCKET s, int how, void *cb_arg)
cand->ready_cb(0, 0, cand->ready_cb_arg);
}

static int nr_ice_candidate_use_nr_resolver(nr_transport_addr *addr)
{
if(addr->fqdn[0] == 0) {
return 0;
}

char use = 0;
if(addr->protocol == IPPROTO_UDP) {
NR_reg_get_char(NR_ICE_REG_USE_NR_RESOLVER_FOR_UDP, &use);
} else if(addr->protocol == IPPROTO_TCP) {
NR_reg_get_char(NR_ICE_REG_USE_NR_RESOLVER_FOR_TCP, &use);
} else {
assert(0);
}

return use;
}

int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, void *cb_arg)
{
int r,_status;
Expand All @@ -603,28 +608,37 @@ int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, vo
/* Fall through */
#endif
case SERVER_REFLEXIVE:
if(cand->stun_server->type == NR_ICE_STUN_SERVER_TYPE_ADDR) {
if(nr_transport_addr_cmp(&cand->base,&cand->stun_server->u.addr,NR_TRANSPORT_ADDR_CMP_MODE_PROTOCOL)) {
r_log(LOG_ICE, LOG_INFO, "ICE-CANDIDATE(%s): Skipping srflx/relayed candidate because of IP version/transport mis-match with STUN/TURN server (%u/%s - %u/%s).", cand->label,cand->base.ip_version,cand->base.protocol==IPPROTO_UDP?"UDP":"TCP",cand->stun_server->u.addr.ip_version,cand->stun_server->u.addr.protocol==IPPROTO_UDP?"UDP":"TCP");
ABORT(R_NOT_FOUND); /* Same error code when DNS lookup fails */
}
if (nr_transport_addr_cmp(&cand->base, &cand->stun_server->addr,
NR_TRANSPORT_ADDR_CMP_MODE_PROTOCOL)) {
r_log(LOG_ICE, LOG_INFO,
"ICE-CANDIDATE(%s): Skipping srflx/relayed candidate because "
"of IP version/transport mis-match with STUN/TURN server "
"(%u/%s - %u/%s).",
cand->label, cand->base.ip_version,
cand->base.protocol == IPPROTO_UDP ? "UDP" : "TCP",
cand->stun_server->addr.ip_version,
cand->stun_server->addr.protocol == IPPROTO_UDP ? "UDP"
: "TCP");
ABORT(R_NOT_FOUND); /* Same error code when DNS lookup fails */
}

/* Just copy the address */
if (r=nr_transport_addr_copy(&cand->stun_server_addr,
&cand->stun_server->u.addr)) {
r_log(LOG_ICE,LOG_ERR,"ICE-CANDIDATE(%s): Could not copy STUN server addr", cand->label);
if(nr_ice_candidate_use_nr_resolver(&cand->stun_server->addr)) {
r_log(
LOG_ICE, LOG_DEBUG,
"ICE-CANDIDATE(%s): Starting DNS resolution (%u/%s - %u/%s).",
cand->label, cand->base.ip_version,
cand->base.protocol == IPPROTO_UDP ? "UDP" : "TCP",
cand->stun_server->addr.ip_version,
cand->stun_server->addr.protocol == IPPROTO_UDP ? "UDP" : "TCP");
nr_resolver_resource resource;
int port;
resource.domain_name = cand->stun_server->addr.fqdn;
if (r = nr_transport_addr_get_port(&cand->stun_server->addr, &port)) {
ABORT(r);
}

if(r=nr_ice_candidate_initialize2(cand))
ABORT(r);
}
else {
nr_resolver_resource resource;
resource.domain_name=cand->stun_server->u.dnsname.host;
resource.port=cand->stun_server->u.dnsname.port;
resource.port = (uint16_t)port;
resource.stun_turn=protocol;
resource.transport_protocol=cand->stun_server->transport;
resource.transport_protocol = cand->stun_server->addr.protocol;

switch (cand->base.ip_version) {
case NR_IPV4:
Expand All @@ -634,6 +648,7 @@ int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, vo
resource.address_family=AF_INET6;
break;
default:
assert(0);
ABORT(R_BAD_ARGS);
}

Expand All @@ -651,6 +666,16 @@ int nr_ice_candidate_initialize(nr_ice_candidate *cand, NR_async_cb ready_cb, vo
r_log(LOG_ICE,LOG_ERR,"ICE-CANDIDATE(%s): Could not invoke DNS resolver",cand->label);
ABORT(r);
}
} else {
/* No nr_resolver for this, just copy the address and finish init */
if (r = nr_transport_addr_copy(&cand->stun_server_addr,
&cand->stun_server->addr)) {
r_log(LOG_ICE,LOG_ERR,"ICE-CANDIDATE(%s): Could not copy STUN server addr", cand->label);
ABORT(r);
}

if(r=nr_ice_candidate_initialize2(cand))
ABORT(r);
}
break;
default:
Expand Down Expand Up @@ -818,6 +843,7 @@ static int nr_ice_start_relay_turn(nr_ice_candidate *cand)
cand->u.relayed.server->username,
cand->u.relayed.server->password,
&cand->stun_server_addr,
cand->component->ctx,
&cand->u.relayed.turn))
ABORT(r);

Expand Down
7 changes: 2 additions & 5 deletions src/ice/ice_candidate_pair.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ static int nr_ice_candidate_copy_for_triggered_check(nr_ice_cand_pair *pair)
copy->nominated = pair->nominated;

r_log(LOG_ICE,LOG_INFO,"CAND-PAIR(%s): Adding pair to check list and trigger check queue: %s",pair->codeword,pair->as_string);
if(r=nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,copy))
ABORT(r);
nr_ice_candidate_pair_insert(&pair->remote->stream->check_list,copy);
nr_ice_candidate_pair_trigger_check_append(&pair->remote->stream->trigger_check_queue,copy);

copy->triggered = 1;
Expand Down Expand Up @@ -603,7 +602,7 @@ int nr_ice_candidate_pair_trigger_check_append(nr_ice_cand_pair_head *head,nr_ic
return(0);
}

int nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair)
void nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair)
{
nr_ice_cand_pair *c1;

Expand All @@ -617,8 +616,6 @@ int nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *p
c1=TAILQ_NEXT(c1,check_queue_entry);
}
if(!c1) TAILQ_INSERT_TAIL(head,pair,check_queue_entry);

return(0);
}

void nr_ice_candidate_pair_restart_stun_nominated_cb(NR_SOCKET s, int how, void *cb_arg)
Expand Down
2 changes: 1 addition & 1 deletion src/ice/ice_candidate_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void nr_ice_candidate_pair_dump_state(nr_ice_cand_pair *pair, int log_level);
void nr_ice_candidate_pair_cancel(nr_ice_peer_ctx *pctx,nr_ice_cand_pair *pair, int move_to_wait_state);
int nr_ice_candidate_pair_select(nr_ice_cand_pair *pair);
int nr_ice_candidate_pair_do_triggered_check(nr_ice_peer_ctx *pctx, nr_ice_cand_pair *pair);
int nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair);
void nr_ice_candidate_pair_insert(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair);
int nr_ice_candidate_pair_trigger_check_append(nr_ice_cand_pair_head *head,nr_ice_cand_pair *pair);
void nr_ice_candidate_pair_restart_stun_nominated_cb(NR_SOCKET s, int how, void *cb_arg);
int nr_ice_candidate_pair_destroy(nr_ice_cand_pair **pairp);
Expand Down
Loading