From 56fae0b1f5a1c8e73693789996e8038293410300 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Tue, 5 Jul 2022 21:00:41 +0800 Subject: [PATCH] chore: reduce wrapper --- context/conn.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/context/conn.go b/context/conn.go index 8ecbf56b..71ec232e 100644 --- a/context/conn.go +++ b/context/conn.go @@ -16,10 +16,15 @@ type ConnContext struct { func NewConnContext(conn net.Conn, metadata *C.Metadata) *ConnContext { id, _ := uuid.NewV4() + + if _, ok := conn.(*CN.BufferedConn); !ok { + conn = CN.NewBufferedConn(conn) + } + return &ConnContext{ id: id, metadata: metadata, - conn: CN.NewBufferedConn(conn), + conn: conn, } }