Documentation ¶
Index ¶
- Constants
- Variables
- func CopyAttrsToClient(attributes models.Attributes, client *Client)
- func CopyClientsToAttrs(client Client, attributes *models.Attributes)
- func NewClientID() (string, error)
- type CalculatedClient
- type Client
- func (c *Client) Banner() string
- func (c *Client) BelongsTo(group *cgroups.ClientGroup) bool
- func (c *Client) BelongsToOneOf(groups []*cgroups.ClientGroup) bool
- func (c *Client) CalculateConnectionState() ConnectionState
- func (c *Client) Close() error
- func (c *Client) GetAddress() (address string)
- func (c *Client) GetAllowedUserGroups() (groups []string)
- func (c *Client) GetAttributes() models.Attributes
- func (c *Client) GetClientAuthID() (authID string)
- func (c *Client) GetConnection() (conn ssh.Conn)
- func (c *Client) GetContext() (ctx context.Context)
- func (c *Client) GetDisconnectedAt() (at *time.Time)
- func (c *Client) GetDisconnectedAtValue() (at time.Time)
- func (c *Client) GetFileReceptionConfig() (fileReceptionConfig *clientconfig.FileReceptionConfig)
- func (c *Client) GetHostname() (hostname string)
- func (c *Client) GetID() (id string)
- func (c *Client) GetIPv4() (ipv4 []string)
- func (c *Client) GetIPv6() (ipv6 []string)
- func (c *Client) GetLabels() (labels map[string]string)
- func (c *Client) GetLastHeartbeatAt() (at *time.Time)
- func (c *Client) GetLastHeartbeatAtValue() (at time.Time)
- func (c *Client) GetLock() (mu *sync.RWMutex)
- func (c *Client) GetMemoryTotal() (mem uint64)
- func (c *Client) GetMonitoringConfig() (monitoringConfig *clientconfig.MonitoringConfig)
- func (c *Client) GetName() (name string)
- func (c *Client) GetNumCPUs() (num int)
- func (c *Client) GetOS() (os string)
- func (c *Client) GetOSArch() (arch string)
- func (c *Client) GetOSFamily() (fam string)
- func (c *Client) GetOSFullName() (name string)
- func (c *Client) GetOSKernel() (kernel string)
- func (c *Client) GetOSVersion() (ver string)
- func (c *Client) GetOSVirtualizationRole() (role string)
- func (c *Client) GetOSVirtualizationSystem() (sys string)
- func (c *Client) GetPausedReason() (reason string)
- func (c *Client) GetSessionID() (sessionID string)
- func (c *Client) GetTags() (tags []string)
- func (c *Client) GetTimezone() (tz string)
- func (c *Client) GetTunnels() (tunnels []*clienttunnel.Tunnel)
- func (c *Client) GetUpdatesStatus() (status models.UpdatesStatus)
- func (c *Client) GetVersion() (version string)
- func (c *Client) HasAccessViaUserGroups(userGroups []string) bool
- func (c *Client) HasLastHeartbeatAt() (has bool)
- func (c *Client) IsConnected() bool
- func (c *Client) IsPaused() (paused bool)
- func (c *Client) Log() (l *logger.Logger)
- func (c *Client) NewTunnelID() (tunnelID string)
- func (c *Client) Obsolete(duration *time.Duration) bool
- func (c *Client) RemoveTunnelByID(tunnelID string)
- func (c *Client) SetAddress(address string)
- func (c *Client) SetAllowedUserGroups(groups []string)
- func (c *Client) SetAttributes(attributes models.Attributes)
- func (c *Client) SetClientAuthID(authID string)
- func (c *Client) SetConnected()
- func (c *Client) SetConnection(conn ssh.Conn)
- func (c *Client) SetDisconnectedAt(at *time.Time)
- func (c *Client) SetDisconnectedNow()
- func (c *Client) SetHeartbeatNow()
- func (c *Client) SetHostname(hostname string)
- func (c *Client) SetID(id string)
- func (c *Client) SetIPAddresses(IPAddresses *models.IPAddresses)
- func (c *Client) SetLastHeartbeatAt(at *time.Time)
- func (c *Client) SetPaused(paused bool, reason string)
- func (c *Client) SetTags(tags []string)
- func (c *Client) SetTunnels(tunnels []*clienttunnel.Tunnel)
- func (c *Client) SetUpdatesStatus(status *models.UpdatesStatus)
- func (c *Client) ToCalculated(allGroups []*cgroups.ClientGroup) *CalculatedClient
- func (c *Client) UserGroupHasAccessViaClientGroup(userGroups []string, allClientGroups []*cgroups.ClientGroup) bool
- type ConnectionState
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)
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 (*Client) BelongsToOneOf ¶
func (c *Client) BelongsToOneOf(groups []*cgroups.ClientGroup) bool
func (*Client) CalculateConnectionState ¶
func (c *Client) CalculateConnectionState() ConnectionState
func (*Client) GetAddress ¶
func (*Client) GetAllowedUserGroups ¶
func (*Client) GetAttributes ¶
func (c *Client) GetAttributes() models.Attributes
func (*Client) GetClientAuthID ¶
func (*Client) GetConnection ¶
func (*Client) GetContext ¶
func (*Client) GetDisconnectedAt ¶
func (*Client) GetDisconnectedAtValue ¶
func (*Client) GetFileReceptionConfig ¶
func (c *Client) GetFileReceptionConfig() (fileReceptionConfig *clientconfig.FileReceptionConfig)
func (*Client) GetHostname ¶
func (*Client) GetLastHeartbeatAt ¶
func (*Client) GetLastHeartbeatAtValue ¶
func (*Client) GetMemoryTotal ¶
func (*Client) GetMonitoringConfig ¶
func (c *Client) GetMonitoringConfig() (monitoringConfig *clientconfig.MonitoringConfig)
func (*Client) GetNumCPUs ¶
func (*Client) GetOSFamily ¶
func (*Client) GetOSFullName ¶
func (*Client) GetOSKernel ¶
func (*Client) GetOSVersion ¶
func (*Client) GetOSVirtualizationRole ¶
func (*Client) GetOSVirtualizationSystem ¶
func (*Client) GetPausedReason ¶
func (*Client) GetSessionID ¶
func (*Client) GetTimezone ¶
func (*Client) GetTunnels ¶
func (c *Client) GetTunnels() (tunnels []*clienttunnel.Tunnel)
func (*Client) GetUpdatesStatus ¶
func (c *Client) GetUpdatesStatus() (status models.UpdatesStatus)
func (*Client) GetVersion ¶
func (*Client) HasAccessViaUserGroups ¶
HasAccessViaUserGroups returns true if at least one of given user groups has access to a current client.
func (*Client) HasLastHeartbeatAt ¶
func (*Client) IsConnected ¶
func (*Client) NewTunnelID ¶
func (*Client) Obsolete ¶
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 (*Client) SetAllowedUserGroups ¶
func (*Client) SetAttributes ¶
func (c *Client) SetAttributes(attributes models.Attributes)
func (*Client) SetConnected ¶
func (c *Client) SetConnected()
func (*Client) SetDisconnectedAt ¶
func (*Client) SetDisconnectedNow ¶
func (c *Client) SetDisconnectedNow()
func (*Client) SetHeartbeatNow ¶
func (c *Client) SetHeartbeatNow()
func (*Client) SetIPAddresses ¶
func (c *Client) SetIPAddresses(IPAddresses *models.IPAddresses)
func (*Client) SetLastHeartbeatAt ¶
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" )
Click to show internal directories.
Click to hide internal directories.