github.com/metacubex/mihomo@v1.18.5/transport/tuic/common/type.go (about) 1 package common 2 3 import ( 4 "bufio" 5 "context" 6 "errors" 7 "net" 8 "time" 9 10 N "github.com/metacubex/mihomo/common/net" 11 C "github.com/metacubex/mihomo/constant" 12 13 "github.com/metacubex/quic-go" 14 ) 15 16 var ( 17 ClientClosed = errors.New("tuic: client closed") 18 TooManyOpenStreams = errors.New("tuic: too many open streams") 19 ) 20 21 type DialFunc func(ctx context.Context, dialer C.Dialer) (transport *quic.Transport, addr net.Addr, err error) 22 23 type Client interface { 24 DialContextWithDialer(ctx context.Context, metadata *C.Metadata, dialer C.Dialer, dialFn DialFunc) (net.Conn, error) 25 ListenPacketWithDialer(ctx context.Context, metadata *C.Metadata, dialer C.Dialer, dialFn DialFunc) (net.PacketConn, error) 26 OpenStreams() int64 27 DialerRef() C.Dialer 28 LastVisited() time.Time 29 SetLastVisited(last time.Time) 30 Close() 31 } 32 33 type ServerHandler interface { 34 AuthOk() bool 35 HandleTimeout() 36 HandleStream(conn *N.BufferedConn) (err error) 37 HandleMessage(message []byte) (err error) 38 HandleUniStream(reader *bufio.Reader) (err error) 39 } 40 41 type UdpRelayMode uint8 42 43 const ( 44 QUIC UdpRelayMode = iota 45 NATIVE 46 )