mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-08-24 19:12:32 +00:00
39 lines
732 B
Go
39 lines
732 B
Go
package context
|
|
|
|
import (
|
|
"net"
|
|
|
|
CN "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 net.Conn
|
|
}
|
|
|
|
func NewConnContext(conn net.Conn, metadata *C.Metadata) *ConnContext {
|
|
id, _ := uuid.NewV4()
|
|
return &ConnContext{
|
|
id: id,
|
|
metadata: metadata,
|
|
conn: CN.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() net.Conn {
|
|
return c.conn
|
|
}
|