177 Commits

Author SHA1 Message Date
Kevin Wang
4b50bc8078 Add support for renomination 2025-08-25 10:44:44 -04:00
Kevin Wang
be0657f17b Fix lint errors 2025-08-16 23:35:36 -04:00
Sean DuBois
2c04474e38 Implement ICE Role conflict resolution
Detect if remote has a role conflict and resolve it as defined by
RFC 8445 section-7.3.1.1

Resolves #359
2025-07-17 12:42:47 -04:00
sirzooro
dd072edae9 Pass LoggerFactory to dtls and mdns (#772) 2025-04-12 19:09:54 +02:00
oto313
37fb5d2fc3 Always send KeepAlives (#767)
Pion incorrectly resets the consent timer when sending any traffic. 
The consent timer must only be reset on STUN traffic.

RFC 7675
> Consent expires after 30 seconds.  That is, if a valid STUN binding
> response has not been received from the remote peer's transport
> address in 30 seconds, the endpoint MUST cease transmission on that
> 5-tuple.  STUN consent responses received after consent expiry do not
> re-establish consent and may be discarded or cause an ICMP error.
2025-03-17 14:06:54 -04:00
cnderrauber
f92d05f17c Add Req/Res count/time to candidate stats (#763)
These details will provide information for
connectivity issue.
2025-02-27 12:57:32 +08:00
Joe Turki
d21ae5e0e5 Include ufrag in generated ICE candidates
Include ufrag extension in the ICE candidates generated by the ICE agent
2025-01-30 23:42:03 -06:00
Joe Turki
cad1676659 Upgrade golangci-lint, more linters
Introduces new linters, upgrade golangci-lint to version (v1.63.4)
2025-01-17 08:21:15 -06:00
WofWca
8b8fffdc3c Use named return val for IP/if filter
This should make it clear that you need to return `true`
to keep it and `false` to exclude.

Relates to pion/webrtc#2958
2024-11-26 10:48:44 -05:00
Raja Subramanian
9407bb0d2a Accept use-candidate unconditionally for ice-lite (#739)
There could be a mismatch between the two ends in candidate priority
when using peer reflexive. It happens in the following scenario

1. Client has two srflx candidates.
   a. The first one gets discovered by LiveKit server as prflx.
   b. The second one gets added via ice-trickle first and then
      gets a STUN ping. So, it is srflx remote candidate from
      server's point-of-view.
2. This leads to a priority issue.
   a. Both candidates have same priority from client's point-of-view
      (both are srflx).
   b. But, from server's point-of-view, the first candidate has
      higher priority (prflx).
3. The first candidate establishes connectivity and becomes
   the selected pair (client is ICE controlling and server is
   ICE controlled, server is in ICE lite).
4. libwebrtc does a sort and switch some time later based on RTT.
   As client side has both at same priority, RTT based sorting
   could make the second candidate the preferred one.
   So, the client sends useCandidate=1 for the second candidate.
   pion/ice does not switch because the selected pair is at
   higher priority due to prflx candidate.
5. STUN pings do not happen and the ICE connection eventually fails.

ICE controlled agent should accept use-candidate unconditionally if
it is an ICE lite agentt.
Just in case existing behaviour is needed, it can be configured
using `EnableUseCandidateCheckPriority`.

NOTE: With aggressive nomination, the selected pair could change
a few times, but should eventually settle on what the controlling
side wants.
2024-10-31 11:05:14 +05:30
Raja Subramanian
2d9be9b7bc Add round trip time measurement to candidate pair (#731)
* Add round trip time measurement to candidate pair

Use the round trip time measurement to populate RTT fields in
CandidatePairStats.

Atomic and tests

* Use int64 nanosecnods to make atomic easier
2024-09-16 23:59:57 +05:30
Pion
bf68674e63 Update CI configs to v0.11.15
Update lint scripts and CI configs.
2024-08-16 12:26:32 -04:00
Sean DuBois
5d9b189feb Take TCP Family into account before connecting
Before if a user disabled TCPv6 (but enabled TCPv4) we would incorrectly
start TCP connections over TCPv6 still.

Resolves pion/webrtc#2782
2024-08-14 14:56:22 -04:00
Sean DuBois
39c90d8419 Upgrade dtls, turn and sturn
New major version of dtls causes API breaks on three packages
2024-08-12 11:43:44 -04:00
Eric Daniels
28cf1cd9f3 Allow multiple agent.Close 2024-08-05 21:59:05 -04:00
Eric Daniels
a0385eec1a Add GracefulClose 2024-07-25 15:02:45 -04:00
Sean DuBois
89093bb75b Revert "Cleanly close agent goroutines"
This reverts commit d8341e71ae.
2024-07-15 12:19:01 -04:00
Eric Daniels
d8341e71ae Cleanly close agent goroutines 2024-07-02 10:40:52 -04:00
Sean DuBois
07b74c8a97 Add BindingRequestHandler
Allow the user to perform custom processing for inbound STUN Binding
requests. This allows users to do some of the following

* Log incoming Binding Requests for debugging
* Implement draft-thatcher-ice-renomination
* Implement custom CandidatePair switching logic

Resolves pion/webrtc#2539
Resolves pion/webrtc#2585
Resolves #623
2024-05-01 23:28:44 -04:00
Paul Wells
a834f55f2d Remove pessimistic String calls for low level logs (#687) 2024-04-21 01:55:26 -07:00
Paul Wells
6f743e393f Handle timer stop race in agent connectivity check (#677) 2024-04-15 19:52:48 -07:00
Paul Wells
00621672bd Reuse connectivity check ticker (#676) 2024-04-13 13:17:50 -07:00
Stephan Rotolante
edaa25e409 Expose stunGatherTimeout in Agent struct (#668) 2024-04-02 23:17:51 -04:00
Eric Daniels
39c0392295 Support IPv6 from mDNS 2024-03-27 12:47:20 -04:00
Steffen Vogel
fdca6c47c0 Move taskloop into dedicated package
Reduce size of Agent and simplify code
2024-03-22 20:09:57 -04:00
Sean DuBois
b36d33253b Remove afterRun from Task Loop
Not needed anymore since we have Notification Queues
2024-03-22 20:09:57 -04:00
Sean DuBois
d17be4df3b Use Notification Queue from 67cc918a51 more
Deliver Candidates and Selected CandidatePairs using the same queue.
This means that things are delivered in order and we don't have to worry
about blocking
2024-03-21 10:09:03 -04:00
sukun
67cc918a51 Fix ConnectionState being reported out of order
Before we launched a goroutine to announce every ConnectionState change
to users. These could then be sent to the user out of order.

This commit adds a connectionStateNotifier. The connectionStateNotifier
delivers them sequentially to the user.

Resolves #624
2024-03-20 14:07:55 -04:00
Sean DuBois
5fcf0380e7 Update module github.com/pion/mdns to v2
Generated by renovateBot
2024-03-19 11:19:01 -04:00
Sean DuBois
2d7ced1d49 Fix linter errors
golangci-lint upgrade to v1.56.2 added more checks

Relates to pion/.goassets#201
2024-03-15 22:25:46 -04:00
Raja Subramanian
c8227261a2 Trace log inbound messages (#641)
* Trace log inbound messages

On an ICE restart in controlled mode, seeing incoming messages
getting discarded to due to username mismatch. That is because the
broswer is still using its old candidate and user name. As the
controlled agent waits for `useCandidate` from the controlling agent,
the controlled agent does not get to connected/nominated state inspite
of getting several success responses. Suspect the controlling side does
not have `useCandidate` for the new pair and it is still sending it for
the old pair. Logging more details in trace to understand it better.

* Fix test
2024-01-11 13:46:39 +05:30
renovate[bot]
8d69e9ecd8 Update module github.com/pion/stun to v2
Generated by renovateBot
2023-09-08 14:25:52 -04:00
renovate[bot]
d21edf9690 Start pion/ice@v3
This is required to update pion/transport/v2 to v3

The public API of transport changed, and we expose transport as part of
our public API.
2023-09-03 23:51:36 -04:00
Raja Subramanian
c62fd28aa8 Clear selected pair on ICE failed (#612)
When ICE times out and fails, all candidates are deleted.

That means all the candidates are closed and their underlying
conns are clsoed.

But, the selected pair could still be valid. On a subsequenct
`Write`, ICE transport conn will get the selected pair and
write to the pair. As the pair is still valid, write will
flow through to the local candidate `writeTo`.

But, as all candidates and their underlying conns are closed,
`Write` will return a `io.ErrClosedPipe` error.

There are cases where it is not ignored and causes a broken
pipe after an ICERestart.

When the `Write` error propagates back to sctp/association,
the writeLoop is exited.

So, sending data channel traffic after a successful ICERestart
still fails as the SCTP association errored out and write loop exited.

I have copied the changes that are done when ICERestart happens
to when ICE state is set to failed (except for gathering state
and resetting ufrag/pwd). In my testing, it is working well,
i. e. can continue data channel after ICE Restart whereas
previously it was failing every time. But, I am not sure of all
the implications of this change.

Update authors

Update AUTHORS.txt
2023-09-02 22:59:39 +05:30
Steffen Vogel
ef637050e2 Add GetRemoteCandidates()
This is analogue to GetLocalCandidates() and provides
the user with the ability to get a slice of previously added
remote candidates without keeping track of them in the
application code.
2023-07-04 11:28:15 +02:00
Steffen Vogel
53beccaed5 Harmonize capitalization of log messages 2023-07-04 05:15:54 +02:00
Sean DuBois
db5d7ea72b Implement Active ICE TCP Candidates
Co-authored-by: Steffen Vogel <post@steffenvogel.de>
Co-authored-by: Artur Shellunts <shellunts.artur@gmail.com>
2023-06-15 21:44:21 -04:00
Sean DuBois
abc1ca33b5 Revert active TCP candidate support
This reverts commit 00bbd2954c
and 1d502ca6ec
2023-05-24 00:05:44 -04:00
Steffen Vogel
00bbd2954c Minor style fixes for active TCP candidate support 2023-05-16 20:07:39 +02:00
Artur Shellunts
1d502ca6ec Implement active TCP candidate type (RFC6544)
By default TCP candidate type priority is UDP one minus 27 (except
relay), so that UDP+srlfx priority > TCP+host priority. That priority
offset can be configured using AgentConfig.
IPv6 TCP candidates are also supported.
2023-05-15 22:41:52 +02:00
Steffen Vogel
898746c1f5 Invoke handlers from their own Goroutines 2023-05-15 08:00:41 +02:00
Steffen Vogel
c2756c121d Change type of ConnectionState constants 2023-05-10 16:33:20 +02:00
Steffen Vogel
ca9de18fd6 Move URL type to pion/stun.URI 2023-05-10 16:33:20 +02:00
Steffen Vogel
ecfb354131 Fix capitalization of log messages
Log messages must start with an upper case letter
2023-04-20 22:15:07 +02:00
Steffen Vogel
b37a5a34eb Change working for logging errors 2023-04-20 22:15:07 +02:00
Steffen Vogel
d660d61495 Move Agent handler related code to separate file 2023-04-20 22:15:07 +02:00
Steffen Vogel
96ef175a89 Remove duplicated code in Agent: closeMDNSConn() 2023-04-20 22:15:07 +02:00
Steffen Vogel
c596a7cc2b Simplify handling if no TCP mux is configured 2023-04-19 14:40:56 +02:00
Steffen Vogel
f40dd65abb Fix comment capitalization
Comments should start with an uppercase letter.
2023-04-18 19:38:54 +02:00
San9H0
f07b6d16ad Add RemoteCandidateCache for better performance
Check sourceAddress from first packet validation of STUNTraffic.
If validation is true, store it in the cache.
Use cache for performance.
2023-04-18 19:20:52 +02:00