peer

package
v0.48.0-dev2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: BSD-3-Clause Imports: 6 Imported by: 8 modules, 21 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment added in v0.26.3

type Environment struct {
	Cloud    string
	Platform string
}

Environment is a system environment information

type File added in v0.28.0

type File struct {
	Path             string
	Exist            bool
	ProcessIsRunning bool
}

File is a file on the system.

type Flags added in v0.47.0

type Flags struct {
	RosenpassEnabled    bool
	RosenpassPermissive bool
	ServerSSHAllowed    bool

	DisableClientRoutes bool
	DisableServerRoutes bool
	DisableDNS          bool
	DisableFirewall     bool
	BlockLANAccess      bool
	BlockInbound        bool

	LazyConnectionEnabled bool
}

Flags defines a set of options to control feature behavior

type Location added in v0.26.0

type Location struct {
	ConnectionIP net.IP `gorm:"serializer:json"` // from grpc peer or reverse proxy headers depends on setup
	CountryCode  string
	CityName     string
	GeoNameID    uint // city level geoname id
}

Location is a geo location information of a Peer based on public connection IP

type NetworkAddress added in v0.26.0

type NetworkAddress struct {
	NetIP netip.Prefix `gorm:"serializer:json"`
	Mac   string
}

NetworkAddress is the IP address with network and MAC address of a network interface

type Peer

type Peer struct {
	// ID is an internal ID of the peer
	ID string `gorm:"primaryKey"`
	// AccountID is a reference to Account that this object belongs
	AccountID string `json:"-" gorm:"index"`
	// WireGuard public key
	Key string `gorm:"index"`
	// IP address of the Peer
	IP net.IP `gorm:"serializer:json"`
	// Meta is a Peer system meta data
	Meta PeerSystemMeta `gorm:"embedded;embeddedPrefix:meta_"`
	// Name is peer's name (machine name)
	Name string
	// DNSLabel is the parsed peer name for domain resolution. It is used to form an FQDN by appending the account's
	// domain to the peer label. e.g. peer-dns-label.netbird.cloud
	DNSLabel string
	// Status peer's management connection status
	Status *PeerStatus `gorm:"embedded;embeddedPrefix:peer_status_"`
	// The user ID that registered the peer
	UserID string
	// SSHKey is a public SSH key of the peer
	SSHKey string
	// SSHEnabled indicates whether SSH server is enabled on the peer
	SSHEnabled bool
	// LoginExpirationEnabled indicates whether peer's login expiration is enabled and once expired the peer has to re-login.
	// Works with LastLogin
	LoginExpirationEnabled bool

	InactivityExpirationEnabled bool
	// LastLogin the time when peer performed last login operation
	LastLogin *time.Time
	// CreatedAt records the time the peer was created
	CreatedAt time.Time
	// Indicate ephemeral peer attribute
	Ephemeral bool `gorm:"index"`
	// Geo location based on connection IP
	Location Location `gorm:"embedded;embeddedPrefix:location_"`

	// ExtraDNSLabels is a list of additional DNS labels that can be used to resolve the peer
	ExtraDNSLabels []string `gorm:"serializer:json"`
	// AllowExtraDNSLabels indicates whether the peer allows extra DNS labels to be used for resolving the peer
	AllowExtraDNSLabels bool
}

Peer represents a machine connected to the network. The Peer is a WireGuard peer identified by a public key

func (*Peer) AddedWithSSOLogin

func (p *Peer) AddedWithSSOLogin() bool

AddedWithSSOLogin indicates whether this peer has been added with an SSO login by a user.

func (*Peer) Copy

func (p *Peer) Copy() *Peer

Copy copies Peer object

func (*Peer) EventMeta

func (p *Peer) EventMeta(dnsDomain string) map[string]any

EventMeta returns activity event meta related to the peer

func (*Peer) FQDN

func (p *Peer) FQDN(dnsDomain string) string

FQDN returns peers FQDN combined of the peer's DNS label and the system's DNS domain

func (*Peer) GetLastLogin added in v0.36.0

func (p *Peer) GetLastLogin() time.Time

GetLastLogin returns the last login time of the peer.

func (*Peer) LoginExpired

func (p *Peer) LoginExpired(expiresIn time.Duration) (bool, time.Duration)

LoginExpired indicates whether the peer's login has expired or not. If Peer.LastLogin plus the expiresIn duration has happened already; then login has expired. Return true if a login has expired, false otherwise, and time left to expiration (negative when expired). Login expiration can be disabled/enabled on a Peer level via Peer.LoginExpirationEnabled property. Login expiration can also be disabled/enabled globally on the Account level via Settings.PeerLoginExpirationEnabled. Only peers added by interactive SSO login can be expired.

func (*Peer) MarkLoginExpired

func (p *Peer) MarkLoginExpired(expired bool)

MarkLoginExpired marks peer's status expired or not

func (*Peer) SessionExpired added in v0.30.2

func (p *Peer) SessionExpired(expiresIn time.Duration) (bool, time.Duration)

SessionExpired indicates whether the peer's session has expired or not. If Peer.LastLogin plus the expiresIn duration has happened already; then session has expired. Return true if a session has expired, false otherwise, and time left to expiration (negative when expired). Session expiration can be disabled/enabled on a Peer level via Peer.LoginExpirationEnabled property. Session expiration can also be disabled/enabled globally on the Account level via Settings.PeerLoginExpirationEnabled. Only peers added by interactive SSO login can be expired.

func (*Peer) UpdateLastLogin

func (p *Peer) UpdateLastLogin() *Peer

UpdateLastLogin and set login expired false

func (*Peer) UpdateMetaIfNew

func (p *Peer) UpdateMetaIfNew(meta PeerSystemMeta) bool

UpdateMetaIfNew updates peer's system metadata if new information is provided returns true if meta was updated, false otherwise

type PeerStatus

type PeerStatus struct {
	// LastSeen is the last time peer was connected to the management service
	LastSeen time.Time
	// Connected indicates whether peer is connected to the management service or not
	Connected bool
	// LoginExpired
	LoginExpired bool
	// RequiresApproval indicates whether peer requires approval or not
	RequiresApproval bool
}

func (*PeerStatus) Copy

func (p *PeerStatus) Copy() *PeerStatus

Copy PeerStatus

type PeerSystemMeta

type PeerSystemMeta struct {
	Hostname           string
	GoOS               string
	Kernel             string
	Core               string
	Platform           string
	OS                 string
	OSVersion          string
	WtVersion          string
	UIVersion          string
	KernelVersion      string
	NetworkAddresses   []NetworkAddress `gorm:"serializer:json"`
	SystemSerialNumber string
	SystemProductName  string
	SystemManufacturer string
	Environment        Environment `gorm:"serializer:json"`
	Flags              Flags       `gorm:"serializer:json"`
	Files              []File      `gorm:"serializer:json"`
}

PeerSystemMeta is a metadata of a Peer machine system

Jump to

Keyboard shortcuts

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