Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrorWaitSec = 3 // If a tunnel cannot be dialed, will wait for this period and retry infinitely TunnelBlockTimeoutSec = 8 // If a tunnel cannot send a block within the limit, will treat it a dead tunnel EmptyPoolDestroySec = 60 // The pool will be destroyed(server side) if no tunnel dialed in SendQueueSize = 48 // SendQueue channel cap RecvQueueSize = 48 // RecvQueue channel cap )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientManager ¶
type ClientManager struct {
// contains filtered or unexported fields
}
func NewClientManager ¶
func (*ClientManager) DecreaseNotify ¶
func (cm *ClientManager) DecreaseNotify(pool *TunnelPool)
Keep tunnelPool size above tunnelNum
func (*ClientManager) Notify ¶
func (cm *ClientManager) Notify(pool *TunnelPool)
type Manager ¶
type Manager interface { Notify(pool *TunnelPool) // When TunnelPool size changed, Notify should be called DecreaseNotify(pool *TunnelPool) // When TunnelPool size decreased, DecreaseNotify should be called }
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
func NewServerManager ¶
func NewServerManager(removePeerFunc context.CancelFunc) ServerManager
func (*ServerManager) DecreaseNotify ¶
func (sm *ServerManager) DecreaseNotify(pool *TunnelPool)
func (*ServerManager) Notify ¶
func (sm *ServerManager) Notify(pool *TunnelPool)
If tunnelPool size is zero for more than EmptyPoolDestroySec, delete it
type Tunnel ¶
func NewActiveTunnel ¶
Create a new tunnel from a net.Conn and cipher with random tunnelID
func (*Tunnel) InboundRelay ¶
Read bytes from connection, parse it to block then put in recv channel
func (*Tunnel) OutboundRelay ¶
Read block from send channel, pack it and send
type TunnelPool ¶
type TunnelPool struct {
// contains filtered or unexported fields
}
func NewTunnelPool ¶
func NewTunnelPool(peerID uint32, manager Manager, peerContext context.Context) *TunnelPool
func (*TunnelPool) AddTunnel ¶
func (tp *TunnelPool) AddTunnel(tunnel *Tunnel)
Add a tunnel to tunnelPool and start bi-relay
func (*TunnelPool) GetRecvQueue ¶
func (tp *TunnelPool) GetRecvQueue() chan block.Block
func (*TunnelPool) GetSendQueue ¶
func (tp *TunnelPool) GetSendQueue() chan block.Block
func (*TunnelPool) RemoveTunnel ¶
func (tp *TunnelPool) RemoveTunnel(tunnel *Tunnel)
Remove a tunnel from tunnelPool and stop bi-relay
Click to show internal directories.
Click to hide internal directories.