mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-17 18:06:15 -05:00
return ErrorInvalidAuthentication when OTA is not valid
This commit is contained in:
parent
1f9bf05a87
commit
76b0db2016
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/v2ray/v2ray-core/common/log"
|
"github.com/v2ray/v2ray-core/common/log"
|
||||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||||
"github.com/v2ray/v2ray-core/common/serial"
|
"github.com/v2ray/v2ray-core/common/serial"
|
||||||
|
"github.com/v2ray/v2ray-core/proxy"
|
||||||
"github.com/v2ray/v2ray-core/transport"
|
"github.com/v2ray/v2ray-core/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
|
|||||||
actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer])
|
actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer])
|
||||||
if !serial.BytesLiteral(actualAuth).Equals(serial.BytesLiteral(authBytes)) {
|
if !serial.BytesLiteral(actualAuth).Equals(serial.BytesLiteral(authBytes)) {
|
||||||
log.Error("Shadowsocks: Invalid OTA: ", actualAuth)
|
log.Error("Shadowsocks: Invalid OTA: ", actualAuth)
|
||||||
return nil, transport.ErrorCorruptedPacket
|
return nil, proxy.ErrorInvalidAuthentication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/v2ray/v2ray-core/common/alloc"
|
"github.com/v2ray/v2ray-core/common/alloc"
|
||||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||||
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
|
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
|
||||||
|
"github.com/v2ray/v2ray-core/proxy"
|
||||||
. "github.com/v2ray/v2ray-core/proxy/shadowsocks"
|
. "github.com/v2ray/v2ray-core/proxy/shadowsocks"
|
||||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||||
"github.com/v2ray/v2ray-core/testing/assert"
|
"github.com/v2ray/v2ray-core/testing/assert"
|
||||||
@ -98,7 +99,7 @@ func TestInvalidOTARequest(t *testing.T) {
|
|||||||
[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5},
|
[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5},
|
||||||
[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5}))
|
[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5}))
|
||||||
_, err := ReadRequest(buffer, auth, false)
|
_, err := ReadRequest(buffer, auth, false)
|
||||||
assert.Error(err).Equals(transport.ErrorCorruptedPacket)
|
assert.Error(err).Equals(proxy.ErrorInvalidAuthentication)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUDPRequestParsing(t *testing.T) {
|
func TestUDPRequestParsing(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user