core

package
v0.0.0-...-e7d7f47 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEndpoint

func CreateEndpoint(dev Device) stack.LinkEndpoint

Types

type Device

type Device interface {
	Reader
	Writer
	DeviceType() string
	GetMTU() int
}

Device is a tun-like device for reading packets from system

type Endpoint

type Endpoint struct {
	*channel.Endpoint
	Reader Reader
	Writer Writer
	// contains filtered or unexported fields
}

func (*Endpoint) Attach

func (e *Endpoint) Attach(dispatcher stack.NetworkDispatcher)

Attach is to attach device to stack

func (*Endpoint) WriteNotify

func (e *Endpoint) WriteNotify()

WriteNotify will be called when a write happens to the queue.

type Handler

type Handler interface {
	Handle(*TCPConn)
	HandlePacket(*UDPPacket)
}

Handler is for handling incoming TCP and UDP connections

type Reader

type Reader interface {
	Read([]byte, int) (int, error)
}

type Stack

type Stack struct {
	Device  Device
	Handler Handler
	Stack   *stack.Stack
}

Stack go netstack provided by gvisor.dev

func (*Stack) Close

func (s *Stack) Close() error

Close is to close the stack

func (*Stack) HandlePacket

func (s *Stack) HandlePacket(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool

func (*Stack) HandleStream

func (s *Stack) HandleStream(r *tcp.ForwarderRequest)

HandleStream is to handle incoming TCP connections

func (*Stack) Start

func (s *Stack) Start(device Device, handler Handler) (err error)

type TCPConn

type TCPConn struct {
	gonet.TCPConn
}

type UDPPacket

type UDPPacket struct {
	// contains filtered or unexported fields
}

func (*UDPPacket) Data

func (p *UDPPacket) Data() []byte

func (*UDPPacket) Drop

func (p *UDPPacket) Drop()

func (*UDPPacket) LocalAddr

func (p *UDPPacket) LocalAddr() net.Addr

func (*UDPPacket) RemoteAddr

func (p *UDPPacket) RemoteAddr() net.Addr

func (*UDPPacket) WriteBack

func (p *UDPPacket) WriteBack(b []byte, addr net.Addr) (int, error)

type Writer

type Writer interface {
	// Write packets to tun device
	Write([]byte, int) (int, error)
}

Jump to

Keyboard shortcuts

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