diff --git a/direct.go b/direct.go index b0084dd..576d06a 100644 --- a/direct.go +++ b/direct.go @@ -29,7 +29,7 @@ func (d *direct) Dial(network, addr string) (net.Conn, error) { return c, err } -// DialUDP connects to the given address via the proxy. +// DialUDP connects to the given address via the proxy func (d *direct) DialUDP(network, addr string) (net.PacketConn, net.Addr, error) { pc, err := net.ListenPacket(network, "") if err != nil { diff --git a/ipset_linux.go b/ipset_linux.go index edb94f4..eddb5e0 100644 --- a/ipset_linux.go +++ b/ipset_linux.go @@ -18,16 +18,17 @@ import ( // netfilter netlink message types // https://github.com/torvalds/linux/blob/9e66317d3c92ddaab330c125dfe9d06eee268aff/include/uapi/linux/netfilter/nfnetlink.h#L56 +// NFNL_SUBSYS_IPSET const NFNL_SUBSYS_IPSET = 6 // http://git.netfilter.org/ipset/tree/include/libipset/linux_ip_set.h -/* The protocol version */ +// IPSET_PROTOCOL: The protocol version const IPSET_PROTOCOL = 6 -/* The max length of strings including NUL: set and type identifiers */ +// IPSET_MAXNAMELEN: The max length of strings including NUL: set and type identifiers const IPSET_MAXNAMELEN = 32 -/* Message types and commands */ +// Message types and commands const IPSET_CMD_CREATE = 2 const IPSET_CMD_FLUSH = 4 const IPSET_CMD_ADD = 9 diff --git a/rule.go b/rule.go index 5e04d8a..2a11419 100644 --- a/rule.go +++ b/rule.go @@ -113,6 +113,7 @@ func (rd *RuleDialer) Dial(network, addr string) (net.Conn, error) { return rd.NextDialer(addr).Dial(network, addr) } +// DialUDP connects to the given address via the proxy func (rd *RuleDialer) DialUDP(network, addr string) (pc net.PacketConn, writeTo net.Addr, err error) { return rd.NextDialer(addr).DialUDP(network, addr) } diff --git a/socks5.go b/socks5.go index ac7154c..32b0184 100644 --- a/socks5.go +++ b/socks5.go @@ -563,6 +563,7 @@ func NewSocks5PktConn(c net.PacketConn, writeAddr net.Addr, tgtAddr Addr, tgtHea return pc } +// ReadFrom overrides the original function from net.PacketConn func (pc *Socks5PktConn) ReadFrom(b []byte) (int, net.Addr, error) { if !pc.tgtHeader { return pc.PacketConn.ReadFrom(b) @@ -595,6 +596,7 @@ func (pc *Socks5PktConn) ReadFrom(b []byte) (int, net.Addr, error) { return n - len(tgtAddr), raddr, err } +// WriteTo overrides the original function from net.PacketConn func (pc *Socks5PktConn) WriteTo(b []byte, addr net.Addr) (int, error) { if !pc.tgtHeader { return pc.PacketConn.WriteTo(b, addr) diff --git a/ss.go b/ss.go index a63952e..d7adbab 100644 --- a/ss.go +++ b/ss.go @@ -87,14 +87,14 @@ func (s *SS) ServeTCP(c net.Conn) { rc, err := net.ListenPacket("udp", "") if err != nil { - logf("UDP remote listen error: %v", err) + logf("proxy-ss UDP remote listen error: %v", err) } defer rc.Close() req := make([]byte, udpBufSize) n, err := c.Read(req) if err != nil { - logf("error in ioutil.ReadAll: %s\n", err) + logf("proxy-ss error in ioutil.ReadAll: %s\n", err) return } @@ -263,6 +263,7 @@ func NewPktConn(c net.PacketConn, writeAddr net.Addr, tgtAddr Addr, tgtHeader bo return pc } +// ReadFrom overrides the original function from net.PacketConn func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) { if !pc.tgtHeader { return pc.PacketConn.ReadFrom(b) @@ -289,6 +290,7 @@ func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) { return n - len(tgtAddr), raddr, err } +// WriteTo overrides the original function from net.PacketConn func (pc *PktConn) WriteTo(b []byte, addr net.Addr) (int, error) { if !pc.tgtHeader { return pc.PacketConn.WriteTo(b, addr)