use net.JoinHostPort

master
fangdingjun 8 years ago
parent 9e68171e81
commit 31850ed384

@ -106,7 +106,7 @@ func httpProxyHandshake(c net.Conn, host string, port int) error {
}
func dialHTTPProxy(host string, port int, p proxy) (net.Conn, error) {
c, err := net.Dial("tcp", fmt.Sprintf("%s:%d", p.Host, p.Port))
c, err := net.Dial("tcp", net.JoinHostPort(p.Host, fmt.Sprintf("%d", p.Port)))
if err != nil {
return nil, err
}
@ -129,7 +129,7 @@ func dialHTTPSProxy(host string, port int, p proxy) (net.Conn, error) {
InsecureSkipVerify: p.Insecure,
}
c, err := tls.Dial("tcp", fmt.Sprintf("%s:%d", p.Host, p.Port), tlsconfig)
c, err := tls.Dial("tcp", net.JoinHostPort(p.Host, fmt.Sprintf("%d", p.Port)), tlsconfig)
if err != nil {
return nil, err
}
@ -147,13 +147,13 @@ func dialHTTPSProxy(host string, port int, p proxy) (net.Conn, error) {
}
func dialSocks5Proxy(host string, port int, p proxy) (net.Conn, error) {
c, err := net.Dial("tcp", fmt.Sprintf("%s:%d", p.Host, p.Port))
c, err := net.Dial("tcp", net.JoinHostPort(p.Host, fmt.Sprintf("%d", p.Port)))
if err != nil {
return nil, err
}
c1 := &socks.Client{Conn: c}
c2, err := c1.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
c2, err := c1.Dial("tcp", net.JoinHostPort(host, fmt.Sprintf("%d", port)))
if err != nil {
c1.Close()
return nil, err

@ -194,7 +194,7 @@ func handleDirectTcpip(newch ssh.NewChannel) {
Log(DEBUG, "create connection to %s:%d", r.Raddr, r.Rport)
rconn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", r.Raddr, r.Rport))
rconn, err := net.Dial("tcp", net.JoinHostPort(r.Raddr, fmt.Sprintf("%d", r.Rport)))
if err != nil {
Log(ERROR, "%s", err.Error())
newch.Reject(ssh.ConnectionFailed, "invalid argument")

Loading…
Cancel
Save