maglevt: show FQDN in header instead of config paths; v1.0.1

Replace the cfgPath field in the TUI header with the system's
fully-qualified hostname via gethostname + CNAME lookup, matching
what `hostname -f` produces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 22:20:35 +02:00
parent 701674399a
commit a8f02b913d
4 changed files with 22 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ FRONTEND_WEB_SRC := $(shell find cmd/frontend/web/src -type f 2>/dev/null) \
FRONTEND_WEB_DIST := cmd/frontend/web/dist/index.html
NATIVE_ARCH := $(shell go env GOARCH)
VERSION := 1.0.0
VERSION := 1.0.1
COMMIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X '$(MODULE)/cmd.version=$(VERSION)' \

View File

@@ -108,7 +108,7 @@ func run() error {
}
m := Model{
cfgPath: strings.Join(cfgPaths, ", "),
host: fqdn(),
vips: vips,
opts: opts,
startAt: time.Now(),
@@ -158,6 +158,24 @@ func run() error {
// deterministic TUI layout: within a file, frontends are visited
// in name-sorted order; across files, the first occurrence of each
// tuple wins and fixes its slot in the output.
// fqdn returns the system's fully-qualified hostname: gethostname(2)
// via os.Hostname() for the short name, then a CNAME lookup to reach
// the canonical form the resolver would hand back — the same two-step
// dance `hostname -f` performs. Falls back to the short name when the
// resolver has nothing to add, so the TUI header always renders.
func fqdn() string {
h, err := os.Hostname()
if err != nil {
return "unknown"
}
if cname, err := net.LookupCNAME(h); err == nil {
if s := strings.TrimSuffix(cname, "."); s != "" {
return s
}
}
return h
}
func buildVIPsUnion(cfgs []*config.Config, cfgPaths []string, filterRe *regexp.Regexp, opts probeOpts) []*vipState {
_ = cfgPaths // reserved for future diagnostics (e.g. which file this tuple came from)
type key struct {

View File

@@ -75,7 +75,7 @@ type errEvent struct {
// probeResultMsg handlers can update rolling/tally without copying
// the whole model.
type Model struct {
cfgPath string
host string
vips []*vipState
opts probeOpts
startAt time.Time

View File

@@ -149,7 +149,7 @@ func (m Model) viewHeader() string {
}
line := fmt.Sprintf(
"maglevt — %s — interval: %s timeout: %s header: %s [%s] uptime: %s",
m.cfgPath,
m.host,
m.opts.Interval,
m.opts.Timeout,
m.opts.Header,