Conversation
Listener and relay sockets hardcoded "0.0.0.0" + the IPv4-only network
strings "udp4"/"tcp4". On IPv4-only hosts that's fine, but on IPv6-only
hosts (e.g. IPv6-only EKS) the socket cannot be reached at all, so
TURN allocations silently fail. On dual-stack hosts (Linux default with
net.ipv6.bindv6only=0) it still works for IPv4 peers but breaks for
IPv6-only peers, including pod-to-pod traffic on IPv6-only Kubernetes.
Switch to the unspecified address (":port" / "") plus the family-neutral
network strings ("udp" / "tcp"). The kernel then opens an IPv6 wildcard
socket that accepts IPv4 (mapped) and IPv6 peers on dual-stack hosts and
the available family on single-family hosts, matching the behavior of
Go's net.Listen with no host. Verified end-to-end on IPv6-only EKS:
- 16-thread UDP listener now bound on [::]:7006 (was 0.0.0.0:7006)
- TURN allocate succeeds from an IPv6-only client
- relay address returned to the client is on the listener's IPv6 addr
No semantic change for IPv4-only deployments: ":port" continues to bind
to the IPv4 wildcard when no IPv6 stack is present.
|
Thanks, looks legit. Unfortunately, this is pending on some upstream pion infra fixes (see the failing tests), see pion/transport#377. I'll try to push that PR and then we can merge this right away. |
|
Confirmed the failing test job is fully resolved by pion/transport#377 — no fix needed in this PR. Reproduction The failures ( Verification on this branch Applying pion/transport#377 via a temporary $ go mod edit -replace=github.com/pion/transport/v4=github.com/rg0now/transport/v4@954fadaa518d
$ go mod tidy
$ go test -run "TestStunnerDefaultServerVNet|TestStunnerConfigFileRoundTrip|TestStunnerURIParser|TestCredentialParser|TestStunnerAuthServerVNet|TestStunnerReconcile|TestStunnerReconcileWithVNetE2E|TestStunnerReconcileWithVNetRollback|TestPortRangePacketConn|TestTurncatLongterm" -count=1 .
ok github.com/l7mp/stunner 80.978sThe replace was rolled back; this comment is informational only — adding the replace to this PR's Suggested path Merge pion/transport#377 (already approved by @JoTurk) and cut a Related work (cross-linked for indexing)
The four together close the loop: this PR fixes the listener bind, #226 fixes the relay socket bind, #566/#567 fix the protocol-level family check on a dual-stack relay, and #377 unblocks CI for this PR specifically. |
|
Can you please go-get the latest version of pion/transport ( |
|
Thanks, applied. I'll take care of the version bump separately |
Summary
StartServerandNewRelayGenhardcoded0.0.0.0together with theIPv4-only network strings
udp4/tcp4(in DTLS as well). On IPv4-onlyhosts this is fine, but on IPv6-only hosts the listener and relay
sockets cannot be reached at all and TURN allocations silently fail
with no obvious log line.
This change switches both call sites to the unspecified-address /
family-neutral network strings:
server.go— listener bind:"0.0.0.0:%d"→":%d",socketPool.ListenPacket("udp4", ...)→"udp",net.ResolveUDPAddr("udp4", ...)anddtls.ListenWithOptions("udp4", ...)→
"udp". The TCP/TLS branches were already family-neutral, so theyjust inherit the new
:portform.relay.go—RelayGen.Addressdefault:"0.0.0.0"→"". Thecomment at
AllocatePacketConnalready noted that an empty address isthe only correct value when the requested network can be either v4 or
v6 — this just makes the default match that comment.
On Linux with the default
net.ipv6.bindv6only=0, this opens a singleIPv6 wildcard socket that accepts both IPv4 (mapped) and IPv6 peers; on
IPv4-only or IPv6-only hosts it still binds the available family. Net
result: IPv4-only deployments are unaffected, IPv6-only deployments
start working, and dual-stack deployments now actually carry both
families instead of silently dropping IPv6 traffic.
Verification
Verified end-to-end on an IPv6-only Linux host with a custom build of
stunnerd from this branch:
0.0.0.0:<port>,/proc/net/udp6empty, TURN allocate from an IPv6-only client timesout (no allocate response).
[::]:<port>(IPv6 wildcard,dual-stack via
bindv6only=0),/proc/net/udpempty, TURN allocatefrom an IPv6-only client succeeds —
coturn turnutils_uclientreceives an
Allocate Successand a relay address on the listener'sIPv6 prefix.
Illustrative
turnutils_uclientoutput (addresses elided / replacedwith documentation-prefix examples):
Smoke-tested in a dual-stack environment with no regression.
Test plan
mainmake testlocallysucceeds, was previously silently broken)