mirror of https://github.com/schollz/croc.git
Merge branch 'master' of github.com:schollz/croc
This commit is contained in:
commit
bb05d48fe9
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/schollz/croc/v8/src/utils"
|
"github.com/schollz/croc/v8/src/utils"
|
||||||
|
@ -31,7 +33,16 @@ func NewConnection(address string, timelimit ...time.Duration) (c *Comm, err err
|
||||||
var connection net.Conn
|
var connection net.Conn
|
||||||
if Socks5Proxy != "" && !utils.IsLocalIP(address) {
|
if Socks5Proxy != "" && !utils.IsLocalIP(address) {
|
||||||
var dialer proxy.Dialer
|
var dialer proxy.Dialer
|
||||||
dialer, err = proxy.SOCKS5("tcp", Socks5Proxy, nil, proxy.Direct)
|
// prepend schema if no schema is given
|
||||||
|
if !strings.Contains(Socks5Proxy, `://`) {
|
||||||
|
Socks5Proxy = `socks5://` + Socks5Proxy
|
||||||
|
}
|
||||||
|
socks5ProxyURL, urlParseError := url.Parse(Socks5Proxy)
|
||||||
|
if urlParseError != nil {
|
||||||
|
err = fmt.Errorf("Unable to parse socks proxy url: %s", urlParseError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dialer, err = proxy.FromURL(socks5ProxyURL, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("proxy failed: %w", err)
|
err = fmt.Errorf("proxy failed: %w", err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue