Mail reverse DNS check, what Jarl adds to named.conf, lists one per line
jarld checks the reverse DNS of the public zones' MX and SPF addresses as the internet sees it, every 6 hours (Exposure page, jarl exposure mail, jarl_mail_reverse_dns_ok). The Server options page, jarl option generated and GET /options/generated list what Jarl writes into named.conf by itself; stats.rate_limit_log turns off the query-errors logging. Option lists of three or more elements are shown one per line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d33f573782
commit
c27a6c10bd
30 files changed
+1095
-16
No files matched your search
@@ -182,3 +182,38 @@ func writeItemsInline(sb *strings.Builder, items []Item) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FormatValueList is FormatValue, except that a value whose block is a
|
||||
// plain list (no nested blocks) of at least min elements is laid out one
|
||||
// element per line, for reading: allow-query, exempt-clients, forwarders.
|
||||
func FormatValueList(name, value string, min int) string {
|
||||
st, err := ParseOptionValue(name, value)
|
||||
if err != nil {
|
||||
return FormatValue(name, value)
|
||||
}
|
||||
items := st.Items[1:]
|
||||
blocks := 0
|
||||
var list *Block
|
||||
for _, it := range items {
|
||||
if it.Block != nil {
|
||||
blocks++
|
||||
list = it.Block
|
||||
}
|
||||
}
|
||||
if blocks != 1 || len(list.Stmts) < min || blockHasBlocks(list) {
|
||||
return FormatValue(name, value)
|
||||
}
|
||||
var sb strings.Builder
|
||||
for _, it := range items {
|
||||
if it.Block == nil {
|
||||
sb.WriteString(Compact([]Item{it}) + " ")
|
||||
continue
|
||||
}
|
||||
sb.WriteString("{\n")
|
||||
for _, s := range list.Stmts {
|
||||
sb.WriteString("\t" + Compact(s.Items) + ";\n")
|
||||
}
|
||||
sb.WriteString("} ")
|
||||
}
|
||||
return strings.TrimSpace(sb.String())
|
||||
}
|
||||
@@ -16,3 +16,23 @@ func TestFormatValue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatValueList(t *testing.T) {
|
||||
cases := []struct{ name, value, want string }{
|
||||
{"allow-query", "{ homelab; localhost; 10.0.0.0/8; }", "{\n\thomelab;\n\tlocalhost;\n\t10.0.0.0/8;\n}"},
|
||||
{"allow-query", "{ homelab; localhost; }", "{ homelab; localhost; }"}, // short: as it was
|
||||
{"listen-on", "port 853 tls dot { 10.0.0.1; 10.0.0.2; 10.0.0.3; }", "port 853 tls dot {\n\t10.0.0.1;\n\t10.0.0.2;\n\t10.0.0.3;\n}"},
|
||||
{"allow-transfer", "{ !10.0.0.9; key xfer; 10.0.0.0/8; }", "{\n\t!10.0.0.9;\n\tkey xfer;\n\t10.0.0.0/8;\n}"},
|
||||
{"recursion", "yes", "yes"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := FormatValueList(c.name, c.value, 3); got != c.want {
|
||||
t.Errorf("%s %q:\n got %q\nwant %q", c.name, c.value, got, c.want)
|
||||
}
|
||||
}
|
||||
// A nested block (rate-limit with exempt-clients) keeps FormatValue's layout.
|
||||
v := "{ responses-per-second 10; log-only yes; exempt-clients { 192.0.2.1; 192.0.2.2; 192.0.2.3; }; }"
|
||||
if got := FormatValueList("rate-limit", v, 3); got != FormatValue("rate-limit", v) {
|
||||
t.Errorf("nested: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user