Chore: pass staticcheck

This commit is contained in:
Dreamacro
2020-08-25 22:19:59 +08:00
parent c1b4382fe8
commit 5805334ccd
31 changed files with 72 additions and 99 deletions

View File

@ -60,6 +60,7 @@ func (l *HttpListener) Address() string {
func canActivate(loginStr string, authenticator auth.Authenticator, cache *cache.Cache) (ret bool) {
if result := cache.Get(loginStr); result != nil {
ret = result.(bool)
return
}
loginData, err := base64.StdEncoding.DecodeString(loginStr)
login := strings.Split(string(loginData), ":")
@ -80,7 +81,7 @@ func HandleConn(conn net.Conn, cache *cache.Cache) {
authenticator := authStore.Authenticator()
if authenticator != nil {
if authStrings := strings.Split(request.Header.Get("Proxy-Authorization"), " "); len(authStrings) != 2 {
_, err = conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic\r\n\r\n"))
conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic\r\n\r\n"))
conn.Close()
return
} else if !canActivate(authStrings[1], authenticator, cache) {

View File

@ -30,14 +30,8 @@ var (
httpMux sync.Mutex
redirMux sync.Mutex
mixedMux sync.Mutex
tunMux sync.Mutex
)
type listener interface {
Close()
Address() string
}
type Ports struct {
Port int `json:"port"`
SocksPort int `json:"socks-port"`

View File

@ -34,5 +34,4 @@ func (c *packet) LocalAddr() net.Addr {
func (c *packet) Drop() {
pool.Put(c.buf)
return
}

View File

@ -34,5 +34,4 @@ func (c *packet) LocalAddr() net.Addr {
func (c *packet) Drop() {
pool.Put(c.bufRef)
return
}