From a6cc8cfb6713b735d52af4222b491b5588fcaa6b Mon Sep 17 00:00:00 2001 From: sayaka Date: Wed, 8 Apr 2020 12:51:14 +0000 Subject: [PATCH] add socks5 support, close #70 git-svn-id: file:///srv/svn/repo/yukari/trunk@109 f3bd38d9-da89-464d-a02a-eb04e43141b5 --- morty.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/morty.go b/morty.go index fc7b0a6..2351fcd 100644 --- a/morty.go +++ b/morty.go @@ -21,6 +21,7 @@ import ( "unicode/utf8" "github.com/valyala/fasthttp" + "github.com/valyala/fasthttp/fasthttpproxy" "golang.org/x/net/html" "golang.org/x/net/html/charset" "golang.org/x/text/encoding" @@ -989,6 +990,7 @@ func main() { ipv6 := flag.Bool("ipv6", false, "Allow IPv6 HTTP requests") version := flag.Bool("version", false, "Show version") requestTimeout := flag.Uint("timeout", 2, "Request timeout") + socks5 := flag.String("socks5", "", "SOCKS5 proxy") flag.Parse() if *version { @@ -997,7 +999,12 @@ func main() { } if *ipv6 { - CLIENT.Dial = fasthttp.DialDualStack + CLIENT.DialDualStack = true + } + + if *socks5 != "" { + // this disables CLIENT.DialDualStack + CLIENT.Dial = fasthttpproxy.FasthttpSocksDialer(*socks5) } p := &Proxy{RequestTimeout: time.Duration(*requestTimeout) * time.Second}