mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
Remove serial.Bytes
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
v2io "github.com/v2ray/v2ray-core/common/io"
|
||||
"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/proxy/internal"
|
||||
"github.com/v2ray/v2ray-core/transport/hub"
|
||||
@@ -231,7 +230,7 @@ func (this *HttpProxyServer) handlePlainHTTP(request *http.Request, dest v2net.D
|
||||
|
||||
requestBuffer := alloc.NewBuffer().Clear() // Don't release this buffer as it is passed into a Packet.
|
||||
request.Write(requestBuffer)
|
||||
log.Debug("Request to remote:\n", serial.BytesT(requestBuffer.Value))
|
||||
log.Debug("Request to remote:\n", requestBuffer.Value)
|
||||
|
||||
ray := this.packetDispatcher.DispatchToOutbound(dest)
|
||||
ray.InboundInput().Write(requestBuffer)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -73,9 +73,9 @@ func (this *AuthChunkReader) Read() (*alloc.Buffer, error) {
|
||||
}
|
||||
}
|
||||
log.Debug("VMess Reader: raw buffer: ", buffer.Value)
|
||||
length := serial.BytesT(buffer.Value[:2]).Uint16Value()
|
||||
length := serial.BytesToUint16(buffer.Value[:2])
|
||||
this.chunkLength = int(length) - 4
|
||||
this.validator = NewValidator(serial.BytesT(buffer.Value[2:6]).Uint32Value())
|
||||
this.validator = NewValidator(serial.BytesToUint32(buffer.Value[2:6]))
|
||||
buffer.SliceFrom(6)
|
||||
} else if buffer.Len() < this.chunkLength {
|
||||
_, err := buffer.FillFrom(this.reader)
|
||||
|
||||
Reference in New Issue
Block a user