Documentation
¶
Index ¶
- Variables
- type AdapterConfig
- type AggPolicy
- type AggSnapshot
- type BandwidthAggregator
- type ClientAdapter
- func (a *ClientAdapter) AddEntry(cfg EntryConfig) error
- func (a *ClientAdapter) AddExit(cfg ExitConfig) error
- func (a *ClientAdapter) AggMetrics(tunnelID string) AggSnapshot
- func (a *ClientAdapter) DisableAggregation(tunnelID string) error
- func (a *ClientAdapter) EnableAggregation(tunnelID string, policy AggPolicy) error
- func (a *ClientAdapter) GetHopChain(tunnelID string) (HopChain, error)
- func (a *ClientAdapter) ListNodes() NodeSnapshot
- func (a *ClientAdapter) Metrics() CoreMetrics
- func (a *ClientAdapter) RemoveEntry(id string) error
- func (a *ClientAdapter) RemoveExit(id string) error
- func (a *ClientAdapter) SetHopChain(tunnelID string, chain HopChain) error
- func (a *ClientAdapter) Start(ctx context.Context) error
- type CoreMetrics
- type EntryConfig
- type EntryHealth
- type EntryNode
- type EntryPool
- type ExitConfig
- type ExitHealth
- type ExitNode
- type ExitRegistry
- type HealthChecker
- type HealthState
- type Hop
- type HopChain
- type HybridScheduler
- type LBPolicy
- type MinRTTScheduler
- type NodeHealth
- type NodeSnapshot
- type Packet
- type PacketReorder
- type PathConn
- type PathScheduler
- type PathSnapshot
- type Protocol
- type ProtocolAdapter
- type ProtocolRegistry
- type QUICAdapter
- func (a QUICAdapter) Dial(ctx context.Context, addr string, cfg AdapterConfig) (net.Conn, error)
- func (a QUICAdapter) Handshake(conn net.Conn) (net.Conn, error)
- func (a QUICAdapter) Listen(ctx context.Context, addr string, cfg AdapterConfig) (net.Listener, error)
- func (a QUICAdapter) Name() Protocol
- type RelayEngine
- type RoundRobinScheduler
- type ServerAdapter
- func (a *ServerAdapter) AddEntry(cfg EntryConfig) error
- func (a *ServerAdapter) AddExit(cfg ExitConfig) error
- func (a *ServerAdapter) AggMetrics(tunnelID string) AggSnapshot
- func (a *ServerAdapter) DisableAggregation(tunnelID string) error
- func (a *ServerAdapter) EnableAggregation(tunnelID string, policy AggPolicy) error
- func (a *ServerAdapter) GetHopChain(tunnelID string) (HopChain, error)
- func (a *ServerAdapter) ListNodes() NodeSnapshot
- func (a *ServerAdapter) Metrics() CoreMetrics
- func (a *ServerAdapter) RemoveEntry(id string) error
- func (a *ServerAdapter) RemoveExit(id string) error
- func (a *ServerAdapter) SetHopChain(tunnelID string, chain HopChain) error
- func (a *ServerAdapter) Start(ctx context.Context) error
- type TCPAdapter
- type TLSAdapter
- type TunnelCore
- type TunnelEvent
- type TunnelInstance
- type TunnelManager
- type TunnelSpec
- type TunnelState
- type UDPAdapter
- type V5Tunnel
- func (t *V5Tunnel) AddEntry(cfg EntryConfig) error
- func (t *V5Tunnel) AddExit(cfg ExitConfig) error
- func (t *V5Tunnel) AggMetrics(tunnelID string) AggSnapshot
- func (t *V5Tunnel) DisableAggregation(tunnelID string) error
- func (t *V5Tunnel) EnableAggregation(tunnelID string, policy AggPolicy) error
- func (t *V5Tunnel) GetHopChain(tunnelID string) (HopChain, error)
- func (t *V5Tunnel) HandleConn(ctx context.Context, src net.Conn)
- func (t *V5Tunnel) ListNodes() NodeSnapshot
- func (t *V5Tunnel) Metrics() CoreMetrics
- func (t *V5Tunnel) RemoveEntry(id string) error
- func (t *V5Tunnel) RemoveExit(id string) error
- func (t *V5Tunnel) SetHopChain(tunnelID string, chain HopChain) error
- func (t *V5Tunnel) Start(ctx context.Context) error
- type WSAdapter
- type WeightedBPSScheduler
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AdapterConfig ¶
type AggSnapshot ¶
type AggSnapshot struct {
TotalBps int64
Paths []PathSnapshot
}
type BandwidthAggregator ¶
type BandwidthAggregator struct {
// contains filtered or unexported fields
}
func NewBandwidthAggregator ¶
func NewBandwidthAggregator(policy AggPolicy) *BandwidthAggregator
func (*BandwidthAggregator) AddPath ¶
func (a *BandwidthAggregator) AddPath(exitID string, conn net.Conn)
func (*BandwidthAggregator) Close ¶
func (a *BandwidthAggregator) Close() error
type ClientAdapter ¶
type ClientAdapter struct {
// contains filtered or unexported fields
}
func NewClientAdapter ¶
func (*ClientAdapter) AddEntry ¶
func (a *ClientAdapter) AddEntry(cfg EntryConfig) error
func (*ClientAdapter) AddExit ¶
func (a *ClientAdapter) AddExit(cfg ExitConfig) error
func (*ClientAdapter) AggMetrics ¶
func (a *ClientAdapter) AggMetrics(tunnelID string) AggSnapshot
func (*ClientAdapter) DisableAggregation ¶
func (a *ClientAdapter) DisableAggregation(tunnelID string) error
func (*ClientAdapter) EnableAggregation ¶
func (a *ClientAdapter) EnableAggregation(tunnelID string, policy AggPolicy) error
func (*ClientAdapter) GetHopChain ¶
func (a *ClientAdapter) GetHopChain(tunnelID string) (HopChain, error)
func (*ClientAdapter) ListNodes ¶
func (a *ClientAdapter) ListNodes() NodeSnapshot
func (*ClientAdapter) Metrics ¶
func (a *ClientAdapter) Metrics() CoreMetrics
func (*ClientAdapter) RemoveEntry ¶
func (a *ClientAdapter) RemoveEntry(id string) error
func (*ClientAdapter) RemoveExit ¶
func (a *ClientAdapter) RemoveExit(id string) error
func (*ClientAdapter) SetHopChain ¶
func (a *ClientAdapter) SetHopChain(tunnelID string, chain HopChain) error
type CoreMetrics ¶
type EntryConfig ¶
type EntryHealth ¶
type EntryNode ¶
type EntryNode struct {
Config EntryConfig
Listener net.Listener
Cancel context.CancelFunc
}
type EntryPool ¶
type EntryPool struct {
// contains filtered or unexported fields
}
func NewEntryPool ¶
func NewEntryPool(registry *ProtocolRegistry, health *HealthChecker) *EntryPool
func (*EntryPool) Add ¶
func (p *EntryPool) Add(cfg EntryConfig) error
func (*EntryPool) List ¶
func (p *EntryPool) List() []EntryConfig
type ExitNode ¶
type ExitNode struct {
Config ExitConfig
Load int64 // atomic
}
type ExitRegistry ¶
type ExitRegistry struct {
// contains filtered or unexported fields
}
func NewExitRegistry ¶
func NewExitRegistry(health *HealthChecker) *ExitRegistry
func (*ExitRegistry) Add ¶
func (r *ExitRegistry) Add(cfg ExitConfig)
func (*ExitRegistry) Remove ¶
func (r *ExitRegistry) Remove(id string)
func (*ExitRegistry) Select ¶
func (r *ExitRegistry) Select() (*ExitNode, error)
func (*ExitRegistry) SetPolicy ¶
func (r *ExitRegistry) SetPolicy(p LBPolicy)
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
func NewHealthChecker ¶
func NewHealthChecker() *HealthChecker
func (*HealthChecker) GetHealth ¶
func (hc *HealthChecker) GetHealth(id string) (NodeHealth, bool)
func (*HealthChecker) ReportFailure ¶
func (hc *HealthChecker) ReportFailure(id string)
func (*HealthChecker) ReportSuccess ¶
func (hc *HealthChecker) ReportSuccess(id string, rtt time.Duration)
type HealthState ¶
type HealthState string
const ( HealthActive HealthState = "active" HealthDegraded HealthState = "degraded" HealthOffline HealthState = "offline" )
type HybridScheduler ¶
type HybridScheduler struct{}
func (*HybridScheduler) Select ¶
func (s *HybridScheduler) Select(paths []*PathConn) *PathConn
type MinRTTScheduler ¶
type MinRTTScheduler struct{}
func (*MinRTTScheduler) Select ¶
func (s *MinRTTScheduler) Select(paths []*PathConn) *PathConn
type NodeHealth ¶
type NodeSnapshot ¶
type NodeSnapshot struct {
Entries []EntryHealth
Exits []ExitHealth
}
type PacketReorder ¶
type PacketReorder struct {
// contains filtered or unexported fields
}
func NewPacketReorder ¶
func NewPacketReorder(windowSize int) *PacketReorder
func (*PacketReorder) Insert ¶
func (r *PacketReorder) Insert(p Packet) []Packet
type PathScheduler ¶
type PathSnapshot ¶
type ProtocolAdapter ¶
type ProtocolRegistry ¶
type ProtocolRegistry struct {
// contains filtered or unexported fields
}
func NewProtocolRegistry ¶
func NewProtocolRegistry() *ProtocolRegistry
func (*ProtocolRegistry) Get ¶
func (r *ProtocolRegistry) Get(name Protocol) (ProtocolAdapter, bool)
func (*ProtocolRegistry) Register ¶
func (r *ProtocolRegistry) Register(adapter ProtocolAdapter)
type QUICAdapter ¶
type QUICAdapter struct{}
QUICAdapter implementation
func (QUICAdapter) Dial ¶
func (a QUICAdapter) Dial(ctx context.Context, addr string, cfg AdapterConfig) (net.Conn, error)
func (QUICAdapter) Listen ¶
func (a QUICAdapter) Listen(ctx context.Context, addr string, cfg AdapterConfig) (net.Listener, error)
func (QUICAdapter) Name ¶
func (a QUICAdapter) Name() Protocol
type RelayEngine ¶
type RelayEngine struct {
// contains filtered or unexported fields
}
func NewRelayEngine ¶
func NewRelayEngine(registry *ProtocolRegistry) *RelayEngine
type RoundRobinScheduler ¶
type RoundRobinScheduler struct {
// contains filtered or unexported fields
}
func (*RoundRobinScheduler) Select ¶
func (s *RoundRobinScheduler) Select(paths []*PathConn) *PathConn
type ServerAdapter ¶
type ServerAdapter struct {
// contains filtered or unexported fields
}
func NewServerAdapter ¶
func (*ServerAdapter) AddEntry ¶
func (a *ServerAdapter) AddEntry(cfg EntryConfig) error
func (*ServerAdapter) AddExit ¶
func (a *ServerAdapter) AddExit(cfg ExitConfig) error
func (*ServerAdapter) AggMetrics ¶
func (a *ServerAdapter) AggMetrics(tunnelID string) AggSnapshot
func (*ServerAdapter) DisableAggregation ¶
func (a *ServerAdapter) DisableAggregation(tunnelID string) error
func (*ServerAdapter) EnableAggregation ¶
func (a *ServerAdapter) EnableAggregation(tunnelID string, policy AggPolicy) error
func (*ServerAdapter) GetHopChain ¶
func (a *ServerAdapter) GetHopChain(tunnelID string) (HopChain, error)
func (*ServerAdapter) ListNodes ¶
func (a *ServerAdapter) ListNodes() NodeSnapshot
func (*ServerAdapter) Metrics ¶
func (a *ServerAdapter) Metrics() CoreMetrics
func (*ServerAdapter) RemoveEntry ¶
func (a *ServerAdapter) RemoveEntry(id string) error
func (*ServerAdapter) RemoveExit ¶
func (a *ServerAdapter) RemoveExit(id string) error
func (*ServerAdapter) SetHopChain ¶
func (a *ServerAdapter) SetHopChain(tunnelID string, chain HopChain) error
type TCPAdapter ¶
type TCPAdapter struct{}
TCPAdapter implementation
func (TCPAdapter) Dial ¶
func (a TCPAdapter) Dial(ctx context.Context, addr string, cfg AdapterConfig) (net.Conn, error)
func (TCPAdapter) Listen ¶
func (a TCPAdapter) Listen(ctx context.Context, addr string, cfg AdapterConfig) (net.Listener, error)
func (TCPAdapter) Name ¶
func (a TCPAdapter) Name() Protocol
type TLSAdapter ¶
type TLSAdapter struct{}
TLSAdapter implementation
func (TLSAdapter) Dial ¶
func (a TLSAdapter) Dial(ctx context.Context, addr string, cfg AdapterConfig) (net.Conn, error)
func (TLSAdapter) Listen ¶
func (a TLSAdapter) Listen(ctx context.Context, addr string, cfg AdapterConfig) (net.Listener, error)
func (TLSAdapter) Name ¶
func (a TLSAdapter) Name() Protocol
type TunnelCore ¶
type TunnelCore interface {
Start(ctx context.Context) error
Metrics() CoreMetrics
// v5 新增 — 多节点
AddEntry(cfg EntryConfig) error
RemoveEntry(id string) error
AddExit(cfg ExitConfig) error
RemoveExit(id string) error
ListNodes() NodeSnapshot
// v5 新增 — 多跳
SetHopChain(tunnelID string, chain HopChain) error
GetHopChain(tunnelID string) (HopChain, error)
// v5 新增 — 带宽聚合
EnableAggregation(tunnelID string, policy AggPolicy) error
DisableAggregation(tunnelID string) error
AggMetrics(tunnelID string) AggSnapshot
}
TunnelCore 是 Agent 与隧道实例之间的唯一契约
type TunnelEvent ¶
type TunnelEvent struct {
ID string
State TunnelState
Err error
}
type TunnelInstance ¶
type TunnelInstance struct {
Spec TunnelSpec
// contains filtered or unexported fields
}
func (*TunnelInstance) Core ¶
func (i *TunnelInstance) Core() TunnelCore
func (*TunnelInstance) State ¶
func (i *TunnelInstance) State() TunnelState
type TunnelManager ¶
type TunnelManager struct {
// v5 全局组件引用
Protocols *ProtocolRegistry
Health *HealthChecker
Entries *EntryPool
Exits *ExitRegistry
// contains filtered or unexported fields
}
func NewTunnelManager ¶
func NewTunnelManager(rootCtx context.Context, onChange chan<- TunnelEvent, reg *ProtocolRegistry, hc *HealthChecker, ep *EntryPool, ex *ExitRegistry) *TunnelManager
func (*TunnelManager) All ¶
func (m *TunnelManager) All() []*TunnelInstance
func (*TunnelManager) Get ¶
func (m *TunnelManager) Get(id string) (*TunnelInstance, bool)
func (*TunnelManager) Start ¶
func (m *TunnelManager) Start(spec TunnelSpec) error
func (*TunnelManager) Stop ¶
func (m *TunnelManager) Stop(id string) error
type TunnelSpec ¶
type TunnelState ¶
type TunnelState int32
const ( StateStarting TunnelState = iota // goroutine 已启动,等待 Start() 返回 StateRunning // 隧道正常工作 StateStopping // 已收到 Stop 指令,context 已 cancel StateStopped // goroutine 正常退出 StateError // goroutine 退出但有 error )
func (TunnelState) String ¶
func (s TunnelState) String() string
type UDPAdapter ¶
type UDPAdapter struct{}
UDPAdapter implementation
func (UDPAdapter) Dial ¶
func (a UDPAdapter) Dial(ctx context.Context, addr string, cfg AdapterConfig) (net.Conn, error)
func (UDPAdapter) Listen ¶
func (a UDPAdapter) Listen(ctx context.Context, addr string, cfg AdapterConfig) (net.Listener, error)
func (UDPAdapter) Name ¶
func (a UDPAdapter) Name() Protocol
type V5Tunnel ¶
type V5Tunnel struct {
ID string
Spec TunnelSpec
// contains filtered or unexported fields
}
func NewV5Tunnel ¶
func NewV5Tunnel(spec TunnelSpec, reg *ProtocolRegistry, hc *HealthChecker, logger *logs.Logger) *V5Tunnel
func (*V5Tunnel) AddEntry ¶
func (t *V5Tunnel) AddEntry(cfg EntryConfig) error
func (*V5Tunnel) AddExit ¶
func (t *V5Tunnel) AddExit(cfg ExitConfig) error
func (*V5Tunnel) AggMetrics ¶
func (t *V5Tunnel) AggMetrics(tunnelID string) AggSnapshot
func (*V5Tunnel) DisableAggregation ¶
func (*V5Tunnel) EnableAggregation ¶
func (*V5Tunnel) ListNodes ¶
func (t *V5Tunnel) ListNodes() NodeSnapshot
func (*V5Tunnel) Metrics ¶
func (t *V5Tunnel) Metrics() CoreMetrics
func (*V5Tunnel) RemoveEntry ¶
func (*V5Tunnel) RemoveExit ¶
func (*V5Tunnel) SetHopChain ¶
type WSAdapter ¶
type WSAdapter struct{}
WSAdapter implementation
type WeightedBPSScheduler ¶
type WeightedBPSScheduler struct{}
func (*WeightedBPSScheduler) Select ¶
func (s *WeightedBPSScheduler) Select(paths []*PathConn) *PathConn
Click to show internal directories.
Click to hide internal directories.