netstacktun

package
v0.0.0-...-19fda0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufConfig = []int{128, 256, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768}

BufConfig defines the shape of the vectorised view used to read packets from the NIC.

View Source
var (
	Dump = false
)

Functions

func DefTcp6Server

func DefTcp6Server(nt *NetstackTun, handler Gateway) (tcpip.Endpoint, waiter.Queue, error)

func DefTcpServer

func DefTcpServer(nt *NetstackTun, handler Gateway) (tcpip.Endpoint, waiter.Queue, error)
func NewReaderWriterLink(tunw io.WriteCloser, tunr io.Reader, opts *Options) tcpip.LinkEndpointID

New creates a new fd-based endpoint.

Makes fd non-blocking, but does not take ownership of fd, which must remain open for the lifetime of the returned endpoint.

func OpenTun

func OpenTun(ifn string) (io.ReadWriteCloser, error)

If NET_CAP or owner, open the tun.

Types

type Gateway

type Gateway interface {
	DialProxy(ctx context.Context,
		addr net.Addr, directClientAddr *net.TCPAddr,
		ctype string, meta ...string) (net.Conn, func(client net.Conn) error, error)
}

Interface implemented by Gateway.

type NetstackTun

type NetstackTun struct {
	// The IP stack serving the tun. It intercepts all TCP connections.
	IPStack *stack.Stack

	DefUDP tcpip.Endpoint
	DefTCP tcpip.Endpoint

	Handler    Gateway
	UDPHandler UDPGateway
	// contains filtered or unexported fields
}

Intercept using a TUN and google netstack to parse TCP/UDP into streams. The connections are redirected to a capture.ProxyHandler

func NewTunCapture

func NewTunCapture(ep *tcpip.LinkEndpointID, handler Gateway, udpNat UDPGateway, snif bool) *NetstackTun

NewTunCapture creates an in-process tcp stack, backed by an tun-like network interface. All TCP streams initiated on the tun or localhost will be captured.

func (*NetstackTun) WriteTo

func (nt *NetstackTun) WriteTo(data []byte, dst *net.UDPAddr, src *net.UDPAddr) (int, error)

type Options

type Options struct {
	MTU             uint32
	EthernetHeader  bool
	ChecksumOffload bool
	ClosedFunc      func(*tcpip.Error)
	Address         tcpip.LinkAddress
}

Options specify the details about the fd-based endpoint to be created.

type UDPGateway

type UDPGateway interface {
	HandleUdp(dstAddr net.IP, dstPort uint16, localAddr net.IP, localPort uint16, data []byte)
}

Interface implemented by Gateway.

type UdpLocalReader

type UdpLocalReader interface {
	ReadLocal(addr *tcpip.DoubleAddress) (buffer.View, tcpip.ControlMessages, *tcpip.Error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL