From a821b9c4d408a0982a513aef055ee7fc6ab0dede Mon Sep 17 00:00:00 2001 From: Aptimex Date: Thu, 14 Aug 2025 17:33:07 -0600 Subject: [PATCH] expose access to network configs Signed-off-by: Aptimex --- tun/netstack/tun.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go index a7aec9e82..229b3485a 100644 --- a/tun/netstack/tun.go +++ b/tun/netstack/tun.go @@ -58,6 +58,11 @@ func CreateNetTUN(localAddresses, dnsServers []netip.Addr, mtu int) (tun.Device, TransportProtocols: []stack.TransportProtocolFactory{tcp.NewProtocol, udp.NewProtocol, icmp.NewProtocol6, icmp.NewProtocol4}, HandleLocal: true, } + return CreateNetTUNwithOptions(localAddresses, dnsServers, mtu, opts) +} + +func CreateNetTUNwithOptions(localAddresses, dnsServers []netip.Addr, mtu int, stackOptions stack.Options) (tun.Device, *Net, error) { + opts := stackOptions dev := &netTun{ ep: channel.New(1024, uint32(mtu), ""), stack: stack.New(opts), @@ -281,6 +286,14 @@ func (net *Net) ListenUDP(laddr *net.UDPAddr) (*gonet.UDPConn, error) { return net.DialUDP(laddr, nil) } +func (net *Net) Stack() *stack.Stack { + return net.stack +} + +func (net *Net) Endpoint() *channel.Endpoint { + return net.ep +} + type PingConn struct { laddr PingAddr raddr PingAddr