diff --git a/README.md b/README.md index 9213fb5..d8867b5 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ gost - GO Simple Tunnel [![GoDoc](https://godoc.org/github.com/ginuerzh/gost?status.svg)](https://godoc.org/github.com/ginuerzh/gost) [![Build Status](https://travis-ci.org/ginuerzh/gost.svg?branch=master)](https://travis-ci.org/ginuerzh/gost) [![Go Report Card](https://goreportcard.com/badge/github.com/ginuerzh/gost)](https://goreportcard.com/report/github.com/ginuerzh/gost) +[![codecov](https://codecov.io/gh/ginuerzh/gost/branch/2.7/graphs/badge.svg)](https://codecov.io/gh/ginuerzh/gost/branch/2.7) [![GitHub release](https://img.shields.io/github/release/ginuerzh/gost.svg)](https://github.com/ginuerzh/gost/releases/latest) [![Snap Status](https://build.snapcraft.io/badge/ginuerzh/gost.svg)](https://build.snapcraft.io/user/ginuerzh/gost) [![Docker Build Status](https://img.shields.io/docker/build/ginuerzh/gost.svg)](https://hub.docker.com/r/ginuerzh/gost/) diff --git a/README_en.md b/README_en.md index 7f5a4b5..e056336 100644 --- a/README_en.md +++ b/README_en.md @@ -6,6 +6,7 @@ gost - GO Simple Tunnel [![GoDoc](https://godoc.org/github.com/ginuerzh/gost?status.svg)](https://godoc.org/github.com/ginuerzh/gost) [![Build Status](https://travis-ci.org/ginuerzh/gost.svg?branch=master)](https://travis-ci.org/ginuerzh/gost) [![Go Report Card](https://goreportcard.com/badge/github.com/ginuerzh/gost)](https://goreportcard.com/report/github.com/ginuerzh/gost) +[![codecov](https://codecov.io/gh/ginuerzh/gost/branch/2.7/graphs/badge.svg)](https://codecov.io/gh/ginuerzh/gost/branch/2.7) [![GitHub release](https://img.shields.io/github/release/ginuerzh/gost.svg)](https://github.com/ginuerzh/gost/releases/latest) [![Snap Status](https://build.snapcraft.io/badge/ginuerzh/gost.svg)](https://build.snapcraft.io/user/ginuerzh/gost) [![Docker Build Status](https://img.shields.io/docker/build/ginuerzh/gost.svg)](https://hub.docker.com/r/ginuerzh/gost/) diff --git a/bypass.go b/bypass.go index 5422b5e..6e8bed9 100644 --- a/bypass.go +++ b/bypass.go @@ -147,7 +147,9 @@ func NewBypassPatterns(reversed bool, patterns ...string) *Bypass { matchers = append(matchers, m) } } - return NewBypass(reversed, matchers...) + bp := NewBypass(reversed) + bp.AddMatchers(matchers...) + return bp } // Contains reports whether the bypass includes addr. @@ -307,13 +309,10 @@ func (bp *Bypass) Stopped() bool { } func (bp *Bypass) String() string { - bp.mux.RLock() - defer bp.mux.RUnlock() - b := &bytes.Buffer{} - fmt.Fprintf(b, "reversed: %v\n", bp.reversed) - fmt.Fprintf(b, "reload: %v\n", bp.period) - for _, m := range bp.matchers { + fmt.Fprintf(b, "reversed: %v\n", bp.Reversed()) + fmt.Fprintf(b, "reload: %v\n", bp.Period()) + for _, m := range bp.Matchers() { b.WriteString(m.String()) b.WriteByte('\n') } diff --git a/http2_test.go b/http2_test.go index 6142fe7..cdba55d 100644 --- a/http2_test.go +++ b/http2_test.go @@ -970,11 +970,15 @@ func TestHTTP2ProxyWithWebProbeResist(t *testing.T) { Transporter: HTTP2Transporter(nil), } + u, err := url.Parse(httpSrv.URL) + if err != nil { + t.Error(err) + } server := &Server{ Listener: ln, Handler: HTTP2Handler( UsersHandlerOption(url.UserPassword("admin", "123456")), - ProbeResistHandlerOption("web:"+httpSrv.URL), + ProbeResistHandlerOption("web:"+u.Host), ), } go server.Run() diff --git a/http_test.go b/http_test.go index 1fbb470..0f99d7b 100644 --- a/http_test.go +++ b/http_test.go @@ -186,11 +186,15 @@ func TestHTTPProxyWithWebProbeResist(t *testing.T) { t.Error(err) } + u, err := url.Parse(httpSrv.URL) + if err != nil { + t.Error(err) + } server := &Server{ Listener: ln, Handler: HTTPHandler( UsersHandlerOption(url.UserPassword("admin", "123456")), - ProbeResistHandlerOption("web:"+httpSrv.URL), + ProbeResistHandlerOption("web:"+u.Host), ), } go server.Run()