2023-05-28 00:18:58 -04:00
|
|
|
package tun
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4"
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/network/ipv6"
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/stack"
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/transport/icmp"
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/transport/tcp"
|
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/transport/udp"
|
|
|
|
)
|
|
|
|
|
2023-05-28 02:17:40 -04:00
|
|
|
type StackOption func(*stack.Stack) error
|
|
|
|
|
2023-05-28 00:18:58 -04:00
|
|
|
func CreateStack(_ stack.LinkEndpoint) (*stack.Stack, error) {
|
|
|
|
s := stack.New(stack.Options{
|
|
|
|
NetworkProtocols: []stack.NetworkProtocolFactory{
|
|
|
|
ipv4.NewProtocol,
|
|
|
|
ipv6.NewProtocol,
|
|
|
|
},
|
|
|
|
TransportProtocols: []stack.TransportProtocolFactory{
|
|
|
|
tcp.NewProtocol,
|
|
|
|
udp.NewProtocol,
|
|
|
|
icmp.NewProtocol4,
|
|
|
|
icmp.NewProtocol6,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// nicID := tcpip.NICID(s.UniqueID())
|
|
|
|
|
|
|
|
return s, nil
|
|
|
|
}
|