go vet fixes
This commit is contained in:
parent
dbaf326869
commit
d9cdae3398
4 changed files with 14 additions and 7 deletions
|
|
@ -194,7 +194,7 @@ func TestTheTest(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp.StatusCode != http.StatusNotFound {
|
||||
t.Fatalf("Expected: 404 StatusNotFound, got %s. Response: %#v\n", resp.StatusCode, resp)
|
||||
t.Fatalf("Expected: 404 StatusNotFound, got %d. Response: %#v\n", resp.StatusCode, resp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ func TestIsSubdomain(t *testing.T) {
|
|||
testSubDomain := func(s, domain string, expectedResult bool) {
|
||||
result := isSubdomain(s, domain)
|
||||
if result != expectedResult {
|
||||
t.Fatalf("Expected: isSubdomain(%s, %s) is %b, Got: %b", s, domain, expectedResult, result)
|
||||
t.Fatalf("Expected: isSubdomain(%s, %s) is %v, Got: %v", s, domain, expectedResult, result)
|
||||
}
|
||||
}
|
||||
testSubDomain("hoooli.abc", "hooya.ya", false)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ var bufferPool sync.Pool
|
|||
|
||||
// TODO?: getStatusCode(err) that casts to http.Error, net Error, etc. and returns correct http status code
|
||||
|
||||
func (fp ForwardProxy) connectPortIsAllowed(port string) bool {
|
||||
func (fp *ForwardProxy) connectPortIsAllowed(port string) bool {
|
||||
portInt, err := strconv.Atoi(port)
|
||||
if err != nil {
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func dial(proxyAddr string, useTls bool) (net.Conn, error) {
|
||||
|
|
@ -188,7 +188,7 @@ func TestPassthrough(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp.StatusCode != http.StatusNotFound {
|
||||
t.Fatalf("Expected: 404 StatusNotFound, got %s. Response: %#v\n", resp.StatusCode, resp)
|
||||
t.Fatalf("Expected: 404 StatusNotFound, got %d. Response: %#v\n", resp.StatusCode, resp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
11
setup.go
11
setup.go
|
|
@ -30,8 +30,15 @@ import (
|
|||
|
||||
func setup(c *caddy.Controller) error {
|
||||
httpserver.GetConfig(c).FallbackSite = true
|
||||
fp := &ForwardProxy{dialTimeout: time.Second * 20, httpTransport: *http.DefaultTransport.(*http.Transport),
|
||||
hostname: httpserver.GetConfig(c).Host(), port: httpserver.GetConfig(c).Port()}
|
||||
fp := &ForwardProxy{dialTimeout: time.Second * 20,
|
||||
hostname: httpserver.GetConfig(c).Host(), port: httpserver.GetConfig(c).Port(),
|
||||
httpTransport: http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}}
|
||||
fp.httpTransport.DialTLS = func(network, addr string) (net.Conn, error) {
|
||||
return nil, &http.ProtocolError{ErrorString: "Proxy does not fetch TLS resources, use CONNECT instead"}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue