peer

package
v0.0.0-...-93fed14 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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;uniqueIndex:idx_peers_account_id_ip"`
	// WireGuard public key
	Key string `gorm:"index"`
	// A setup key this peer was registered with
	SetupKey string
	// IP address of the Peer
	IP net.IP `gorm:"uniqueIndex:idx_peers_account_id_ip"`
	// 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
	// LastLogin the time when peer performed last login operation
	LastLogin time.Time
	// Indicate ephemeral peer attribute
	Ephemeral 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) 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) 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
	WtVersion string
	UIVersion string
}

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