Commit Graph

57 Commits

Author SHA1 Message Date
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
Sean DuBois
acbf5671b7 IP -> Address in public API
ICE RFC specifies this value as `Address` and not IP. We need to fix
this divergence to implement mDNS

Relates to pion/webrtc#699
2019-06-21 20:22:21 +08:00
Aleksandr Razumov
116ba6b111 Add turn client Close support
Fix the goroutine leak.
2019-06-07 20:42:39 -07:00
Sean DuBois
06c58b8883 Fix ServerReflexive race condition
We need to hold the same socket when gathering ServerReflexive
candidates. If we Open -> Close -> Open the port we have selected could
quickly be taken by another process

Resolves #63
2019-06-06 15:34:23 -07:00
Sean DuBois
98502a8695 Use net.Dialer for ServerReflexive candidates
Don't attempt to gather ServerReflexive candidates, instead use
net.Dialer. This properly chooses the correct interface, and still
respects our port restrictions

Resolves #58

Co-authored-by: Konstantin Itskov <konstantin.itskov@kovits.com>
2019-06-05 13:52:10 -07:00
Sean DuBois
cfa4fc76ee Minor checklist cleanup
Add helper function to add localCandidates. Brings down the duplication
and make sure we have a properly formed checklist when we are doing
trickle.

When comparing candidates in findPair do by value, and not address.
Before some candidates were failing to be found because of this.
2019-06-01 00:54:16 -07:00
Sean DuBois
a58a281d3a Improve Gathering error handling
Gather only asserted that it wasn't GatheringStateGathering. This
meant that if gathering was complete it would allow multiple runs.
2019-05-29 16:43:32 -07:00
Konstantin Itskov
ce0a3bd08b Modify gathering process to be parallel
resolves #55
2019-05-29 03:41:09 -04:00
Sean DuBois
2a96a308d5 Initial TURN implementation
This implementation is not fully tested, and we don't
handle all error case yet. We will continue to work on it though.

Tests for send/recv and shutdown are in the works.

Relates to #47
2019-05-27 23:30:50 -07:00
Sean DuBois
78c7f4e989 Return error from GatherCandidates
When OnCandidate handler isn't defined and trickle
is enabled return an error

Relates to #51
2019-05-27 01:23:34 -07:00
Sean DuBois
dc601c0675 Configure Agent only via AgentConfig
Update GatherCandidates to not accept any arguments, it pulls
everything from AgentConfig instead

Relates to #51
2019-05-27 01:23:34 -07:00