diff --git a/CHANGELOG b/CHANGELOG index d981466..78b5640 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ proxy更新日志 v6.4 1.http(s)代理增加了--jumper参数,可以穿透外部代理连接上级. 2.优化了socks5代理UDP功能可能存在的内存占用过多问题. +3.优化了jumper,避免某些情况下不能正确返回错误的问题. v6.3 1.fixed #156 diff --git a/VERSION b/VERSION index 1f2be2a..124bfa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.3 \ No newline at end of file +6.4 \ No newline at end of file diff --git a/utils/jumper/jumper.go b/utils/jumper/jumper.go index 11fe4eb..4e26029 100644 --- a/utils/jumper/jumper.go +++ b/utils/jumper/jumper.go @@ -24,8 +24,9 @@ func (s socks5Dialer) Dial(network, addr string) (net.Conn, error) { } func New(proxyURL string, timeout time.Duration) (j Jumper, err error) { - u, err := url.Parse(proxyURL) - if err != nil { + u, e := url.Parse(proxyURL) + if e != nil { + err = e return } j = Jumper{ @@ -34,7 +35,7 @@ func New(proxyURL string, timeout time.Duration) (j Jumper, err error) { } return } -func (j *Jumper) Dial(address string, timeout time.Duration) (conn net.Conn, err error) { +func (j *Jumper) Dial(address string, timeout time.Duration) (net.Conn, error) { switch j.proxyURL.Scheme { case "https": return j.dialHTTPS(address, timeout) @@ -70,10 +71,10 @@ func (j *Jumper) dialHTTPS(address string, timeout time.Duration) (conn net.Conn } reply := make([]byte, 1024) conn.SetDeadline(time.Now().Add(timeout)) - n, err := conn.Read(reply) + n, e := conn.Read(reply) conn.SetDeadline(time.Time{}) - if err != nil { - err = fmt.Errorf("error read reply from proxy: %s", err) + if e != nil { + err = fmt.Errorf("error read reply from proxy: %s", e) conn.Close() conn = nil return @@ -94,9 +95,9 @@ func (j *Jumper) dialSOCKS5(address string, timeout time.Duration) (conn net.Con } else { auth = nil } - dialSocksProxy, err := proxy.SOCKS5("tcp", j.proxyURL.Host, auth, socks5Dialer{timeout: timeout}) - if err != nil { - err = fmt.Errorf("error connecting to proxy: %s", err) + dialSocksProxy, e := proxy.SOCKS5("tcp", j.proxyURL.Host, auth, socks5Dialer{timeout: timeout}) + if e != nil { + err = fmt.Errorf("error connecting to proxy: %s", e) return } return dialSocksProxy.Dial("tcp", address)