Skip to content

Commit

Permalink
Merge pull request #86 from Equim-chan/socks5
Browse files Browse the repository at this point in the history
add socks5 support, close #70
  • Loading branch information
asciimoo authored Apr 17, 2020
2 parents 6617791 + 939ebe2 commit 74a0548
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion morty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -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}
Expand Down

0 comments on commit 74a0548

Please sign in to comment.