mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-14 05:12:36 +08:00
Update proxy.go
This commit is contained in:
parent
57eeb41453
commit
464128cdee
@ -2,34 +2,29 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"golang.org/x/net/proxy"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/proxy"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Socks5 struct {
|
func WrapperTcpWithTimeout(network, address string, timeout time.Duration) (net.Conn, error) {
|
||||||
Address string
|
|
||||||
}
|
|
||||||
|
|
||||||
func WrapperTcpWithTimeout(network, address string, socks5Proxy Socks5, timeout time.Duration) (net.Conn, error) {
|
|
||||||
d := &net.Dialer{Timeout: timeout}
|
d := &net.Dialer{Timeout: timeout}
|
||||||
return WrapperTCP(network, address, socks5Proxy, d)
|
return WrapperTCP(network, address, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WrapperTCP(network, address string, socks5Proxy Socks5, forward *net.Dialer) (net.Conn, error) {
|
func WrapperTCP(network, address string, forward *net.Dialer) (net.Conn, error) {
|
||||||
//get conn
|
//get conn
|
||||||
var conn net.Conn
|
var conn net.Conn
|
||||||
if socks5Proxy.Address == "" {
|
if Socks5Proxy == "" {
|
||||||
var err error
|
var err error
|
||||||
conn, err = forward.Dial(network, address)
|
conn, err = forward.Dial(network, address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dailer, err := Socks5Dailer(forward, socks5Proxy)
|
dailer, err := Socks5Dailer(forward)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -39,10 +34,11 @@ func WrapperTCP(network, address string, socks5Proxy Socks5, forward *net.Dialer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return conn, nil
|
return conn, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Socks5Dailer(forward *net.Dialer, socks5Proxy Socks5) (proxy.Dialer, error) {
|
func Socks5Dailer(forward *net.Dialer) (proxy.Dialer, error) {
|
||||||
u, err := url.Parse(socks5Proxy.Address)
|
u, err := url.Parse(Socks5Proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user