Documentation
¶
Overview ¶
Package serverready reports whether a server can run the control plane and in which mode. Assess is pure over Facts, so each proxy and port situation is a table fixture; Collect gathers real Facts.
Index ¶
Constants ¶
const ( StatusPass = "pass" StatusWarn = "warn" StatusFail = "fail" StatusInfo = "info" )
Status of one check.
const ( ModeOwnPorts = "own_ports" ModeBehindProxy = "behind_proxy" )
Install modes.
const ( CheckOS = "os" CheckDocker = "docker" CheckDockerRootles = "docker_rootless" CheckDockerSocket = "docker_socket" CheckPort80 = "port_80" CheckPort443 = "port_443" CheckDisk = "disk" CheckMemory = "memory" CheckFirewall = "firewall" CheckDNS = "dns" )
Check IDs.
const ( ProxyTraefik = "traefik" ProxyNginx = "nginx" ProxyCaddy = "caddy" ProxyApache = "apache" ProxyHAProxy = "haproxy" ProxyOther = "unknown" )
Proxy kinds recognised by process or container image name.
Variables ¶
This section is empty.
Functions ¶
func ClassifyProxy ¶
ClassifyProxy names the proxy family of a process or image, "" if neither looks like a web server or proxy.
Types ¶
type Check ¶
type Check struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Detail string `json:"detail"`
Fix string `json:"fix,omitempty"`
}
Check is one result.
type DockerInfo ¶
DockerInfo is what the engine says about itself.
type Facts ¶
type Facts struct {
OS string `json:"os"`
Arch string `json:"arch"`
Systemd bool `json:"systemd"`
Listeners []Listener `json:"listeners"`
// SelfProcesses are process names that mean "this product is already
// running here", so its own ports are not a conflict.
SelfProcesses []string `json:"-"`
DockerPresent bool `json:"docker_present"`
DockerVersion string `json:"docker_version,omitempty"`
DockerRootless bool `json:"docker_rootless"`
DockerError string `json:"docker_error,omitempty"`
// DockerSocketWorldWritable and DockerTCPExposed flag an exposed daemon.
DockerSocketPath string `json:"docker_socket_path,omitempty"`
DockerSocketWorldWritable bool `json:"docker_socket_world_writable"`
DiskFreeGB float64 `json:"disk_free_gb"`
DiskPath string `json:"disk_path,omitempty"`
MemoryMB int `json:"memory_mb"`
Firewall Firewall `json:"firewall"`
Domain string `json:"domain,omitempty"`
DomainIPs []string `json:"domain_ips,omitempty"`
DNSError string `json:"dns_error,omitempty"`
LocalIPs []string `json:"local_ips,omitempty"`
}
Facts is everything Assess needs, gathered once.
type Firewall ¶
type Firewall struct {
// Kind is ufw, firewalld or "" when none was found.
Kind string `json:"kind"`
Active bool `json:"active"`
Known bool `json:"known"`
Allowed []int `json:"allowed,omitempty"`
}
Firewall describes the host firewall as far as it can be read.
func ParseFirewalld ¶
ParseFirewalld reads firewall-cmd --list-ports and --list-services output.
type Listener ¶
type Listener struct {
Addr string `json:"addr"`
Port int `json:"port"`
Process string `json:"process,omitempty"`
PID int `json:"pid,omitempty"`
// Container and Image are set when a Docker container publishes the port.
Container string `json:"container,omitempty"`
Image string `json:"image,omitempty"`
}
Listener is one TCP listening socket and who owns it.
func HostUDPHolder ¶
HostUDPHolder names the local process bound to a UDP port, if ss can see it.
func ParseSS ¶
ParseSS reads `ss -H -ltnp` output into listeners. Lines it cannot read are skipped: a half-parsed table must not hide the ports that did parse.
func ParseSSUDP ¶
ParseSSUDP reads `ss -H -lunp` output into bound UDP sockets.
type Probes ¶
type Probes struct {
SS func(ctx context.Context) (string, error)
UFW func(ctx context.Context) (string, error)
Firewalld func(ctx context.Context) (ports, services string, err error)
DockerInfo func(ctx context.Context) (DockerInfo, error)
Published func(ctx context.Context) ([]Listener, error)
SocketMode func(path string) (os.FileMode, error)
DiskFreeGB func(path string) (float64, error)
MemoryMB func() (int, error)
LookupHost func(ctx context.Context, host string) ([]string, error)
LocalIPs func() []string
HasSystemd func() bool
DockerPresent func() bool
}
Probes are the host reads Collect performs, injected so tests need no host.
func HostProbes ¶
func HostProbes() Probes
HostProbes returns the real probes. DockerInfo and Published are left nil for the caller, which already holds an engine client.
type Report ¶
type Report struct {
Checks []Check `json:"checks"`
// Mode is the recommended install mode.
Mode string `json:"mode"`
// Proxy is the reverse proxy found on 80/443, "" when none.
Proxy string `json:"proxy,omitempty"`
// Holders names who owns each contested port.
Holders map[int]string `json:"holders,omitempty"`
// NextStep is the exact command or action to take now.
NextStep string `json:"next_step"`
Blocked bool `json:"blocked"`
Summary string `json:"summary"`
}
Report is the assessment.
func Assess ¶
func Assess(f Facts, th Thresholds) Report
Assess turns facts into a report and a recommended mode.