conf

package
v0.0.0-...-48db7f4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PROD_URL = "https://www.appcanary.com"
	DEV_URL  = "http://localhost:4000"

	DEFAULT_CONF_PATH      = "/etc/appcanary/"
	DEFAULT_CONF_FILE_BASE = DEFAULT_CONF_PATH + "agent"
	DEFAULT_VAR_PATH       = "/var/db/appcanary/"
	DEFAULT_VAR_FILE_BASE  = DEFAULT_VAR_PATH + "server"
	DEFAULT_CONF_FILE      = DEFAULT_CONF_FILE_BASE + ".yml"
	DEFAULT_VAR_FILE       = DEFAULT_VAR_FILE_BASE + ".yml"
	OLD_DEFAULT_CONF_FILE  = DEFAULT_CONF_FILE_BASE + ".conf"
	OLD_DEFAULT_VAR_FILE   = DEFAULT_VAR_FILE_BASE + ".conf"

	DEFAULT_HEARTBEAT_DURATION = 1 * time.Hour
	DEV_HEARTBEAT_DURATION     = 10 * time.Second

	DEFAULT_SYNC_ALL_DURATION = 24 * time.Hour
	DEV_SYNC_ALL_DURATION     = 30 * time.Second

	DEFAULT_LOG_FILE = "/var/log/appcanary.log"
)

env vars

View Source
const (
	API_VERSION   = "/api/v1/agent/"
	API_HEARTBEAT = API_VERSION + "heartbeat"
	API_SERVERS   = API_VERSION + "servers"
)

api endpoints

View Source
const (
	DEFAULT_POLL_SLEEP = 5 * time.Minute
	// test env.PollSleep is 1second
	// test poll sleep is double to give the fs time to flush
	DEV_POLL_SLEEP  = time.Second
	TEST_POLL_SLEEP = (time.Second + (150 * time.Millisecond)) * 2
)

file polling

View Source
const (



     __     _____   _____     ___     __      ___      __     _ __   __  __
   /'__` + "`" + `\  /\ '__` + "`" + `\/\ '__` + "`" + `\  /'___\ /'__` + "`" + `\  /' _ ` + "`" + `\  /'__` + "`" + `\  /\` + "`" + `'__\/\ \/\ \
  /\ \L\.\_\ \ \L\ \ \ \L\ \/\ \__//\ \L\.\_/\ \/\ \/\ \L\.\_\ \ \/ \ \ \_\ \
  \ \__/.\_\\ \ ,__/\ \ ,__/\ \____\ \__/.\_\ \_\ \_\ \__/.\_\\ \_\  \/` + "`" + `____ \
   \/__/\/_/ \ \ \/  \ \ \/  \/____/\/__/\/_/\/_/\/_/\/__/\/_/ \/_/   ` + "`" + `/___/> \
              \ \_\   \ \_\                                              /\___/
               \/_/    \/_/                                              \/__/


`
)

trolol

Variables

View Source
var DEV_CONF_FILE string
View Source
var DEV_CONF_PATH string

consts can't be outputs of functions?

View Source
var DEV_VAR_FILE string
View Source
var DEV_VAR_PATH string
View Source
var OLD_DEV_CONF_FILE string
View Source
var OLD_DEV_VAR_FILE string

Functions

func ApiHeartbeatPath

func ApiHeartbeatPath(ident string) string

func ApiPath

func ApiPath(resource string) string

func ApiServerPath

func ApiServerPath(ident string) string

func ApiServerProcsPath

func ApiServerProcsPath(ident string) string

func ApiServersPath

func ApiServersPath() string

func FetchLog

func FetchLog() *logging.Logger

func InitEnv

func InitEnv(envStr string)

func InitLogging

func InitLogging()

Types

type Conf

type Conf struct {
	detect.LinuxOSInfo `yaml:",inline"`
	ApiKey             string        `yaml:"api_key,omitempty" toml:"api_key"`
	LogPath            string        `yaml:"log_path,omitempty" toml:"log_path"`
	ServerName         string        `yaml:"server_name,omitempty" toml:"server_name"`
	Watchers           []WatcherConf `yaml:"watchers" toml:"files"`
	StartupDelay       int           `yaml:"startup_delay,omitempty" toml:"startup_delay"`
	ServerConf         *ServerConf   `yaml:"-" toml:"-"`
	Tags               []string      `yaml:"tags,omitempty"` // no toml support for this
}

func NewConf

func NewConf() *Conf

func NewConfFromEnv

func NewConfFromEnv() (*Conf, error)

we can't function without configuration so at some point some substack callee of this method will Fatal() if it can't find what it needs

func NewTomlConfFromEnv

func NewTomlConfFromEnv(confFile, varFile string) (*Conf, error)

func NewYamlConfFromEnv

func NewYamlConfFromEnv() (*Conf, error)

func (*Conf) FullSave

func (c *Conf) FullSave(confFile, varFile string)

Saves the whole structure in two files

func (*Conf) OSInfo

func (c *Conf) OSInfo() *detect.LinuxOSInfo

func (*Conf) Save

func (c *Conf) Save()

type Env

type Env struct {
	Env               string
	Prod              bool
	DryRun            bool
	FailOnConflict    bool
	BaseUrl           string
	ConfFile          string
	VarFile           string
	LogFile           string
	LogFileHandle     *os.File
	HeartbeatDuration time.Duration
	SyncAllDuration   time.Duration
	PollSleep         time.Duration
}

func FetchEnv

func FetchEnv() *Env

type ServerConf

type ServerConf struct {
	UUID string `toml:"uuid" yaml:"uuid"`
}

type WatcherConf

type WatcherConf struct {
	Path    string `yaml:"path,omitempty" toml:"path"`
	Process string `yaml:"process,omitempty" toml:"inspect_process"`
	Command string `yaml:"command,omitempty" toml:"process"`
}

Jump to

Keyboard shortcuts

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