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