clients

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 PortRange

type PortRange struct {
	Min      uint16 `json:"min"`
	Max      uint16 `json:"max"`
	Protocol string `json:"protocol"` // "tcp" or "udp"
}

type Target

type Target struct {
	SourcePrefix   string                 `json:"sourcePrefix"`
	SourcePrefixes []string               `json:"sourcePrefixes"`
	DestPrefix     string                 `json:"destPrefix"`
	RewriteTo      string                 `json:"rewriteTo,omitempty"`
	DisableIcmp    bool                   `json:"disableIcmp,omitempty"`
	PortRange      []PortRange            `json:"portRange,omitempty"`
	ResourceId     int                    `json:"resourceId,omitempty"`
	Protocol       string                 `json:"protocol,omitempty"`    // for now practicably either http or https
	HTTPTargets    []netstack2.HTTPTarget `json:"httpTargets,omitempty"` // for http protocol, list of downstream services to load balance across
	TLSCert        string                 `json:"tlsCert,omitempty"`     // PEM-encoded certificate for incoming HTTPS termination
	TLSKey         string                 `json:"tlsKey,omitempty"`      // PEM-encoded private key for incoming HTTPS termination
}

type WgConfig

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

type WireGuardService

type WireGuardService struct {
	Port uint16

	// Proxy manager for tunnel
	TunnelIP string
	// contains filtered or unexported fields
}

func NewWireGuardService

func NewWireGuardService(interfaceName string, port uint16, mtu int, host string, newtId string, wsClient *websocket.Client, dns string, useNativeInterface bool) (*WireGuardService, error)

func (*WireGuardService) Close

func (s *WireGuardService) Close()

func (*WireGuardService) GetNetstackNet

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

GetNetstackNet returns the netstack network interface for use by other components

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) ReportRTT

func (s *WireGuardService) ReportRTT(seconds float64)

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

func (*WireGuardService) SetBlocked added in v1.13.0

func (s *WireGuardService) SetBlocked(v bool)

SetBlocked enables or disables connection blocking for this WireGuard service. The state is persisted and applied immediately to any active proxy handler.

func (*WireGuardService) SetCredentialStore added in v1.13.0

func (s *WireGuardService) SetCredentialStore(store *nativessh.CredentialStore)

SetCredentialStore sets the in-memory SSH credential store used by the native SSH server. It must be called before the netstack is configured (i.e. before the first newt/wg/receive-config message is processed).

func (*WireGuardService) SetOnNetstackClose

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

func (*WireGuardService) SetOnNetstackReady

func (s *WireGuardService) SetOnNetstackReady(callback func(*netstack2.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) StartDirectUDPRelay

func (s *WireGuardService) StartDirectUDPRelay(tunnelIP string) error

StartDirectUDPRelay starts a direct UDP relay from the main tunnel netstack to the clients' WireGuard. This bypasses the proxy by listening on the main tunnel's netstack and forwarding packets directly to the SharedBind that feeds the clients' WireGuard device. Responses are automatically routed back through the netstack by the SharedBind. tunnelIP is the IP address to listen on within the main tunnel's netstack.

func (*WireGuardService) StartHolepunch

func (s *WireGuardService) StartHolepunch(publicKey string, endpoint string, relayPort uint16)

StartHolepunch starts hole punching to a specific endpoint

func (*WireGuardService) StopDirectUDPRelay

func (s *WireGuardService) StopDirectUDPRelay()

StopDirectUDPRelay stops the direct UDP relay and closes the netstack listener

func (*WireGuardService) Sync added in v1.14.0

func (s *WireGuardService) Sync(peers []Peer, targets []Target)

Sync synchronizes the clients WireGuard peers and targets with the desired state received as part of the main newt/sync message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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