Documentation ¶
Index ¶
- Constants
- Variables
- func FreeBytes(b []byte)
- func Input(pkt []byte) (int, error)
- func NewBytes(size int) []byte
- func NewLWIPError(code int) error
- func ParseTCPAddr(addr string, port uint16) net.Addr
- func ParseUDPAddr(addr string, port uint16) net.Addr
- func RegisterOutputFn(fn func([]byte) (int, error))
- func RegisterTCPConnectionHandler(h ConnectionHandler)
- func RegisterUDPConnectionHandler(h ConnectionHandler)
- func SetBufferPool(p *sync.Pool)
- type Connection
- type ConnectionHandler
- type LWIPStack
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 NewLWIPError ¶
func RegisterOutputFn ¶
func RegisterTCPConnectionHandler ¶
func RegisterTCPConnectionHandler(h ConnectionHandler)
func RegisterUDPConnectionHandler ¶
func RegisterUDPConnectionHandler(h ConnectionHandler)
func SetBufferPool ¶
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.
Click to show internal directories.
Click to hide internal directories.