Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tun/netstack/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down