general: optimize domain parts operations

This commit is contained in:
nadoo committed 2020-08-16 12:00:46 +08:00
1 parent 3a6fd63bc0
commit a118ec5837
14 files changed
+51 -65

No files matched your search

+3 -3
View File
@@ -21,7 +21,7 @@ type PktConn struct {
ctrlConn net.Conn // tcp control conn
}
// NewPktConn returns a PktConn
// NewPktConn returns a PktConn.
func NewPktConn(c net.PacketConn, writeAddr net.Addr, tgtAddr socks.Addr, tgtHeader bool, ctrlConn net.Conn) *PktConn {
pc := &PktConn{
PacketConn: c,
@@ -48,7 +48,7 @@ func NewPktConn(c net.PacketConn, writeAddr net.Addr, tgtAddr socks.Addr, tgtHea
return pc
}
// ReadFrom overrides the original function from net.PacketConn
// 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)
@@ -90,7 +90,7 @@ func (pc *PktConn) ReadFrom(b []byte) (int, net.Addr, error) {
return n - len(tgtAddr) - 3, raddr, err
}
// WriteTo overrides the original function from net.PacketConn
// 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)
+1 -1
View File
@@ -42,7 +42,7 @@ func init() {
proxy.RegisterServer("socks5", NewSocks5Server)
}
// NewSocks5 returns a Proxy that makes SOCKS v5 connections to the given address
// NewSocks5 returns a Proxy that makes SOCKS v5 connections to the given address.
// with an optional username and password. (RFC 1928)
func NewSocks5(s string, d proxy.Dialer, p proxy.Proxy) (*Socks5, error) {
u, err := url.Parse(s)