Documentation
¶
Index ¶
- type CertData
- type CertPair
- type Peer
- type PeerBandwidth
- type PeerReading
- type PortRange
- type Target
- type WgConfig
- type WireGuardService
- func (s *WireGuardService) AddCerts(certs []CertData)
- func (s *WireGuardService) Close()
- func (s *WireGuardService) GetNetstackNet() *netstack2.Net
- func (s *WireGuardService) GetPublicKey() wgtypes.Key
- func (s *WireGuardService) IsReady() bool
- func (s *WireGuardService) LoadRemoteConfig() error
- func (s *WireGuardService) RemoveCerts(ids []string)
- func (s *WireGuardService) ReportRTT(seconds float64)
- func (s *WireGuardService) SetBlocked(v bool)
- func (s *WireGuardService) SetCerts(certs []CertData)
- func (s *WireGuardService) SetCredentialStore(store *nativessh.CredentialStore)
- func (s *WireGuardService) SetOnNetstackClose(callback func())
- func (s *WireGuardService) SetOnNetstackReady(callback func(*netstack2.Net))
- func (s *WireGuardService) SetOthertnet(tnet *netstack.Net)
- func (s *WireGuardService) SetToken(token string)
- func (s *WireGuardService) StartDirectUDPRelay(tunnelIP string) error
- func (s *WireGuardService) StartHolepunch(publicKey string, endpoint string, relayPort uint16)
- func (s *WireGuardService) StopDirectUDPRelay()
- func (s *WireGuardService) Sync(peers []Peer, targets []Target, identities []netstack2.ClientIdentity)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertData ¶ added in v1.16.0
CertData is a single shared TLS certificate/key pair, referenced by ID from one or more Targets via TLSCertID. Sent once per sync message so that many targets backed by the same certificate (e.g. a wildcard cert) don't each carry a full copy of the PEM data.
type CertPair ¶ added in v1.16.0
CertPair holds the resolved PEM certificate/key material for a CertData entry.
type PeerBandwidth ¶
type PeerReading ¶
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
TLSCertID string `json:"tlsCertId,omitempty"` // references an entry in the sync message's Certs list instead of inlining TLSCert/TLSKey
}
type WireGuardService ¶
type WireGuardService struct {
Port uint16
// Proxy manager for tunnel
TunnelIP string
// contains filtered or unexported fields
}
func NewWireGuardService ¶
func (*WireGuardService) AddCerts ¶ added in v1.16.0
func (s *WireGuardService) AddCerts(certs []CertData)
AddCerts upserts the given certs into the lookup table used by resolveTLS, without discarding any certs already present. Used for incremental cert pushes (e.g. after a renewal) outside of a full newt/sync or newt/wg/receive-config, which replace the table wholesale via SetCerts.
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) RemoveCerts ¶ added in v1.16.0
func (s *WireGuardService) RemoveCerts(ids []string)
RemoveCerts deletes the given cert IDs from the lookup table, e.g. once the server knows no target references them anymore.
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) SetCerts ¶ added in v1.16.0
func (s *WireGuardService) SetCerts(certs []CertData)
SetCerts replaces the TLSCertID lookup table used by resolveTLS. The server sends the complete set of referenced certs on every full sync, so this is a wholesale replacement rather than an incremental merge.
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, identities []netstack2.ClientIdentity)
Sync synchronizes the clients WireGuard peers and targets with the desired state received as part of the main newt/sync message.