mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 21:31:16 +08:00
43 lines
810 B
Go
43 lines
810 B
Go
package context
|
|
|
|
import (
|
|
"github.com/Dreamacro/clash/common/utils"
|
|
"net"
|
|
|
|
N "github.com/Dreamacro/clash/common/net"
|
|
C "github.com/Dreamacro/clash/constant"
|
|
|
|
"github.com/gofrs/uuid"
|
|
)
|
|
|
|
type ConnContext struct {
|
|
id uuid.UUID
|
|
metadata *C.Metadata
|
|
conn *N.BufferedConn
|
|
}
|
|
|
|
func NewConnContext(conn net.Conn, metadata *C.Metadata) *ConnContext {
|
|
id, _ := utils.UnsafeUUIDGenerator.NewV4()
|
|
|
|
return &ConnContext{
|
|
id: id,
|
|
metadata: metadata,
|
|
conn: N.NewBufferedConn(conn),
|
|
}
|
|
}
|
|
|
|
// ID implement C.ConnContext ID
|
|
func (c *ConnContext) ID() uuid.UUID {
|
|
return c.id
|
|
}
|
|
|
|
// Metadata implement C.ConnContext Metadata
|
|
func (c *ConnContext) Metadata() *C.Metadata {
|
|
return c.metadata
|
|
}
|
|
|
|
// Conn implement C.ConnContext Conn
|
|
func (c *ConnContext) Conn() *N.BufferedConn {
|
|
return c.conn
|
|
}
|