Commit Graph

67 Commits

Author SHA1 Message Date
Antoine Baché
45ff379fd3 Makes UDPMux IPv4/IPv6 aware
UDPMux before only worked with UDP4 traffic.
UDP6 traffic would simply be ignored.

This commit implements 2 connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Relates to pion/webrtc#1915
2022-03-02 19:02:34 +01:00
Kyle Carberry
427ac0fddb Fix goroutine leak for closing while gathering
The "gatherCandidates()" function could previously leak after
close, because the WaitGroup was left unchecked.
2022-03-01 19:53:05 -05:00
Sean DuBois
fb4760c37b Make TCPMux IPv4/IPv6 aware
TCPMux before would create one internal connection per ufrag. This could
cause remote IPv6 traffic to be dispatched to a local IPv4 handler (or
the inverse). The ice.Agent would then discard the traffic since a
candidate pair must be the same IP version.

This commit now creates two connections per ufrag. When requesting a
connection for a ufrag the user must specify if they want IPv4 or IPv6.

Relates to pion/webrtc#2125
Relates to pion/webrtc#1356
2022-02-21 08:55:50 -05:00
Mikhail Bragin
2d70ec8e3c Support UDP muxing for SRFLX candidates
The original UDPMux only works for the HOST candidates.
UniversalUDPMux adds support for SRFLX candidates
and will later support Relay candidates.
UniversalUDPMux embeds UDPMuxDefault and
handles STUN server packets to discover XORMappedAddr
forwarding the remaining packets for muxing to UDPMuxDefault.
2022-02-20 12:29:29 -08:00
hexiang
361b29a525 Update UDPMux to listen on all interfaces
Before we would only listen on the first
2021-11-16 11:25:51 -05:00
Sean DuBois
6d30128765 Revert "Remove unknown constant"
We will re-do this in the future, but need to keep it for a major
release.

Resolves #385
2021-08-11 13:09:13 -04:00
Woodrow Douglass
366757d59d Remove unknown constant
This constant tends to cause collisions with enumerations, and is
in general a source of bugs
2021-08-10 15:51:40 -04:00
Meelap Shah
1b533aee68 Populate RelayProtocol for relay candidates
The webrtc-stats spec defines this field as:
> It is the protocol used by the endpoint to communicate with the TURN
> server. This is only present for local candidates. Valid values are
> "udp", "tcp", or "tls".
https://w3.org/TR/webrtc-stats/#dom-rtcicecandidatestats-relayprotocol
2021-07-20 16:05:57 -04:00
Sam Lancia
2eafed30bb Pass ServerName to dtls.Config
Otherwise DTLS would only work if InsecureSkipVerify
was enabled
2021-07-03 14:01:44 -04:00
David Zhao
c4d5d1c670 Bypass other host candidates with UDPMux
Separate candidate gathering when UDPMux is enabled.
Only a single UDP host candidate should be generated
that points to the mux.
2021-04-25 14:07:45 -07:00
Sean DuBois
b3b84a5b0a Generalize UDP and TCP Mux
Refactor UDPMux to match TCPMux patterns. The goal is to have a
collection of mux instances and no specific UDP/TCP code

Resolves #350
2021-04-20 14:38:25 -07:00
David Zhao
f7b11daf96 Improve UDPMux performance
improved buffer handling and prevents channel clogging
2021-04-14 14:19:07 -07:00
David Zhao
86d69d6ce5 Single port handling via UDPMux
Allows for ICE to handle connections on a single UDP port
2021-04-12 20:42:10 -07:00
Assad Obaid
64a2cf0c47 Add proxy dialer interface
Enable user to implement the golang.org/x/net/proxy
dialer interface in order to have a customized dialer.
The customized dialer could be one that connect through
a corporate HTTP/HTTPS proxy.

Resolves #284
2020-10-09 12:09:21 -07:00
Pion
d3e1775d73 Update CI configs to v0.4.7
Update lint scripts and CI configs.
2020-09-26 08:54:24 -07:00
Sam Lancia
30fd1787bc Fix logging nogo warnings
Fix two nogo warnings on incorrect log format and
error wrapping operator
2020-08-27 19:45:44 -07:00
Jerko Steiner
3b9a989177 Remove global state for ICE TCP
This addresses a few points issue of #245:

 - Take a net.Listener instead of having global state
 - Expose a net.TCPMux based API

Also, the unused closeChannel was removed from tcp_mux.go

Closes #253.
2020-08-01 09:28:28 +02:00
Jerko Steiner
12f44e93f1 Add support for passive ICE TCP candidate
Closes #196
2020-07-15 07:51:55 +02:00
Atsushi Watanabe
245c513fed Fix turn client routine leak on close
Clean-up turn connection if task run failed.
2020-07-06 15:48:19 +09:00
Atsushi Watanabe
553df099a0 Prevent multiple gathering in parallel
Multiple candidate gathering routine were executed in parallel
when Restart() called immediately after previous start of gathering.
Cancel previous gathering by context to prevent mixing candidates
from two routines.
2020-07-06 14:33:02 +09:00
Atsushi Watanabe
06922c1601 Refactor agent task runner
- Control blocking tasks by context
- Add tests to check deadlock by calling Close/Restart in
  state change callback
- Remove unnecessary chan
2020-07-05 16:05:45 +09:00
Sean DuBois
caa80e3027 Don't re-create chanCandidate every gather
Instead keep the channel around the entire time, and use
the same thread to distribute state changes and candidates.

Resolves #217
Resolves #218
2020-07-03 23:05:59 -07:00
Lander Noterman
d8d3ef3aac Gather srflx candidates from turn: urls
allow gathering srflx candidates from turn: urls
2020-06-29 22:10:03 +02:00
Sam Lancia
5c1bbaa050 Gather all candidate types in parallel
This was an especially noticable issue in an environment
where all UDP was blocked, then we waited for STUN to
timeout (5 seconds) before trying TCP/turn
2020-06-28 12:49:38 -07:00
Sean DuBois
5cab987ca4 Add an additional done to Agent.run
Callers of run need to be able to cancel their waiting individually.
This would cause hung threads during restart if we attempted to close
a candidate while processing a packet for it.

Before the run would be canceled by the global close, but we can't
depend on that anymore.

Resolves #190
2020-06-25 00:16:58 -07:00
Sam Lancia
b3ade1e219 Gather: fix closable crash again
Add assert for nil pointer as well
2020-06-06 03:17:05 -07:00
adwpc
dea84cf1fb Fix closeable panic
Fix closeable panic when conn == nil
2020-04-25 15:09:59 +08:00
Atsushi Watanabe
e1e28e8a83 Fix asynchronous task processing
Make callback handler atomic/Value.
Launch candidate callback loop in gatherCandidates().
2020-04-04 16:51:42 +09:00
Atsushi Watanabe
6ee96d4632 Fix candidate/state callback order
Call callbacks serially instead of running asynchronously.
2020-04-04 12:10:58 +09:00
Sean DuBois
f1bfc8fea1 Start Agent performance refactor
Remove taskChan and make .run just take an Agent wide mutex and run the
function. These is now a blocking operation so all channels used to
communicate from it must be buffered.

After this we will slowly remove usage of .run and make things more
thread safe.

Relates to #80, #67, #2
2020-03-01 20:25:45 -08:00
Sean DuBois
bf81fb5154 Implement TLS and DTLS Gathering
Also add tests to cover.

Resolves #133
2020-02-24 21:25:32 -08:00
Sean DuBois
3e38db1ea5 Gather TURN/STUN concurrently
Each URL is gathered in a goroutine. Add tests to ensure that this
doesn't regress in the future.

Resolves #118
2020-02-23 22:05:13 -08:00
Sean DuBois
50bd9f60bd Close sockets if error during gathering
Add logic that if we hit errors close the socket
we are using that hasn't been moved into a a candidate yet.

Resolves #102
2020-02-23 22:05:13 -08:00
Sean DuBois
33bb85884f Move 1:1 mapped gathering into own function
Allows us to move all code up one level. In the future STUN/TURN will be
trickled and this change will make it easier to implement.

Relates to #118
2020-02-23 22:05:13 -08:00
Sean DuBois
086024fde6 Remove addCandidate duplication
Every caller to addCandidate does the same things. Move all this code
into addCandidate.

Relates to #118
2020-02-23 22:05:13 -08:00
Sean DuBois
9ca33c2380 Move localInterfaces and listenUDPInPortRange
Move more code out of the agent that doesn't actually require any state
from the ICE Agent.

Relates to #118
2020-02-23 22:05:13 -08:00
Sean DuBois
11318ea39f Cleanup gather code
Simplify tests and use assert where possible. Move all generic code out
of gather.go into util.go

Relates to #118
2020-02-23 22:05:13 -08:00
Atsushi Watanabe
b8eb3d4ec4 Upgrade golangci-lint to 1.19.1
Fix whitespace error.
Disable dogsled and godox.
2020-01-11 22:58:26 -08:00
Sean DuBois
442c324a51 Bump pion/turn
Use v2, should have no client changes
2020-01-09 22:05:54 -08:00
Sean DuBois
84576aed1f Support TURN over TCP
Relates to pion/turn#1
2019-10-06 10:15:27 -07:00
Chao Yuan
b0ac6d9c37 Refactor: Use random port to gather udp candidate
This speed up the gather progress if many connections existed
2019-10-02 00:23:34 -07:00
Aaron France
36f3009418 Add InterfaceFilter to AgentConfig
This callback can be used to exclude interfaces from
gathering.

Relates to pion/webrtc#843
2019-09-25 00:45:21 -07:00
Yutaka Takeda
867a355033 Support 1:1 NAT option
Relates to pion/webrtc#835
2019-09-24 11:51:07 -07:00
Hugo Arregui
2a0747d42d Fix connection nil pointer
Don't assume connection is present if there is an error in listenUDP
2019-09-07 02:42:10 -04:00
Hugo Arregui
358dc33274 Start a candidate before adding it
This way we ensure the connection will be already present when the
candidate is in the checklist
2019-08-07 18:50:30 +00:00
Sean DuBois
8508d5a6b3 More error handling around interface iteration
If we can't iterate host interfaces give a warning to the user.
Also don't bail early if a single interface fails, other interfaces
might still be in a good condition.

Resolves pion/ice#75
2019-07-18 10:11:34 -07:00
Yutaka Takeda
a1667f5cb7 Fixed unexpected goroutine error
TURN client's loc conn was not closed when agent.Close() was called
Relates to pion/webrtc#740
2019-07-17 11:12:26 -07:00
Hugo Arregui
b3e05469f0 Add vnet support with the new pion/turn client
Relates to pion/webrtc#712
2019-07-15 01:00:21 -07:00
Hugo Arregui
77a03cd608 Use config to create candidate
Use config objects to create candidates + add optional candidateID
2019-06-25 19:30:23 +00:00
Sean DuBois
0116bdd649 Add mDNS Host Candidate support
Relates to pion/webrtc#699
2019-06-21 20:22:21 +08:00