2016-06-07 06:29:29 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"h12.me/socks"
|
|
|
|
"net"
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetNetworkConnection(onionService string, port int, proxy string, timeout time.Duration) (net.Conn, error) {
|
|
|
|
portNumber := strconv.Itoa(port)
|
|
|
|
conn, err := socks.DialSocksProxy(socks.SOCKS5, proxy)("", onionService+":"+portNumber)
|
2016-06-11 23:02:44 +00:00
|
|
|
if err == nil {
|
|
|
|
conn.SetDeadline(time.Now().Add(timeout))
|
|
|
|
}
|
2016-06-07 06:29:29 +00:00
|
|
|
return conn, err
|
|
|
|
}
|