Documentation
¶
Index ¶
Constants ¶
View Source
const MaxPacketSize = 65535 - 20 - 8
MaxPacketSize is max udp packet payload size. It is 65535 - 20(IP header) - 8(UDP header).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Dialer dial tcp to server and return a Conn. Dialer func(string) (Conn, error) // Timeout is used to close an inactive connection, default 5min. // Since udp is not connection based, we donot know when a udp connection closed. Timeout time.Duration // BufSize is max buffered udp packet count, default 8. // Since there's no Congestion-Control in udp, // if a large number of UDP packets arrived, there's no time to send it to remote over tcp. // if buffer is full, new udp packet will be dropped. BufSize int // Logf is log func, default nil, no log output. Logf func(string, ...interface{}) }
Client is client.
func (*Client) Serve ¶
func (c *Client) Serve(conn PacketConn, server string)
Serve read udp packet and send to server over tcp. read response from server and send to address on the packet.
type Conn ¶
type Conn interface { net.Conn // Handshake handle with target address of udp packet. // In server side, Handshake receives a nil net.Addr, read and return the target net.Addr. // In client side, Handshake receives a non-nil net.Addr, send target address to server. Handshake(net.Addr) (net.Addr, error) }
Conn is an udp-over-tcp connection.
func DefaultInConn ¶
DefaultInConn return a default server side Conn.
func DefaultOutConn ¶
DefaultOutConn return a default client side Conn.
type PacketConn ¶
type PacketConn interface { net.PacketConn // ReadPacket is similar with ReadFrom. // It returns readed packet length, target address of udp packet, remote address, error. ReadPacket(p []byte) (n int, target net.Addr, addr net.Addr, err error) // WritePacket is similar with WriteTo. // It writes packet to addr. target is origin packet addr. WritePacket(p []byte, target net.Addr, addr net.Addr) (n int, err error) }
PacketConn is client side udp connection.
func DefaultPacketConn ¶
func DefaultPacketConn(conn net.PacketConn) PacketConn
DefaultPacketConn return a default packet conn.
type Server ¶
type Server struct { // Logf is log func, default nil, no log output. Logf func(string, ...interface{}) }
Server server.
type SocksAddr ¶
type SocksAddr []byte
SocksAddr is socks addr defined in RFC 1928.
func ParseSocksAddr ¶
ParseSocksAddr parses the address in string s. Returns nil if failed.
func ReadSocksAddr ¶
ReadSocksAddr read socks addr.
Click to show internal directories.
Click to hide internal directories.