mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 22:45:13 +00:00
clean up errors
This commit is contained in:
5 files changed
+11
-13
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"v2ray.com/core/common/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/proxy"
|
||||
"v2ray.com/core/common/crypto"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -70,13 +71,13 @@ func ReadAuthentication(reader io.Reader) (auth Socks5AuthenticationRequest, aut
|
||||
auth.nMethods = buffer[1]
|
||||
if auth.nMethods <= 0 {
|
||||
log.Warning("Socks: Zero length of authentication methods")
|
||||
err = proxy.ErrInvalidAuthentication
|
||||
err = crypto.ErrAuthenticationFailed
|
||||
return
|
||||
}
|
||||
|
||||
if nBytes-2 != int(auth.nMethods) {
|
||||
log.Warning("Socks: Unmatching number of auth methods, expecting ", auth.nMethods, ", but got ", nBytes)
|
||||
err = proxy.ErrInvalidAuthentication
|
||||
err = crypto.ErrAuthenticationFailed
|
||||
return
|
||||
}
|
||||
copy(auth.authMethods[:], buffer[2:nBytes])
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/proxy"
|
||||
"v2ray.com/core/testing/assert"
|
||||
"v2ray.com/core/common/crypto"
|
||||
)
|
||||
|
||||
func TestHasAuthenticationMethod(t *testing.T) {
|
||||
@@ -145,7 +146,7 @@ func TestZeroAuthenticationMethod(t *testing.T) {
|
||||
buffer := alloc.NewBuffer()
|
||||
buffer.AppendBytes(5, 0)
|
||||
_, _, err := ReadAuthentication(buffer)
|
||||
assert.Error(err).Equals(proxy.ErrInvalidAuthentication)
|
||||
assert.Error(err).Equals(crypto.ErrAuthenticationFailed)
|
||||
}
|
||||
func TestWrongProtocolVersion(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
Reference in new issue
Block a user