clientdata

package
v0.0.0-...-8fd811e Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const PausedDueToMaxClientsExceeded = "unlicensed"

Variables

View Source
var Now = time.Now

Now is used to stub time.Now in tests

Functions

func CopyAttrsToClient

func CopyAttrsToClient(attributes models.Attributes, client *Client)

func CopyClientsToAttrs

func CopyClientsToAttrs(client Client, attributes *models.Attributes)

func NewClientID

func NewClientID() (string, error)

NewClientID generates a new client ID.

Types

type CalculatedClient

type CalculatedClient struct {
	*Client
	Groups          []string        `json:"groups"`
	ConnectionState ConnectionState `json:"connection_state"`
}

CalculatedClient contains additional fields and is calculated on each request

func NewCalculatedClient

func NewCalculatedClient(c *Client, groups []string, connectionState ConnectionState) (cc *CalculatedClient)

func (*CalculatedClient) GetConnectionState

func (cc *CalculatedClient) GetConnectionState() (cs ConnectionState)

type Client

type Client struct {
	ID                     string                 `json:"id"`
	SessionID              string                 `json:"session_id"`
	Name                   string                 `json:"name"`
	OS                     string                 `json:"os"`
	OSArch                 string                 `json:"os_arch"`
	OSFamily               string                 `json:"os_family"`
	OSKernel               string                 `json:"os_kernel"`
	OSFullName             string                 `json:"os_full_name"`
	OSVersion              string                 `json:"os_version"`
	OSVirtualizationSystem string                 `json:"os_virtualization_system"`
	OSVirtualizationRole   string                 `json:"os_virtualization_role"`
	CPUFamily              string                 `json:"cpu_family"`
	CPUModel               string                 `json:"cpu_model"`
	CPUModelName           string                 `json:"cpu_model_name"`
	CPUVendor              string                 `json:"cpu_vendor"`
	NumCPUs                int                    `json:"num_cpus"`
	MemoryTotal            uint64                 `json:"mem_total"`
	Timezone               string                 `json:"timezone"`
	Hostname               string                 `json:"hostname"`
	IPv4                   []string               `json:"ipv4"`
	IPv6                   []string               `json:"ipv6"`
	Tags                   []string               `json:"tags"`
	Labels                 map[string]string      `json:"labels"`
	Version                string                 `json:"version"`
	Address                string                 `json:"address"`
	Tunnels                []*clienttunnel.Tunnel `json:"tunnels"`

	// DisconnectedAt is a time when a client was disconnected. If nil - it's connected.
	DisconnectedAt      *time.Time            `json:"disconnected_at"`
	LastHeartbeatAt     *time.Time            `json:"last_heartbeat_at"`
	ClientAuthID        string                `json:"client_auth_id"`
	AllowedUserGroups   []string              `json:"allowed_user_groups"`
	UpdatesStatus       *models.UpdatesStatus `json:"updates_status"`
	IPAddresses         *models.IPAddresses   `json:"ext_ip_addresses"`
	ClientConfiguration *clientconfig.Config  `json:"client_configuration"`

	Connection   ssh.Conn        `json:"-"`
	Context      context.Context `json:"-"`
	Paused       bool            `json:"-"`
	PausedReason string          `json:"-"`

	Logger *logger.Logger `json:"-"`
	// contains filtered or unexported fields
}

Client represents client connection

func NewClientFromConnRequest

func NewClientFromConnRequest(ctx context.Context, existingClient *Client, clientAuthID string, clientID string, req *chshare.ConnectionRequest, clientHost string, sshConn ssh.Conn, clog *logger.Logger) (client *Client)

func (*Client) Banner

func (c *Client) Banner() string

func (*Client) BelongsTo

func (c *Client) BelongsTo(group *cgroups.ClientGroup) bool

func (*Client) BelongsToOneOf

func (c *Client) BelongsToOneOf(groups []*cgroups.ClientGroup) bool

func (*Client) CalculateConnectionState

func (c *Client) CalculateConnectionState() ConnectionState

func (*Client) Close

func (c *Client) Close() error

func (*Client) GetAddress

func (c *Client) GetAddress() (address string)

func (*Client) GetAllowedUserGroups

func (c *Client) GetAllowedUserGroups() (groups []string)

func (*Client) GetAttributes

func (c *Client) GetAttributes() models.Attributes

func (*Client) GetClientAuthID

func (c *Client) GetClientAuthID() (authID string)

func (*Client) GetConnection

func (c *Client) GetConnection() (conn ssh.Conn)

func (*Client) GetContext

func (c *Client) GetContext() (ctx context.Context)

func (*Client) GetDisconnectedAt

func (c *Client) GetDisconnectedAt() (at *time.Time)

func (*Client) GetDisconnectedAtValue

func (c *Client) GetDisconnectedAtValue() (at time.Time)

func (*Client) GetFileReceptionConfig

func (c *Client) GetFileReceptionConfig() (fileReceptionConfig *clientconfig.FileReceptionConfig)

func (*Client) GetHostname

func (c *Client) GetHostname() (hostname string)

func (*Client) GetID

func (c *Client) GetID() (id string)

func (*Client) GetIPv4

func (c *Client) GetIPv4() (ipv4 []string)

func (*Client) GetIPv6

func (c *Client) GetIPv6() (ipv6 []string)

func (*Client) GetLabels

func (c *Client) GetLabels() (labels map[string]string)

func (*Client) GetLastHeartbeatAt

func (c *Client) GetLastHeartbeatAt() (at *time.Time)

func (*Client) GetLastHeartbeatAtValue

func (c *Client) GetLastHeartbeatAtValue() (at time.Time)

func (*Client) GetLock

func (c *Client) GetLock() (mu *sync.RWMutex)

func (*Client) GetMemoryTotal

func (c *Client) GetMemoryTotal() (mem uint64)

func (*Client) GetMonitoringConfig

func (c *Client) GetMonitoringConfig() (monitoringConfig *clientconfig.MonitoringConfig)

func (*Client) GetName

func (c *Client) GetName() (name string)

func (*Client) GetNumCPUs

func (c *Client) GetNumCPUs() (num int)

func (*Client) GetOS

func (c *Client) GetOS() (os string)

func (*Client) GetOSArch

func (c *Client) GetOSArch() (arch string)

func (*Client) GetOSFamily

func (c *Client) GetOSFamily() (fam string)

func (*Client) GetOSFullName

func (c *Client) GetOSFullName() (name string)

func (*Client) GetOSKernel

func (c *Client) GetOSKernel() (kernel string)

func (*Client) GetOSVersion

func (c *Client) GetOSVersion() (ver string)

func (*Client) GetOSVirtualizationRole

func (c *Client) GetOSVirtualizationRole() (role string)

func (*Client) GetOSVirtualizationSystem

func (c *Client) GetOSVirtualizationSystem() (sys string)

func (*Client) GetPausedReason

func (c *Client) GetPausedReason() (reason string)

func (*Client) GetSessionID

func (c *Client) GetSessionID() (sessionID string)

func (*Client) GetTags

func (c *Client) GetTags() (tags []string)

func (*Client) GetTimezone

func (c *Client) GetTimezone() (tz string)

func (*Client) GetTunnels

func (c *Client) GetTunnels() (tunnels []*clienttunnel.Tunnel)

func (*Client) GetUpdatesStatus

func (c *Client) GetUpdatesStatus() (status models.UpdatesStatus)

func (*Client) GetVersion

func (c *Client) GetVersion() (version string)

func (*Client) HasAccessViaUserGroups

func (c *Client) HasAccessViaUserGroups(userGroups []string) bool

HasAccessViaUserGroups returns true if at least one of given user groups has access to a current client.

func (*Client) HasLastHeartbeatAt

func (c *Client) HasLastHeartbeatAt() (has bool)

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) IsPaused

func (c *Client) IsPaused() (paused bool)

func (*Client) Log

func (c *Client) Log() (l *logger.Logger)

func (*Client) NewTunnelID

func (c *Client) NewTunnelID() (tunnelID string)

func (*Client) Obsolete

func (c *Client) Obsolete(duration *time.Duration) bool

Obsolete returns true if a given client was disconnected longer than a given duration. If a given duration is nil - returns false (never obsolete).

func (*Client) RemoveTunnelByID

func (c *Client) RemoveTunnelByID(tunnelID string)

func (*Client) SetAddress

func (c *Client) SetAddress(address string)

test only

func (*Client) SetAllowedUserGroups

func (c *Client) SetAllowedUserGroups(groups []string)

func (*Client) SetAttributes

func (c *Client) SetAttributes(attributes models.Attributes)

func (*Client) SetClientAuthID

func (c *Client) SetClientAuthID(authID string)

test only

func (*Client) SetConnected

func (c *Client) SetConnected()

func (*Client) SetConnection

func (c *Client) SetConnection(conn ssh.Conn)

test only

func (*Client) SetDisconnectedAt

func (c *Client) SetDisconnectedAt(at *time.Time)

func (*Client) SetDisconnectedNow

func (c *Client) SetDisconnectedNow()

func (*Client) SetHeartbeatNow

func (c *Client) SetHeartbeatNow()

func (*Client) SetHostname

func (c *Client) SetHostname(hostname string)

test only

func (*Client) SetID

func (c *Client) SetID(id string)

test only

func (*Client) SetIPAddresses

func (c *Client) SetIPAddresses(IPAddresses *models.IPAddresses)

func (*Client) SetLastHeartbeatAt

func (c *Client) SetLastHeartbeatAt(at *time.Time)

func (*Client) SetPaused

func (c *Client) SetPaused(paused bool, reason string)

func (*Client) SetTags

func (c *Client) SetTags(tags []string)

test only

func (*Client) SetTunnels

func (c *Client) SetTunnels(tunnels []*clienttunnel.Tunnel)

func (*Client) SetUpdatesStatus

func (c *Client) SetUpdatesStatus(status *models.UpdatesStatus)

func (*Client) ToCalculated

func (c *Client) ToCalculated(allGroups []*cgroups.ClientGroup) *CalculatedClient

func (*Client) UserGroupHasAccessViaClientGroup

func (c *Client) UserGroupHasAccessViaClientGroup(userGroups []string, allClientGroups []*cgroups.ClientGroup) bool

UserGroupHasAccessViaClientGroup returns true if the user is member of a user group that has access to a client group the current client is member of

type ConnectionState

type ConnectionState string
const (
	Connected    ConnectionState = "connected"
	Disconnected ConnectionState = "disconnected"
)

Jump to

Keyboard shortcuts

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