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