Documentation
¶
Index ¶
- type ExitNode
- type HolepunchStatus
- type HolepunchStatusCallback
- type HolepunchTester
- func (t *HolepunchTester) ClearCache()
- func (t *HolepunchTester) InvalidateCache(endpoint string)
- func (t *HolepunchTester) SetCallback(callback HolepunchStatusCallback)
- func (t *HolepunchTester) Start() error
- func (t *HolepunchTester) Stop()
- func (t *HolepunchTester) TestEndpoint(endpoint string, timeout time.Duration) TestResult
- type Manager
- func (m *Manager) AddExitNode(exitNode ExitNode) bool
- func (m *Manager) GetExitNodes() []ExitNode
- func (m *Manager) GetServerHolepunchInterval() (min, max time.Duration)
- func (m *Manager) IsRunning() bool
- func (m *Manager) RemoveExitNode(endpoint string) bool
- func (m *Manager) RemoveExitNodesByPeer(peerID int) int
- func (m *Manager) ResetServerHolepunchInterval()
- func (m *Manager) SetServerHolepunchInterval(min, max time.Duration)
- func (m *Manager) SetToken(token string)
- func (m *Manager) Start() error
- func (m *Manager) StartMultipleExitNodes(exitNodes []ExitNode) error
- func (m *Manager) Stop()
- func (m *Manager) TriggerHolePunch() error
- type TestConnectionOptions
- type TestResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExitNode ¶
type ExitNode struct {
Endpoint string `json:"endpoint"`
RelayPort uint16 `json:"relayPort"`
PublicKey string `json:"publicKey"`
SiteIds []int `json:"siteIds,omitempty"`
}
ExitNode represents a WireGuard exit node for hole punching
type HolepunchStatus ¶
HolepunchStatus represents the status of a holepunch connection
type HolepunchStatusCallback ¶
type HolepunchStatusCallback func(status HolepunchStatus)
HolepunchStatusCallback is called when holepunch status changes
type HolepunchTester ¶
type HolepunchTester struct {
// contains filtered or unexported fields
}
HolepunchTester monitors holepunch connectivity using magic packets
func NewHolepunchTester ¶
func NewHolepunchTester(sharedBind *bind.SharedBind) *HolepunchTester
NewHolepunchTester creates a new holepunch tester using the given SharedBind
func (*HolepunchTester) ClearCache ¶ added in v1.9.0
func (t *HolepunchTester) ClearCache()
ClearCache clears all cached addresses
func (*HolepunchTester) InvalidateCache ¶ added in v1.9.0
func (t *HolepunchTester) InvalidateCache(endpoint string)
InvalidateCache removes a specific endpoint from the address cache
func (*HolepunchTester) SetCallback ¶
func (t *HolepunchTester) SetCallback(callback HolepunchStatusCallback)
SetCallback sets the callback for connection status changes
func (*HolepunchTester) Start ¶
func (t *HolepunchTester) Start() error
Start begins listening for magic packet responses
func (*HolepunchTester) TestEndpoint ¶
func (t *HolepunchTester) TestEndpoint(endpoint string, timeout time.Duration) TestResult
TestEndpoint sends a magic test packet to the endpoint and waits for a response. This uses the SharedBind so packets come from the same source port as WireGuard.
type Manager ¶
type Manager struct {
ID string
// contains filtered or unexported fields
}
Manager handles UDP hole punching operations
func NewManager ¶
func NewManager(sharedBind *bind.SharedBind, ID string, clientType string, publicKey string) *Manager
NewManager creates a new hole punch manager
func (*Manager) AddExitNode ¶
AddExitNode adds a new exit node to the rotation if it doesn't already exist
func (*Manager) GetExitNodes ¶
GetExitNodes returns a copy of the current exit nodes
func (*Manager) GetServerHolepunchInterval ¶ added in v1.9.0
GetInterval returns the current min and max intervals
func (*Manager) RemoveExitNode ¶
RemoveExitNode removes an exit node from the rotation
func (*Manager) RemoveExitNodesByPeer ¶
RemoveExitNodesByPeer removes the peer ID from the SiteIds list in each exit node. If the SiteIds list becomes empty after removal, the exit node is removed entirely. Returns the number of exit nodes removed.
func (*Manager) ResetServerHolepunchInterval ¶ added in v1.9.0
func (m *Manager) ResetServerHolepunchInterval()
ResetServerHolepunchInterval resets the hole punch interval back to the default values. This restores normal operation after low power mode or other custom settings.
func (*Manager) SetServerHolepunchInterval ¶ added in v1.9.0
SetServerHolepunchInterval sets custom min and max intervals for hole punching. This is useful for low power mode where longer intervals are desired.
func (*Manager) StartMultipleExitNodes ¶
StartMultipleExitNodes starts hole punching to multiple exit nodes
func (*Manager) TriggerHolePunch ¶
TriggerHolePunch sends an immediate hole punch packet to all configured exit nodes This is useful for triggering hole punching on demand without waiting for the interval
type TestConnectionOptions ¶
type TestConnectionOptions struct {
// Timeout is how long to wait for a response (default: 5 seconds)
Timeout time.Duration
// Retries is the number of times to retry on failure (default: 0)
Retries int
}
TestConnectionOptions configures the connection test
func DefaultTestOptions ¶
func DefaultTestOptions() TestConnectionOptions
DefaultTestOptions returns the default test options
type TestResult ¶
type TestResult struct {
// Success indicates whether the test was successful
Success bool
// RTT is the round-trip time of the test packet
RTT time.Duration
// Endpoint is the endpoint that was tested
Endpoint string
// Error contains any error that occurred during the test
Error error
}
TestResult represents the result of a connection test
func TestConnectionWithBind ¶
func TestConnectionWithBind(sharedBind *bind.SharedBind, endpoint string, opts *TestConnectionOptions) TestResult
TestConnectionWithBind sends a magic test packet using an existing SharedBind. This is useful when you want to test the connection through the same socket that WireGuard is using, which tests the actual hole-punched path.