mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Fix up
This commit is contained in:
parent
34d7ba04c7
commit
d13a546149
@ -21,8 +21,7 @@ var (
|
||||
|
||||
type FakeTLSConn struct {
|
||||
net.Conn
|
||||
remain int
|
||||
writeLock sync.Mutex
|
||||
remain int
|
||||
|
||||
clientEncryptor cipher.Stream
|
||||
clientDecryptor cipher.Stream
|
||||
@ -31,7 +30,7 @@ type FakeTLSConn struct {
|
||||
serverDecryptor cipher.Stream
|
||||
|
||||
unreadServerHandshake []byte
|
||||
serverHandshakeMutex sync.Locker
|
||||
serverHandshakeMutex *sync.Mutex
|
||||
}
|
||||
|
||||
func (c *FakeTLSConn) SetupObfs2(en, de cipher.Stream) {
|
||||
@ -67,9 +66,7 @@ func (c *FakeTLSConn) Write(p []byte) (n int, err error) {
|
||||
if c.clientEncryptor != nil {
|
||||
c.clientEncryptor.XORKeyStream(frame[5:], frame[5:5+lenP])
|
||||
}
|
||||
c.writeLock.Lock()
|
||||
_, err = c.Conn.Write(frame)
|
||||
c.writeLock.Unlock()
|
||||
buf.Put(frame)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -123,9 +120,11 @@ func (c *FakeTLSConn) Read(p []byte) (n int, err error) {
|
||||
if lenH := len(c.unreadServerHandshake); lenH > 0 {
|
||||
if lenH < lenP {
|
||||
copy(p, c.unreadServerHandshake)
|
||||
c.unreadServerHandshake = nil
|
||||
p = p[lenH:]
|
||||
} else if lenH == lenP {
|
||||
copy(p, c.unreadServerHandshake)
|
||||
c.unreadServerHandshake = nil
|
||||
return lenH, nil
|
||||
} else { // lenH > lenP
|
||||
copy(p, c.unreadServerHandshake)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
|
||||
const (
|
||||
secretFakeTLSFirstByte byte = 0xEE
|
||||
secretKeyLength = 16
|
||||
secretKeyLength int = 16
|
||||
)
|
||||
|
||||
// Secret is a data structure that presents a secret.
|
||||
|
Loading…
x
Reference in New Issue
Block a user