CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 16s
CI / Tests (Linux, race detector) (push) Successful in 1m3s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 3s
Optional second firewall (URUTAU_ENFORCE off/observe/on) through the host fail2ban, outbound traffic analysis (beaconing, mining, spam, DNS bypass, unauthorised scans) with authorised scanner workloads, host kit in deploy/host and a printable HTML report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
928 B
Go
43 lines
928 B
Go
package fed
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"sync"
|
|
)
|
|
|
|
// EgressFor asks the online peers (or one) for their egress analysis of the
|
|
// window [from, to] (unix seconds). The raw answers are untrusted: the caller
|
|
// decodes and sanitizes them.
|
|
func (h *Hub) EgressFor(ctx context.Context, from, to int64, only string) map[string]json.RawMessage {
|
|
out := map[string]json.RawMessage{}
|
|
var mu sync.Mutex
|
|
var wg sync.WaitGroup
|
|
for _, p := range h.Peers {
|
|
if only != "" && only != p.Name {
|
|
continue
|
|
}
|
|
h.mu.RLock()
|
|
st := h.state[p.Name]
|
|
online := st != nil && st.online
|
|
h.mu.RUnlock()
|
|
if !online {
|
|
continue
|
|
}
|
|
wg.Add(1)
|
|
go func(p Peer) {
|
|
defer wg.Done()
|
|
var raw json.RawMessage
|
|
if _, err := h.get(ctx, p, fmt.Sprintf("/api/v1/peer/egress?from=%d&to=%d", from, to), &raw); err != nil {
|
|
return
|
|
}
|
|
mu.Lock()
|
|
out[p.Name] = raw
|
|
mu.Unlock()
|
|
}(p)
|
|
}
|
|
wg.Wait()
|
|
return out
|
|
}
|