Documentation ¶
Index ¶
- Constants
- Variables
- func FreeBytes(b []byte)
- func FreeConnKeyArg(p unsafe.Pointer)
- func GetConnKeyVal(p unsafe.Pointer) uint32
- func GetIP4Addr(ipaddr C.struct_ip_addr) string
- func GetSyncMapLen(m sync.Map) int
- func Input(pkt []byte) error
- func MustResolveTCPAddr(addr string, port uint16) net.Addr
- func MustResolveUDPAddr(addr string, port uint16) net.Addr
- func NewBytes(size int) []byte
- func NewConnKeyArg() unsafe.Pointer
- func NewTCPConnection(pcb *C.struct_tcp_pcb, handler tun2socks.ConnectionHandler) (tun2socks.Connection, error)
- func NewUDPConnection(pcb *C.struct_udp_pcb, handler tun2socks.ConnectionHandler, ...) (tun2socks.Connection, error)
- func Output(p *C.struct_pbuf) C.err_t
- func RegisterOutputFn(fn func([]byte) (int, error))
- func RegisterTCPConnectionHandler(h tun2socks.ConnectionHandler)
- func RegisterUDPConnectionHandler(h tun2socks.ConnectionHandler)
- func SetConnKeyVal(p unsafe.Pointer, val uint32)
- func SetTCPAcceptCallback(pcb *C.struct_tcp_pcb)
- func SetTCPErrCallback(pcb *C.struct_tcp_pcb)
- func SetTCPPollCallback(pcb *C.struct_tcp_pcb, interval C.u8_t)
- func SetTCPRecvCallback(pcb *C.struct_tcp_pcb)
- func SetTCPSentCallback(pcb *C.struct_tcp_pcb)
- func SetUDPRecvCallback(pcb *C.struct_udp_pcb, recvArg unsafe.Pointer)
- func Setup()
- func TCPAcceptFn(arg unsafe.Pointer, newpcb *C.struct_tcp_pcb, err C.err_t) C.err_t
- func TCPErrFn(arg unsafe.Pointer, err C.err_t)
- func TCPPollFn(arg unsafe.Pointer, tpcb *C.struct_tcp_pcb) C.err_t
- func TCPRecvFn(arg unsafe.Pointer, tpcb *C.struct_tcp_pcb, p *C.struct_pbuf, err C.err_t) C.err_t
- func TCPSentFn(arg unsafe.Pointer, tpcb *C.struct_tcp_pcb, len C.u16_t) C.err_t
- func UDPRecvFn(arg unsafe.Pointer, pcb *C.struct_udp_pcb, p *C.struct_pbuf, addr *C.ip_addr_t, ...)
Constants ¶
View Source
const BufSize = 4096
Variables ¶
View Source
var OutputFn func([]byte) (int, error) = defaultOutputFn
Functions ¶
func FreeConnKeyArg ¶
func GetConnKeyVal ¶
func GetIP4Addr ¶
func GetIP4Addr(ipaddr C.struct_ip_addr) string
func GetSyncMapLen ¶
func NewConnKeyArg ¶
We need such a key-value mechanism because when passing a Go pointer to C, the Go pointer will only be valid during the call. If we pass a Go pointer to tcp_arg(), this pointer will not be usable in subsequent callbacks (e.g.: tcp_recv(), tcp_err()).
Instead we need to pass a C pointer to tcp_arg(), we manually allocate the memory in C and return its pointer to Go code. After the connection end, the memory should be freed manually.
func NewTCPConnection ¶
func NewTCPConnection(pcb *C.struct_tcp_pcb, handler tun2socks.ConnectionHandler) (tun2socks.Connection, error)
func NewUDPConnection ¶
func NewUDPConnection(pcb *C.struct_udp_pcb, handler tun2socks.ConnectionHandler, localAddr, remoteAddr C.ip_addr_t, localPort, remotePort C.u16_t) (tun2socks.Connection, error)
func RegisterOutputFn ¶
func RegisterTCPConnectionHandler ¶
func RegisterTCPConnectionHandler(h tun2socks.ConnectionHandler)
func RegisterUDPConnectionHandler ¶
func RegisterUDPConnectionHandler(h tun2socks.ConnectionHandler)
func SetConnKeyVal ¶
func SetTCPAcceptCallback ¶
func SetTCPAcceptCallback(pcb *C.struct_tcp_pcb)
func SetTCPErrCallback ¶
func SetTCPErrCallback(pcb *C.struct_tcp_pcb)
func SetTCPPollCallback ¶
func SetTCPPollCallback(pcb *C.struct_tcp_pcb, interval C.u8_t)
func SetTCPRecvCallback ¶
func SetTCPRecvCallback(pcb *C.struct_tcp_pcb)
func SetTCPSentCallback ¶
func SetTCPSentCallback(pcb *C.struct_tcp_pcb)
func SetUDPRecvCallback ¶
func SetUDPRecvCallback(pcb *C.struct_udp_pcb, recvArg unsafe.Pointer)
func TCPAcceptFn ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.