From b4c098890c709e12daf001375b9499e6025e7aa0 Mon Sep 17 00:00:00 2001 From: abrown38 Date: Fri, 23 Oct 2026 18:06:39 +0100 Subject: [PATCH] hc forward show: hits, comment, and hairpin without a stray dash Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 ++ cmd/hc/rules.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc79f3..547ec0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,6 +162,8 @@ All notable changes to Housecarl are documented here. The format follows ### Fixed +- `hc forward show` shows the forward's hits and comment, and its + hairpin as `no`, `yes` or `yes, from …` (it printed `no -`). - A history entry's ruleset diff showed the object it changed as moved: stepping back put the old form at the end of its list, so updating one port forward (turning hairpin off) also showed its forward and diff --git a/cmd/hc/rules.go b/cmd/hc/rules.go index 7779c1c..239de64 100644 --- a/cmd/hc/rules.go +++ b/cmd/hc/rules.go @@ -605,7 +605,16 @@ func forwardCmd() *cobra.Command { if f.ToPort != "" { fmt.Fprintf(w, "To port:\t%s\n", f.ToPort) } - fmt.Fprintf(w, "To (IPv6):\t%s\nFrom:\t%s\nHairpin:\t%s %s\n", orDash(f.To6), list(f.Sources), yesNo(f.Hairpin), list(f.HairpinSources)) + hairpin := yesNo(f.Hairpin) + if f.Hairpin && len(f.HairpinSources) > 0 { + hairpin += ", from " + list(f.HairpinSources) + } + fmt.Fprintf(w, "To (IPv6):\t%s\nFrom:\t%s\nHairpin:\t%s\n", orDash(f.To6), list(f.Sources), hairpin) + if f.Comment != "" { + fmt.Fprintf(w, "Comment:\t%s\n", f.Comment) + } + cs := counters() + fmt.Fprintf(w, "Hits:\t%s\n", hits(cs, fmt.Sprintf("f%d", f.ID), fmt.Sprintf("f%d-6", f.ID))) })) var pf model.PortForward var to string