diff --git a/transport/mtproto/conn.go b/transport/mtproto/conn.go index 1815467d..0f4ba314 100644 --- a/transport/mtproto/conn.go +++ b/transport/mtproto/conn.go @@ -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) diff --git a/transport/mtproto/secret.go b/transport/mtproto/secret.go index 43aab7c2..d1bf4925 100644 --- a/transport/mtproto/secret.go +++ b/transport/mtproto/secret.go @@ -11,7 +11,7 @@ import ( const ( secretFakeTLSFirstByte byte = 0xEE - secretKeyLength = 16 + secretKeyLength int = 16 ) // Secret is a data structure that presents a secret.