mirror of
https://github.com/qdm12/gluetun.git
synced 2026-07-22 18:36:27 +02:00
fix tests
This commit is contained in:
@@ -81,7 +81,7 @@ func Test_Settings_String(t *testing.T) {
|
||||
| | ├── 1.1.1.1
|
||||
| | └── 8.8.8.8
|
||||
| └── Restart VPN on healthcheck failure: yes
|
||||
├── SOCKS5 proxy settings:
|
||||
├── SOCKS5 proxy server settings:
|
||||
| └── Enabled: no
|
||||
├── Shadowsocks server settings:
|
||||
| └── Enabled: no
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package socks5
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrSubnegotiationVersionNotSupported = errors.New("subnegotiation version not supported")
|
||||
ErrUsernameNotValid = errors.New("username not valid")
|
||||
ErrPasswordNotValid = errors.New("password not valid")
|
||||
)
|
||||
|
||||
// See https://datatracker.ietf.org/doc/html/rfc1929#section-2
|
||||
func usernamePasswordSubnegotiate(conn io.ReadWriter, username, password string) (err error) {
|
||||
status := byte(1)
|
||||
@@ -27,7 +20,7 @@ func usernamePasswordSubnegotiate(conn io.ReadWriter, username, password string)
|
||||
|
||||
if header[0] != authUsernamePasswordSubNegotiation1 {
|
||||
_, _ = conn.Write([]byte{defaultVersion, status})
|
||||
return fmt.Errorf("%w: %d", ErrSubnegotiationVersionNotSupported, header[0])
|
||||
return fmt.Errorf("subnegotiation version not supported: %d", header[0])
|
||||
}
|
||||
version := header[0]
|
||||
|
||||
@@ -38,7 +31,7 @@ func usernamePasswordSubnegotiate(conn io.ReadWriter, username, password string)
|
||||
return fmt.Errorf("reading username bytes: %w", err)
|
||||
} else if username != string(usernameBytes) {
|
||||
_, _ = conn.Write([]byte{version, status})
|
||||
return fmt.Errorf("%w: %s", ErrUsernameNotValid, string(usernameBytes))
|
||||
return fmt.Errorf("username not valid: %s", string(usernameBytes))
|
||||
}
|
||||
|
||||
const passwordHeaderLength = 1
|
||||
@@ -56,7 +49,7 @@ func usernamePasswordSubnegotiate(conn io.ReadWriter, username, password string)
|
||||
return fmt.Errorf("reading password bytes: %w", err)
|
||||
} else if password != string(passwordBytes) {
|
||||
_, _ = conn.Write([]byte{version, status})
|
||||
return fmt.Errorf("%w: %s", ErrPasswordNotValid, string(passwordBytes))
|
||||
return fmt.Errorf("password not valid for username %q", string(usernameBytes))
|
||||
}
|
||||
|
||||
status = 0
|
||||
|
||||
Reference in New Issue
Block a user