CLI: shorter, plainer output
Tables name a journal source by its first two units or identifiers; guard test shows 20 matching lines and addresses (--all for all), no /32; Housecarl connection errors without Go's request URL, said once by guard check; status tells "not running" from "no permission"; bans says when there are none; "1 ban lifted". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
96f551be80
commit
b87cc6fb62
5 files changed
+169
-37
No files matched your search
@@ -173,6 +173,28 @@ func Describe(w *config.Watch) string {
|
||||
return "file " + w.File
|
||||
}
|
||||
|
||||
// Short describes a watch's source in a table's few columns: at most
|
||||
// two journal units or identifiers, then how many more.
|
||||
func Short(w *config.Watch) string {
|
||||
switch w.Kind() {
|
||||
case "journal":
|
||||
names := w.Journal.Unit
|
||||
if len(names) == 0 {
|
||||
names = w.Journal.Identifier
|
||||
} else {
|
||||
names = append(append([]string(nil), names...), w.Journal.Identifier...)
|
||||
}
|
||||
s := "journal " + strings.Join(names[:min(len(names), 2)], ", ")
|
||||
if len(names) > 2 {
|
||||
s += fmt.Sprintf(" +%d", len(names)-2)
|
||||
}
|
||||
return s
|
||||
case config.SourceHousecarlDrops:
|
||||
return "Housecarl drops (" + w.Protocol + ")"
|
||||
}
|
||||
return "file " + w.File
|
||||
}
|
||||
|
||||
// loadGroups asks Housecarl how each ban list groups IPv6 addresses, so
|
||||
// bounties are counted as the list bans. A list that can't be read now
|
||||
// counts by /64, its default.
|
||||
@@ -409,7 +431,7 @@ type WatchStatus struct {
|
||||
func (d *Daemon) Status() Status {
|
||||
s := Status{Started: d.started}
|
||||
for _, w := range d.watches {
|
||||
s.Watches = append(s.Watches, WatchStatus{Name: w.Cfg.Name, Source: Describe(w.Cfg), List: w.Cfg.Ban.List, Hits: w.Cfg.Hits,
|
||||
s.Watches = append(s.Watches, WatchStatus{Name: w.Cfg.Name, Source: Short(w.Cfg), List: w.Cfg.Ban.List, Hits: w.Cfg.Hits,
|
||||
Within: w.Cfg.Within.String(), Lines: w.lines.Load(), Matches: w.matches.Load(), Bans: w.bans.Load(), Top: w.Tracker.Top(10, d.Now())})
|
||||
}
|
||||
s.Recent, s.Pending = d.state.Snapshot()
|
||||
|
||||
Reference in new issue
Block a user