core

package
v0.0.0-...-5efa5bd Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PL package list
	PL = "pl"
	// AR autoremove
	AR = "ar"
	// Ping client
	Ping = "p"
	// Sign client
	Sign = "s"
	// Reboot client
	Reboot = "r"
	// JS job status
	JS = "j"
	// Del client
	Del = "d"

	// UU update upgrade
	UU = "uu"
	// UUR update upgrade reboot
	UUR = "uur"
	// UD update dist-upgrade
	UD = "ud"
	// UDR update dist-upgrade reboot
	UDR = "udr"
	// UUCP update upgrade chosen package
	UUCP = "uucp"
	// UUCPR update upgrade chosen package reboot
	UUCPR = "uucpr"
)

Client actions

View Source
const (
	// Login user logs in
	Login = "login"
	// Logout user logs out
	Logout = "logout"
	// Comment of client is changed
	Comment = "comment"

	// CreateGroup a new group is created
	CreateGroup = "created group "
	// ChangeGroup a group is changed
	ChangeGroup = "changed group "
	// DeleteGroup a group is deleted
	DeleteGroup = "deleted group "
	// CreateUser user is created
	CreateUser = "created user "
	// CHangeUser user is changed
	ChangeUser = "changed user "
	// DeleteUser user is deleted
	DeleteUser = "deleted user "
)

Server actions

View Source
const (
	// DefDataDir is the default running directory
	DefDataDir = "/var/lib/harkonn"
	// DefLogFile is the default log file
	DefLogFile = "/var/log/harkonn.log"
	// DefConfigFile is the default config file
	DefConfigFile = "/etc/harkonn/harkonn.json"
	// DefServerAddress is the default server listening address
	DefServerAddress = "0.0.0.0"
	// DefServerPort is the default server listening/connect port
	DefServerPort = "2600"
	// DefMaxClients defines the maximum client connections
	DefMaxClients = 100
	// DefClientExecTimeout is the default client exec timeout in minutes
	DefClientExecTimeout = 20
	// DefClientReconnect is the default client reconnect timeout in seconds
	DefClientReconnect = 15
	// DefClientInterval is the default client update interval in hours
	DefClientInterval = 1
	// DefHTTPPort is the default HTTP(S) port
	DefHTTPPort = "443"
	// DefHTTPPoolSize is the default API client connection pool size
	DefHTTPPoolSize = 10
	// DefHTTPCert is the default HTTP certificate file
	DefHTTPCert = "srv.pem"
	// DefHTTPKey is the default HTTP key file
	DefHTTPKey = "srv.key"
	// DefUnlockUser is the default user to unlock
	DefUnlockUser = "admin"
	// DBFile is the default file to store the database
	DBFile = "datastore"
)
View Source
const BcryptCost = 13

BcryptCost defines the cost for bcrypt password hashing

Variables

View Source
var (
	// C is the globally shared config
	C config
	// Version is the globally shared version
	Version string
)
View Source
var Actions = map[string]string{
	Sign:    "Sign Client Certificate",
	Del:     "Deleted Client",
	AR:      "Autoremove",
	PL:      "Package List",
	Ping:    "Ping Client",
	Reboot:  "Reboot",
	UUCP:    "Update Upgrade Chosen Software",
	UUCPR:   "Update Upgrade Chosen Software Reboot",
	UU:      "Update Upgrade",
	UUR:     "Update Upgrade Reboot",
	UD:      "Update Dist-Upgrade",
	UDR:     "Update Dist-Upgrade Reboot",
	Login:   "Login",
	Logout:  "Logout",
	Comment: "Comment Changed",
}

Actions represents a string map between constants and their description

Functions

func Contains

func Contains(str string, a []string) bool

Contains checks if str is in slice a

func Date

func Date() string

Date returns the current date as string

func Time

func Time() string

Time returns the current date and time as string

Types

type APIKey

type APIKey struct {
	UserID string `json:"user_id"`
	Key    string `json:"key"`
}

APIKey json struct for api usage

type Audit

type Audit struct {
	Host     string `json:"host"`
	User     string `json:"user"`
	Action   string `json:"action"`
	Executed string `json:"executed"`
}

Audit json struct for api usage

type CSR

type CSR struct {
	Host        string          `json:"host"`
	Address     string          `json:"address,omitempty"`
	Fingerprint string          `json:"fingerprint,omitempty"`
	Raw         []byte          `json:"raw,omitempty"`
	C           chan ClientCert `json:"-"`
	Err         chan error      `json:"-"`
}

CSR represents a pending Certificate Signing Request

type Client

type Client struct {
	Host       string    `json:"host"`
	Dist       string    `json:"dist"`
	Version    string    `json:"version"`
	IP         string    `json:"ip"`
	Updates    bool      `json:"updates"`
	LastUpdate string    `json:"last_update"`
	Connected  bool      `json:"connected"`
	Member     bool      `json:"member"`
	Arch       string    `json:"arch"`
	CPU        string    `json:"cpu"`
	RAM        int       `json:"ram"`
	Comment    string    `json:"comment"`
	Packages   []Package `json:"packages"`
	Jobs       []Job     `json:"jobs,omitempty"`
	Serial     string    `json:"-"`
}

Client json struct for api usage

type ClientCert

type ClientCert struct {
	Cert []byte `json:"cert"`
	CA   []byte `json:"ca"`
}

ClientCert represents the signed client certificate

type Group

type Group struct {
	Name     string   `json:"name"`
	UMembers []string `json:"umembers"`
	CMembers []string `json:"cmembers"`
}

Group json struct for api usage

type Info

type Info struct {
	Client   Client `json:"client"`
	Interval int    `json:"interval"`
}

Info json struct for client info

type Job

type Job struct {
	Action   string
	Started  string
	Finished string
	Status   JobStatus
	Log      string
}

Job stores a client job

type JobStatus

type JobStatus int

JobStatus represents the enum status of a Job

const (
	// Queued job is in queue
	Queued JobStatus = iota
	// Running job is running
	Running
	// OK job finished successful
	OK
	// Failure job finished unsuccessful
	Failure
)

func (JobStatus) String

func (s JobStatus) String() string

String implements the stringer interface

type Jobs

type Jobs struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Jobs represents the job handling struct

func NewJobs

func NewJobs() *Jobs

NewJobs returns a new *Jobs struct

func (*Jobs) Add

func (j *Jobs) Add(data SendData)

Add adds a new job to the queue

func (*Jobs) Finish

func (j *Jobs) Finish(ok bool, log string)

Finish finishes the currently active job with the stats

func (*Jobs) Jobs

func (j *Jobs) Jobs() (jobs []Job)

Jobs returns all jobs

type LDAP

type LDAP struct {
	Address      string
	Port         string
	TLS          bool
	BindDN       string
	BindPassword string
	UserDN       string
	UserFilter   string
}

LDAP is the LDAP configuration struct

type Package

type Package struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	NewVersion string `json:"new_version"`
}

Package json struct for api usage

type PackageClient

type PackageClient struct {
	Host    string  `json:"host"`
	Package Package `json:"package"`
}

PackageClient represents a client with specific package

type PackageList

type PackageList struct {
	Name     string              `json:"name"`
	Versions []string            `json:"versions"`
	Clients  int                 `json:"clients"`
	VerMap   map[string]struct{} `json:"-"`
}

PackageList represents a package with version and the number of affected clients

type Route

type Route struct {
	Path    string
	Handler http.HandlerFunc
	Methods []string
}

Route represents a http route

type SendData

type SendData struct {
	Type     string    `json:"type"`
	Host     string    `json:"host"`
	Delay    int       `json:"delay,omitempty"`
	Packages []string  `json:"packages,omitempty"`
	Timeout  chan bool `json:"-"`
}

SendData for communication between api and worker

type Stats

type Stats struct {
	Goroutines  int     `json:"goroutines"`
	Alloc       float64 `json:"alloc"`
	Sys         float64 `json:"sys"`
	Clients     int     `json:"clients"`
	ClientsConn int     `json:"clients_conn"`
	Version     string  `json:"version"`
	GoVersion   string  `json:"go_version"`
}

Stats json struct for api usage

type UpdatePackages

type UpdatePackages struct {
	Host     string   `json:"host"`
	Packages []string `json:"packages"`
}

UpdatePackages represents a client hostname and a package list

type User

type User struct {
	User      string `json:"user"`
	Password  string `json:"password,omitempty"`
	LastLogin string `json:"last_login,omitempty"`
	Type      string `json:"type,omitempty"`
	Enabled   bool   `json:"enabled,omitempty"`
	Admin     bool   `json:"admin,omitempty"`
	Locked    int    `json:"locked,omitempty"`
	Member    bool   `json:"member,omitempty"`
}

User json struct for api usage

Jump to

Keyboard shortcuts

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