wgnetstack

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAvailableUDPPort

func FindAvailableUDPPort(minPort, maxPort uint16) (uint16, error)

find an available UDP port in the range [minPort, maxPort] and also the next port for the wgtester

func NewFixedPortBind

func NewFixedPortBind(port uint16) conn.Bind

Types

type Peer

type Peer struct {
	PublicKey  string   `json:"publicKey"`
	AllowedIPs []string `json:"allowedIps"`
	Endpoint   string   `json:"endpoint"`
}

type PeerBandwidth

type PeerBandwidth struct {
	PublicKey string  `json:"publicKey"`
	BytesIn   float64 `json:"bytesIn"`
	BytesOut  float64 `json:"bytesOut"`
}

type PeerReading

type PeerReading struct {
	BytesReceived    int64
	BytesTransmitted int64
	LastChecked      time.Time
}

type TargetData

type TargetData struct {
	Targets []string `json:"targets"`
}

type TargetsByType

type TargetsByType struct {
	UDP []string `json:"udp"`
	TCP []string `json:"tcp"`
}

type WgConfig

type WgConfig struct {
	IpAddress string        `json:"ipAddress"`
	Peers     []Peer        `json:"peers"`
	Targets   TargetsByType `json:"targets"`
}

type WireGuardService

type WireGuardService struct {
	Port uint16

	TunnelIP string
	// contains filtered or unexported fields
}

func NewWireGuardService

func NewWireGuardService(interfaceName string, mtu int, generateAndSaveKeyTo string, host string, newtId string, wsClient *websocket.Client, dns string) (*WireGuardService, error)

func (*WireGuardService) AddProxyTarget

func (s *WireGuardService) AddProxyTarget(proto, listenIP string, port int, targetAddr string) error

AddProxyTarget adds a target to the proxy manager

func (*WireGuardService) Close

func (s *WireGuardService) Close(rm bool)

func (*WireGuardService) GetNetstackNet

func (s *WireGuardService) GetNetstackNet() *netstack.Net

GetNetstackNet returns the netstack network interface for use by other components

func (*WireGuardService) GetProxyManager

func (s *WireGuardService) GetProxyManager() *proxy.ProxyManager

GetProxyManager returns the proxy manager for this WireGuardService

func (*WireGuardService) GetPublicKey

func (s *WireGuardService) GetPublicKey() wgtypes.Key

GetPublicKey returns the public key of this WireGuard service

func (*WireGuardService) IsReady

func (s *WireGuardService) IsReady() bool

IsReady returns true if the WireGuard service is ready to use

func (*WireGuardService) LoadRemoteConfig

func (s *WireGuardService) LoadRemoteConfig() error

func (*WireGuardService) RemoveProxyTarget

func (s *WireGuardService) RemoveProxyTarget(proto, listenIP string, port int) error

RemoveProxyTarget removes a target from the proxy manager

func (*WireGuardService) ReplaceNetstack

func (s *WireGuardService) ReplaceNetstack() error

Add this method to WireGuardService

func (*WireGuardService) ReportRTT

func (s *WireGuardService) ReportRTT(seconds float64)

ReportRTT allows reporting native RTTs to telemetry, rate-limited externally.

func (*WireGuardService) SetOnNetstackClose

func (s *WireGuardService) SetOnNetstackClose(callback func())

func (*WireGuardService) SetOnNetstackReady

func (s *WireGuardService) SetOnNetstackReady(callback func(*netstack.Net))

SetOnNetstackReady sets a callback function to be called when the netstack interface is ready

func (*WireGuardService) SetOthertnet

func (s *WireGuardService) SetOthertnet(tnet *netstack.Net)

func (*WireGuardService) SetToken

func (s *WireGuardService) SetToken(token string)

func (*WireGuardService) StartHolepunch

func (s *WireGuardService) StartHolepunch(serverPubKey string, endpoint string)

Jump to

Keyboard shortcuts

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