Migration: go 1.18

This commit is contained in:
Dreamacro
2022-03-16 12:10:13 +08:00
parent d1dd21417b
commit 6a661bff0c
73 changed files with 705 additions and 307 deletions

View File

@ -108,7 +108,7 @@ func authenticate(request *http.Request, cache *cache.Cache) *http.Response {
return resp
}
var authed interface{}
var authed any
if authed = cache.Get(credential); authed == nil {
user, pass, err := decodeBasicProxyAuthorization(credential)
authed = err == nil && authenticator.Verify(user, pass)

View File

@ -65,10 +65,10 @@ func decodeBasicProxyAuthorization(credential string) (string, string, error) {
return "", "", err
}
login := strings.Split(string(plain), ":")
if len(login) != 2 {
user, pass, found := strings.Cut(string(plain), ":")
if !found {
return "", "", errors.New("invalid login")
}
return login[0], login[1], nil
return user, pass, nil
}

View File

@ -1,5 +1,4 @@
//go:build linux && !386
// +build linux,!386
package redir

View File

@ -1,5 +1,4 @@
//go:build !darwin && !linux && !freebsd
// +build !darwin,!linux,!freebsd
package redir

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package tproxy

View File

@ -1,5 +1,4 @@
//go:build !linux
// +build !linux
package tproxy

View File

@ -1,5 +1,4 @@
//go:build linux
// +build linux
package tproxy

View File

@ -1,5 +1,4 @@
//go:build !linux
// +build !linux
package tproxy