platform/upstream/libnice.git
2 years agogstnicesink: disable drop out of segment on nicesink
Guillaume Desmottes [Fri, 26 Nov 2021 14:30:21 +0000 (15:30 +0100)]
gstnicesink: disable drop out of segment on nicesink

It's very tricky and unintuitive to have webrtcbin not sending data
because of the segment.

Fix https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/907

2 years agotest-io-stream-common: Avoid CPU starvation by yielding
Ole André Vadla Ravnås [Thu, 4 Nov 2021 21:48:22 +0000 (22:48 +0100)]
test-io-stream-common: Avoid CPU starvation by yielding

Busy-looping is not a good idea, especially not when run under Valgrind,
where such a thread may result in well-behaved threads running thousands
of times slower. While passing --fair-sched=yes to Valgrind avoids the
issue, it's still better to make our busy-looping less aggressive.

2 years agoagent: Consume data before removing disconnected socket
Ole André Vadla Ravnås [Sun, 16 May 2021 10:35:23 +0000 (12:35 +0200)]
agent: Consume data before removing disconnected socket

This was caught by tests randomly failing (timing out).

2 years agoiostream: Implement close() for ICE-TCP also
Ole André Vadla Ravnås [Sat, 15 May 2021 20:20:40 +0000 (22:20 +0200)]
iostream: Implement close() for ICE-TCP also

2 years agocomponent: Clear buffer pointers to avoid potential double free
Ole André Vadla Ravnås [Sat, 15 May 2021 20:19:03 +0000 (22:19 +0200)]
component: Clear buffer pointers to avoid potential double free

In case close() is called more than once.

2 years agotest-io-stream-thread: Handle partial I/O
Ole André Vadla Ravnås [Sat, 15 May 2021 22:22:19 +0000 (00:22 +0200)]
test-io-stream-thread: Handle partial I/O

2 years agotest-io-stream-closing-write: Handle partial I/O
Ole André Vadla Ravnås [Sat, 15 May 2021 22:08:13 +0000 (00:08 +0200)]
test-io-stream-closing-write: Handle partial I/O

2 years agotest-io-stream-closing-read: Handle partial I/O
Ole André Vadla Ravnås [Sat, 15 May 2021 22:07:49 +0000 (00:07 +0200)]
test-io-stream-closing-read: Handle partial I/O

2 years agotest-io-stream-common: Remove incorrect assertion
Ole André Vadla Ravnås [Fri, 14 May 2021 23:38:21 +0000 (01:38 +0200)]
test-io-stream-common: Remove incorrect assertion

We cannot assume that the message will be completely filled even in
reliable mode.

2 years agotest-io-stream-common: Fix GSource callback signature
Ole André Vadla Ravnås [Wed, 12 May 2021 22:28:53 +0000 (00:28 +0200)]
test-io-stream-common: Fix GSource callback signature

Cannot pass g_main_loop_quit as the GSourceFunc as its return type is
void.

2 years agotest-io-stream-common: Remove dead code
Ole André Vadla Ravnås [Wed, 12 May 2021 22:26:58 +0000 (00:26 +0200)]
test-io-stream-common: Remove dead code

Due to off-by-one errors. Since the code added above now handles what
this code tried to handle, we can go ahead and remove it.

2 years agoagent: Add support for bytestream TCP
Ole André Vadla Ravnås [Wed, 12 May 2021 22:47:22 +0000 (00:47 +0200)]
agent: Add support for bytestream TCP

2 years agoconncheck: don't ignore local socket errors
Fabrice Bellet [Fri, 1 Oct 2021 15:35:44 +0000 (17:35 +0200)]
conncheck: don't ignore local socket errors

With this patch we ensure that local socket errors during connection
establishment are properly transmitted to the connection check layer, so
the related pair can be put in state failed when needed. The local
socket errors we are interested in, are those occuring when the local
source address cannot be bound anymore, because the underlying interface
vanished for example.

In particular, we don't ignore errors coming from g_socket_bind() with
tcp active sockets, that perform a bind to *whatever* local address is
available, in case it cannot bind to the specified address.

This behaviour was demonstrated with the test-tcp example, that tried
to bind to the IPv4 loopback address on a socket initially created for
the IPv6 loopback.

2 years agomeson: Add agent include dir to uninstalled pkgconfig file
Nirbheek Chauhan [Mon, 15 Nov 2021 08:17:30 +0000 (13:47 +0530)]
meson: Add agent include dir to uninstalled pkgconfig file

Meson picks up the includedirs from the library target that it is
building the pkgconfig file for. Since libnice's headers are split
into the nice/ and agent/ subdirs, we need to add agent/ to
include_directories: so that it's automatically added to the
uninstalled pkgconfig file by Meson.

2 years agoagent: Handle failure to create TCP TURN socket
Ole André Vadla Ravnås [Tue, 2 Nov 2021 22:39:30 +0000 (23:39 +0100)]
agent: Handle failure to create TCP TURN socket

E.g. if the server address is IPv6 but the local system cannot reach it,
so connect() fails right away.

2 years agoconncheck: schedule the connection check in most relevant places
Fabrice Bellet [Fri, 23 Oct 2020 15:38:53 +0000 (17:38 +0200)]
conncheck: schedule the connection check in most relevant places

The patch invokes the conncheck timer creation where it makes most
sense: when a new pair is inserted in the conncheck list, and when a
pair is added to the triggered check list (because the conncheck
scheduler works on these two lists).

2 years agostun: Use a specific variable to enable Win32 crypto
Olivier Crête [Tue, 2 Nov 2021 18:18:57 +0000 (12:18 -0600)]
stun: Use a specific variable to enable Win32 crypto

This should make it possible to use OpenSSL or GnuTLS also on Windows if
required.

2 years agogitlab-ci: Try to disable CI on non-MR/non-master branches
Olivier Crête [Tue, 2 Nov 2021 16:46:06 +0000 (12:46 -0400)]
gitlab-ci: Try to disable CI on non-MR/non-master branches

2 years agogitlab-ci: Add OpenSSL specific build
Olivier Crête [Tue, 2 Nov 2021 02:49:11 +0000 (22:49 -0400)]
gitlab-ci: Add OpenSSL specific build

2 years agomeson: Simplify finding OpenSSL
Olivier Crête [Tue, 2 Nov 2021 17:14:55 +0000 (13:14 -0400)]
meson: Simplify finding OpenSSL

Remove duplicated calls to dependency() so we can have fallback in all
cases.

2 years agomeson: Fix name of variable
Olivier Crête [Tue, 2 Nov 2021 16:33:13 +0000 (12:33 -0400)]
meson: Fix name of variable

This is a fix over the recent fix in commit 574f44b4

2 years agotests: Use g_assert_true() instead of g_assert() everywhere
Olivier Crête [Tue, 2 Nov 2021 02:25:02 +0000 (22:25 -0400)]
tests: Use g_assert_true() instead of g_assert() everywhere

2 years agoRemove g_assert_cmp* macros outside of the unit tests
Olivier Crête [Tue, 2 Nov 2021 02:22:32 +0000 (22:22 -0400)]
Remove g_assert_cmp* macros outside of the unit tests

2 years agoagent: ensure suceeded and discovered pairs fail the same time
Fabrice Bellet [Fri, 1 Oct 2021 10:17:19 +0000 (12:17 +0200)]
agent: ensure suceeded and discovered pairs fail the same time

This patch ensures that related succeeded-discovered pairs change to
state failed simultaneously, to avoid leaving dangling pointers if one
is freeed while the other is still in the conncheck list. Such
transition is very rare, and only occurs in regular nomination mode,
when the network conditions change between the time the pair is
initially discovered and the time it is rechecked with the use-candidate
flag.

2 years agoFix error when crypto/ssl libs are found without pkg-config
Xavier Claessens [Thu, 28 Oct 2021 14:24:39 +0000 (10:24 -0400)]
Fix error when crypto/ssl libs are found without pkg-config

In that case crypto_dep is a list and we can't call .found() method.

2 years agoagent: Unify constructors into nice_agent_new_full
Juan Navarro [Tue, 7 Sep 2021 14:15:03 +0000 (16:15 +0200)]
agent: Unify constructors into nice_agent_new_full

Instead of having 3 independent implementations, make the simpler
versions delegate into the full one.

The simplest constructor needs to pass "no option", for which no
constant exists in the NiceAgentOption enum. Thus the new
NICE_AGENT_OPTION_NONE constant is added to reflect this possibility.

2 years agoUse native crypto support on Windows by default
Ole André Vadla Ravnås [Tue, 6 Apr 2021 20:47:17 +0000 (22:47 +0200)]
Use native crypto support on Windows by default

As we only need a few primitives there isn't much OS-specific code
needed, and for applications that don't already depend on OpenSSL or
GnuTLS it simplifies the build process quite a lot.

Note that we use the vintage WinCrypt APIs as the Cryptography Next
Generation APIs are only available on Vista and newer.

2 years agocomponent: reset the stun agent on ice restart
Fabrice Bellet [Fri, 1 Oct 2021 10:41:29 +0000 (12:41 +0200)]
component: reset the stun agent on ice restart

The stun agent may contain references to the password previously stored
in some remote candidates, freeed by nice_component_restart(), that were
used by keep-alive stun requests. These stun replies may arrive later
after ice has been restarted. Since the remote candidates are freeed
when ice is restarted, the stun agent must be reset to get rid of these
related references.

2 years agogitlab-ci: Update Windows image
Olivier Crête [Fri, 1 Oct 2021 14:08:29 +0000 (10:08 -0400)]
gitlab-ci: Update Windows image

2 years agogitlab-ci: Update ci-fairy to upstream recommended script
Olivier Crête [Fri, 1 Oct 2021 14:03:49 +0000 (10:03 -0400)]
gitlab-ci: Update ci-fairy to upstream recommended script

2 years agonice: Bring new symbols to 0.1.19
Olivier Crête [Thu, 19 Aug 2021 19:12:23 +0000 (15:12 -0400)]
nice: Bring new symbols to 0.1.19

It's not released yet and we don't do even/odd in this project.

2 years agonice: Export nice_candidate_transport_to_string
Olivier Crête [Thu, 19 Aug 2021 18:43:13 +0000 (14:43 -0400)]
nice: Export nice_candidate_transport_to_string

Also update the Since to 0.1.19, because it's not really usable now

2 years agonice: Export nice_candidate_type_to_string
Olivier Crête [Thu, 19 Aug 2021 18:42:28 +0000 (14:42 -0400)]
nice: Export nice_candidate_type_to_string

Also update the Since to 0.1.19, because it's not really usable now

2 years agostun: Make the headers usable from C++ code
abhijeetbhagat [Sun, 6 Jun 2021 06:39:09 +0000 (12:09 +0530)]
stun: Make the headers usable from C++ code

Add the relevant ifdef extern C bits

2 years agoagent: Simplify accepting state changes to FAILED
Olivier Crête [Tue, 20 Jul 2021 17:06:58 +0000 (13:06 -0400)]
agent: Simplify accepting state changes to FAILED

The component can go from any state to FAILED, so simplify
that and make it explicit.

2 years agoagent: Accept any transition back to the gathering state
Olivier Crête [Tue, 20 Jul 2021 17:04:17 +0000 (13:04 -0400)]
agent: Accept any transition back to the gathering state

When doing a ICE restart, which can be done from any state, we can
always go back into the gathering state.

This fixes a regression introduced by b20ac5ba7b731f2cc698f26e8def28a518de058e

2 years agogitlab-ci: Allow msys CI to fail
Olivier Crête [Tue, 20 Jul 2021 20:55:41 +0000 (16:55 -0400)]
gitlab-ci: Allow msys CI to fail

It just won't work for now.

2 years agosubprojects: Get zlib from Qt mirror
Olivier Crête [Tue, 20 Jul 2021 17:30:09 +0000 (13:30 -0400)]
subprojects: Get zlib from Qt mirror

Getting it from the upstream mirror seems to fail miserably

2 years agogitlab-ci: Remove meson update
Olivier Crête [Tue, 20 Jul 2021 17:25:13 +0000 (13:25 -0400)]
gitlab-ci: Remove meson update

2 years agoUpdate Windows image
Olivier Crête [Tue, 20 Jul 2021 17:14:11 +0000 (13:14 -0400)]
Update Windows image

3 years agotest-restart: fix potential stack buffer overflow with new candidate API
Fabrice Bellet [Sat, 13 Feb 2021 13:16:10 +0000 (14:16 +0100)]
test-restart: fix potential stack buffer overflow with new candidate API

3 years agotest-consent: fix potential stack buffer overflow with new candidate API
Fabrice Bellet [Sat, 13 Feb 2021 13:15:58 +0000 (14:15 +0100)]
test-consent: fix potential stack buffer overflow with new candidate API

3 years agotest-io-stream-pollable: Handle partial reads
Ole André Vadla Ravnås [Tue, 11 May 2021 08:52:55 +0000 (10:52 +0200)]
test-io-stream-pollable: Handle partial reads

3 years agopseudotcp: Disable Nagle algorithm by default
Ole André Vadla Ravnås [Mon, 10 May 2021 10:37:18 +0000 (12:37 +0200)]
pseudotcp: Disable Nagle algorithm by default

To be consistent with what we do for ICE-TCP.

3 years agotcp-bsd: Handle send before connect() completes
Ole André Vadla Ravnås [Sun, 9 May 2021 21:55:07 +0000 (23:55 +0200)]
tcp-bsd: Handle send before connect() completes

3 years agoagent: Remove duplicated early return
Olivier Crête [Mon, 3 May 2021 21:04:34 +0000 (17:04 -0400)]
agent: Remove duplicated early return

The type is already checked to not be peer reflexive earlier.

3 years agoagent: Avoid leak on programming error
Olivier Crête [Mon, 3 May 2021 21:01:59 +0000 (17:01 -0400)]
agent: Avoid leak on programming error

Even if the agent is invalid, don't leak.

This makes coverity a little happier.

3 years agoconncheck: Free password in more obvious way
Olivier Crête [Mon, 3 May 2021 21:00:51 +0000 (17:00 -0400)]
conncheck: Free password in more obvious way

This should make Coverity's job a little easier. And also fix a little
leak in the error path.

3 years agoudp-turn: Remove request before freeing it
Olivier Crête [Mon, 3 May 2021 20:58:01 +0000 (16:58 -0400)]
udp-turn: Remove request before freeing it

As removing the request from the queue looks into the SendRequest, one
needs to unqueue it before freeing it.

3 years agoagent: avoid leak of all turn refreshes when disposing the agent
Fabrice Bellet [Sat, 19 Dec 2020 16:56:16 +0000 (17:56 +0100)]
agent: avoid leak of all turn refreshes when disposing the agent

With this patch we free all outstanding refreshes when the agent dispose
method is called, even those that are in the way to be discarded
asynchronously, when a stream is removed.

We also make the final user callback of the refresh proces synchronous,
so we don't have to deal with an heap use-after-free problem. This also
requires to order some parts of code.

3 years agodiscovery: fix asynchronous agent refreshes pruning
Fabrice Bellet [Thu, 17 Dec 2020 11:06:38 +0000 (12:06 +0100)]
discovery: fix asynchronous agent refreshes pruning

Asynchronous refreshes pruning may occur when the agent async close
function is called, but also when a stream is closed. A flag
'discarding' is used in the CandidateRefresh object to determine
if a refresh is already on the way to be asynchronously freed. A refresh
definitely freed is removed from agent refresh_list.

When the agent async close function is called, it is passed a user
callback that will be invoked when all refreshes have been freed.

This is not exactly how things work currently, because right now, the
callback function is also invoked when all CandidateRefresh objects have
the discarding flag set, with the test 'data->items_to_free==0'. In that
case, clearly not all refreshes have been freed, as some are still there
in the refresh_list with the discarding flag set.

This is probably not what the user expects from the function
nice_agent_close_async(), where the callback is supposed to be invoked
after all refreshes have been freed: and including those asynchronously
pruned by nice_prune_stream_async().

This patch adds a supplementary timeout when closing the agent async,
that waits until the agent refresh list becomes empty.

3 years agoagent: avoid leak of turn refreshes
Fabrice Bellet [Sun, 13 Dec 2020 16:59:41 +0000 (17:59 +0100)]
agent: avoid leak of turn refreshes

We keep refreshes having the discarding flag set. They may be freed later
if the agent main context remains alive after agent deletion.

3 years agoagent: warn when closing the agent with alive turn refreshes
Fabrice Bellet [Sat, 12 Dec 2020 20:12:52 +0000 (21:12 +0100)]
agent: warn when closing the agent with alive turn refreshes

This patch suggests the developer to close its alive reservations on
the turn server before disposing the agent.

Not removing reservations on the turn server, will make them alive until
their default timeout, generally 300 seconds, which is not fair for the
turn server resources, but also it may cause a fatal error 437,
"Mismatched allocation: wrong transaction ID", when another agent tries
to contact the same turn server using the same nat mapping before this
delay expires.

3 years agoagent: Verify the source before dereferencing the pointer
Olivier Crête [Tue, 20 Apr 2021 19:09:11 +0000 (15:09 -0400)]
agent: Verify the source before dereferencing the pointer

The reason is that the component object could have been destroyed in the
mean time.

3 years agoagent: don't allocate large arrays on the stack
Fabrice Bellet [Sun, 6 Dec 2020 18:12:48 +0000 (19:12 +0100)]
agent: don't allocate large arrays on the stack

3 years agoudp-turn: don't allocate large arrays on the stack
Fabrice Bellet [Sun, 6 Dec 2020 18:09:33 +0000 (19:09 +0100)]
udp-turn: don't allocate large arrays on the stack

3 years agoagent: keep a track of the candidate refreshes being pruned
Fabrice Bellet [Mon, 6 Jul 2020 11:53:44 +0000 (13:53 +0200)]
agent: keep a track of the candidate refreshes being pruned

Refreshes with zero lifetime sent over tcp transport may cause the
removal of the underlying socket when the remote peer closes the
connection taking our request into account. These refreshes must be
tracked and freeed on our side to avoid retransmission attempt on a
closed socket and a heap-use-after-free error in that case.

3 years agointerfaces: Skip special interfaces on Apple OSes
Ole André Vadla Ravnås [Mon, 19 Apr 2021 19:05:51 +0000 (21:05 +0200)]
interfaces: Skip special interfaces on Apple OSes

Including unused utun devices.

3 years agointerfaces: Skip special interfaces on Apple OSes
Ole André Vadla Ravnås [Mon, 19 Apr 2021 19:05:51 +0000 (21:05 +0200)]
interfaces: Skip special interfaces on Apple OSes

Including unused utun devices.

3 years agogitlab-ci: Accept double pipeline otherwise MRs arent mergeable
Olivier Crête [Tue, 20 Apr 2021 00:06:37 +0000 (20:06 -0400)]
gitlab-ci: Accept double pipeline otherwise MRs arent mergeable

3 years agogitlab-ci: Stop base msvc build on msys
Olivier Crête [Mon, 19 Apr 2021 23:50:21 +0000 (19:50 -0400)]
gitlab-ci: Stop base msvc build on msys

3 years agogitlab-ci: Mark all tasks as interruptible
Olivier Crête [Mon, 19 Apr 2021 23:35:42 +0000 (19:35 -0400)]
gitlab-ci: Mark all tasks as interruptible

3 years agogitlab-ci: Move pacman setup to before_script
Olivier Crête [Mon, 19 Apr 2021 23:10:13 +0000 (19:10 -0400)]
gitlab-ci: Move pacman setup to before_script

3 years agogitlab-ci: Run meson, ninja and meson test separately
Olivier Crête [Mon, 19 Apr 2021 22:09:04 +0000 (18:09 -0400)]
gitlab-ci: Run meson, ninja and meson test separately

3 years agogitlab-ci: Just skip the msys global upgrade
Olivier Crête [Mon, 19 Apr 2021 20:48:40 +0000 (16:48 -0400)]
gitlab-ci: Just skip the msys global upgrade

3 years agogitlab-ci: Update to 2021-02-04 Windows image
Olivier Crête [Mon, 19 Apr 2021 20:33:03 +0000 (16:33 -0400)]
gitlab-ci: Update to 2021-02-04 Windows image

3 years agogitlab-ci: Verify that allow-edit is set
Olivier Crête [Mon, 19 Apr 2021 20:37:31 +0000 (16:37 -0400)]
gitlab-ci: Verify that allow-edit is set

3 years agoagent: reset remote credentials when restarting ice
Fabrice Bellet [Sun, 21 Feb 2021 10:10:12 +0000 (11:10 +0100)]
agent: reset remote credentials when restarting ice

The remote credentials recorded in the streams should be reset,
in the case the restarted conncheck begins with new remote candidates
*before* the updated remote credentials are received.

3 years agoagent: transition to state gathering when restarting ice
Fabrice Bellet [Sun, 21 Feb 2021 10:06:00 +0000 (11:06 +0100)]
agent: transition to state gathering when restarting ice

The state of the component is downgraded to gathering state, so it can
really restart a new conncheck from scratch. It'll transition to state
connecting when receiving the updated remote candidates.

3 years agoagent: don't change agent role when restarting ice
Fabrice Bellet [Sun, 21 Feb 2021 10:04:14 +0000 (11:04 +0100)]
agent: don't change agent role when restarting ice

Ice restart must not change the role of the agents since RFC8445,
section 9, "ICE Restarts".

3 years agoAdd (in) annotation to buf_len argument
demotomohiro [Thu, 4 Mar 2021 11:24:33 +0000 (20:24 +0900)]
Add (in) annotation to buf_len argument

3 years agogst: Fix gst-env and libgstreamer-full.so suppport
Nicolas Dufresne [Fri, 5 Mar 2021 02:18:47 +0000 (21:18 -0500)]
gst: Fix gst-env and libgstreamer-full.so suppport

gst-build uses meson introspection and reads the plugins array of each
subproject in order to locate the plugins. Setting libnice plugins array allow
enabling nice plugin in both gst-env.py and when building single library
libgstreamer-full.so.

3 years agointerfaces: Accept only IPv4/IPv4 addresses using ioctl() method
Olivier Crête [Thu, 25 Feb 2021 19:37:37 +0000 (14:37 -0500)]
interfaces: Accept only IPv4/IPv4 addresses  using ioctl() method

Android now spits other address types too confusing libnice.

This patch is a collaborative work with Tom Gilbert <twcgilbert@gmail.com>

3 years agogitlab-ci: Lock meson to 0.56.2
Olivier Crête [Tue, 16 Feb 2021 18:01:17 +0000 (13:01 -0500)]
gitlab-ci: Lock meson to 0.56.2

3 years agointerfaces: Fix small warnings on Win32
Olivier Crête [Tue, 16 Feb 2021 17:37:22 +0000 (12:37 -0500)]
interfaces: Fix small warnings on Win32

3 years agoUse a namespace http://www.w3.org/2001/XInclude instead of a deprecated one
Lemures Lemniscati [Wed, 6 Jan 2021 13:03:16 +0000 (22:03 +0900)]
Use a namespace w3.org/2001/XInclude instead of a deprecated one

Avoid to use a deprecated namespace http://www.w3.org/2003/XInclude

3 years agoUse https instead of http as far as possible in README
Lemures Lemniscati [Wed, 6 Jan 2021 13:33:05 +0000 (22:33 +0900)]
Use https instead of http as far as possible in README

3 years agoUse https instead of http in libnice-docs.xml
Lemures Lemniscati [Wed, 6 Jan 2021 13:33:03 +0000 (22:33 +0900)]
Use https instead of http in libnice-docs.xml

3 years agotest-fallback: fix stack buffer overflow with new candidate API
Fabrice Bellet [Thu, 24 Sep 2020 19:12:10 +0000 (21:12 +0200)]
test-fallback: fix stack buffer overflow with new candidate API

3 years agoagent: reject addition of peer-reflexive remote candidates
Fabrice Bellet [Fri, 20 Nov 2020 21:17:09 +0000 (22:17 +0100)]
agent: reject addition of peer-reflexive remote candidates

Peer-reflexive candidates are not supposed to be set by the application,
since they are not exchanged in the SDP.

3 years agodiscovery: use the address of a relayed candidate for its foundation
Fabrice Bellet [Thu, 16 Apr 2020 18:09:59 +0000 (20:09 +0200)]
discovery: use the address of a relayed candidate for its foundation

According to the RFC, the base address of a relayed candidate is that
candidate itself. This precision is interesting and not just
anecdotical, since it allows the relayed candidates from the same turn
server to share the same foundation, and to not be tested concurrently.

However, since the base address in its current form is required to
compute a unique priority, we choose the keep the
candidate->base_address for this purpose, and to apply the RFC
consequence about relay candidate base being equal to the candidate
itself in the foundation assignment instead.

3 years agodiscovery: remove turn refresh after discarding relay candidate
Fabrice Bellet [Sun, 19 Apr 2020 15:22:35 +0000 (17:22 +0200)]
discovery: remove turn refresh after discarding relay candidate

When a redundant relay candidate is discarded, a turn refresh with zero
lifetime must be sent to release its allocation on the turn server.

3 years agodiscovery: redundant candidates should have the same transport
Fabrice Bellet [Fri, 8 May 2020 20:44:35 +0000 (22:44 +0200)]
discovery: redundant candidates should have the same transport

When dropping redundant server-reflexive and relay candidates, they
should of course have the same transport too.

3 years agodiscovery: use a single server reflexive and relay local candidate
Fabrice Bellet [Wed, 26 Feb 2020 19:46:56 +0000 (20:46 +0100)]
discovery: use a single server reflexive and relay local candidate

The rationale with this patch is that an agent running on a multihomed
host have no gain to store multiple identical server reflexive and relay
local candidates (those obtained by a stun bind request sent from each
local interface). The stun requests that use the same default route are
all expected to provide the same answer.

This patch should keep intact the ICE conncheck versatility, and
drastically improve the conncheck time to completion, as the number of
checked pairs is reduced.

3 years agointerfaces: skip unhandled interface families early
Fabrice Bellet [Sat, 26 Sep 2020 17:46:04 +0000 (19:46 +0200)]
interfaces: skip unhandled interface families early

We handle interfaces of type AF_INET or AF_INET6 only, so discard other
families before calling sockaddr_to_string() on them, for example
PF_PACKET.

3 years agoagent: set component is state gathering earlier
Fabrice Bellet [Mon, 1 Jun 2020 19:40:59 +0000 (21:40 +0200)]
agent: set component is state gathering earlier

This patch avoids to bypass state gathering, with transition
from disconnected to connecting.

3 years agocandidate: fix unused variable
Fabrice Bellet [Mon, 7 Sep 2020 19:51:04 +0000 (21:51 +0200)]
candidate: fix unused variable

3 years agoagent: implement support for RFC7675 - Consent Freshness
Matthew Waters [Tue, 15 Sep 2020 04:54:00 +0000 (14:54 +1000)]
agent: implement support for RFC7675 - Consent Freshness

Specified in https://tools.ietf.org/html/rfc7675

RFC 7675 is a slight modification of the existing keepalive connection
checks that could be enabled manually or were used with the GOOGLE
compatibility mode.

Slight differences from the existing keepalive connection checks
include:
- an additional consent expiry timer instead of relying on all binding
  requests to succeed.
- 403: 'Forbidden' stun error-code which revokes consent with immediate
  effect.

3 years agointerfaces: IPv6 addresses can have a scope and be very long
Olivier Crête [Wed, 18 Nov 2020 00:14:46 +0000 (19:14 -0500)]
interfaces: IPv6 addresses can have a scope and be very long

Just put a much larger buffer for this to work.

Fixes #126

3 years agoconncheck: fix a buggy state transition
Fabrice Bellet [Mon, 23 Nov 2020 21:53:45 +0000 (22:53 +0100)]
conncheck: fix a buggy state transition

The previous patch handling tcp disconnections forgot a case when the
selected pair is removed, while in state ready, and in that situation,
we should not jump back to connecting state, but fail instead. Just like
we did at the beginning of the function.

3 years agoagent: report duplicated port in udp bsd sockets too
Fabrice Bellet [Sat, 26 Sep 2020 15:02:12 +0000 (17:02 +0200)]
agent: report duplicated port in udp bsd sockets too

This patch fixes cases, where the range is full, some ports fail with
HOST_CANDIDATE_CANT_CREATE_SOCKET, other fail with
HOST_CANDIDATE_DUPLICATE_PORT, the value of res we keep when leaving the
loop is randomly the one of the last iteration of the loop.

CANT_CREATE_SOCKET still happens when trying to create an udp bsd socket
with the same address and port than one of another component, so it is
also a case of duplicate port in fact.

To be homogeneous, we add a gerror for nice_udp_bsd_socket_new(), like
we did in nice_tcp_passive_socket_new(), and we can catch the same
G_IO_ERROR_ADDRESS_IN_USE there too, when failing to get free available
udp ports.

This patch is a complement to merge request !158

3 years agoconncheck: better handle remote tcp disconnection
Fabrice Bellet [Mon, 23 Nov 2020 21:53:45 +0000 (22:53 +0100)]
conncheck: better handle remote tcp disconnection

With this patch, we handle tcp disconnections in a more robust way.
Such disconnections cause the underlying socket to be detached, and
various related pairs have to be discarded from the conncheck list.
This may cause unexpected behaviour, like a previously connected
component to come back in state connecting, if the selected pair
is concerned by a tcp disconnection for example.

3 years agocomponent: Fix potential NULL deference
Olivier Crête [Mon, 26 Oct 2020 14:54:37 +0000 (10:54 -0400)]
component: Fix potential NULL deference

This was introduced recently and flagged by Coverity.

3 years agogitlab-ci: mingw now works, so dont allow failure
Olivier Crête [Wed, 21 Oct 2020 22:42:37 +0000 (18:42 -0400)]
gitlab-ci: mingw now works, so dont allow failure

3 years agogitlab-ci: Download an updated keyring
Olivier Crête [Wed, 21 Oct 2020 21:59:55 +0000 (17:59 -0400)]
gitlab-ci: Download an updated keyring

The keyring in our base image is outdated.

3 years agogitlab-ci: Limit ninja to 1 job on mingw
Olivier Crête [Wed, 21 Oct 2020 22:17:47 +0000 (18:17 -0400)]
gitlab-ci: Limit ninja to 1 job on mingw

3 years agogitlab-ci: Switch to new Windows v13-master Windows image
Olivier Crête [Wed, 21 Oct 2020 20:08:01 +0000 (16:08 -0400)]
gitlab-ci: Switch to new Windows v13-master Windows image

3 years agogitlab-ci: Kill all msys tasks after upgrading
Olivier Crête [Thu, 25 Jun 2020 18:36:27 +0000 (14:36 -0400)]
gitlab-ci: Kill all msys tasks after upgrading

Also don't fail the first iteration of upgrade

Solution found by Jordan Petritis

3 years agogitlab-ci: Disable trigger again
Olivier Crête [Wed, 21 Oct 2020 19:47:49 +0000 (15:47 -0400)]
gitlab-ci: Disable trigger again

3 years agoconncheck: add stun transaction id of stun ping response in debugging logs
Chi Liu [Thu, 3 Sep 2020 21:08:52 +0000 (17:08 -0400)]
conncheck: add stun transaction id of stun ping response in debugging logs