mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
general: optimize domain parts operations
This commit is contained in:
1 parent
3a6fd63bc0
commit
a118ec5837
14 files changed
+51
-65
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user