mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-12 20:31:17 +08:00
41 lines
786 B
Go
41 lines
786 B
Go
package context
|
|
|
|
import (
|
|
"github.com/metacubex/mihomo/common/utils"
|
|
"net"
|
|
|
|
N "github.com/metacubex/mihomo/common/net"
|
|
C "github.com/metacubex/mihomo/constant"
|
|
|
|
"github.com/gofrs/uuid/v5"
|
|
)
|
|
|
|
type ConnContext struct {
|
|
id uuid.UUID
|
|
metadata *C.Metadata
|
|
conn *N.BufferedConn
|
|
}
|
|
|
|
func NewConnContext(conn net.Conn, metadata *C.Metadata) *ConnContext {
|
|
return &ConnContext{
|
|
id: utils.NewUUIDV4(),
|
|
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
|
|
}
|