Improve: simple dns prefetch

This commit is contained in:
Dreamacro
2018-06-11 18:36:39 +08:00
parent 4f192ef575
commit 4f769debe7
8 changed files with 30 additions and 21 deletions

View File

@ -31,7 +31,7 @@ type Direct struct {
}
func (d *Direct) Generator(addr *C.Addr) (adapter C.ProxyAdapter, err error) {
c, err := net.Dial("tcp", net.JoinHostPort(addr.Host, addr.Port))
c, err := net.Dial("tcp", net.JoinHostPort(addr.String(), addr.Port))
if err != nil {
return
}

View File

@ -87,10 +87,10 @@ func serializesSocksAddr(addr *C.Addr) []byte {
host := []byte(addr.Host)
buf = [][]byte{[]byte{aType, len}, host, port}
case socks.AtypIPv4:
host := net.ParseIP(addr.Host).To4()
host := addr.IP.To4()
buf = [][]byte{[]byte{aType}, host, port}
case socks.AtypIPv6:
host := net.ParseIP(addr.Host).To16()
host := addr.IP.To16()
buf = [][]byte{[]byte{aType}, host, port}
}
return bytes.Join(buf, []byte(""))