mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2026-12-03 18:42:09 +07:00
[PR #210] conn: fix truncated IPv6 destination after an IPv4 send #208
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amneziawg-go#208
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/amnezia-vpn/amneziawg-go/pull/210
Author: @und3f1ned
Created: 11/7/2026
Status: 🔄 Open
Base:
master← Head:fix/ipv6-send-truncated-dst📝 Commits (1)
9e05616conn: fix truncated IPv6 destination after an IPv4 send📊 Changes
1 file changed (+6 additions, -2 deletions)
View changed files
📝
conn/bind_std.go(+6 -2)📄 Description
Problem
On a dual-stack server,
StdNetBind.Sendsends replies to IPv6 peers to a truncated address — the first 4 bytes of the peer address, the rest zero (or stale) — as soon as IPv4 peers are also sending traffic. The IPv6 peer's handshake never completes: e.g. an initiation from2001:db8:1:2::3is answered to2001:db8::.Cause
uacomes fromudpAddrPool. The IPv4 branch reslicesua.IPto 4 bytes, and the address goes back to the pool that way. The IPv6 branch then runscopy(ua.IP, as16[:])beforeua.IP = ua.IP[:16], socopywrites onlylen(ua.IP)= 4 bytes.Without IPv4 traffic the pooled address keeps its 16-byte length and IPv6 works, so the failure depends on load. The same code is in WireGuard/wireguard-go
master.Fix
Restore the slice length before copying, in both branches.
Testing
v3.1.20260828in Docker: a server with one IPv4 peer under continuous ping and one IPv6 peer. With the unpatched binary the server logsSending handshake responsefor the IPv6 peer, but tcpdump shows the response going to<first 4 bytes>::and the handshake never completes. With the patch the IPv6 handshake completes and traffic flows.gofmt,go vet ./conn/,go build ./...andgo test ./conn/...pass (Go 1.25.12).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.