# 不通过代理连接
package main
import (
"fmt"
"net"
)
conn, err := net.Dial("tcp", "127.0.0.1")
if err != nil {
fmt.Println("net.Dial error:", err)
return nil
}
conn.Write([]byte("hello world"))
# 通过代理连接
package main
import (
"fmt"
"net"
)
sksurl, err := nurl.Parse(`socks5://127.0.0.1:30011`)
if err != nil {
panic(sksurl)
}
dialer, err := proxy.FromURL(sksurl, proxy.Direct)
if err != nil {
panic(sksurl)
}
conn, err := dialer.Dial("tcp", "126.556.36.5:5263")
if err != nil {
panic(err)
}