core

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LWIP_ERR_OK int = iota
	LWIP_ERR_ABRT
)
View Source
const BufSize = 2 * 1024
View Source
const CHECK_TIMEOUTS_INTERVAL = 250 // in millisecond
View Source
const TCP_POLL_INTERVAL = 8 // poll every 4 seconds

Variables

View Source
var OutputFn func([]byte) (int, error)

Functions

func FreeBytes

func FreeBytes(b []byte)

func Input

func Input(pkt []byte) (int, error)

func NewBytes

func NewBytes(size int) []byte

func NewLWIPError

func NewLWIPError(code int) error

func ParseTCPAddr

func ParseTCPAddr(addr string, port uint16) net.Addr

func ParseUDPAddr

func ParseUDPAddr(addr string, port uint16) net.Addr

func RegisterOutputFn

func RegisterOutputFn(fn func([]byte) (int, error))

func RegisterTCPConnectionHandler

func RegisterTCPConnectionHandler(h ConnectionHandler)

func RegisterUDPConnectionHandler

func RegisterUDPConnectionHandler(h ConnectionHandler)

func SetBufferPool

func SetBufferPool(p *sync.Pool)

Types

type Connection

type Connection interface {
	// RemoteAddr returns the destination network address.
	RemoteAddr() net.Addr

	// LocalAddr returns the local client network address.
	LocalAddr() net.Addr

	// Receive receives data from TUN.
	Receive(data []byte) error

	// Write writes data to TUN.
	Write(data []byte) (int, error)

	// Sent will be called when sent data has been acknowledged by clients (TCP only).
	Sent(len uint16) error

	// Close closes the connection (TCP only).
	Close() error

	// Abort aborts the connection to client by sending a RST segment (TCP only).
	Abort()

	// Err will be called when a fatal error has occurred on the connection (TCP only).
	Err(err error)

	// LocalDidClose will be called when local client has close the connection (TCP only).
	LocalDidClose() error

	// Poll will be periodically called by timers (TCP only).
	Poll() error
}

Connection abstracts a TCP/UDP connection comming from TUN. This connection should be handled by a registered TCP/UDP proxy handler.

type ConnectionHandler

type ConnectionHandler interface {
	// Connect connects the proxy server.
	Connect(conn Connection, target net.Addr) error

	// DidReceive will be called when data arrives from TUN.
	DidReceive(conn Connection, data []byte) error

	// DidSend will be called when sent data has been acknowledged by local clients.
	DidSend(conn Connection, len uint16)

	// DidClose will be called when the connection has been closed.
	DidClose(conn Connection)

	// LocalDidClose will be called when local client has close the connection.
	LocalDidClose(conn Connection)
}

ConnectionHandler handles connections comming from TUN.

type LWIPStack

type LWIPStack interface {
	Write([]byte) (int, error)
	Close() error
	RestartTimeouts()
}

func NewLWIPStack

func NewLWIPStack() LWIPStack

Jump to

Keyboard shortcuts

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