config

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationName = "snips"
	UsageFormat     = `
KEY	TYPE	DEFAULT	DESCRIPTION
{{range .}}{{usage_key .}}	{{usage_type .}}	{{usage_default .}}	{{usage_description .}}
{{end}}`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug bool `default:"False" desc:"enable debug logging and pprof"`

	// NOTE: always false on arm64 arch.
	// currently not shipping libtensorflow for arm
	// https://github.com/robherley/snips.sh/issues/39
	EnableGuesser bool `default:"True" desc:"enable guesslang model to detect file types"`

	HMACKey string `default:"hmac-and-cheese" desc:"symmetric key used to sign URLs"`

	FileCompression bool `default:"True" desc:"enable compression of file contents"`

	Limits struct {
		FileSize        uint64        `default:"1048576" desc:"maximum file size in bytes"`
		FilesPerUser    uint64        `default:"100" desc:"maximum number of files per user"`
		SessionDuration time.Duration `default:"15m" desc:"maximum ssh session duration"`
	}

	DB struct {
		FilePath string `default:"data/snips.db" desc:"path to database file"`
	}

	HTTP struct {
		Internal url.URL `default:"http://localhost:8080" desc:"internal address to listen for http requests"`
		External url.URL `default:"http://localhost:8080" desc:"external http address displayed in commands"`
	}

	HTML struct {
		ExtendHeadFile string `default:"" desc:"path to html file for extra content in <head>"`
	}

	SSH struct {
		Internal           url.URL `default:"ssh://localhost:2222" desc:"internal address to listen for ssh requests"`
		External           url.URL `default:"ssh://localhost:2222" desc:"external ssh address displayed in commands"`
		HostKeyPath        string  `default:"data/keys/snips" desc:"path to host keys (without extension)"`
		AuthorizedKeysPath string  `default:"" desc:"path to authorized keys, if specified will restrict SSH access"`
	}

	Metrics struct {
		Statsd       *url.URL `desc:"statsd server address (e.g. udp://localhost:8125)"`
		UseDogStatsd bool     `default:"False" desc:"use dogstatsd instead of statsd"`
	}
}

func Load

func Load() (*Config, error)

func (*Config) HTTPAddressForFile

func (cfg *Config) HTTPAddressForFile(fileID string) string

func (*Config) PrintUsage

func (cfg *Config) PrintUsage() error

func (*Config) SSHAuthorizedKeys added in v0.3.0

func (cfg *Config) SSHAuthorizedKeys() ([]ssh.PublicKey, error)

SSHAuthorizedKeys returns the authorized keys if the file is specified in the config. If the file is not specified, it returns an empty slice.

func (*Config) SSHCommandForFile

func (cfg *Config) SSHCommandForFile(fileID string) string

Jump to

Keyboard shortcuts

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