diff --git a/mtglib/conns.go b/mtglib/conns.go index 9c3fa67..1759ca1 100644 --- a/mtglib/conns.go +++ b/mtglib/conns.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "io" - "sync" "github.com/9seconds/mtg/v2/essentials" ) @@ -40,22 +39,15 @@ func (c connTraffic) Write(b []byte) (int, error) { type connRewind struct { essentials.Conn - active io.Reader buf bytes.Buffer - mutex sync.RWMutex + active io.Reader } func (c *connRewind) Read(p []byte) (int, error) { - c.mutex.RLock() - defer c.mutex.RUnlock() - - return c.active.Read(p) //nolint: wrapcheck + return c.active.Read(p) } func (c *connRewind) Rewind() { - c.mutex.Lock() - defer c.mutex.Unlock() - c.active = io.MultiReader(&c.buf, c.Conn) } diff --git a/mtglib/proxy.go b/mtglib/proxy.go index 9dc6bba..fe69862 100644 --- a/mtglib/proxy.go +++ b/mtglib/proxy.go @@ -243,14 +243,14 @@ func (p *Proxy) doTelegramCall(ctx *streamContext) error { return fmt.Errorf("no addresses to call: %w", err) } - conn, err = foundAddr.Obfuscator.SendHandshake(conn, ctx.dc) + tgConn, err := foundAddr.Obfuscator.SendHandshake(conn, ctx.dc) if err != nil { conn.Close() return fmt.Errorf("cannot perform server handshake: %w", err) } ctx.telegramConn = connTraffic{ - Conn: conn, + Conn: tgConn, streamID: ctx.streamID, stream: p.eventStream, ctx: ctx,