mirror of
https://github.com/fosrl/newt.git
synced 2026-03-08 23:03:03 -05:00
[PR #130] feat: implement dual ipv[4-6] stack and allow newt to ipv6 hole punch #137
Reference in New Issue
Block a user
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/fosrl/newt/pull/130
Author: @kevin-gillet
Created: 9/6/2025
Status: 🔄 Open
Base:
main← Head:126-fix-newt-ipv6-hole-punching📝 Commits (4)
fdc56f7fix: revised network stack for ipv6 holepunch udp2f17c0bdoc: reformat comments2a9d48ddoc: removed personnal commentse15c9b7fix: correct logger var type📊 Changes
4 files changed (+252 additions, -299 deletions)
View changed files
📝
main.go(+5 -5)📝
network/network.go(+50 -124)📝
wg/wg.go(+168 -154)📝
wgnetstack/wgnetstack.go(+29 -16)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
see newt issue #126 (base problem)
Refactored the Networking Layer for Dual-Stack Support
Problem: The core network package was the primary source of crashes. It was built exclusively for IPv4, using low-level raw sockets, manual packet building with gopacket, and IPv4-specific BPF filters. This design was fundamentally incompatible with IPv6.
Solution: The entire network/network.go file was rewritten to use standard, high-level UDP sockets (net.ListenPacket). This modern approach allows the operating system's kernel to handle the complexities of both IPv4 and IPv6 packet creation. This change simplified the code by removing the gopacket dependency and all the complex raw socket management logic.
This is a big change and i tested all my common uses-cases, but I am not sure it will not break edge cases.
Corrected Hole Punching Address Parsing
Problem: The initial hole punching logic failed because it used a simple strings.Split on colons (:) to find the port, which does not work for IPv6 addresses. It also attempted to perform DNS lookups on literal IP addresses.
Solution: Replaced the brittle string manipulation with net.SplitHostPort and added a check to correctly parse literal IP addresses without sending them to a DNS resolver.
Please see https://github.com/fosrl/olm/pull/28 also, i made the same fix to prevent Olm from trying to nameresolve a litteral ipv6.
How to test?
Built with
GOOS=linux GOARCH=amd64 go build .Successfully established a full ipv6 connection from Olm to Newt
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.