peer

package
v0.27.7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 4 Imported by: 2

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 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"`
	// A setup key this peer was registered with
	SetupKey string
	// 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
	// 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
	// Geo location based on connection IP
	Location Location `gorm:"embedded;embeddedPrefix:location_"`
}

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
	OSVersion          string
	WtVersion          string
	UIVersion          string
	KernelVersion      string
	NetworkAddresses   []NetworkAddress `gorm:"serializer:json"`
	SystemSerialNumber string
	SystemProductName  string
	SystemManufacturer string
	Environment        Environment `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