Commit Graph

107 Commits

Author SHA1 Message Date
Sean DuBois
325b7f711d Request connectivity checks on new local candidate
Match behavior of adding a remote candidate

Relates to pion/webrtc#767
2020-01-29 22:56:01 -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
2d60776193 Add MulticastDNSHostName to AgentConfig
Allow users to pass in a static MulticastDNSHostName, this can be used to
connect peers in a LAN without signaling. If you set a static uFrag/uPwd
on either side and have a static hostname you can gather without knowing
an IP Address on either side.
2019-12-08 20:04:29 -08:00
Nevio Vesic
a077bc201a Allow setting local credentials via AgentConfig
Add local credential support to the AgentConfig and
validate credentials per RFC standard. If no credentials
are passed we still generate random ones ourselves.
2019-11-08 01:09:08 -08:00
Sean DuBois
e161aa966e Update to pion/transport@v0.8.10
Tests now assert for routine leaks on startup as well
2019-10-31 09:54:40 -07:00
Jason Maldonis
34ef65fcea Lifetime instead of length for binding requests
Before we have a hard limit of 50, this will fall down if users
has more local/remote candidates then we expect.

Resolves #122

Co-authored-by: Sean DuBois <sean@siobud.com>
2019-10-15 21:59:32 -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
Zizheng Tai
ae2f2877cb Fix typo
Change a few "Sucess" to "Success".
2019-09-07 02:46:01 -04:00
Sebastian Waisbrot
953f36f07f Add config to run Agent in Lite mode
Allow the agent to run in Lite mode. This is useful in
cases where you never want connectivity checks, and reduces
possible attacks surfaces when you have a public IP.
2019-09-02 16:13:08 -07:00
Hugo Arregui
a4f1e92eb7 Avoid agent.run for getSelectedPair
Use a RWMutex instead
2019-08-13 18:09:22 +00:00
Sean DuBois
372175cca4 Do connectivity check when candidate is added
When trickle is enabled do a connectivity check everytime a candidate
is added. Because we have a new candidate there is a chance we could
have a success this time.
2019-08-01 18:26:17 -07:00
Atsushi Watanabe
0f5c553070 Fix Ticker leak
time.Ticker leaks if not Stop()-ed after use.
Close connectivity interval ticker on Agent.Close() to fix leak.
2019-08-01 07:21:42 -07:00
Sean DuBois
5a812008b1 If mDNS fails to listen fallback to non-mDNS
If we are unable to bind continue Agent startup but without mDNS.
Log an error to help debugging
2019-07-22 10:06:21 -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
d2d97a6293 Add nominated flag to candidate pair stats
This way we can identify, between the valid candidate, which one has
been nominated.
2019-06-28 04:05:21 +00: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
Hugo Arregui
1ff70e0ee1 Initial stats
Add basic candidate and candidate pair stats
2019-06-22 11:55:06 +00:00
Hugo Arregui
da599f54ff CandidatePairState is public now
Use more appropiate naming
2019-06-22 11:55:06 +00:00
Sean DuBois
935aca0809 Shutdown mDNS Connection once connected
Close the connection when we have connected. There is no
benefit to leaving it open, but some risk. This allows
us to avoid fingerprinting and port exhaustion that might
come up when running lots of peers

Relates to pion/webrtc#699
2019-06-21 20:22:21 +08: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
Hugo Arregui
165d04e58f Use binding request for keepalive
instead of indication (to support consent refreshness)
2019-06-03 21:48:44 -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
Hugo Arregui
bf57064619 Improve nomination
This implements a basic validation schema using a checklist. We try
every pair at least maxTries, and mark it as failed if we don't get a
success response after that many requests. Once we get a success
response, we check if it belongs to the best candidate available so far,
if it does we nominate it, otherwise we continue.

Also, after a given timeout, if no candidate has been nominated, we
simply choose the best valid candidate we got so far (if no candidate is
valid, we mark the connection as failed).

Finally, the nomination request also has a maximum of maxTries, we mark
the connection as failed if after that many attempt we fail to get a
success response.
2019-06-01 00:54:16 -07: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
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
Konstantin Itskov
e928d7b932 Add trickle support
Resolves #51
2019-05-27 01:23:34 -07:00
Sean DuBois
ef86b93272 Add CandidateTypes to AgentConfig
Allow users to specify CandidateTypes, this allows us to support
IceTransportPolicy in pion/webrtc
2019-05-25 15:57:39 -07:00
Sean DuBois
63b37975b6 Make Candidate an interface
This change will allow us to have custom logic and members
per interface type. Relay candidates will have a completely different
read loop, and candidate specific state.

Relates to #47
2019-05-24 15:55:42 -07:00
Aleksandr Razumov
35330ae9e7 Use merged pion/stun instead of gortc/stun
The only thing that should be changed after complete merge is version
2019-05-21 15:53:04 -07:00
Aleksandr Razumov
d895187fa4 Prepare for stun v2
Using github.com/gortc/stun for now.
Should be easy to change it later.
2019-05-21 15:53:04 -07:00
Sean DuBois
05cad45711 Emit Closed via ConnectionStateCallback
When Close is called on an agent emit 'Closed'
to the connection state callback

Resolves #39
2019-05-09 08:45:11 -07:00
Hugo Arregui
05a28b3ee3 Handle INDICATION messages
Handle keepAlive messages
2019-05-04 09:30:50 -07:00
Hugo Arregui
cafd8d7860 Implement regular nomination
In this first iteration we nominate the first valid pair we found.
2019-05-02 14:32:27 -03:00
Hugo Arregui
ea5cdd03c0 Refactor handleInboundControlling/Controlled
Both methods pretty much do the same
2019-04-29 00:09:49 -03:00
Sean DuBois
5ca0eeb721 Assert bindingSuccessResponse is non-symmetric
We previously didn't correctly follow [0] This updates
the agent to assert that a bindingSuccessResponse is
for the address it was sent too.

https://tools.ietf.org/html/rfc8445#section-7.2.5.2.1
2019-04-28 17:53:21 -07:00
Sean DuBois
bb69dcb592 Assert that agent isn't started twice
Check was lost, also add tests so we don't regress again
2019-04-25 16:45:38 -07:00
Hugo Arregui
4d10a30c45 Fix handleInboundBindingSuccess bug
Some transactions were lost because a small bug in indexing
2019-04-24 14:14:50 -07:00
Sean DuBois
f5e8cc510d Validate inbound success messages
Validate all inbound binding success messages, before
peers could create valid prflx candidates without doing
a full request response

Resolves #21
2019-04-17 10:03:03 -07:00
Sean DuBois
7fa75afc59 Discard non-STUN if no associated candidate
If a inbound message is not associated with a valid remote STUN
candidate discard it

Resolves #20
2019-04-15 15:37:10 -07:00
Sean DuBois
df66c58d56 Shorten agent code
Move code out of agent that is general to dedicated files, no logic
changes just moving.
2019-04-14 10:52:10 -07:00
Sean DuBois
217c656222 Assert MessageIntegrity/Username for inbound
When we get an inbound message assert these values, also discard any
other packet types besides binding. In the future we should extend to
handle inbound error messages

Resolves #19
Resolves #21
2019-04-14 01:22:18 -07:00
Sean DuBois
f58e725a2c Send connectivity checks right on agent start
Connectivity checks are done via a Ticker, the inital tick does not
happen immediately (by design) causing the startup time to be the
Duration the Ticker is created with.

This change adds another chan forceCandidateContact that can be used to
force contact at anytime. Currently it is only called on startup, but
could be useful in the future for reuse.

Resolve #15
2019-04-13 11:31:04 -07:00
Michael MacDonald
ad7c8697fd Candidate priority is incorrectly calculated
Some constants were being incorrectly generated using 2^N (XOR)
instead of 1 << N. This resulted in incorrect candidate priorities
being used to evaluate candidate pairs.

Resolves #14.
2019-04-11 13:40:39 -04:00
Sean DuBois
7245ac0866 Don't modify config.LoggerFactory
Avoid possible data race
2019-04-06 14:06:58 -07:00
Sean DuBois
af1bcf662b Mass replace pions -> pion
Pions organization was renamed to pion
2019-04-04 14:22:31 -07:00
Hugo Arregui
91d046483f Update pions/logging to v0.2.0
Support custom loggers
2019-04-01 10:44:36 -03:00
Sean DuBois
3580f6234f Return typed error when no candidate pairs
Returning a typed error allows us to handle it gracefully in
pions/webrtc
2019-03-26 00:50:44 -07:00
Sean DuBois
8b4aeeaa8d Docs: Add readme and CI
Added the readme and CI using the common style.
2019-03-25 16:04:12 -07:00