41 Commits

Author SHA1 Message Date
Xiaobo Liu
f6a1153ce7 Optimize slice allocation in UDPMuxDefault
Pre-allocate localAddrsForUnspecified slice with known capacity
and use index assignment instead of append to avoid multiple
slice reallocations.

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
2025-07-07 23:05:14 -04:00
Xiaobo Liu
eef8d96d36 Replace interface{} with any type alias
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>
2025-06-14 16:52:30 +08: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
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
Paul Wells
b5f4ca01ae Remove pessimistic String calls for low level logs 2024-04-30 23:59:23 -07:00
Paul Wells
75ca3a2c3a Skip UDP address serialization in muxed conn (#688) 2024-04-30 03:23:43 -07:00
Eric Daniels
39c0392295 Support IPv6 from mDNS 2024-03-27 12:47:20 -04:00
sebapeti
66051b6877 Improve performance of UDPMux map lookups
UDPMux is using a map to lookup addresses of each packets.
Unfortunately the key is based on a string and each time we
want to check the map, a conversion of the UDP address to string
is made (.String()) which is expensive.

This CR replace the string key by a binary key called ipPort. This
structure contains a netip.Addr field and ipPort could be used as
a map key
2024-03-25 12:48:50 -04:00
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
Steffen Vogel
53beccaed5 Harmonize capitalization of log messages 2023-07-04 05:15:54 +02:00
Steffen Vogel
f40dd65abb Fix comment capitalization
Comments should start with an uppercase letter.
2023-04-18 19:38:54 +02:00
Steffen Vogel
5ef81b65f4 Make package REUSE compliant 2023-04-18 13:46:38 +02:00
Steffen Vogel
69c6b0ee66 Add comment to new Net field in UDPMuxParams
To describe its purpose.
2023-02-08 21:58:49 +01:00
Steffen Vogel
0194bd6ce8 Use new pion/transport Net interface
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.
2023-02-08 21:58:49 +01:00
cnderrauber
e90a58e51a Add option to include loopback candidate
Add option to include loopback candidate
2022-11-22 17:07:31 +08:00
Steffen Vogel
d415139840 Refactor variable names from buffer to buf
Go encourages short names. And a quick
survey through the Pion code bases reveals,
that we have been using buf more often than buffer.
So this change will harmonize the different spellings.
2022-11-13 21:56:24 +01:00
Steffen Vogel
dc5bce4401 Refactor variable names {r,s}addr to {r,s}Addr
As most variables are using camelCase.
2022-11-13 21:56:24 +01:00
cnderrauber
f7d4014f5a Revert mixup ipv4 and ipv6 connections
Revert mixup ipv4 and ipv6 connections for unspecified address
2022-10-10 20:22:30 +08:00
cnderrauber
227b290b77 Solve comments and clean code
Solve comments and clean code
2022-10-10 20:22:30 +08:00
cnderrauber
41b77f19a5 Use String to compare net address
Use String to compare net address
2022-10-10 20:22:30 +08:00
cnderrauber
a931199dc1 UDPMuxDefault accept unspecified addr with warn
UDPMuxDefault accept unspecified address with a warn log to
keep current application work.
2022-10-10 20:22:30 +08:00
cnderrauber
04a6027e93 Use MultiUDPMux to implement listen any address
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.
2022-10-10 20:22:30 +08:00
cnderrauber
af9281dc76 Fix udpmux not work on AWS/ECS
ECS network might not set destination address of udp packet
to local address, so we can't only rely on it to dispatch
packet.
2022-10-08 10:50:19 +08:00
cnderrauber
12148c5d62 Fix build failed on windows
Udp mux need retrieve destination address to dispatch received
packet when listen at Any address. Windows use winsock APIs to
get that, but conn.FD() is not implement for windows, so
dispatch packet to first candidate, not ideally, but it will
work for ice connectin, wasm will have same result too.
2022-09-27 15:59:29 +08:00
cnderrauber
93980395c8 Fix muxed conn shared by candidate
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.
2022-09-26 09:26:23 +08:00
Antoine Baché
cfc20992b4 Fix UDPMux memory leaks
Clients performing an early termination/cancelation
would cause `udpMuxedConn` to leak addresses
into `UDPMuxDefault`
2022-08-26 14:18:57 +02:00
Steffen Vogel
e32a520e4c Do not use newlines in logging statements
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.
2022-05-08 22:53:42 -04:00
Pion
16e03db8f8 Update CI configs to v0.7.2
Update lint scripts and CI configs.
2022-04-26 23:27:21 -04:00
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
Sean DuBois
d5db223420 UDPMuxParams use net.PacketConn instead of UDPConn
UDPConn satisifies the net.PacketConn interface. Allows us to pass in
structures that satisfy the interface, but aren't a UDPConn
2021-10-26 14:45:21 -04:00
cgojin
1f4e18f401 Fix UDPMux logger
If no logger is passed in, it will be created.
Error running webrtc/examples/ice-single-port :
invalid memory address or nil pointer dereference
2021-04-27 14:13:03 +08: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
Juliusz Chroboczek
894452d0c3 Use os.IsTimeout instead of os.ErrDeadlineExceeded
This fixes compilation with Go 1.13 and 1.14.
2021-04-22 09:03:35 -07:00
Sean DuBois
e6e49f59b0 Update UDPMux to dispatch inbound packets on ufrag
If we get a packet for an address we don't know dispatch it
by ufrag still.

Resolves #357
2021-04-20 22:52:35 -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
35f704e2e4 Fix UDPMux read/write race condition
Resolves #351
2021-04-19 18:36:38 -07:00
David Zhao
166ba31563 Improved performance of UDPMux
The previous implementation of UDPMux was dropping
packets due to channel usage in the critical write path.
2021-04-18 13:44:08 -07:00
David Zhao
cdb84a2dcf Remove print line
accidentally left in the last PR
2021-04-15 13:18:44 -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