Documentation
¶
Index ¶
- func DeviceIDFromCert(cert []byte) entity.DeviceID
- type Client
- type ClientOptions
- type ConnectionHandler
- type ConnectionProvider
- type ConnectionTracker
- type DefaultConnectionHandler
- type DefaultConnectionProvider
- type DefaultConnectionTracker
- type DefaultSessionManager
- func (mgr *DefaultSessionManager) Acquire(ctx context.Context, peer *entity.Server) (ss *SessionStream, err error)
- func (mgr *DefaultSessionManager) Close() error
- func (mgr *DefaultSessionManager) EnsureConn(ctx context.Context, peer *entity.Server) (conn quic.Connection, err error)
- func (mgr *DefaultSessionManager) Serve(ctx context.Context)
- type DialOptions
- type Resolver
- type ServeMux
- type Server
- type ServerOptions
- type SessionManager
- type SessionManagerOptions
- type SessionStream
- func (ss *SessionStream) CloseWrite() error
- func (ss *SessionStream) Read(data []byte) (int, error)
- func (ss *SessionStream) Reader() *bufio.Reader
- func (ss *SessionStream) RemoteAddr() net.Addr
- func (ss *SessionStream) RemotePeer() *entity.Server
- func (ss *SessionStream) Write(data []byte) (int, error)
- type StreamHandler
- type StreamHandlerFunc
- type Transport
- type TransportOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeviceIDFromCert ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(options *ClientOptions) (cli *Client)
type ClientOptions ¶
type ClientOptions struct { Handler ConnectionHandler DialOptions }
type ConnectionHandler ¶
type ConnectionProvider ¶
type ConnectionProvider interface {
Acquire(ctx context.Context, peer *entity.Server) (quic.Connection, error)
}
ConnectionProvider 链接器(不需要进行多线程保护)
type ConnectionTracker ¶
type ConnectionTracker interface { Enter(conn_id uint64, device_id entity.DeviceID, conn quic.Connection) Leave(conn_id uint64, device_id entity.DeviceID, conn quic.Connection) Close() error }
func NewDefaultConnectionTracker ¶
func NewDefaultConnectionTracker() ConnectionTracker
type DefaultConnectionHandler ¶
type DefaultConnectionHandler struct { Tracker ConnectionTracker Handler StreamHandler // contains filtered or unexported fields }
func (*DefaultConnectionHandler) Close ¶
func (svr *DefaultConnectionHandler) Close() error
func (*DefaultConnectionHandler) ServeConn ¶
func (svr *DefaultConnectionHandler) ServeConn(ctx context.Context, conn quic.Connection)
type DefaultConnectionProvider ¶
type DefaultConnectionProvider struct {
// contains filtered or unexported fields
}
type DefaultConnectionTracker ¶
type DefaultConnectionTracker struct {
// contains filtered or unexported fields
}
func (*DefaultConnectionTracker) Close ¶
func (st *DefaultConnectionTracker) Close() error
type DefaultSessionManager ¶
type DefaultSessionManager struct {
// contains filtered or unexported fields
}
func (*DefaultSessionManager) Acquire ¶
func (mgr *DefaultSessionManager) Acquire(ctx context.Context, peer *entity.Server) (ss *SessionStream, err error)
func (*DefaultSessionManager) Close ¶
func (mgr *DefaultSessionManager) Close() error
func (*DefaultSessionManager) EnsureConn ¶
func (*DefaultSessionManager) Serve ¶
func (mgr *DefaultSessionManager) Serve(ctx context.Context)
type DialOptions ¶
type ServeMux ¶
type ServeMux struct {
// contains filtered or unexported fields
}
func NewServeMux ¶
func NewServeMux() (mux *ServeMux)
func (ServeMux) Handle ¶
func (mux ServeMux) Handle(path string, handler StreamHandler)
func (ServeMux) HandleFunc ¶
func (mux ServeMux) HandleFunc(path string, fn func(ctx context.Context, ss *SessionStream))
func (ServeMux) ServeStream ¶
func (mux ServeMux) ServeStream(ctx context.Context, src *SessionStream)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(options *ServerOptions) (svr *Server, err error)
type ServerOptions ¶
type SessionManager ¶
type SessionManager interface { EnsureConn(ctx context.Context, peer *entity.Server) (conn quic.Connection, err error) Acquire(ctx context.Context, peer *entity.Server) (stream *SessionStream, err error) Serve(ctx context.Context) Close() error }
func NewSessionManager ¶
func NewSessionManager(options *SessionManagerOptions) (mgr SessionManager)
type SessionManagerOptions ¶
type SessionManagerOptions struct { DialOptions Resolver Resolver // 默认为空时,不支持 P2P 寻址 Handler ConnectionHandler }
type SessionStream ¶
type SessionStream struct { Peer entity.Server Conn quic.Connection // contains filtered or unexported fields }
func NewSessionStream ¶
func NewSessionStream(peer *entity.Server, conn quic.Connection) (ss *SessionStream, err error)
func (*SessionStream) CloseWrite ¶
func (ss *SessionStream) CloseWrite() error
func (*SessionStream) Reader ¶
func (ss *SessionStream) Reader() *bufio.Reader
func (*SessionStream) RemoteAddr ¶
func (ss *SessionStream) RemoteAddr() net.Addr
func (*SessionStream) RemotePeer ¶
func (ss *SessionStream) RemotePeer() *entity.Server
type StreamHandler ¶
type StreamHandler interface {
ServeStream(ctx context.Context, stream *SessionStream)
}
type StreamHandlerFunc ¶
type StreamHandlerFunc struct {
// contains filtered or unexported fields
}
func (StreamHandlerFunc) ServeStream ¶
func (shf StreamHandlerFunc) ServeStream(ctx context.Context, ss *SessionStream)
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
var DefaultTransport *Transport
func InitTransport ¶
func InitTransport(options TransportOptions) (tr *Transport, err error)
func (*Transport) Dial ¶
func (tr *Transport) Dial(ctx context.Context, options *DialOptions) (conn quic.Connection, device_id entity.DeviceID, err error)
func (*Transport) LocalAddress ¶
type TransportOptions ¶
type TransportOptions struct {
LocalAddress string
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.