Documentation
¶
Overview ¶
Package quicbinding 提供 quic_native 传输绑定实现。
Index ¶
- func NewSession(role SessionRole, config SessionConfig) (transport.Session, error)
- type Conn
- func (conn *Conn) AcceptControlChannel(ctx context.Context) (transport.ControlChannel, error)
- func (conn *Conn) Close(cause error) error
- func (conn *Conn) Done() <-chan struct{}
- func (conn *Conn) Err() error
- func (conn *Conn) LocalAddr() net.Addr
- func (conn *Conn) OpenControlChannel(ctx context.Context) (transport.ControlChannel, error)
- func (conn *Conn) RemoteAddr() net.Addr
- type Listener
- type QUICControlChannel
- func (channel *QUICControlChannel) Close(ctx context.Context) error
- func (channel *QUICControlChannel) Done() <-chan struct{}
- func (channel *QUICControlChannel) Err() error
- func (channel *QUICControlChannel) ReadControlFrame(ctx context.Context) (transport.ControlFrame, error)
- func (channel *QUICControlChannel) WriteControlFrame(ctx context.Context, frame transport.ControlFrame) error
- func (channel *QUICControlChannel) WritePrioritizedControlFrame(ctx context.Context, frame transport.PrioritizedControlFrame) error
- type QUICTunnel
- func (tunnel *QUICTunnel) BindingInfo() transport.BindingInfo
- func (tunnel *QUICTunnel) Close() error
- func (tunnel *QUICTunnel) CloseWrite() error
- func (tunnel *QUICTunnel) Done() <-chan struct{}
- func (tunnel *QUICTunnel) Err() error
- func (tunnel *QUICTunnel) Flush() error
- func (tunnel *QUICTunnel) ID() string
- func (tunnel *QUICTunnel) Meta() transport.TunnelMeta
- func (tunnel *QUICTunnel) Probe(ctx context.Context) error
- func (tunnel *QUICTunnel) Read(payload []byte) (int, error)
- func (tunnel *QUICTunnel) Recyclable() bool
- func (tunnel *QUICTunnel) Reset(cause error) error
- func (tunnel *QUICTunnel) ReuseCount() int
- func (tunnel *QUICTunnel) SetDeadline(deadline time.Time) error
- func (tunnel *QUICTunnel) SetReadDeadline(deadline time.Time) error
- func (tunnel *QUICTunnel) SetWriteDeadline(deadline time.Time) error
- func (tunnel *QUICTunnel) State() transport.TunnelState
- func (tunnel *QUICTunnel) Write(payload []byte) (int, error)
- type SessionConfig
- type SessionRole
- type Transport
- func (binding *Transport) Config() TransportConfig
- func (binding *Transport) Dial(ctx context.Context, address string, tlsConfig *tls.Config) (*Conn, error)
- func (binding *Transport) ListenAddr(address string, tlsConfig *tls.Config) (*Listener, error)
- func (binding *Transport) QUICConfig() *quic.Config
- type TransportConfig
- type TunnelAcceptor
- type TunnelAcceptorConfig
- type TunnelIdentityConfig
- type TunnelProducer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSession ¶
func NewSession(role SessionRole, config SessionConfig) (transport.Session, error)
NewSession 按角色创建 quic_native 的 transport.Session 聚合根。
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn 表示一条 Agent/Bridge 共享的 QUIC 连接。
func (*Conn) AcceptControlChannel ¶
AcceptControlChannel 在服务端等待首条入站 stream 作为控制流。
func (*Conn) OpenControlChannel ¶
OpenControlChannel 在客户端侧打开控制流。
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener 包装 quic-go listener,并把接入连接映射为 quicbinding.Conn。
type QUICControlChannel ¶
type QUICControlChannel struct {
// contains filtered or unexported fields
}
QUICControlChannel 把一条专用 QUIC 双向 stream 适配成控制面通道。
func (*QUICControlChannel) Close ¶
func (channel *QUICControlChannel) Close(ctx context.Context) error
Close 主动关闭控制流。
func (*QUICControlChannel) Done ¶
func (channel *QUICControlChannel) Done() <-chan struct{}
Done 返回关闭信号。
func (*QUICControlChannel) ReadControlFrame ¶
func (channel *QUICControlChannel) ReadControlFrame(ctx context.Context) (transport.ControlFrame, error)
ReadControlFrame 读取一条完整控制帧。
func (*QUICControlChannel) WriteControlFrame ¶
func (channel *QUICControlChannel) WriteControlFrame(ctx context.Context, frame transport.ControlFrame) error
WriteControlFrame 写入一条控制帧。
func (*QUICControlChannel) WritePrioritizedControlFrame ¶
func (channel *QUICControlChannel) WritePrioritizedControlFrame( ctx context.Context, frame transport.PrioritizedControlFrame, ) error
WritePrioritizedControlFrame 首版先保证语义正确,优先级信息仅用于保留统一接口。
type QUICTunnel ¶
type QUICTunnel struct {
// contains filtered or unexported fields
}
QUICTunnel 把一条长期 QUIC 双向 stream 适配为 transport.Tunnel。
func NewQUICTunnel ¶
func NewQUICTunnel(stream *quic.Stream, meta transport.TunnelMeta) (*QUICTunnel, error)
NewQUICTunnel 使用指定元数据创建 tunnel 适配器。
func (*QUICTunnel) BindingInfo ¶
func (tunnel *QUICTunnel) BindingInfo() transport.BindingInfo
BindingInfo 返回 binding 元信息。
func (*QUICTunnel) CloseWrite ¶
func (tunnel *QUICTunnel) CloseWrite() error
CloseWrite 对应 QUIC stream 的半关闭写方向。
func (*QUICTunnel) Flush ¶
func (tunnel *QUICTunnel) Flush() error
Flush 在 QUIC stream 语义下只需确认本地没有额外缓存。
func (*QUICTunnel) Meta ¶
func (tunnel *QUICTunnel) Meta() transport.TunnelMeta
Meta 返回 tunnel 元数据快照。
func (*QUICTunnel) Probe ¶
func (tunnel *QUICTunnel) Probe(ctx context.Context) error
Probe 在 quic_native 首版中依赖连接级 keepalive,不额外暴露 tunnel 探活。
func (*QUICTunnel) Read ¶
func (tunnel *QUICTunnel) Read(payload []byte) (int, error)
Read 从底层 QUIC stream 读取数据。
func (*QUICTunnel) Recyclable ¶
func (tunnel *QUICTunnel) Recyclable() bool
Recyclable 报告 tunnel 是否满足回收前提。
func (*QUICTunnel) Reset ¶
func (tunnel *QUICTunnel) Reset(cause error) error
Reset 中断 tunnel 并把当前 stream 标记为 broken。
func (*QUICTunnel) ReuseCount ¶
func (tunnel *QUICTunnel) ReuseCount() int
ReuseCount 返回当前 tunnel 已完成回收轮次。
func (*QUICTunnel) SetDeadline ¶
func (tunnel *QUICTunnel) SetDeadline(deadline time.Time) error
SetDeadline 同时设置读写 deadline。
func (*QUICTunnel) SetReadDeadline ¶
func (tunnel *QUICTunnel) SetReadDeadline(deadline time.Time) error
SetReadDeadline 设置读 deadline。
func (*QUICTunnel) SetWriteDeadline ¶
func (tunnel *QUICTunnel) SetWriteDeadline(deadline time.Time) error
SetWriteDeadline 设置写 deadline。
func (*QUICTunnel) State ¶
func (tunnel *QUICTunnel) State() transport.TunnelState
State 返回 tunnel 当前状态。
type SessionConfig ¶
type SessionConfig struct {
Meta transport.SessionMeta
ControlChannel transport.ControlChannel
TunnelProducer transport.TunnelProducer
TunnelAcceptor transport.TunnelAcceptor
TunnelPool transport.TunnelPool
}
SessionConfig 描述 quic_native session 构造参数。
type SessionRole ¶
type SessionRole string
SessionRole 描述 quic_native session 的运行角色。
const ( // SessionRoleAgent 表示 Agent 侧角色。 SessionRoleAgent SessionRole = "agent" // SessionRoleServer 表示 Server 侧角色。 SessionRoleServer SessionRole = "server" )
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport 封装 quic_native 的配置快照和连接创建逻辑。
func NewTransportWithConfig ¶
func NewTransportWithConfig(config TransportConfig) (*Transport, error)
NewTransportWithConfig 使用指定配置创建实例。
func (*Transport) Dial ¶
func (binding *Transport) Dial(ctx context.Context, address string, tlsConfig *tls.Config) (*Conn, error)
Dial 在指定地址上建立一条 QUIC 连接。
func (*Transport) ListenAddr ¶
ListenAddr 在指定 UDP 地址上监听 QUIC 连接。
func (*Transport) QUICConfig ¶
QUICConfig 返回可传给 quic-go 的配置副本。
type TransportConfig ¶
type TransportConfig struct {
HandshakeIdleTimeout time.Duration
MaxIdleTimeout time.Duration
KeepAlivePeriod time.Duration
StreamOpenTimeout time.Duration
MaxIncomingStreams int64
MaxControlFramePayloadSize int
MaxTunnelFramePayloadSize int
}
TransportConfig 描述 quic_native binding 的基础参数。
func DefaultTransportConfig ¶
func DefaultTransportConfig() TransportConfig
DefaultTransportConfig 返回默认配置。
func (TransportConfig) NormalizeAndValidate ¶
func (config TransportConfig) NormalizeAndValidate() (TransportConfig, error)
NormalizeAndValidate 归一化并校验配置。
type TunnelAcceptor ¶
type TunnelAcceptor struct {
// contains filtered or unexported fields
}
TunnelAcceptor 实现 Server 侧接收 QUIC tunnel 的能力。
func NewTunnelAcceptor ¶
func NewTunnelAcceptor(conn *Conn, config TunnelAcceptorConfig) (*TunnelAcceptor, error)
NewTunnelAcceptor 创建 tunnel acceptor,并启动底层 stream 分发循环。
func (*TunnelAcceptor) AcceptTunnel ¶
AcceptTunnel 返回下一条接收到的 tunnel。
func (*TunnelAcceptor) Close ¶
func (acceptor *TunnelAcceptor) Close(cause error)
Close 停止 acceptor,后续 AcceptTunnel 将返回 closed 错误。
func (*TunnelAcceptor) Done ¶
func (acceptor *TunnelAcceptor) Done() <-chan struct{}
Done 返回 acceptor 关闭信号。
type TunnelAcceptorConfig ¶
type TunnelAcceptorConfig struct {
IdentityConfig TunnelIdentityConfig
QueueSize int
}
TunnelAcceptorConfig 描述 QUIC tunnel acceptor 配置。
type TunnelIdentityConfig ¶
type TunnelIdentityConfig struct {
SessionID string
SessionEpoch uint64
TunnelIDPrefix string
Labels map[string]string
}
TunnelIdentityConfig 描述 quic tunnel 的身份信息。
type TunnelProducer ¶
type TunnelProducer struct {
// contains filtered or unexported fields
}
TunnelProducer 实现 Agent 侧主动打开 QUIC tunnel stream 的能力。
func NewTunnelProducer ¶
func NewTunnelProducer(conn *Conn, identityConfig TunnelIdentityConfig) (*TunnelProducer, error)
NewTunnelProducer 创建 QUIC tunnel producer。
func (*TunnelProducer) OpenTunnel ¶
OpenTunnel 主动打开一条 QUIC tunnel stream,并先写入 stream 级握手头。