mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-26 16:58:47 +03:00
bug fix
This commit is contained in:
@@ -109,12 +109,14 @@ func (v *ShadowsocksServerConfig) Build() (proto.Message, error) {
|
||||
}
|
||||
|
||||
func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) {
|
||||
v.Cipher = strings.ToLower(v.Cipher)
|
||||
if len(v.Users) == 0 {
|
||||
config := new(shadowsocks_2022.ServerConfig)
|
||||
config.Method = v.Cipher
|
||||
config.Key = v.Password
|
||||
config.Network = v.NetworkList.Build()
|
||||
config.Email = v.Email
|
||||
config.Level = int32(v.Level)
|
||||
return config, nil
|
||||
}
|
||||
|
||||
@@ -169,6 +171,7 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) {
|
||||
Email: user.Email,
|
||||
Address: user.Address.Build(),
|
||||
Port: uint32(user.Port),
|
||||
Level: int32(user.Level),
|
||||
})
|
||||
}
|
||||
return config, nil
|
||||
|
||||
@@ -431,8 +431,6 @@ func (i *MultiUserInbound) processUDP(ctx context.Context, conn stat.Connection,
|
||||
}
|
||||
|
||||
payload := bodyPlain[offset+addrLen:]
|
||||
payloadCopy := make([]byte, len(payload))
|
||||
copy(payloadCopy, payload)
|
||||
|
||||
entry, ok := udpConns.Load(sessionID)
|
||||
if !ok {
|
||||
@@ -496,7 +494,7 @@ func (i *MultiUserInbound) processUDP(ctx context.Context, conn stat.Connection,
|
||||
|
||||
entry.timer.Update()
|
||||
pBuf := buf.New()
|
||||
pBuf.Write(payloadCopy)
|
||||
pBuf.Write(payload)
|
||||
_ = entry.link.Writer.WriteMultiBuffer(buf.MultiBuffer{pBuf})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
gonet "net"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
|
||||
@@ -25,8 +25,7 @@ type SlidingWindow struct {
|
||||
}
|
||||
|
||||
func (f *SlidingWindow) Reset() {
|
||||
f.last = 0
|
||||
f.ring[0] = 0
|
||||
*f = SlidingWindow{}
|
||||
}
|
||||
|
||||
func (f *SlidingWindow) Check(counter uint64) bool {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"math"
|
||||
mrand "math/rand"
|
||||
mrand "math/rand/v2"
|
||||
"time"
|
||||
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
@@ -169,7 +169,7 @@ func (r *StreamReader) Read(p []byte) (int, error) {
|
||||
|
||||
payloadLen := int(binary.BigEndian.Uint16(decryptedLen))
|
||||
if payloadLen == 0 {
|
||||
return 0, nil
|
||||
return 0, ErrInvalidRequest
|
||||
}
|
||||
|
||||
chunkEnd := payloadLen + AEADTagSize
|
||||
@@ -213,7 +213,7 @@ func (r *StreamReader) ReadMultiBuffer() (buf.MultiBuffer, error) {
|
||||
|
||||
payloadLen := int(binary.BigEndian.Uint16(decryptedLen))
|
||||
if payloadLen == 0 {
|
||||
return nil, nil
|
||||
return nil, ErrInvalidRequest
|
||||
}
|
||||
|
||||
chunkEnd := payloadLen + AEADTagSize
|
||||
@@ -375,7 +375,7 @@ func WriteTCPRequest(w io.Writer, method *CipherMethod, pskList [][]byte, dest n
|
||||
payloadLen := len(payload)
|
||||
var paddingLen int
|
||||
if payloadLen < MaxPaddingLength {
|
||||
paddingLen = mrand.Intn(MaxPaddingLength-payloadLen) + 1
|
||||
paddingLen = mrand.IntN(MaxPaddingLength-payloadLen) + 1
|
||||
}
|
||||
addrPortLen := AddrPortLength(dest)
|
||||
varHeaderLen := addrPortLen + 2 + paddingLen + payloadLen
|
||||
|
||||
Reference in New Issue
Block a user