Fix: dial IPv6 host (#29)

This commit is contained in:
gVisor bot 2018-11-04 21:12:16 +08:00
parent e9dfbae5cb
commit 1cd055b9ce
3 changed files with 5 additions and 4 deletions

View file

@ -72,7 +72,7 @@ func (ss *ShadowSocks) Generator(metadata *C.Metadata) (adapter C.ProxyAdapter,
} }
func NewShadowSocks(option ShadowSocksOption) (*ShadowSocks, error) { func NewShadowSocks(option ShadowSocksOption) (*ShadowSocks, error) {
server := fmt.Sprintf("%s:%d", option.Server, option.Port) server := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
cipher := option.Cipher cipher := option.Cipher
password := option.Password password := option.Password
ciph, err := core.PickCipher(cipher, nil, password) ciph, err := core.PickCipher(cipher, nil, password)

View file

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"strconv"
C "github.com/Dreamacro/clash/constant" C "github.com/Dreamacro/clash/constant"
@ -114,7 +115,7 @@ func NewSocks5(option Socks5Option) *Socks5 {
} }
return &Socks5{ return &Socks5{
addr: fmt.Sprintf("%s:%d", option.Server, option.Port), addr: net.JoinHostPort(option.Server, strconv.Itoa(option.Port)),
name: option.Name, name: option.Name,
tls: option.TLS, tls: option.TLS,
skipCertVerify: option.SkipCertVerify, skipCertVerify: option.SkipCertVerify,

View file

@ -68,7 +68,7 @@ func NewVmess(option VmessOption) (*Vmess, error) {
AlterID: uint16(option.AlterID), AlterID: uint16(option.AlterID),
Security: security, Security: security,
TLS: option.TLS, TLS: option.TLS,
Host: fmt.Sprintf("%s:%d", option.Server, option.Port), Host: net.JoinHostPort(option.Server, strconv.Itoa(option.Port)),
NetWork: option.Network, NetWork: option.Network,
WebSocketPath: option.WSPath, WebSocketPath: option.WSPath,
SkipCertVerify: option.SkipCertVerify, SkipCertVerify: option.SkipCertVerify,
@ -80,7 +80,7 @@ func NewVmess(option VmessOption) (*Vmess, error) {
return &Vmess{ return &Vmess{
name: option.Name, name: option.Name,
server: fmt.Sprintf("%s:%d", option.Server, option.Port), server: net.JoinHostPort(option.Server, strconv.Itoa(option.Port)),
client: client, client: client,
}, nil }, nil
} }