mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-07-14 13:22:35 +08:00
Merge branch 'main' of github.com:ccreater222/fscan
This commit is contained in:
commit
c67d09371f
@ -232,6 +232,8 @@ func GetProtocol(host string, Timeout int64) (protocol string) {
|
|||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
conn.SetDeadline(time.Now().Add(time.Duration(Timeout) * time.Second))
|
||||||
|
err = conn.Handshake()
|
||||||
if err == nil || strings.Contains(err.Error(), "handshake failure") {
|
if err == nil || strings.Contains(err.Error(), "handshake failure") {
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
}
|
}
|
||||||
|
@ -31,28 +31,13 @@ func Inithttp(PocInfo common.PocInfo) {
|
|||||||
|
|
||||||
func InitHttpClient(ThreadsNum int, DownProxy string, Timeout time.Duration) error {
|
func InitHttpClient(ThreadsNum int, DownProxy string, Timeout time.Duration) error {
|
||||||
type DialContext = func(ctx context.Context, network, addr string) (net.Conn, error)
|
type DialContext = func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||||
var dialContext DialContext
|
|
||||||
dialer := &net.Dialer{
|
dialer := &net.Dialer{
|
||||||
Timeout: dialTimout,
|
Timeout: dialTimout,
|
||||||
KeepAlive: keepAlive,
|
KeepAlive: keepAlive,
|
||||||
}
|
}
|
||||||
if common.Socks5Proxy != "" {
|
|
||||||
dialSocksProxy, err := common.Socks5Dailer(dialer)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if contextDialer, ok := dialSocksProxy.(proxy.ContextDialer); ok {
|
|
||||||
dialContext = contextDialer.DialContext
|
|
||||||
} else {
|
|
||||||
return errors.New("Failed type assertion to DialContext")
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
dialContext = dialer.DialContext
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
DialContext: dialContext,
|
DialContext: dialer.DialContext,
|
||||||
MaxConnsPerHost: 5,
|
MaxConnsPerHost: 5,
|
||||||
MaxIdleConns: 0,
|
MaxIdleConns: 0,
|
||||||
MaxIdleConnsPerHost: ThreadsNum * 2,
|
MaxIdleConnsPerHost: ThreadsNum * 2,
|
||||||
@ -61,7 +46,18 @@ func InitHttpClient(ThreadsNum int, DownProxy string, Timeout time.Duration) err
|
|||||||
TLSHandshakeTimeout: 5 * time.Second,
|
TLSHandshakeTimeout: 5 * time.Second,
|
||||||
DisableKeepAlives: false,
|
DisableKeepAlives: false,
|
||||||
}
|
}
|
||||||
if DownProxy != "" {
|
|
||||||
|
if common.Socks5Proxy != "" {
|
||||||
|
dialSocksProxy, err := common.Socks5Dailer(dialer)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if contextDialer, ok := dialSocksProxy.(proxy.ContextDialer); ok {
|
||||||
|
tr.DialContext = contextDialer.DialContext
|
||||||
|
} else {
|
||||||
|
return errors.New("Failed type assertion to DialContext")
|
||||||
|
}
|
||||||
|
}else if DownProxy != "" {
|
||||||
if DownProxy == "1" {
|
if DownProxy == "1" {
|
||||||
DownProxy = "http://127.0.0.1:8080"
|
DownProxy = "http://127.0.0.1:8080"
|
||||||
} else if DownProxy == "2" {
|
} else if DownProxy == "2" {
|
||||||
@ -69,6 +65,9 @@ func InitHttpClient(ThreadsNum int, DownProxy string, Timeout time.Duration) err
|
|||||||
} else if !strings.Contains(DownProxy, "://") {
|
} else if !strings.Contains(DownProxy, "://") {
|
||||||
DownProxy = "http://127.0.0.1:" + DownProxy
|
DownProxy = "http://127.0.0.1:" + DownProxy
|
||||||
}
|
}
|
||||||
|
if !strings.HasPrefix(DownProxy,"socks") && !strings.HasPrefix(DownProxy,"http") {
|
||||||
|
return errors.New("no support this proxy")
|
||||||
|
}
|
||||||
u, err := url.Parse(DownProxy)
|
u, err := url.Parse(DownProxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user