This change maintains full backward compatibility while adopting
modern Go type alias conventions for better code clarity.
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Add network to resolve stun host error message
Most error message in gatherCandidatesSrflx and
gatherCandidatesSrflxUDPMux include the network in
them but not the one when failing to Resolve the host.
Today, all relay candidates from Pion have the same priority.
This PR attempts to reproduce libwebrtc's behavior, where the
TURN servers candidates priority is based on the underlying
relay protocol. UDP are preferred over TCP, which are preferred
over the TLS options.
Currently, when using UDPMuxDefault with unspecified address,
the loopback address is included by default, but
agentConfig.IncludeLoopback is not respected when gathering
local candidates.
The same holds true when UDPMuxDefault is configured with a loopback
address, but agentConfig.IncludeLoopback is not explicitly set to
true.
This commit adds an extra check to gatherCandidatesLocalUDPMux()
for respecting that setting in both cases.
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.
PR #496 added a mechanism to close connections of duplicate candidates
and avoid memory leaks. When UDPMuxDefault and NAT1To1IPs are used
together, candidates may share the same connection, and candidates may
be equal, since their IPs are overridden by the one specified in
NAT1To1IPs. When a duplicate candidate is found, its connection is
closed, making impossible to use any other candidate that shares the
same connection.
This PR fixes the issue as it prevents duplicate candidates from
creating connections and getting their connection closed.
Canceling previous gathering does not happen synchronously. If it takes
a little bit longer, it can close newly created `gatherCandidateDone`
channel. If we pass channel to the `gatherCandidates` function, it will
always close its done channel and only the latest done channel will be
available in `gatherCandidateDone`.
This change adapts pion/ice to use a new interface for most network
related operations. The interface was formerly a simple struct vnet.Net
which was originally intended to facilicate testing. By replacing it
with an interface we have greater flexibility and allow users to hook
into the networking stack by providing their own implementation of
the interface.
In #475, import low-level API (ReadMsgUDP) to determine
destination interface for packets received by UDPConn listen
at any(unspecified) address, to fix msg received by incorrect
candidate that shared same ufrags. But the api has compatibility
issues, also not reliable in some special network cases like
AWS/ECS.
So this pr revert that change, and make UDPMuxDefault not
accept Conn listen at unspecified address. Also provide a
NewMultiUDPMuxFromPort helper function to create a MultiUDPMux
to listen at all addresses.
For ice gather, it will use UDPMux's listen address to generate
canidates instead of create it from interfaces.
When machine's network interface have more than one ip address and
user don't want expose one of these ips to remote peer, interface
filter can't work in this case, so add a ip filter for that.
When we have multiple host candidates and mux to a
single port, if these candidates share a same conn
(either tcp or udp), they might read other's msg
cause ice connection cost long time or failed.
These wrappers allow a caller to provide UDPMux and TCPMux instances
to the ICE agent that represent multiple open ports. This can be
desirable in what would otherwise be single-port deployments, as it
increases the chance that one of the fixed ports will not be blocked
by a users firewall.
A newline is automatically added by the DefaultLeveledLogger.
The current code-base used a mix of log statements w/o endlines.
This is misleading for custom loggers.