fix: host filter accepts all and comma lists; hub no longer drops traefik lines after a copytruncate rotation

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-16 20:27:18 -03:00
1 parent 19afd221e2
commit 7b90d9e40f
15 files changed
+329 -85

No files matched your search

+13 -25
View File
@@ -371,27 +371,23 @@ func (s *Server) logout(w http.ResponseWriter, r *http.Request) {
// parts returns the summaries to merge for a host selection.
func (s *Server) parts(ctx context.Context, rg store.Range, host string) (parts []store.Summary, all []store.HostInfo) {
self := s.opt.Store.Name()
local := s.opt.Store.SummaryFor(rg)
all = append(all, local.Hosts...)
if s.opt.Hub != nil {
all = append(all, s.opt.Hub.Hosts()...)
}
if host == "" || host == "all" || host == self {
sel, _ := s.parseHosts(host)
if sel.local {
parts = append(parts, local)
}
if s.opt.Hub != nil && host != self {
only := ""
if host != "" && host != "all" {
only = host
}
parts = append(parts, s.opt.Hub.SummariesFor(ctx, rg, only)...)
if s.opt.Hub != nil && (sel.all || len(sel.peers) > 0) {
parts = append(parts, s.opt.Hub.SummariesFor(ctx, rg, sel.only())...)
}
return
}
func (s *Server) knownHost(w http.ResponseWriter, host string) bool {
if host != "all" && host != s.opt.Store.Name() && (s.opt.Hub == nil || !s.opt.Hub.Has(host)) {
if _, ok := s.parseHosts(host); !ok {
writeJSON(w, http.StatusNotFound, map[string]string{"error": "unknown host"})
return false
}
@@ -437,16 +433,12 @@ func (s *Server) allIPs(ctx context.Context, rg store.Range, host string) []stor
func (s *Server) ipsOf(ctx context.Context, rg store.Range, host string, localOnly bool) []store.IPSummary {
var lists [][]store.IPSummary
self := s.opt.Store.Name()
if host == "" || host == "all" || host == self {
sel, _ := s.parseHosts(host)
if sel.local {
lists = append(lists, s.opt.Store.AllIPs(rg, false))
}
if s.opt.Hub != nil && host != self && !localOnly {
only := ""
if host != "" && host != "all" {
only = host
}
for _, p := range s.opt.Hub.SummariesFor(ctx, rg, only) {
if s.opt.Hub != nil && (sel.all || len(sel.peers) > 0) && !localOnly {
for _, p := range s.opt.Hub.SummariesFor(ctx, rg, sel.only()) {
lists = append(lists, p.IPs)
}
}
@@ -714,20 +706,16 @@ func (s *Server) traffic(w http.ResponseWriter, r *http.Request) {
if host == "" {
host = "all"
}
self := s.opt.Store.Name()
if !s.knownHost(w, host) {
return
}
sel, _ := s.parseHosts(host)
var parts []store.TrafficData
if host == "all" || host == self {
if sel.local {
parts = append(parts, s.opt.Store.TrafficFor(rg, domain))
}
if s.opt.Hub != nil && host != self {
only := ""
if host != "all" {
only = host
}
parts = append(parts, s.opt.Hub.TrafficFor(r.Context(), rg, domain, only)...)
if s.opt.Hub != nil && (sel.all || len(sel.peers) > 0) {
parts = append(parts, s.opt.Hub.TrafficFor(r.Context(), rg, domain, sel.only())...)
}
out := store.MergeTraffic(host, parts)
out.Domain = domain