Documentation ¶
Index ¶
- func NewConnectionAlreadyClosed(peer string) error
- func NewConnectionClosedError(peer string) error
- func NewConnectionDisconnectedError(peer string) error
- func NewConnectionTimeoutError(peer string, timeout time.Duration) error
- type Conn
- func (conn *Conn) Close() error
- func (conn *Conn) GetConf() ConnConfig
- func (conn *Conn) GetKey() string
- func (conn *Conn) OnRemoteAnswer(answer OfferAnswer) bool
- func (conn *Conn) OnRemoteCandidate(candidate ice.Candidate)
- func (conn *Conn) OnRemoteOffer(offer OfferAnswer) bool
- func (conn *Conn) Open() error
- func (conn *Conn) RegisterProtoSupportMeta(support []uint32)
- func (conn *Conn) SetSendSignalMessage(handler func(message *sProto.Message) error)
- func (conn *Conn) SetSignalAnswer(handler func(answer OfferAnswer) error)
- func (conn *Conn) SetSignalCandidate(handler func(candidate ice.Candidate) error)
- func (conn *Conn) SetSignalOffer(handler func(offer OfferAnswer) error)
- func (conn *Conn) Status() ConnStatus
- func (conn *Conn) UpdateConf(conf ConnConfig)
- type ConnConfig
- type ConnStatus
- type ConnectionAlreadyClosedError
- type ConnectionClosedError
- type ConnectionDisconnectedError
- type ConnectionTimeoutError
- type FullStatus
- type IceCredentials
- type Listener
- type LocalPeerState
- type ManagementState
- type ModeMessage
- type OfferAnswer
- type SignalState
- 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) FinishPeerListModifications()
- func (d *Status) GetFullStatus() FullStatus
- func (d *Status) GetPeer(peerPubKey string) (State, error)
- func (d *Status) GetPeerStateChangeNotifier(peer string) <-chan struct{}
- func (d *Status) MarkManagementConnected()
- func (d *Status) MarkManagementDisconnected()
- func (d *Status) MarkSignalConnected()
- func (d *Status) MarkSignalDisconnected()
- 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) UpdateLocalPeerState(localPeerState LocalPeerState)
- func (d *Status) UpdateManagementAddress(mgmAddress string)
- func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error
- func (d *Status) UpdatePeerState(receivedState State) error
- func (d *Status) UpdateSignalAddress(signalURL string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func NewConn ¶
func NewConn(config ConnConfig, statusRecorder *Status, adapter iface.TunAdapter, iFaceDiscover stdnet.ExternalIFaceDiscover) (*Conn, error)
NewConn creates a new not opened Conn to the remote peer. To establish a connection run Conn.Open
func (*Conn) GetConf ¶ added in v0.6.3
func (conn *Conn) GetConf() ConnConfig
GetConf returns the connection config
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 ¶
func (conn *Conn) OnRemoteCandidate(candidate ice.Candidate)
OnRemoteCandidate Handles ICE connection Candidate provided by the remote peer.
func (*Conn) OnRemoteOffer ¶
func (conn *Conn) 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 (*Conn) Open ¶
Open opens connection to the remote peer starting ICE candidate gathering process. Blocks until connection has been closed or connection timeout. ConnStatus will be set accordingly
func (*Conn) RegisterProtoSupportMeta ¶ added in v0.14.5
RegisterProtoSupportMeta register supported proto message in the connection metadata
func (*Conn) SetSendSignalMessage ¶ added in v0.14.5
SetSendSignalMessage sets a handler function to be triggered by Conn when there is new message to send via signal
func (*Conn) SetSignalAnswer ¶
func (conn *Conn) SetSignalAnswer(handler func(answer OfferAnswer) error)
SetSignalAnswer sets a handler function to be triggered by Conn when a new connection answer has to be signalled to the remote peer
func (*Conn) SetSignalCandidate ¶
SetSignalCandidate sets a handler function to be triggered by Conn when a new ICE local connection candidate has to be signalled to the remote peer
func (*Conn) SetSignalOffer ¶
func (conn *Conn) SetSignalOffer(handler func(offer OfferAnswer) error)
SetSignalOffer sets a handler function to be triggered by Conn when a new connection offer has to be signalled to the remote peer
func (*Conn) Status ¶
func (conn *Conn) Status() ConnStatus
Status returns current status of the Conn
func (*Conn) UpdateConf ¶ added in v0.8.3
func (conn *Conn) UpdateConf(conf ConnConfig)
UpdateConf updates the connection 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 // StunTurn is a list of STUN and TURN URLs StunTurn []*ice.URL // InterfaceBlackList is a list of machine interfaces that should be filtered out by ICE Candidate gathering // (e.g. if eth0 is in the list, host candidate of this interface won't be used) InterfaceBlackList []string DisableIPv6Discovery bool Timeout time.Duration ProxyConfig proxy.Config UDPMux ice.UDPMux UDPMuxSrflx ice.UniversalUDPMux LocalWgPort int NATExternalIPs []string // UsesBind indicates whether the WireGuard interface is userspace and uses bind.ICEBind UserspaceBind bool }
ConnConfig is a peer Connection configuration
type ConnStatus ¶
type ConnStatus int
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 }
FullStatus contains the full state held by the Status instance
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
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 ModeMessage ¶ added in v0.14.5
type ModeMessage struct { // Direct indicates that it decided to use a direct connection Direct bool }
ModeMessage represents a connection mode chosen by the peer
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 }
OfferAnswer represents a session establishment offer or answer
type SignalState ¶ added in v0.14.3
SignalState contains the latest state of a signal connection
type State ¶ added in v0.14.3
type State struct { IP string PubKey string FQDN string ConnStatus ConnStatus ConnStatusUpdate time.Time Relayed bool Direct bool LocalIceCandidateType string RemoteIceCandidateType string }
State contains the latest state of a peer
type Status ¶ added in v0.14.3
type Status struct {
// contains filtered or unexported fields
}
Status holds a state of peers, signal and management connections
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) FinishPeerListModifications ¶ added in v0.21.5
func (d *Status) FinishPeerListModifications()
FinishPeerListModifications this event invoke the notification
func (*Status) GetFullStatus ¶ added in v0.14.3
func (d *Status) GetFullStatus() FullStatus
GetFullStatus gets full status
func (*Status) GetPeerStateChangeNotifier ¶ added in v0.14.3
GetPeerStateChangeNotifier returns a change notifier channel for a peer
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
func (d *Status) MarkManagementDisconnected()
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
func (d *Status) MarkSignalDisconnected()
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) 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) UpdatePeerState ¶ added in v0.14.3
UpdatePeerState updates peer status
func (*Status) UpdateSignalAddress ¶ added in v0.14.5
UpdateSignalAddress update the address of the signal server