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

@@ -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 {