Add is_tor plumbing from collector->aggregator->frontend/cli

This commit is contained in:
2026-03-23 22:17:39 +01:00
parent b89caa594c
commit cd7f15afaf
20 changed files with 1815 additions and 212 deletions

View File

@@ -113,8 +113,21 @@ func applyTerm(term string, fs *filterState) error {
return fmt.Errorf("prefix only supports =, not %q", op)
}
fs.Prefix = value
case "is_tor":
if op != "=" && op != "!=" {
return fmt.Errorf("is_tor only supports = and !=, not %q", op)
}
if value != "0" && value != "1" {
return fmt.Errorf("is_tor value must be 0 or 1, not %q", value)
}
// Normalise: is_tor=1 and is_tor!=0 both mean "TOR only"
if (op == "=" && value == "1") || (op == "!=" && value == "0") {
fs.IsTor = "1"
} else {
fs.IsTor = "0"
}
default:
return fmt.Errorf("unknown field %q; valid: status, website, uri, prefix", field)
return fmt.Errorf("unknown field %q; valid: status, website, uri, prefix, is_tor", field)
}
return nil
}
@@ -151,6 +164,9 @@ func FilterExprString(f filterState) string {
if f.Status != "" {
parts = append(parts, statusTermStr(f.Status))
}
if f.IsTor != "" {
parts = append(parts, "is_tor="+f.IsTor)
}
return strings.Join(parts, " AND ")
}