config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright 2023 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	APITypeHTTP = "http"
	APITypeDBus = "dbus"
)
View Source
const (
	VersionUnknown = "unknown"
)

Variables

View Source
var (
	DefaultConfDir     = "/etc/nt-connect"
	DefaultPathDataDir = "/usr/share/nt-connect"
	DefaultDataStore   = "/var/lib/nt-connect"

	DefaultShellCommand      = "/bin/sh"
	DefaultShellArguments    = []string{"--login"}
	DefaultDeviceConnectPath = "/api/devices/v1/deviceconnect/connect"

	DefaultTerminalString = "xterm-256color"
	DefaultTerminalHeight = uint16(40)
	DefaultTerminalWidth  = uint16(80)

	DefaultConfFile         = path.Join(GetConfDirPath(), "nt-connect.json")
	DefaultFallbackConfFile = path.Join(GetStateDirPath(), "nt-connect.json")

	DefaultDebug = false
	DefaultTrace = false

	MaxReconnectAttempts             = uint(10)
	DefaultReconnectIntervalsSeconds = 5
	MessageWriteTimeout              = 2 * time.Second
	MaxShellsSpawned                 = uint(16)
)

default configuration paths

View Source
var (
	// Version information of current build
	Version string
)

Functions

func GetConfDirPath

func GetConfDirPath() string

GetConfDirPath returns the default config directory

func GetStateDirPath

func GetStateDirPath() string

GetStateDirPath returns the default data store directory

func ShowVersion

func ShowVersion() string

func ShowVersionCLI

func ShowVersionCLI(ctx *cli.Context) error

func VersionString

func VersionString() string

Types

type APIConfig

type APIConfig struct {
	APIType        `json:"Type"`
	ServerURL      string `json:"ServerURL"`
	PrivateKeyPath string `json:"PrivateKeyPath"`
	IdentityPath   string `json:"IdentityPath"`
	TenantToken    string `json:"TenantToken"`
	ExternalID     string `json:"ExternalID"`

	InventoryExecutable string         `json:"InventoryExecutable"`
	InventoryInterval   types.Duration `json:"InventoryInterval"`
	// contains filtered or unexported fields
}

func (*APIConfig) GetIdentity

func (cfg *APIConfig) GetIdentity() *api.Identity

func (*APIConfig) GetPrivateKey

func (cfg *APIConfig) GetPrivateKey() crypto.Signer

func (*APIConfig) Validate

func (cfg *APIConfig) Validate() error

type APIType

type APIType string

func (APIType) Validate

func (t APIType) Validate() error

type FileTransferConfig

type FileTransferConfig struct {
	// Disable file transfer features
	Disable bool
}

type FileTransferLimits

type FileTransferLimits struct {
	// No way to escape Chroot, even if this one is set the Chroot setting will
	// be checked for the target of any link and restricted accordingly
	FollowSymLinks bool
	// Allow overwrite files
	AllowOverwrite bool
	// set the owner of new files to OwnerPut
	OwnerPut string
	// set the owner of new files to OwnerPut
	GroupPut string
	// allow to get only files owned by OwnerGet
	OwnerGet []string
	// allow to get only files owned by OwnerGet
	GroupGet []string
	// umask for new files
	Umask string
	// Maximum allowed file size
	MaxFileSize uint64
	// File transfer rate limits
	Counters RateLimits
	// If true it is allowed to upload files with set user id on execute bit set
	AllowSuid bool
	// By default we only allow to send/put regular files
	RegularFilesOnly bool
	// By default we preserve the file modes but set one according to
	//the current umask or configured Umask above
	PreserveMode bool
	// By default we preserve the owner of the file uploaded
	PreserveOwner bool
}

Limits and restrictions for the File Transfer on and off the device(MEN-4325)

type Limits

type Limits struct {
	Enabled      bool               `json:"Enabled"`
	FileTransfer FileTransferLimits `json:"FileTransfer"`
}

type MenderClientConfig

type MenderClientConfig struct {
	// Disable mender-client websocket bindings.
	Disable bool
}

type NTConnectConfig

type NTConnectConfig struct {
	NTConnectConfigFromFile
	Debug bool
	Trace bool
}

NTConnectConfig holds the configuration settings for the Mender shell client

func LoadConfig

func LoadConfig(mainConfigFile string, fallbackConfigFile string) (*NTConnectConfig, error)

LoadConfig parses the mender configuration json-files (/etc/mender/mender-connect.conf and /var/lib/mender/mender-connect.conf) and loads the values into the NTConnectConfig structure defining high level client configurations.

func NewNTConnectConfig

func NewNTConnectConfig() *NTConnectConfig

NewNTConnectConfig initializes a new NTConnectConfig struct

func (*NTConnectConfig) Validate

func (c *NTConnectConfig) Validate() (err error)

Validate verifies the Servers fields in the configuration

type NTConnectConfigFromFile

type NTConnectConfigFromFile struct {
	// The command to run as shell
	ShellCommand string `json:",omitempty"`
	// ShellArguments is the arguments the shell is launched with. Defaults
	// to '--login'.
	ShellArguments []string `json:",omitempty"`
	// Name of the user who owns the shell process
	User string `json:",omitempty"`
	// Terminal settings
	Terminal TerminalConfig `json:"Terminal,omitempty"`
	// User sessions settings
	Sessions SessionsConfig `json:"Sessions,omitempty"`
	// Limits and restrictions
	Limits Limits `json:"Limits,omitempty"`
	// Reconnect interval
	ReconnectIntervalSeconds int `json:",omitempty"`
	// FileTransfer config
	FileTransfer FileTransferConfig `json:",omitempty"`
	// PortForward config
	PortForward PortForwardConfig `json:",omitempty"`
	// TLS configures how the client manages tls sessions.
	TLS TLSConfig `json:"TLS,omitempty"`
	// APIConfig
	APIConfig APIConfig `json:"API,omitempty"`
	// MenderClient config
	MenderClient MenderClientConfig
	Chroot       string `json:"Chroot,omitempty"`
}

NTConnectConfigFromFile holds the configuration settings read from the config file

type PortForwardConfig

type PortForwardConfig struct {
	// Disable port forwarding feature
	Disable bool
}

type RateLimits

type RateLimits struct {
	// Maximum bytes count allowed to transfer per minute
	// this is per device global limit, which is consulted
	// every time there is a transfer starting. if above
	// the limit, we answer with error message indicating
	// limit reached.
	MaxBytesTxPerMinute uint64
	MaxBytesRxPerMinute uint64
}

Counter for the limits and restrictions for the File Transfer on and off the device(MEN-4325)

type SessionsConfig

type SessionsConfig struct {
	// Whether to stop expired sessions
	StopExpired bool
	// Seconds after startup of a sessions that will make it expire
	ExpireAfter uint32
	// Seconds after last activity of a sessions that will make it expire
	ExpireAfterIdle uint32
	// Max sessions per user
	MaxPerUser uint32
}

type TLSConfig

type TLSConfig struct {
	CACertificate      string `json:"CACertificate,omitempty"`
	InsecureSkipVerify bool   `json:"InsecureSkipVerify,omitempty"`
}

func (TLSConfig) ToStdConfig

func (cfg TLSConfig) ToStdConfig() (*tls.Config, error)

type TerminalConfig

type TerminalConfig struct {
	Width  uint16
	Height uint16
	// Disable remote terminal
	Disable bool
}

Jump to

Keyboard shortcuts

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