github.com/yaling888/clash@v1.53.0/context/conn.go (about) 1 package context 2 3 import ( 4 "net" 5 6 "github.com/yaling888/clash/common/uuid" 7 C "github.com/yaling888/clash/constant" 8 ) 9 10 type ConnContext struct { 11 id uuid.UUID 12 metadata *C.Metadata 13 conn net.Conn 14 } 15 16 func NewConnContext(conn net.Conn, metadata *C.Metadata) *ConnContext { 17 id := uuid.RandomB64Hlf() 18 return &ConnContext{ 19 id: id, 20 metadata: metadata, 21 conn: conn, 22 } 23 } 24 25 // ID implement C.ConnContext ID 26 func (c *ConnContext) ID() uuid.UUID { 27 return c.id 28 } 29 30 // Metadata implement C.ConnContext Metadata 31 func (c *ConnContext) Metadata() *C.Metadata { 32 return c.metadata 33 } 34 35 // Conn implement C.ConnContext Conn 36 func (c *ConnContext) Conn() net.Conn { 37 return c.conn 38 }