Documentation ¶
Index ¶
- Variables
- func NewConnectionAlreadyClosed(peer string) error
- func NewConnectionClosedError(peer string) error
- func NewConnectionDisconnectedError(peer string) error
- func NewConnectionTimeoutError(peer string, timeout time.Duration) error
- type AtomicConnStatus
- type Conn
- func (conn *Conn) AddAfterRemovePeerHook(hook nbnet.RemoveHookFunc)
- func (conn *Conn) AddBeforeAddPeerHook(hook nbnet.AddHookFunc)
- func (conn *Conn) Close()
- func (conn *Conn) GetKey() string
- func (conn *Conn) OnRemoteAnswer(answer OfferAnswer) bool
- func (conn *Conn) OnRemoteCandidate(candidate ice.Candidate, haRoutes route.HAMap)
- func (conn *Conn) OnRemoteOffer(offer OfferAnswer) bool
- func (conn *Conn) Open()
- func (conn *Conn) SetOnConnected(...)
- func (conn *Conn) SetOnDisconnected(handler func(remotePeer string, wgIP string))
- func (conn *Conn) Status() ConnStatus
- func (conn *Conn) WgConfig() WgConfig
- type ConnConfig
- type ConnPriority
- type ConnStatus
- type ConnectionAlreadyClosedError
- type ConnectionClosedError
- type ConnectionDisconnectedError
- type ConnectionTimeoutError
- type FullStatus
- type Handshaker
- type ICEConnInfo
- type IceCredentials
- type Listener
- type LocalPeerState
- type ManagementState
- type NSGroupState
- type OfferAnswer
- type RelayConnInfo
- type RosenpassState
- type SignalState
- type Signaler
- type State
- type Status
- func (d *Status) AddPeer(peerPubKey string, fqdn string) error
- func (d *Status) CleanLocalPeerState()
- func (d *Status) ClientStart()
- func (d *Status) ClientStop()
- func (d *Status) ClientTeardown()
- func (d *Status) DeleteResolvedDomainsStates(domain domain.Domain)
- func (d *Status) FinishPeerListModifications()
- func (d *Status) GetDNSStates() []NSGroupState
- func (d *Status) GetFullStatus() FullStatus
- func (d *Status) GetLocalPeerState() LocalPeerState
- func (d *Status) GetManagementState() ManagementState
- func (d *Status) GetPeer(peerPubKey string) (State, error)
- func (d *Status) GetPeerStateChangeNotifier(peer string) <-chan struct{}
- func (d *Status) GetRelayStates() []relay.ProbeResult
- func (d *Status) GetResolvedDomainsStates() map[domain.Domain][]netip.Prefix
- func (d *Status) GetRosenpassState() RosenpassState
- func (d *Status) GetSignalState() SignalState
- func (d *Status) IsLoginRequired() bool
- func (d *Status) MarkManagementConnected()
- func (d *Status) MarkManagementDisconnected(err error)
- func (d *Status) MarkSignalConnected()
- func (d *Status) MarkSignalDisconnected(err error)
- func (d *Status) RemoveConnectionListener()
- func (d *Status) RemovePeer(peerPubKey string) error
- func (d *Status) ReplaceOfflinePeers(replacement []State)
- func (d *Status) SetConnectionListener(listener Listener)
- func (d *Status) SetRelayMgr(manager *relayClient.Manager)
- func (d *Status) UpdateDNSStates(dnsStates []NSGroupState)
- func (d *Status) UpdateLatency(pubKey string, latency time.Duration) error
- func (d *Status) UpdateLocalPeerState(localPeerState LocalPeerState)
- func (d *Status) UpdateManagementAddress(mgmAddress string)
- func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error
- func (d *Status) UpdatePeerICEState(receivedState State) error
- func (d *Status) UpdatePeerICEStateToDisconnected(receivedState State) error
- func (d *Status) UpdatePeerRelayedState(receivedState State) error
- func (d *Status) UpdatePeerRelayedStateToDisconnected(receivedState State) error
- func (d *Status) UpdatePeerState(receivedState State) error
- func (d *Status) UpdateRelayStates(relayResults []relay.ProbeResult)
- func (d *Status) UpdateResolvedDomainsStates(domain domain.Domain, prefixes []netip.Prefix)
- func (d *Status) UpdateRosenpass(rosenpassEnabled, rosenpassPermissive bool)
- func (d *Status) UpdateSignalAddress(signalURL string)
- func (d *Status) UpdateWireGuardPeerState(pubKey string, wgStats configurer.WGStats) error
- type WgConfig
- type WorkerCallbacks
- type WorkerICE
- type WorkerICECallbacks
- type WorkerRelay
- func (w *WorkerRelay) CloseConn()
- func (w *WorkerRelay) DisableWgWatcher()
- func (w *WorkerRelay) EnableWgWatcher(ctx context.Context)
- func (w *WorkerRelay) IsRelayConnectionSupportedWithPeer() bool
- func (w *WorkerRelay) OnNewOffer(remoteOfferAnswer *OfferAnswer)
- func (w *WorkerRelay) RelayInstanceAddress() (string, error)
- func (w *WorkerRelay) RelayIsSupportedLocally() bool
- type WorkerRelayCallbacks
Constants ¶
This section is empty.
Variables ¶
var (
ErrSignalIsNotReady = errors.New("signal is not ready")
)
Functions ¶
func NewConnectionAlreadyClosed ¶
NewConnectionAlreadyClosed creates a new ConnectionAlreadyClosedError error
func NewConnectionClosedError ¶
NewConnectionClosedError creates a new ConnectionClosedError error
func NewConnectionDisconnectedError ¶
NewConnectionDisconnectedError creates a new ConnectionDisconnectedError error
Types ¶
type AtomicConnStatus ¶ added in v0.29.3
type AtomicConnStatus struct {
// contains filtered or unexported fields
}
AtomicConnStatus is a thread-safe wrapper for ConnStatus
func NewAtomicConnStatus ¶ added in v0.29.3
func NewAtomicConnStatus() *AtomicConnStatus
NewAtomicConnStatus creates a new AtomicConnStatus with the given initial status
func (*AtomicConnStatus) Get ¶ added in v0.29.3
func (acs *AtomicConnStatus) Get() ConnStatus
Get returns the current connection status
func (*AtomicConnStatus) Set ¶ added in v0.29.3
func (acs *AtomicConnStatus) Set(status ConnStatus)
Set updates the connection status
func (*AtomicConnStatus) String ¶ added in v0.29.3
func (acs *AtomicConnStatus) String() string
String returns the string representation of the current status
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func NewConn ¶
func NewConn(engineCtx context.Context, config ConnConfig, statusRecorder *Status, signaler *Signaler, iFaceDiscover stdnet.ExternalIFaceDiscover, relayManager *relayClient.Manager, srWatcher *guard.SRWatcher) (*Conn, error)
NewConn creates a new not opened Conn to the remote peer. To establish a connection run Conn.Open
func (*Conn) AddAfterRemovePeerHook ¶ added in v0.27.0
func (conn *Conn) AddAfterRemovePeerHook(hook nbnet.RemoveHookFunc)
func (*Conn) AddBeforeAddPeerHook ¶ added in v0.27.0
func (conn *Conn) AddBeforeAddPeerHook(hook nbnet.AddHookFunc)
func (*Conn) Close ¶
func (conn *Conn) Close()
Close closes this peer Conn issuing a close event to the Conn closeCh
func (*Conn) OnRemoteAnswer ¶
func (conn *Conn) OnRemoteAnswer(answer OfferAnswer) bool
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 ¶
OnRemoteCandidate Handles ICE connection Candidate provided by the remote peer.
func (*Conn) OnRemoteOffer ¶
func (conn *Conn) OnRemoteOffer(offer OfferAnswer) bool
func (*Conn) Open ¶
func (conn *Conn) Open()
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 ¶ added in v0.25.4
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 ¶ added in v0.25.4
SetOnDisconnected sets a handler function to be triggered by Conn when a connection to a remote disconnected
func (*Conn) Status ¶
func (conn *Conn) Status() ConnStatus
Status returns current status of the Conn
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 Timeout time.Duration WgConfig WgConfig LocalWgPort int // RosenpassPubKey is this peer's Rosenpass public key RosenpassPubKey []byte // RosenpassPubKey is this peer's RosenpassAddr server address (IP:port) RosenpassAddr string // ICEConfig ICE protocol configuration ICEConfig icemaker.Config }
ConnConfig is a peer Connection configuration
type ConnPriority ¶ added in v0.29.0
type ConnPriority int
type ConnStatus ¶
type ConnStatus int32
ConnStatus describe the status of a peer's connection
const ( // StatusConnected indicate the peer is in connected state StatusConnected ConnStatus = iota // StatusConnecting indicate the peer is in connecting state StatusConnecting // StatusDisconnected indicate the peer is in disconnected state StatusDisconnected )
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 ¶
func (e *ConnectionAlreadyClosedError) Error() string
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 ¶
func (e *ConnectionDisconnectedError) Error() string
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 FullStatus ¶ added in v0.14.3
type FullStatus struct { Peers []State ManagementState ManagementState SignalState SignalState LocalPeerState LocalPeerState RosenpassState RosenpassState Relays []relay.ProbeResult NSGroupStates []NSGroupState }
FullStatus contains the full state held by the Status instance
type Handshaker ¶ added in v0.29.0
type Handshaker struct {
// contains filtered or unexported fields
}
func NewHandshaker ¶ added in v0.29.0
func NewHandshaker(ctx context.Context, log *log.Entry, config ConnConfig, signaler *Signaler, ice *WorkerICE, relay *WorkerRelay) *Handshaker
func (*Handshaker) AddOnNewOfferListener ¶ added in v0.29.0
func (h *Handshaker) AddOnNewOfferListener(offer func(remoteOfferAnswer *OfferAnswer))
func (*Handshaker) Listen ¶ added in v0.29.0
func (h *Handshaker) Listen()
func (*Handshaker) OnRemoteAnswer ¶ added in v0.29.0
func (h *Handshaker) OnRemoteAnswer(answer OfferAnswer) bool
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 ¶ added in v0.29.0
func (h *Handshaker) OnRemoteOffer(offer OfferAnswer) bool
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 ¶ added in v0.29.0
func (h *Handshaker) SendOffer() error
type ICEConnInfo ¶ added in v0.29.0
type IceCredentials ¶
IceCredentials ICE protocol credentials struct
type Listener ¶ added in v0.14.5
type Listener interface { OnConnected() OnDisconnected() OnConnecting() OnDisconnecting() OnAddressChanged(string, string) OnPeersListChanged(int) }
Listener is a callback type about the NetBird network connection state
type LocalPeerState ¶ added in v0.14.3
type LocalPeerState struct { IP string PubKey string KernelInterface bool FQDN string Routes map[string]struct{} }
LocalPeerState contains the latest state of the local peer
type ManagementState ¶ added in v0.14.3
ManagementState contains the latest state of a management connection
type NSGroupState ¶ added in v0.26.3
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 ¶ added in v0.8.12
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 NetBird 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 }
OfferAnswer represents a session establishment offer or answer
type RelayConnInfo ¶ added in v0.29.0
type RelayConnInfo struct {
// contains filtered or unexported fields
}
type RosenpassState ¶ added in v0.26.1
RosenpassState contains the latest state of the Rosenpass configuration
type SignalState ¶ added in v0.14.3
SignalState contains the latest state of a signal connection
type Signaler ¶ added in v0.29.0
type Signaler struct {
// contains filtered or unexported fields
}
func NewSignaler ¶ added in v0.29.0
func (*Signaler) SignalAnswer ¶ added in v0.29.0
func (s *Signaler) SignalAnswer(offer OfferAnswer, remoteKey string) error
func (*Signaler) SignalICECandidate ¶ added in v0.29.0
func (*Signaler) SignalOffer ¶ added in v0.29.0
func (s *Signaler) SignalOffer(offer OfferAnswer, remoteKey string) error
type State ¶ added in v0.14.3
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 // contains filtered or unexported fields }
State contains the latest state of a peer
func (*State) DeleteRoute ¶ added in v0.27.3
DeleteRoute removes a route from the network amp
type Status ¶ added in v0.14.3
type Status struct {
// contains filtered or unexported fields
}
Status holds a state of peers, signal, management connections and relays
func NewRecorder ¶ added in v0.14.3
NewRecorder returns a new Status instance
func (*Status) CleanLocalPeerState ¶ added in v0.14.3
func (d *Status) CleanLocalPeerState()
CleanLocalPeerState cleans local peer status
func (*Status) ClientStart ¶ added in v0.14.5
func (d *Status) ClientStart()
ClientStart will notify all listeners about the new service state
func (*Status) ClientStop ¶ added in v0.14.5
func (d *Status) ClientStop()
ClientStop will notify all listeners about the new service state
func (*Status) ClientTeardown ¶ added in v0.14.6
func (d *Status) ClientTeardown()
ClientTeardown will notify all listeners about the service is under teardown
func (*Status) DeleteResolvedDomainsStates ¶ added in v0.28.0
func (*Status) FinishPeerListModifications ¶ added in v0.21.5
func (d *Status) FinishPeerListModifications()
FinishPeerListModifications this event invoke the notification
func (*Status) GetDNSStates ¶ added in v0.26.3
func (d *Status) GetDNSStates() []NSGroupState
func (*Status) GetFullStatus ¶ added in v0.14.3
func (d *Status) GetFullStatus() FullStatus
GetFullStatus gets full status
func (*Status) GetLocalPeerState ¶ added in v0.26.3
func (d *Status) GetLocalPeerState() LocalPeerState
GetLocalPeerState returns the local peer state
func (*Status) GetManagementState ¶ added in v0.25.5
func (d *Status) GetManagementState() ManagementState
func (*Status) GetPeerStateChangeNotifier ¶ added in v0.14.3
GetPeerStateChangeNotifier returns a change notifier channel for a peer
func (*Status) GetRelayStates ¶ added in v0.25.5
func (d *Status) GetRelayStates() []relay.ProbeResult
GetRelayStates returns the stun/turn/permanent relay states
func (*Status) GetResolvedDomainsStates ¶ added in v0.28.0
func (*Status) GetRosenpassState ¶ added in v0.26.1
func (d *Status) GetRosenpassState() RosenpassState
func (*Status) GetSignalState ¶ added in v0.25.5
func (d *Status) GetSignalState() SignalState
func (*Status) IsLoginRequired ¶ added in v0.26.3
IsLoginRequired determines if a peer's login has expired.
func (*Status) MarkManagementConnected ¶ added in v0.14.3
func (d *Status) MarkManagementConnected()
MarkManagementConnected sets ManagementState to connected
func (*Status) MarkManagementDisconnected ¶ added in v0.14.3
MarkManagementDisconnected sets ManagementState to disconnected
func (*Status) MarkSignalConnected ¶ added in v0.14.3
func (d *Status) MarkSignalConnected()
MarkSignalConnected sets SignalState to connected
func (*Status) MarkSignalDisconnected ¶ added in v0.14.3
MarkSignalDisconnected sets SignalState to disconnected
func (*Status) RemoveConnectionListener ¶ added in v0.14.5
func (d *Status) RemoveConnectionListener()
RemoveConnectionListener remove the listener from the notifier
func (*Status) RemovePeer ¶ added in v0.14.3
RemovePeer removes peer from Daemon status map
func (*Status) ReplaceOfflinePeers ¶ added in v0.14.3
ReplaceOfflinePeers replaces
func (*Status) SetConnectionListener ¶ added in v0.15.0
SetConnectionListener set a listener to the notifier
func (*Status) SetRelayMgr ¶ added in v0.29.0
func (d *Status) SetRelayMgr(manager *relayClient.Manager)
func (*Status) UpdateDNSStates ¶ added in v0.26.3
func (d *Status) UpdateDNSStates(dnsStates []NSGroupState)
func (*Status) UpdateLatency ¶ added in v0.26.4
func (*Status) UpdateLocalPeerState ¶ added in v0.14.3
func (d *Status) UpdateLocalPeerState(localPeerState LocalPeerState)
UpdateLocalPeerState updates local peer status
func (*Status) UpdateManagementAddress ¶ added in v0.14.5
UpdateManagementAddress update the address of the management server
func (*Status) UpdatePeerFQDN ¶ added in v0.14.3
UpdatePeerFQDN update peer's state fqdn only
func (*Status) UpdatePeerICEState ¶ added in v0.29.0
func (*Status) UpdatePeerICEStateToDisconnected ¶ added in v0.29.0
func (*Status) UpdatePeerRelayedState ¶ added in v0.29.0
func (*Status) UpdatePeerRelayedStateToDisconnected ¶ added in v0.29.0
func (*Status) UpdatePeerState ¶ added in v0.14.3
UpdatePeerState updates peer status
func (*Status) UpdateRelayStates ¶ added in v0.25.5
func (d *Status) UpdateRelayStates(relayResults []relay.ProbeResult)
func (*Status) UpdateResolvedDomainsStates ¶ added in v0.28.0
func (*Status) UpdateRosenpass ¶ added in v0.26.1
UpdateRosenpass update the Rosenpass configuration
func (*Status) UpdateSignalAddress ¶ added in v0.14.5
UpdateSignalAddress update the address of the signal server
func (*Status) UpdateWireGuardPeerState ¶ added in v0.26.1
func (d *Status) UpdateWireGuardPeerState(pubKey string, wgStats configurer.WGStats) error
UpdateWireGuardPeerState updates the WireGuard bits of the peer state
type WorkerCallbacks ¶ added in v0.29.0
type WorkerCallbacks struct { OnRelayReadyCallback func(info RelayConnInfo) OnRelayStatusChanged func(ConnStatus) OnICEConnReadyCallback func(ConnPriority, ICEConnInfo) OnICEStatusChanged func(ConnStatus) }
type WorkerICE ¶ added in v0.29.0
type WorkerICE struct { StunTurn []*stun.URI // contains filtered or unexported fields }
func NewWorkerICE ¶ added in v0.29.0
func NewWorkerICE(ctx context.Context, log *log.Entry, config ConnConfig, signaler *Signaler, ifaceDiscover stdnet.ExternalIFaceDiscover, statusRecorder *Status, hasRelayOnLocally bool, callBacks WorkerICECallbacks) (*WorkerICE, error)
func (*WorkerICE) GetLocalUserCredentials ¶ added in v0.29.0
func (*WorkerICE) OnNewOffer ¶ added in v0.29.0
func (w *WorkerICE) OnNewOffer(remoteOfferAnswer *OfferAnswer)
func (*WorkerICE) OnRemoteCandidate ¶ added in v0.29.0
OnRemoteCandidate Handles ICE connection Candidate provided by the remote peer.
type WorkerICECallbacks ¶ added in v0.29.0
type WorkerICECallbacks struct { OnConnReady func(ConnPriority, ICEConnInfo) OnStatusChanged func(ConnStatus) }
type WorkerRelay ¶ added in v0.29.0
type WorkerRelay struct {
// contains filtered or unexported fields
}
func NewWorkerRelay ¶ added in v0.29.0
func NewWorkerRelay(log *log.Entry, ctrl bool, config ConnConfig, relayManager relayClient.ManagerService, callbacks WorkerRelayCallbacks) *WorkerRelay
func (*WorkerRelay) CloseConn ¶ added in v0.29.0
func (w *WorkerRelay) CloseConn()
func (*WorkerRelay) DisableWgWatcher ¶ added in v0.29.0
func (w *WorkerRelay) DisableWgWatcher()
func (*WorkerRelay) EnableWgWatcher ¶ added in v0.29.0
func (w *WorkerRelay) EnableWgWatcher(ctx context.Context)
func (*WorkerRelay) IsRelayConnectionSupportedWithPeer ¶ added in v0.29.0
func (w *WorkerRelay) IsRelayConnectionSupportedWithPeer() bool
func (*WorkerRelay) OnNewOffer ¶ added in v0.29.0
func (w *WorkerRelay) OnNewOffer(remoteOfferAnswer *OfferAnswer)
func (*WorkerRelay) RelayInstanceAddress ¶ added in v0.29.0
func (w *WorkerRelay) RelayInstanceAddress() (string, error)
func (*WorkerRelay) RelayIsSupportedLocally ¶ added in v0.29.0
func (w *WorkerRelay) RelayIsSupportedLocally() bool
type WorkerRelayCallbacks ¶ added in v0.29.0
type WorkerRelayCallbacks struct { OnConnReady func(RelayConnInfo) OnDisconnected func() }