mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-02 00:19:24 +00:00
Remove serial.Bytes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package shadowsocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"io"
|
||||
@@ -79,7 +80,7 @@ func (this *ChunkReader) Read() (*alloc.Buffer, error) {
|
||||
}
|
||||
// There is a potential buffer overflow here. Large buffer is 64K bytes,
|
||||
// while uin16 + 10 will be more than that
|
||||
length := serial.BytesT(buffer.Value[:2]).Uint16Value() + AuthSize
|
||||
length := serial.BytesToUint16(buffer.Value[:2]) + AuthSize
|
||||
if _, err := io.ReadFull(this.reader, buffer.Value[:length]); err != nil {
|
||||
buffer.Release()
|
||||
return nil, err
|
||||
@@ -90,7 +91,7 @@ func (this *ChunkReader) Read() (*alloc.Buffer, error) {
|
||||
payload := buffer.Value[AuthSize:]
|
||||
|
||||
actualAuthBytes := this.auth.Authenticate(nil, payload)
|
||||
if !serial.BytesT(authBytes).Equals(serial.BytesT(actualAuthBytes)) {
|
||||
if !bytes.Equal(authBytes, actualAuthBytes) {
|
||||
buffer.Release()
|
||||
log.Debug("AuthenticationReader: Unexpected auth: ", authBytes)
|
||||
return nil, transport.ErrorCorruptedPacket
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package shadowsocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/common/serial"
|
||||
"github.com/v2ray/v2ray-core/proxy"
|
||||
"github.com/v2ray/v2ray-core/transport"
|
||||
)
|
||||
@@ -129,7 +129,7 @@ func ReadRequest(reader io.Reader, auth *Authenticator, udp bool) (*Request, err
|
||||
|
||||
if request.OTA {
|
||||
actualAuth := auth.Authenticate(nil, buffer.Value[0:lenBuffer])
|
||||
if !serial.BytesT(actualAuth).Equals(serial.BytesT(authBytes)) {
|
||||
if !bytes.Equal(actualAuth, authBytes) {
|
||||
log.Debug("Shadowsocks: Invalid OTA. Expecting ", actualAuth, ", but got ", authBytes)
|
||||
log.Warning("Shadowsocks: Invalid OTA.")
|
||||
return nil, proxy.ErrorInvalidAuthentication
|
||||
|
||||
Reference in New Issue
Block a user