peer

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: BSD-3-Clause Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKeyNBForceRelay = "NB_FORCE_RELAY"
)

Variables

View Source
var (
	ErrPeerNotAvailable              = signal.ErrPeerNotAvailable
	ErrSignalNotSupportDeliveryCheck = errors.New("the signal client does not support SendWithDeliveryCheck")
)
View Source
var (
	ErrSignalIsNotReady = errors.New("signal is not ready")
)

Functions

func NewConnectionAlreadyClosed

func NewConnectionAlreadyClosed(peer string) error

NewConnectionAlreadyClosed creates a new ConnectionAlreadyClosedError error

func NewConnectionClosedError

func NewConnectionClosedError(peer string) error

NewConnectionClosedError creates a new ConnectionClosedError error

func NewConnectionDisconnectedError

func NewConnectionDisconnectedError(peer string) error

NewConnectionDisconnectedError creates a new ConnectionDisconnectedError error

func NewConnectionTimeoutError

func NewConnectionTimeoutError(peer string, timeout time.Duration) error

NewConnectionTimeoutError creates a new ConnectionTimeoutError error

Types

type AsyncOfferListener

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

func NewAsyncOfferListener

func NewAsyncOfferListener(fn callbackFunc) *AsyncOfferListener

func (*AsyncOfferListener) Notify

func (o *AsyncOfferListener) Notify(remoteOfferAnswer *OfferAnswer)

type Conn

type Conn struct {
	Log *log.Entry
	// contains filtered or unexported fields
}

func NewConn

func NewConn(config ConnConfig, services ServiceDependencies) (*Conn, error)

NewConn creates a new not opened Conn to the remote peer. To establish a connection run Conn.Open

func (*Conn) AgentVersionString

func (conn *Conn) AgentVersionString() string

func (*Conn) AllowedIP

func (conn *Conn) AllowedIP() netip.Addr

AllowedIP returns the allowed IP of the remote peer

func (*Conn) Close

func (conn *Conn) Close(signalToRemote bool)

Close closes this peer Conn issuing a close event to the Conn closeCh

func (*Conn) ConnID

func (conn *Conn) ConnID() id.ConnID

func (*Conn) GetKey

func (conn *Conn) GetKey() string

func (*Conn) IsConnected

func (conn *Conn) IsConnected() bool

IsConnected returns true if the peer is connected

func (*Conn) OnRemoteAnswer

func (conn *Conn) OnRemoteAnswer(answer OfferAnswer)

OnRemoteAnswer handles an offer from the remote peer and returns true if the message was accepted, false otherwise doesn't block, discards the message if connection wasn't ready

func (*Conn) OnRemoteCandidate

func (conn *Conn) OnRemoteCandidate(candidate ice.Candidate, haRoutes route.HAMap)

OnRemoteCandidate Handles ICE connection Candidate provided by the remote peer.

func (*Conn) OnRemoteOffer

func (conn *Conn) OnRemoteOffer(offer OfferAnswer)

func (*Conn) Open

func (conn *Conn) Open(engineCtx context.Context) error

Open opens connection to the remote peer It will try to establish a connection using ICE and in parallel with relay. The higher priority connection type will be used.

func (*Conn) SetOnConnected

func (conn *Conn) SetOnConnected(handler func(remoteWireGuardKey string, remoteRosenpassPubKey []byte, wireGuardIP string, remoteRosenpassAddr string))

SetOnConnected sets a handler function to be triggered by Conn when a new connection to a remote peer established

func (*Conn) SetOnDisconnected

func (conn *Conn) SetOnDisconnected(handler func(remotePeer string))

SetOnDisconnected sets a handler function to be triggered by Conn when a connection to a remote disconnected

func (*Conn) SetRosenpassInitializedPresharedKeyValidator added in v0.3.0

func (conn *Conn) SetRosenpassInitializedPresharedKeyValidator(handler func(peerKey string) bool)

SetRosenpassInitializedPresharedKeyValidator sets a function to check if Rosenpass has taken over PSK management for a peer. When this returns true, presharedKey() returns nil to prevent UpdatePeer from overwriting the Rosenpass-managed PSK.

func (*Conn) WgConfig

func (conn *Conn) WgConfig() WgConfig

WgConfig returns the WireGuard config

type ConnConfig

type ConnConfig struct {
	// Key is a public key of a remote peer
	Key string
	// LocalKey is a public key of a local peer
	LocalKey string

	AgentVersion string

	Timeout time.Duration

	WgConfig WgConfig

	LocalWgPort int

	RosenpassConfig RosenpassConfig

	// ICEConfig ICE protocol configuration
	ICEConfig icemaker.Config
}

ConnConfig is a peer Connection configuration

type ConnStatus

type ConnStatus int32

ConnStatus describe the status of a peer's connection

const (
	// StatusIdle indicate the peer is in disconnected state
	StatusIdle ConnStatus = iota
	// StatusConnecting indicate the peer is in connecting state
	StatusConnecting
	// StatusConnected indicate the peer is in connected state
	StatusConnected
)

func (ConnStatus) String

func (s ConnStatus) String() string

type ConnectionAlreadyClosedError

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

ConnectionAlreadyClosedError is an error indicating that a peer Conn has been already closed and the invocation of the Close() method has been performed over a closed connection

func (*ConnectionAlreadyClosedError) Error

type ConnectionClosedError

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

ConnectionClosedError is an error indicating that a peer Conn has been forcefully closed

func (*ConnectionClosedError) Error

func (e *ConnectionClosedError) Error() string

type ConnectionDisconnectedError

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

ConnectionDisconnectedError is an error indicating that a peer Conn has ctx from the remote

func (*ConnectionDisconnectedError) Error

type ConnectionTimeoutError

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

ConnectionTimeoutError is an error indicating that a peer Conn has been timed out

func (*ConnectionTimeoutError) Error

func (e *ConnectionTimeoutError) Error() string

type EndpointUpdater

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

func NewEndpointUpdater

func NewEndpointUpdater(log *logrus.Entry, wgConfig WgConfig, initiator bool) *EndpointUpdater

func (*EndpointUpdater) ConfigureWGEndpoint

func (e *EndpointUpdater) ConfigureWGEndpoint(addr *net.UDPAddr, presharedKey *wgtypes.Key) error

ConfigureWGEndpoint sets up the WireGuard endpoint configuration. The initiator immediately configures the endpoint, while the non-initiator waits for a fallback period before configuring to avoid handshake congestion.

func (*EndpointUpdater) RemoveWgPeer

func (e *EndpointUpdater) RemoveWgPeer() error

type EventListener

type EventListener interface {
	OnEvent(event *proto.SystemEvent)
}

type EventQueue

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

func NewEventQueue

func NewEventQueue(size int) *EventQueue

func (*EventQueue) Add

func (q *EventQueue) Add(event *proto.SystemEvent)

func (*EventQueue) GetAll

func (q *EventQueue) GetAll() []*proto.SystemEvent

type EventSubscription

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

func (*EventSubscription) Events

func (s *EventSubscription) Events() <-chan *proto.SystemEvent

type FullStatus

type FullStatus struct {
	Peers                 []State
	ManagementState       ManagementState
	SignalState           SignalState
	LocalPeerState        LocalPeerState
	RosenpassState        RosenpassState
	Relays                []relay.ProbeResult
	NSGroupStates         []NSGroupState
	NumOfForwardingRules  int
	LazyConnectionEnabled bool
	Events                []*proto.SystemEvent
}

FullStatus contains the full state held by the Status instance

func (FullStatus) ToProto added in v0.3.0

func (fs FullStatus) ToProto() *proto.FullStatus

ToProto converts FullStatus to proto.FullStatus.

type Guard added in v0.2.4

type Guard interface {
	Start(ctx context.Context, eventCallback func())
	SetRelayedConnDisconnected()
	SetICEConnDisconnected()
	FailedToSendOffer()
}

type Handshaker

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

func NewHandshaker

func NewHandshaker(log *log.Entry, config ConnConfig, signaler *Signaler, ice *WorkerICE, relay *WorkerRelay) *Handshaker

func (*Handshaker) AddICEListener

func (h *Handshaker) AddICEListener(offer func(remoteOfferAnswer *OfferAnswer))

func (*Handshaker) AddRelayListener

func (h *Handshaker) AddRelayListener(offer func(remoteOfferAnswer *OfferAnswer))

func (*Handshaker) Listen

func (h *Handshaker) Listen(ctx context.Context)

func (*Handshaker) OnRemoteAnswer

func (h *Handshaker) OnRemoteAnswer(answer OfferAnswer)

OnRemoteAnswer handles an offer from the remote peer and returns true if the message was accepted, false otherwise doesn't block, discards the message if connection wasn't ready

func (*Handshaker) OnRemoteOffer

func (h *Handshaker) OnRemoteOffer(offer OfferAnswer)

OnRemoteOffer handles an offer from the remote peer and returns true if the message was accepted, false otherwise doesn't block, discards the message if connection wasn't ready

func (*Handshaker) SendOffer

func (h *Handshaker) SendOffer() error

type ICEConnInfo

type ICEConnInfo struct {
	RemoteConn                 net.Conn
	RosenpassPubKey            []byte
	RosenpassAddr              string
	LocalIceCandidateType      string
	RemoteIceCandidateType     string
	RemoteIceCandidateEndpoint string
	LocalIceCandidateEndpoint  string
	Relayed                    bool
	RelayedOnLocal             bool
}

type ICESessionID

type ICESessionID string

func ICESessionIDFromBytes

func ICESessionIDFromBytes(b []byte) (ICESessionID, error)

func NewICESessionID

func NewICESessionID() (ICESessionID, error)

NewICESessionID generates a new session ID for distinguishing sessions

func (ICESessionID) Bytes

func (id ICESessionID) Bytes() ([]byte, error)

Bytes returns the raw bytes of the session ID for protobuf serialization

func (ICESessionID) String

func (id ICESessionID) String() string

type IceCredentials

type IceCredentials struct {
	UFrag string
	Pwd   string
}

IceCredentials ICE protocol credentials struct

type Listener

type Listener interface {
	OnConnected()
	OnDisconnected()
	OnConnecting()
	OnDisconnecting()
	OnAddressChanged(string, string)
	OnPeersListChanged(int)
}

Listener is a callback type about the Nirvati Connect network connection state

type LocalPeerState

type LocalPeerState struct {
	IP              string
	PubKey          string
	KernelInterface bool
	FQDN            string
	Routes          map[string]struct{}
}

LocalPeerState contains the latest state of the local peer

func (LocalPeerState) Clone

func (l LocalPeerState) Clone() LocalPeerState

Clone returns a copy of the LocalPeerState

type ManagementState

type ManagementState struct {
	URL       string
	Connected bool
	Error     error
}

ManagementState contains the latest state of a management connection

type NSGroupState

type NSGroupState struct {
	ID      string
	Servers []netip.AddrPort
	Domains []string
	Enabled bool
	Error   error
}

NSGroupState represents the status of a DNS server group, including associated domains, whether it's enabled, and the last error message encountered during probing.

type OfferAnswer

type OfferAnswer struct {
	IceCredentials IceCredentials
	// WgListenPort is a remote WireGuard listen port.
	// This field is used when establishing a direct WireGuard connection without any proxy.
	// We can set the remote peer's endpoint with this port.
	WgListenPort int

	// Version of Nirvati Connect Agent
	Version string
	// RosenpassPubKey is the Rosenpass public key of the remote peer when receiving this message
	// This value is the local Rosenpass server public key when sending the message
	RosenpassPubKey []byte
	// RosenpassAddr is the Rosenpass server address (IP:port) of the remote peer when receiving this message
	// This value is the local Rosenpass server address when sending the message
	RosenpassAddr string

	// relay server address
	RelaySrvAddress string
	// SessionID is the unique identifier of the session, used to discard old messages
	SessionID *ICESessionID
}

OfferAnswer represents a session establishment offer or answer

func (*OfferAnswer) SessionIDString

func (oa *OfferAnswer) SessionIDString() string

type RelayConnInfo

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

type ResolvedDomainInfo

type ResolvedDomainInfo struct {
	Prefixes     []netip.Prefix
	ParentDomain domain.Domain
}

type RosenpassConfig

type RosenpassConfig struct {
	// RosenpassPubKey is this peer's Rosenpass public key
	PubKey []byte
	// RosenpassPubKey is this peer's RosenpassAddr server address (IP:port)
	Addr string

	PermissiveMode bool
}

type RosenpassState

type RosenpassState struct {
	Enabled    bool
	Permissive bool
}

RosenpassState contains the latest state of the Rosenpass configuration

type RouterState

type RouterState struct {
	Status  ConnStatus
	Relayed bool
	Latency time.Duration
}

RouterState status for router peers. This contains relevant fields for route manager

type ServiceDependencies

type ServiceDependencies struct {
	StatusRecorder     *Status
	Signaler           *Signaler
	IFaceDiscover      stdnet.ExternalIFaceDiscover
	RelayManager       *relayClient.Manager
	SrWatcher          *guard.SRWatcher
	Semaphore          *semaphoregroup.SemaphoreGroup
	PeerConnDispatcher *dispatcher.ConnectionDispatcher
}

type SignalState

type SignalState struct {
	URL       string
	Connected bool
	Error     error
}

SignalState contains the latest state of a signal connection

type Signaler

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

func NewSignaler

func NewSignaler(signal signal.Client, wgPrivateKey wgtypes.Key) *Signaler

func (*Signaler) Ready

func (s *Signaler) Ready() bool

func (*Signaler) SignalAnswer

func (s *Signaler) SignalAnswer(offer OfferAnswer, remoteKey string) error

func (*Signaler) SignalICECandidate

func (s *Signaler) SignalICECandidate(candidate ice.Candidate, remoteKey string) error

func (*Signaler) SignalIdle

func (s *Signaler) SignalIdle(remoteKey string) error

func (*Signaler) SignalOffer

func (s *Signaler) SignalOffer(offer OfferAnswer, remoteKey string) error

type State

type State struct {
	Mux                        *sync.RWMutex
	IP                         string
	PubKey                     string
	FQDN                       string
	ConnStatus                 ConnStatus
	ConnStatusUpdate           time.Time
	Relayed                    bool
	LocalIceCandidateType      string
	RemoteIceCandidateType     string
	LocalIceCandidateEndpoint  string
	RemoteIceCandidateEndpoint string
	RelayServerAddress         string
	LastWireguardHandshake     time.Time
	BytesTx                    int64
	BytesRx                    int64
	Latency                    time.Duration
	RosenpassEnabled           bool
	SSHHostKey                 []byte
	// contains filtered or unexported fields
}

State contains the latest state of a peer

func (*State) AddRoute

func (s *State) AddRoute(network string)

AddRoute add a single route to routes map

func (*State) DeleteRoute

func (s *State) DeleteRoute(network string)

DeleteRoute removes a route from the network amp

func (*State) GetRoutes

func (s *State) GetRoutes() map[string]struct{}

GetRoutes return routes map

func (*State) SetRoutes

func (s *State) SetRoutes(routes map[string]struct{})

SetRoutes set state routes

type Status

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

Status holds a state of peers, signal, management connections and relays

func NewRecorder

func NewRecorder(mgmAddress string) *Status

NewRecorder returns a new Status instance

func (*Status) AddLocalPeerStateRoute

func (d *Status) AddLocalPeerStateRoute(route string, resourceId route.ResID)

AddLocalPeerStateRoute adds a route to the local peer state

func (*Status) AddPeer

func (d *Status) AddPeer(peerPubKey string, fqdn string, ip string) error

AddPeer adds peer to Daemon status map

func (*Status) AddPeerStateRoute

func (d *Status) AddPeerStateRoute(peer string, route string, resourceId route.ResID) error

func (*Status) AddResolvedIPLookupEntry

func (d *Status) AddResolvedIPLookupEntry(prefix netip.Prefix, resourceId route.ResID)

AddResolvedIPLookupEntry adds a resolved IP lookup entry

func (*Status) CheckRoutes

func (d *Status) CheckRoutes(ip netip.Addr) ([]byte, bool)

CheckRoutes checks if the source and destination addresses are within the same route and returns the resource ID of the route that contains the addresses

func (*Status) CleanLocalPeerState

func (d *Status) CleanLocalPeerState()

CleanLocalPeerState cleans local peer status

func (*Status) CleanLocalPeerStateRoutes

func (d *Status) CleanLocalPeerStateRoutes()

CleanLocalPeerStateRoutes cleans all routes from the local peer state

func (*Status) ClientStart

func (d *Status) ClientStart()

ClientStart will notify all listeners about the new service state

func (*Status) ClientStop

func (d *Status) ClientStop()

ClientStop will notify all listeners about the new service state

func (*Status) ClientTeardown

func (d *Status) ClientTeardown()

ClientTeardown will notify all listeners about the service is under teardown

func (*Status) DeleteResolvedDomainsStates

func (d *Status) DeleteResolvedDomainsStates(domain domain.Domain)

func (*Status) FinishPeerListModifications

func (d *Status) FinishPeerListModifications()

FinishPeerListModifications this event invoke the notification

func (*Status) ForwardingRules

func (d *Status) ForwardingRules() []firewall.ForwardRule

func (*Status) GetDNSStates

func (d *Status) GetDNSStates() []NSGroupState

func (*Status) GetEventHistory

func (d *Status) GetEventHistory() []*proto.SystemEvent

GetEventHistory returns all events in the queue

func (*Status) GetFullStatus

func (d *Status) GetFullStatus() FullStatus

GetFullStatus gets full status

func (*Status) GetLazyConnection

func (d *Status) GetLazyConnection() bool

func (*Status) GetLocalPeerState

func (d *Status) GetLocalPeerState() LocalPeerState

GetLocalPeerState returns the local peer state

func (*Status) GetManagementState

func (d *Status) GetManagementState() ManagementState

func (*Status) GetPeer

func (d *Status) GetPeer(peerPubKey string) (State, error)

GetPeer adds peer to Daemon status map

func (*Status) GetRelayStates

func (d *Status) GetRelayStates() []relay.ProbeResult

GetRelayStates returns the stun/turn/permanent relay states

func (*Status) GetResolvedDomainsStates

func (d *Status) GetResolvedDomainsStates() map[domain.Domain]ResolvedDomainInfo

func (*Status) GetRosenpassState

func (d *Status) GetRosenpassState() RosenpassState

func (*Status) GetSignalState

func (d *Status) GetSignalState() SignalState

func (*Status) IsLoginRequired

func (d *Status) IsLoginRequired() bool

IsLoginRequired determines if a peer's login has expired.

func (*Status) MarkManagementConnected

func (d *Status) MarkManagementConnected()

MarkManagementConnected sets ManagementState to connected

func (*Status) MarkManagementDisconnected

func (d *Status) MarkManagementDisconnected(err error)

MarkManagementDisconnected sets ManagementState to disconnected

func (*Status) MarkSignalConnected

func (d *Status) MarkSignalConnected()

MarkSignalConnected sets SignalState to connected

func (*Status) MarkSignalDisconnected

func (d *Status) MarkSignalDisconnected(err error)

MarkSignalDisconnected sets SignalState to disconnected

func (*Status) PeerByIP

func (d *Status) PeerByIP(ip string) (string, bool)

func (*Status) PeersStatus

func (d *Status) PeersStatus() (*configurer.Stats, error)

func (*Status) PublishEvent

func (d *Status) PublishEvent(
	severity proto.SystemEvent_Severity,
	category proto.SystemEvent_Category,
	msg string,
	userMsg string,
	metadata map[string]string,
)

PublishEvent adds an event to the queue and distributes it to all subscribers

func (*Status) RefreshWireGuardStats added in v0.3.0

func (d *Status) RefreshWireGuardStats() error

RefreshWireGuardStats fetches fresh WireGuard statistics from the interface and updates the cached peer states. This ensures accurate handshake times and transfer statistics in status reports without running full health probes.

func (*Status) RemoveConnectionListener

func (d *Status) RemoveConnectionListener()

RemoveConnectionListener remove the listener from the notifier

func (*Status) RemoveLocalPeerStateRoute

func (d *Status) RemoveLocalPeerStateRoute(route string)

RemoveLocalPeerStateRoute removes a route from the local peer state

func (*Status) RemovePeer

func (d *Status) RemovePeer(peerPubKey string) error

RemovePeer removes peer from Daemon status map

func (*Status) RemovePeerStateRoute

func (d *Status) RemovePeerStateRoute(peer string, route string) error

func (*Status) RemoveResolvedIPLookupEntry

func (d *Status) RemoveResolvedIPLookupEntry(route string)

RemoveResolvedIPLookupEntry removes a resolved IP lookup entry

func (*Status) ReplaceOfflinePeers

func (d *Status) ReplaceOfflinePeers(replacement []State)

ReplaceOfflinePeers replaces

func (*Status) SetConnectionListener

func (d *Status) SetConnectionListener(listener Listener)

SetConnectionListener set a listener to the notifier

func (*Status) SetIngressGwMgr

func (d *Status) SetIngressGwMgr(ingressGwMgr *ingressgw.Manager)

func (*Status) SetRelayMgr

func (d *Status) SetRelayMgr(manager *relayClient.Manager)

func (*Status) SetWgIface

func (d *Status) SetWgIface(wgInterface WGIfaceStatus)

func (*Status) SubscribeToEvents

func (d *Status) SubscribeToEvents() *EventSubscription

SubscribeToEvents returns a new event subscription

func (*Status) SubscribeToPeerStateChanges

func (d *Status) SubscribeToPeerStateChanges(ctx context.Context, peerID string) *StatusChangeSubscription

func (*Status) UnsubscribeFromEvents

func (d *Status) UnsubscribeFromEvents(sub *EventSubscription)

UnsubscribeFromEvents removes an event subscription

func (*Status) UnsubscribePeerStateChanges

func (d *Status) UnsubscribePeerStateChanges(subscription *StatusChangeSubscription)

func (*Status) UpdateDNSStates

func (d *Status) UpdateDNSStates(dnsStates []NSGroupState)

func (*Status) UpdateLatency

func (d *Status) UpdateLatency(pubKey string, latency time.Duration) error

func (*Status) UpdateLazyConnection

func (d *Status) UpdateLazyConnection(enabled bool)

func (*Status) UpdateLocalPeerState

func (d *Status) UpdateLocalPeerState(localPeerState LocalPeerState)

UpdateLocalPeerState updates local peer status

func (*Status) UpdateManagementAddress

func (d *Status) UpdateManagementAddress(mgmAddress string)

UpdateManagementAddress update the address of the management server

func (*Status) UpdatePeerFQDN

func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error

UpdatePeerFQDN update peer's state fqdn only

func (*Status) UpdatePeerICEState

func (d *Status) UpdatePeerICEState(receivedState State) error

func (*Status) UpdatePeerICEStateToDisconnected

func (d *Status) UpdatePeerICEStateToDisconnected(receivedState State) error

func (*Status) UpdatePeerRelayedState

func (d *Status) UpdatePeerRelayedState(receivedState State) error

func (*Status) UpdatePeerRelayedStateToDisconnected

func (d *Status) UpdatePeerRelayedStateToDisconnected(receivedState State) error

func (*Status) UpdatePeerSSHHostKey

func (d *Status) UpdatePeerSSHHostKey(peerPubKey string, sshHostKey []byte) error

UpdatePeerSSHHostKey updates peer's SSH host key

func (*Status) UpdatePeerState

func (d *Status) UpdatePeerState(receivedState State) error

UpdatePeerState updates peer status

func (*Status) UpdateRelayStates

func (d *Status) UpdateRelayStates(relayResults []relay.ProbeResult)

func (*Status) UpdateResolvedDomainsStates

func (d *Status) UpdateResolvedDomainsStates(originalDomain domain.Domain, resolvedDomain domain.Domain, prefixes []netip.Prefix, resourceId route.ResID)

func (*Status) UpdateRosenpass

func (d *Status) UpdateRosenpass(rosenpassEnabled, rosenpassPermissive bool)

UpdateRosenpass update the Rosenpass configuration

func (*Status) UpdateSignalAddress

func (d *Status) UpdateSignalAddress(signalURL string)

UpdateSignalAddress update the address of the signal server

func (*Status) UpdateWireGuardPeerState

func (d *Status) UpdateWireGuardPeerState(pubKey string, wgStats configurer.WGStats) error

UpdateWireGuardPeerState updates the WireGuard bits of the peer state

type StatusChangeSubscription

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

func (*StatusChangeSubscription) Events

func (s *StatusChangeSubscription) Events() chan map[string]RouterState

type WGIface

type WGIface interface {
	UpdatePeer(peerKey string, allowedIps []netip.Prefix, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error
	RemovePeer(peerKey string) error
	GetStats() (map[string]configurer.WGStats, error)
	GetProxy() wgproxy.Proxy
	Address() wgaddr.Address
	RemoveEndpointAddress(key string) error
}

type WGIfaceStatus

type WGIfaceStatus interface {
	FullStats() (*configurer.Stats, error)
}

type WGInterfaceStater

type WGInterfaceStater interface {
	GetStats() (map[string]configurer.WGStats, error)
}

type WGWatcher

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

func NewWGWatcher

func NewWGWatcher(log *log.Entry, wgIfaceStater WGInterfaceStater, peerKey string, stateDump *stateDump) *WGWatcher

func (*WGWatcher) EnableWgWatcher

func (w *WGWatcher) EnableWgWatcher(ctx context.Context, onDisconnectedFn func())

EnableWgWatcher starts the WireGuard watcher. If it is already enabled, it will return immediately and do nothing. The watcher runs until ctx is cancelled. Caller is responsible for context lifecycle management.

func (*WGWatcher) IsEnabled added in v0.3.0

func (w *WGWatcher) IsEnabled() bool

IsEnabled returns true if the WireGuard watcher is currently enabled

type WgConfig

type WgConfig struct {
	WgListenPort int
	RemoteKey    string
	WgInterface  WGIface
	AllowedIps   []netip.Prefix
	PreSharedKey *wgtypes.Key
}

type WorkerICE

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

func NewWorkerICE

func NewWorkerICE(ctx context.Context, log *log.Entry, config ConnConfig, conn *Conn, signaler *Signaler, ifaceDiscover stdnet.ExternalIFaceDiscover, statusRecorder *Status, hasRelayOnLocally bool) (*WorkerICE, error)

func (*WorkerICE) Close

func (w *WorkerICE) Close()

func (*WorkerICE) GetLocalUserCredentials

func (w *WorkerICE) GetLocalUserCredentials() (frag string, pwd string)

func (*WorkerICE) InProgress

func (w *WorkerICE) InProgress() bool

func (*WorkerICE) OnNewOffer

func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer)

func (*WorkerICE) OnRemoteCandidate

func (w *WorkerICE) OnRemoteCandidate(candidate ice.Candidate, haRoutes route.HAMap)

OnRemoteCandidate Handles ICE connection Candidate provided by the remote peer.

func (*WorkerICE) SessionID

func (w *WorkerICE) SessionID() ICESessionID

type WorkerRelay

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

func NewWorkerRelay

func NewWorkerRelay(ctx context.Context, log *log.Entry, ctrl bool, config ConnConfig, conn *Conn, relayManager *relayClient.Manager) *WorkerRelay

func (*WorkerRelay) CloseConn

func (w *WorkerRelay) CloseConn()

func (*WorkerRelay) IsRelayConnectionSupportedWithPeer

func (w *WorkerRelay) IsRelayConnectionSupportedWithPeer() bool

func (*WorkerRelay) OnNewOffer

func (w *WorkerRelay) OnNewOffer(remoteOfferAnswer *OfferAnswer)

func (*WorkerRelay) RelayInstanceAddress

func (w *WorkerRelay) RelayInstanceAddress() (string, error)

func (*WorkerRelay) RelayIsSupportedLocally

func (w *WorkerRelay) RelayIsSupportedLocally() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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