Documentation ¶
Index ¶
- Constants
- Variables
- func ApiHeartbeatPath(ident string) string
- func ApiPath(resource string) string
- func ApiServerPath(ident string) string
- func ApiServersPath() string
- func FetchLog() *logging.Logger
- func InitEnv(env_str string)
- func InitLogging()
- type Agent
- func (agent *Agent) BuildAndSyncWatchers()
- func (agent *Agent) CloseWatches()
- func (agent *Agent) FirstRun() bool
- func (agent *Agent) Heartbeat() error
- func (agent *Agent) OnChange(file Watcher)
- func (agent *Agent) PerformUpgrade()
- func (agent *Agent) RegisterServer() error
- func (agent *Agent) StartPolling()
- func (agent *Agent) SyncAllFiles()
- type CanaryClient
- func (c *CanaryClient) CreateServer(srv *Server) (string, error)
- func (client *CanaryClient) FetchUpgradeablePackages() (map[string]string, error)
- func (client *CanaryClient) Heartbeat(uuid string, files Watchers) error
- func (client *CanaryClient) SendFile(path string, kind string, contents []byte) error
- type ChangeHandler
- type Client
- type Conf
- type Env
- type FileConf
- type MockClient
- type Server
- type ServerConf
- type UpgradeCommand
- type UpgradeSequence
- type Watcher
- type Watchers
Constants ¶
View Source
const ( PROD_URL = "https://www.appcanary.com" DEV_URL = "http://localhost:4000" DEFAULT_CONF_PATH = "/etc/appcanary/" DEFAULT_CONF_FILE = DEFAULT_CONF_PATH + "agent.conf" DEFAULT_VAR_PATH = "/var/db/appcanary/" DEFAULT_VAR_FILE = DEFAULT_VAR_PATH + "server.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 ( DEV_LOGO = `` /* 497-byte string literal not displayed */ PROD_LOGO = ` __ _____ _____ ___ __ ___ __ _ __ __ __ /'__` + "`" + `\ /\ '__` + "`" + `\/\ '__` + "`" + `\ /'___\ /'__` + "`" + `\ /' _ ` + "`" + `\ /'__` + "`" + `\ /\` + "`" + `'__\/\ \/\ \ /\ \L\.\_\ \ \L\ \ \ \L\ \/\ \__//\ \L\.\_/\ \/\ \/\ \L\.\_\ \ \/ \ \ \_\ \ \ \__/.\_\\ \ ,__/\ \ ,__/\ \____\ \__/.\_\ \_\ \_\ \__/.\_\\ \_\ \/` + "`" + `____ \ \/__/\/_/ \ \ \/ \ \ \/ \/____/\/__/\/_/\/_/\/_/\/__/\/_/ \/_/ ` + "`" + `/___/> \ \ \_\ \ \_\ /\___/ \/_/ \/_/ \/__/ ` )
trolol
Variables ¶
View Source
var ( ErrApi = errors.New("api error") ErrDeprecated = errors.New("api deprecated") )
View Source
var CanaryVersion string
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
Functions ¶
func ApiHeartbeatPath ¶
func ApiServerPath ¶
func ApiServersPath ¶
func ApiServersPath() string
func InitLogging ¶
func InitLogging()
Types ¶
type Agent ¶
func (*Agent) BuildAndSyncWatchers ¶
func (agent *Agent) BuildAndSyncWatchers()
func (*Agent) CloseWatches ¶
func (agent *Agent) CloseWatches()
This has to be called before exiting
func (*Agent) PerformUpgrade ¶
func (agent *Agent) PerformUpgrade()
func (*Agent) RegisterServer ¶
func (*Agent) SyncAllFiles ¶
func (agent *Agent) SyncAllFiles()
type CanaryClient ¶
type CanaryClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(apiKey string, server *Server) *CanaryClient
func (*CanaryClient) CreateServer ¶
func (c *CanaryClient) CreateServer(srv *Server) (string, error)
func (*CanaryClient) FetchUpgradeablePackages ¶
func (client *CanaryClient) FetchUpgradeablePackages() (map[string]string, error)
type ChangeHandler ¶
type ChangeHandler func(Watcher)
type Conf ¶
type Conf struct { ApiKey string `toml:"api_key"` LogPath string `toml:"log_path"` ServerName string `toml:"server_name"` detect.LinuxOSInfo Files []*FileConf `toml:"files"` ServerConf *ServerConf `toml:"-"` }
func NewConfFromEnv ¶
func NewConfFromEnv() *Conf
func (*Conf) OSInfo ¶
func (c *Conf) OSInfo() *detect.LinuxOSInfo
type Env ¶
type MockClient ¶
func (*MockClient) CreateServer ¶
func (m *MockClient) CreateServer(_a0 *Server) (string, error)
func (*MockClient) FetchUpgradeablePackages ¶
func (m *MockClient) FetchUpgradeablePackages() (map[string]string, error)
type Server ¶
type Server struct { Hostname string `json:"hostname"` Uname string `json:"uname"` Ip string `json:"ip"` Name string `json:"name"` UUID string `json:"uuid,omitempty"` Distro string `json:"distro,omitempty"` Release string `json:"release,omitempty"` }
func NewServer ¶
func NewServer(agentConf *Conf, conf *ServerConf) *Server
Creates a new server and syncs conf if needed
type ServerConf ¶
type ServerConf struct {
UUID string `toml:"uuid"`
}
type UpgradeCommand ¶
type UpgradeSequence ¶
type UpgradeSequence []UpgradeCommand
type Watcher ¶
type Watcher interface { Start() Stop() Contents() ([]byte, error) Path() string Kind() string MarshalJSON() ([]byte, error) }
func NewFileWatcher ¶
func NewFileWatcher(path string, callback ChangeHandler) Watcher
only used for tests
func NewFileWatcherWithHook ¶
func NewFileWatcherWithHook(path string, callback ChangeHandler) Watcher
TODO: time.Now() needs to be called whenever it updates
func NewProcessWatcher ¶
func NewProcessWatcher(process string, callback ChangeHandler) Watcher
func NewProcessWatcherWithHook ¶
func NewProcessWatcherWithHook(path string, callback ChangeHandler) Watcher
Source Files ¶
Click to show internal directories.
Click to hide internal directories.