Documentation ¶
Index ¶
- Constants
- func DownloadFile(filepath string, url string, mode os.FileMode) error
- func GetBlacklistedMacAddrPrefixes() []string
- func GetMacAddr() string
- func GetRandomSecondAsString() string
- func GetTimeNow() string
- func IsValidMACAddress(mAddr string, blacklistPrefixes []string) bool
- func Reboot() error
- func VerifyFileSignature(directory, targetFile, signedFile string, keys []io.Reader) error
- type APIConfig
- type Config
- type LogReporter
- type LoggerInstance
- type SpeedTestInstance
- type SpeedTestResults
- type SpeedTestRunner
- type Task
- type TaskData
- type TaskLogEntry
Constants ¶
const ConfigFileName = "speedsnitch.txt"
const ExeFileName = "speedsnitch"
const MaxSecondsOffset = 50
const NetworkOffline = "offline"
const NetworkOnline = "online"
const TypeError = "error"
const TypePing = "ping"
const TypeReboot = "reboot"
const TypeRestarted = "restarted" // For sending a log after a restart
const TypeSpeedTest = "speedTest"
const Version = "0.0.13"
Variables ¶
This section is empty.
Functions ¶
func DownloadFile ¶
DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.
func GetBlacklistedMacAddrPrefixes ¶
func GetBlacklistedMacAddrPrefixes() []string
func GetMacAddr ¶
func GetMacAddr() string
getMacAddr gets the lowest (alphabetically) MAC hardware address of the host machine
func GetRandomSecondAsString ¶
func GetRandomSecondAsString() string
func GetTimeNow ¶
func GetTimeNow() string
GetTimeNow returns the current UTC time in the RFC3339 format
func IsValidMACAddress ¶
IsValidMacAddress checks whether the input is ...
- 12 hexacedimal digits OR
- 6 pairs of hexadecimal digits separated by colons and/or hyphens
It also rejects those that begin with text that matches an entry in the blacklistPrefixes slice.
Types ¶
type APIConfig ¶
func GetAppConfig ¶
GetAppConfig accepts an io.Reader for testing purposes. If the io.Reader param is nil, then it uses the default config file to provide an custom APIConfig
type LogReporter ¶
Any struct that implements a Process method - for swapping which Logging service we use
type LoggerInstance ¶
type LoggerInstance struct {
LogReporter
}
Needed to be able to swap in a customized logging struct that implements a Logger To use this ...
` // mycustomlogapp.go `type Logger struct {}` `func (l Logger) Process(logKey, text string, a ...interface{}) { ... }` `// main.go `logger := agent.LoggerInstance{mycustomlogapp.Logger{}}`
type SpeedTestInstance ¶
type SpeedTestInstance struct {
SpeedTestRunner
}
type SpeedTestResults ¶
type SpeedTestResults struct { Download float64 `json:"Download,omitempty"` // Mb per second Upload float64 `json:"Upload,omitempty"` // Mb per second Latency time.Duration `json:"Latency,omitempty"` // Latency in nanoseconds PacketLossPercent float64 `json:"PacketLossPercent,omitempty"` // Percentage of package loss on ping Timestamp time.Time `json:"Timestamp"` Error string `json:"Error"` }
func (*SpeedTestResults) CleanData ¶
func (s *SpeedTestResults) CleanData()
type SpeedTestRunner ¶
type SpeedTestRunner interface {
Run(TaskData) (SpeedTestResults, error)
}
type TaskLogEntry ¶
type TaskLogEntry struct { Timestamp int64 `json:"Timestamp"` EntryType string `json:"EntryType"` ServerCountry string `json:"ServerCountry,omitempty"` NamedServerID uint `json:"NamedServerID,omitempty"` Upload float64 `json:"Upload,omitempty"` Download float64 `json:"Download,omitempty"` Latency float64 `json:"Latency,omitempty"` PacketLossPercent float64 `json:"PacketLossPercent,omitempty"` ErrorCode string `json:"ErrorCode,omitempty"` ErrorMessage string `json:"ErrorMessage,omitempty"` DowntimeStart string `json:"DowntimeStart,omitempty"` DowntimeSeconds int64 `json:"DowntimeSeconds,omitempty"` }
func GetTaskLogEntry ¶
func GetTaskLogEntry(entryType string) TaskLogEntry