golib/net/ippolicy/format.go
AJ ONeal 07d4a2652c
feat!(ippolicy): share refreshed IP policy behavior
Rename net/ipgate to net/ippolicy and compose independently refreshed
whitelist and blacklist sources into one IP decision policy.

- rename slog group and error prefixes from ipgate to ippolicy
- delete unused ParseDomainSet and RecordReader from domainsetcsv.go
- rewrite README to match the actual Config API
- document nil-whitelist behavior on New()
- bump iplist dependency to v0.8.5
- go mod tidy: remove stale ipgate and iplist entries
2026-09-09 02:55:09 -06:00

32 lines
460 B
Go

package ippolicy
import (
"log/slog"
"strconv"
"strings"
)
func log() *slog.Logger { return slog.Default().WithGroup("ippolicy") }
func commaify(n int) string {
s := strconv.Itoa(n)
if n < 0 {
return "-" + commaify(-n)
}
if len(s) <= 3 {
return s
}
rem := len(s) % 3
if rem == 0 {
rem = 3
}
var out strings.Builder
out.WriteString(s[:rem])
for i := rem; i < len(s); i += 3 {
out.WriteString("," + s[i:i+3])
}
return out.String()
}