bridge

package
v0.34.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: GPL-3.0 Imports: 37 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServerTcpEnable  = false
	ServerKcpEnable  = false
	ServerQuicEnable = false
	ServerTlsEnable  = false
	ServerWsEnable   = false
	ServerWssEnable  = false
	ServerSecureMode = false
)
View Source
var (
	// ErrClientOffline is returned by RequestClientUpdate for a client that
	// has no connected npc.
	ErrClientOffline = errors.New("client is offline")
	// ErrUpdateUnsupported is returned by RequestClientUpdate when no
	// connected npc of the client acts on update requests.
	ErrUpdateUnsupported = fmt.Errorf("client version does not support remote update, npc %s or newer is required", version.RemoteUpdateMinVersion)
)
View Source
var ClientSelectMode = Primary

Functions

func SetClientSelectMode added in v0.30.3

func SetClientSelectMode(v any) error

Types

type Bridge

type Bridge struct {
	Client             *sync.Map
	VirtualTcpListener *netx.ChanListener
	VirtualTlsListener *netx.ChanListener
	VirtualWsListener  *netx.ChanListener
	VirtualWssListener *netx.ChanListener
	OpenHost           chan *file.Host
	OpenTask           chan *file.Tunnel
	CloseTask          chan *file.Tunnel
	CloseClient        chan int
	SecretChan         chan *conn.Secret
	// contains filtered or unexported fields
}

func NewTunnel

func NewTunnel(runList *sync.Map, disconnectTime int) *Bridge

func (*Bridge) CliProcess added in v0.33.7

func (s *Bridge) CliProcess(c *conn.Conn, tunnelType string)

func (*Bridge) DelClient

func (s *Bridge) DelClient(id int)

func (*Bridge) GetHealthFromClient

func (s *Bridge) GetHealthFromClient(id int, c *conn.Conn, client *Client, node *Node)

func (*Bridge) IsServer added in v0.30.4

func (s *Bridge) IsServer() bool

func (*Bridge) RequestClientUpdate added in v0.34.9

func (s *Bridge) RequestClientUpdate(id int) (int, error)

RequestClientUpdate asks every connected npc of client id that supports it to update itself to the latest release. It returns how many were asked.

func (*Bridge) SendLinkInfo

func (s *Bridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error)

func (*Bridge) StartP2P added in v0.34.8

func (s *Bridge) StartP2P(cfg P2PConfig) error

StartP2P starts the NAT observers and the coordinator. It must be called before the bridge serves clients; without it P2P requests are refused.

func (*Bridge) StartTunnel

func (s *Bridge) StartTunnel() error

func (*Bridge) StopP2P added in v0.34.8

func (s *Bridge) StopP2P()

StopP2P closes the P2P service; running sessions end.

type Client

type Client struct {
	Id       int
	LastUUID string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(id int, n *Node) *Client

func (*Client) AddFile added in v0.30.3

func (c *Client) AddFile(key, uuid string) error

func (*Client) AddNode added in v0.30.6

func (c *Client) AddNode(n *Node)

func (*Client) CheckNode added in v0.30.6

func (c *Client) CheckNode() *Node

func (*Client) Close added in v0.30.3

func (c *Client) Close() error

func (*Client) GetNode added in v0.30.6

func (c *Client) GetNode() *Node

func (*Client) GetNodeByFile added in v0.30.6

func (c *Client) GetNodeByFile(key string) (*Node, bool)

func (*Client) GetNodeByUUID added in v0.32.0

func (c *Client) GetNodeByUUID(uuid string) (*Node, bool)

func (*Client) InConnectGraceWindow added in v0.34.5

func (c *Client) InConnectGraceWindow(window time.Duration) bool

func (*Client) IsClosed added in v0.30.3

func (c *Client) IsClosed() bool

func (*Client) MarkConnectedNow added in v0.34.5

func (c *Client) MarkConnectedNow()

func (*Client) NodeCount added in v0.30.6

func (c *Client) NodeCount() int

func (*Client) RemoveFile added in v0.30.6

func (c *Client) RemoveFile(key string)

func (*Client) RemoveOfflineNodes added in v0.31.1

func (c *Client) RemoveOfflineNodes(ignoreClientGrace bool) (removed int)

func (*Client) RemoveOfflineNodesExcept added in v0.34.5

func (c *Client) RemoveOfflineNodesExcept(keepUUID string, ignoreClientGrace bool) (removed int)

type IdleTimer added in v0.32.0

type IdleTimer struct {
	// contains filtered or unexported fields
}

func NewIdleTimer added in v0.32.0

func NewIdleTimer(idle time.Duration, closeFn func()) *IdleTimer

func (*IdleTimer) Dec added in v0.32.0

func (it *IdleTimer) Dec()

func (*IdleTimer) Inc added in v0.32.0

func (it *IdleTimer) Inc()

func (*IdleTimer) Stop added in v0.32.0

func (it *IdleTimer) Stop()

type Node added in v0.30.6

type Node struct {
	Client  *Client
	UUID    string
	Version string
	BaseVer int
	// contains filtered or unexported fields
}

func NewNode added in v0.30.6

func NewNode(uuid, vs string, bv int) *Node

func (*Node) AddNode added in v0.30.6

func (n *Node) AddNode(node *Node)

func (*Node) AddSignal added in v0.30.6

func (n *Node) AddSignal(signal *conn.Conn)

func (*Node) AddTunnel added in v0.30.6

func (n *Node) AddTunnel(tunnel any)

func (*Node) Close added in v0.30.6

func (n *Node) Close() error

func (*Node) CloseIfSignalCurrent added in v0.34.8

func (n *Node) CloseIfSignalCurrent(signal *conn.Conn) bool

CloseIfSignalCurrent closes the node only while signal is still its signal connection, so that an outdated connection exiting cannot tear down a node that has been taken over by a newer connection with the same UUID.

func (*Node) CloseIfTunnelCurrent added in v0.34.8

func (n *Node) CloseIfTunnelCurrent(tunnel any) bool

CloseIfTunnelCurrent is CloseIfSignalCurrent for the tunnel.

func (*Node) GetSignal added in v0.30.6

func (n *Node) GetSignal() *conn.Conn

func (*Node) GetTunnel added in v0.30.6

func (n *Node) GetTunnel() any

func (*Node) InJoinGraceWindow added in v0.34.5

func (n *Node) InJoinGraceWindow(window time.Duration) bool

func (*Node) IsOffline added in v0.30.6

func (n *Node) IsOffline() bool

func (*Node) IsOnline added in v0.30.6

func (n *Node) IsOnline() bool

func (*Node) IsTunnelClosed added in v0.32.0

func (n *Node) IsTunnelClosed() bool

func (*Node) Retry added in v0.31.1

func (n *Node) Retry() bool

type P2PConfig added in v0.34.8

type P2PConfig struct {
	// BasePort is the first of the observers' three UDP ports; they listen
	// on 0.0.0.0 and, when the host allows it, on ::. 0 lets the kernel
	// choose.
	BasePort int
	// IP is p2p_ip: the addresses (IPs or host names, comma separated)
	// announced to the clients; 0.0.0.0 and :: detect the host's IPv4 and
	// IPv6 address.
	IP          string
	STUNServers []string          // host:port of public STUN servers handed to the clients; empty: none
	Timeouts    protocol.Timeouts // zero fields take the library defaults
	// PortMapping enables the clients' port mapping methods.
	PortMapping protocol.PortMappingPolicy
}

P2PConfig configures the bridge's P2P service: the NAT observers and the coordinator that pairs a visitor with a provider.

type SelectMode added in v0.30.3

type SelectMode int32
const (
	Primary SelectMode = iota
	RoundRobin
	Random
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL