check / check (push) Successful in 2m0s
The header drew the host's local time and then America/Los_Angeles time, so on a Mac in that zone both clocks read the same and neither was UTC. The first clock is now UTC and the second the host's local time, which also drops the hardcoded zone and its load-failure path.
73 lines
2.2 KiB
Go
73 lines
2.2 KiB
Go
package monitor
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.eeqj.de/sneak/rtnetmon/internal/starlink"
|
|
)
|
|
|
|
// Test-only accessors exposing unexported state for white-box assertions.
|
|
|
|
// SetStarlinkClient injects a Starlink client for iface, bypassing the real
|
|
// gRPC dialer so the loop can be driven with a fake.
|
|
func (m *Monitor) SetStarlinkClient(iface string, c starlink.Client) {
|
|
for _, st := range m.interfaces {
|
|
if st.Name == iface {
|
|
m.slPane = st
|
|
m.slState = &starlinkState{}
|
|
m.slClient = c
|
|
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
// StarlinkEnabled reports whether a Starlink client is configured.
|
|
func (m *Monitor) StarlinkEnabled() bool { return m.slClient != nil }
|
|
|
|
// StarlinkPaneName returns the name of the pane the Starlink lines attach
|
|
// to, or "" if none.
|
|
func (m *Monitor) StarlinkPaneName() string {
|
|
if m.slPane == nil {
|
|
return ""
|
|
}
|
|
|
|
return m.slPane.Name
|
|
}
|
|
|
|
// StarlinkProbeStep runs one detection step.
|
|
func (m *Monitor) StarlinkProbeStep(ctx context.Context) { m.starlinkProbe(ctx) }
|
|
|
|
// StarlinkRefreshStep runs one status-refresh step.
|
|
func (m *Monitor) StarlinkRefreshStep(ctx context.Context) { m.starlinkRefresh(ctx) }
|
|
|
|
// StarlinkSnapshot returns the current Starlink display state: detected,
|
|
// have-status, and the latest status.
|
|
func (m *Monitor) StarlinkSnapshot() (bool, bool, starlink.Status) {
|
|
return m.slState.snapshot()
|
|
}
|
|
|
|
// ReachabilityHosts returns the configured reachability hosts.
|
|
func (m *Monitor) ReachabilityHosts() []string { return m.reachabilityHosts }
|
|
|
|
// PacketLossHosts returns the configured packet-loss hosts.
|
|
func (m *Monitor) PacketLossHosts() []string { return m.packetLossHosts }
|
|
|
|
// TCPHosts returns the configured TCP hosts.
|
|
func (m *Monitor) TCPHosts() []string { return m.tcpHosts }
|
|
|
|
// Interfaces returns the monitored interfaces.
|
|
func (m *Monitor) Interfaces() []*InterfaceStatus { return m.interfaces }
|
|
|
|
// ClockStrings exposes clockStrings for external tests.
|
|
func ClockStrings(now time.Time) (string, string) { return clockStrings(now) }
|
|
|
|
// PingArgs exposes pingArgs for external tests.
|
|
func PingArgs(goos, iface, host string) []string { return pingArgs(goos, iface, host) }
|
|
|
|
// LossArgs exposes lossArgs for external tests.
|
|
func LossArgs(goos, iface, host string, count int) []string {
|
|
return lossArgs(goos, iface, host, count)
|
|
}
|