From 15b98359b1516a9d46d21481469555f05c3cac15 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Mon, 17 Sep 2018 19:16:17 +0800 Subject: [PATCH] http: fixed a compatibility issue with some http proxy server. #62 --- conf.go | 4 ++-- proxy/http/http.go | 2 ++ proxy/redir/redir_linux.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/conf.go b/conf.go index edf498a..4e0b74c 100644 --- a/conf.go +++ b/conf.go @@ -78,6 +78,7 @@ func confInit() { if !path.IsAbs(ruleFile) { ruleFile = path.Join(flag.ConfDir(), ruleFile) } + rule, err := rule.NewConfFromFile(ruleFile) if err != nil { log.Fatal(err) @@ -90,14 +91,13 @@ func confInit() { if !path.IsAbs(conf.RulesDir) { conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir) } - ruleFolderFiles, _ := rule.ListDir(conf.RulesDir, ".rule") + ruleFolderFiles, _ := rule.ListDir(conf.RulesDir, ".rule") for _, ruleFile := range ruleFolderFiles { rule, err := rule.NewConfFromFile(ruleFile) if err != nil { log.Fatal(err) } - conf.rules = append(conf.rules, rule) } } diff --git a/proxy/http/http.go b/proxy/http/http.go index 49615e3..a2e9d39 100644 --- a/proxy/http/http.go +++ b/proxy/http/http.go @@ -242,8 +242,10 @@ func (s *HTTP) Dial(network, addr string) (net.Conn, error) { respR := bufio.NewReader(rc) respTP := textproto.NewReader(respR) + _, code, _, ok := parseFirstLine(respTP) if ok && code == "200" { + respTP.ReadMIMEHeader() return rc, err } else if code == "407" { log.F("[http] authencation needed by proxy %s", s.addr) diff --git a/proxy/redir/redir_linux.go b/proxy/redir/redir_linux.go index 3a808f8..15c4ee5 100644 --- a/proxy/redir/redir_linux.go +++ b/proxy/redir/redir_linux.go @@ -58,8 +58,8 @@ func NewRedirServer(s string, dialer proxy.Dialer) (proxy.Server, error) { return NewRedirProxy(s, dialer, false) } -// NewRedirServer returns a redir server. -func NewRedirServer6(s string, dialer proxy.Dialer) (proxy.Server, error) { +// NewRedir6Server returns a redir server for ipv6. +func NewRedir6Server(s string, dialer proxy.Dialer) (proxy.Server, error) { return NewRedirProxy(s, dialer, true) }