chore: sync vless encryption code
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-13) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run

This commit is contained in:
wwqgtxx 2025-08-13 20:50:46 +08:00
parent 335d54e488
commit 0408da2aee
3 changed files with 7 additions and 6 deletions

View File

@ -104,7 +104,7 @@ func (i *ClientInstance) Handshake(conn net.Conn) (net.Conn, error) {
EncodeHeader(clientHello[5+1+1184+1088:], 23, int(paddingLen)) EncodeHeader(clientHello[5+1+1184+1088:], 23, int(paddingLen))
rand.Read(clientHello[5+1+1184+1088+5:]) rand.Read(clientHello[5+1+1184+1088+5:])
if n, err := c.Conn.Write(clientHello); n != len(clientHello) || err != nil { if _, err := c.Conn.Write(clientHello); err != nil {
return nil, err return nil, err
} }
// client can send more padding / NFS AEAD messages if needed // client can send more padding / NFS AEAD messages if needed
@ -181,7 +181,7 @@ func (c *ClientConn) Write(b []byte) (int, error) {
} }
} }
IncreaseNonce(c.nonce) IncreaseNonce(c.nonce)
if n, err := c.Conn.Write(data); n != len(data) || err != nil { if _, err := c.Conn.Write(data); err != nil {
return 0, err return 0, err
} }
} }
@ -196,7 +196,7 @@ func (c *ClientConn) Read(b []byte) (int, error) {
var t byte var t byte
var l int var l int
var err error var err error
if c.instance == nil { // 1-RTT if c.instance == nil { // from 1-RTT
for { for {
if _, t, l, err = ReadAndDecodeHeader(c.Conn); err != nil { if _, t, l, err = ReadAndDecodeHeader(c.Conn); err != nil {
return 0, err return 0, err

View File

@ -8,4 +8,5 @@
// https://github.com/XTLS/Xray-core/commit/3c20bddfcfd8999be5f9a2ac180dc959950e4c61 // https://github.com/XTLS/Xray-core/commit/3c20bddfcfd8999be5f9a2ac180dc959950e4c61
// https://github.com/XTLS/Xray-core/commit/1720be168fa069332c418503d30341fc6e01df7f // https://github.com/XTLS/Xray-core/commit/1720be168fa069332c418503d30341fc6e01df7f
// https://github.com/XTLS/Xray-core/commit/0fd7691d6b28e05922d7a5a9313d97745a51ea63 // https://github.com/XTLS/Xray-core/commit/0fd7691d6b28e05922d7a5a9313d97745a51ea63
// https://github.com/XTLS/Xray-core/commit/09cc92c61d9067e0d65c1cae9124664ecfc78f43
package encryption package encryption

View File

@ -162,7 +162,7 @@ func (i *ServerInstance) Handshake(conn net.Conn) (net.Conn, error) {
EncodeHeader(serverHello[5+1088+21:], 23, int(paddingLen)) EncodeHeader(serverHello[5+1088+21:], 23, int(paddingLen))
rand.Read(serverHello[5+1088+21+5:]) rand.Read(serverHello[5+1088+21+5:])
if n, err := c.Conn.Write(serverHello); n != len(serverHello) || err != nil { if _, err := c.Conn.Write(serverHello); err != nil {
return nil, err return nil, err
} }
// server can send more padding / PFS AEAD messages if needed // server can send more padding / PFS AEAD messages if needed
@ -185,7 +185,7 @@ func (c *ServerConn) Read(b []byte) (int, error) {
return 0, nil return 0, nil
} }
if c.peerAead == nil { if c.peerAead == nil {
if c.peerRandom == nil { // 1-RTT if c.peerRandom == nil { // from 1-RTT
var t byte var t byte
var l int var l int
var err error var err error
@ -288,7 +288,7 @@ func (c *ServerConn) Write(b []byte) (int, error) {
} }
} }
IncreaseNonce(c.nonce) IncreaseNonce(c.nonce)
if n, err := c.Conn.Write(data); n != len(data) || err != nil { if _, err := c.Conn.Write(data); err != nil {
return 0, err return 0, err
} }
} }