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
+29
-1
@@ -721,7 +721,35 @@ func optionCmd() *cobra.Command {
|
||||
}
|
||||
scopeArgs(describe)
|
||||
describe.Flags().StringVar(&zoneType, "zone-type", "primary", "with --zone: the zone type")
|
||||
cmd.AddCommand(list, set, unset, describe)
|
||||
generated := &cobra.Command{
|
||||
Use: "generated",
|
||||
Short: "What Jarl adds to named.conf by itself, why, and what controls it",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
c, err := newClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var gen []struct {
|
||||
Where string `json:"where"`
|
||||
Text string `json:"text"`
|
||||
Why string `json:"why"`
|
||||
Setting string `json:"setting"`
|
||||
}
|
||||
if err := c.Get(ctx(), "/options/generated", nil, &gen); err != nil {
|
||||
return err
|
||||
}
|
||||
return output(gen, func(w io.Writer) {
|
||||
for i, g := range gen {
|
||||
if i > 0 {
|
||||
fmt.Fprintln(w)
|
||||
}
|
||||
fmt.Fprintf(w, "# %s: %s\n# controlled by: %s\n%s\n", g.Where, g.Why, g.Setting, g.Text)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(list, set, unset, describe, generated)
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
||||
+81
-1
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@@ -42,6 +43,54 @@ type exposureReport struct {
|
||||
Count int64
|
||||
} `json:"names"`
|
||||
} `json:"rate_limiting"`
|
||||
Mail *mailReport `json:"mail"`
|
||||
}
|
||||
|
||||
type mailReport struct {
|
||||
Checked string `json:"checked"`
|
||||
Results []struct {
|
||||
Zone string `json:"zone"`
|
||||
Address string `json:"address"`
|
||||
Roles []string `json:"roles"`
|
||||
PTR []string `json:"ptr"`
|
||||
OK bool `json:"ok"`
|
||||
Level string `json:"level"`
|
||||
Message string `json:"message"`
|
||||
ManagedBy string `json:"managed_by"`
|
||||
LocalZone string `json:"local_zone"`
|
||||
} `json:"results"`
|
||||
Errors []string `json:"errors"`
|
||||
}
|
||||
|
||||
func printMail(w io.Writer, m *mailReport) {
|
||||
if len(m.Results) == 0 && len(m.Errors) == 0 {
|
||||
fmt.Fprintln(w, "No mail addresses: no public zone has an MX record or SPF addresses.")
|
||||
return
|
||||
}
|
||||
fmt.Fprintln(w, "ZONE\tADDRESS\tFOR\tPTR\tSTATUS")
|
||||
for _, r := range m.Results {
|
||||
ptr := strings.Join(r.PTR, ",")
|
||||
if ptr == "" {
|
||||
ptr = "-"
|
||||
}
|
||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", r.Zone, r.Address, strings.Join(r.Roles, ", "), ptr, r.Level)
|
||||
if r.Level != "ok" {
|
||||
fmt.Fprintf(w, " %s\n", r.Message)
|
||||
}
|
||||
if r.LocalZone != "" {
|
||||
fmt.Fprintf(w, " Jarl's reverse zone %s only answers inside: receivers ask %s\n", r.LocalZone, orOwner(r.ManagedBy))
|
||||
}
|
||||
}
|
||||
for _, e := range m.Errors {
|
||||
fmt.Fprintf(w, "error: %s\n", e)
|
||||
}
|
||||
}
|
||||
|
||||
func orOwner(s string) string {
|
||||
if s == "" {
|
||||
return "the address's owner"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// exposureScope turns "server" (or "") into the server, anything else
|
||||
@@ -115,6 +164,10 @@ fix Jarl can stage for each.`,
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.Mail != nil {
|
||||
fmt.Fprintln(w, "\nMAIL REVERSE DNS")
|
||||
printMail(w, r.Mail)
|
||||
}
|
||||
if a := r.RateLimiting; a != nil && len(a.Counts) > 0 {
|
||||
fmt.Fprintf(w, "\nRATE LIMITING, LAST %s\n", a.Since)
|
||||
for _, e := range a.Counts {
|
||||
@@ -186,6 +239,33 @@ fix Jarl can stage for each.`,
|
||||
return report(resp)
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(fix, ack, unack)
|
||||
mail := &cobra.Command{
|
||||
Use: "mail",
|
||||
Short: "Check the reverse DNS of the addresses that send and receive your mail, now",
|
||||
Long: `Finds the addresses of the public zones' MX hosts and SPF records and checks,
|
||||
through public resolvers, that each has a PTR record whose name resolves
|
||||
back to it, as Gmail and Outlook do. Exits 1 when one doesn't.`,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
c, err := newClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var m mailReport
|
||||
if err := c.Do(ctx(), "POST", "/exposure/mail", nil, map[string]any{}, &m); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := output(m, func(w io.Writer) { printMail(w, &m) }); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range m.Results {
|
||||
if !r.OK {
|
||||
return errors.New("some mail addresses have no working reverse DNS")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(fix, ack, unack, mail)
|
||||
return cmd
|
||||
}
|
||||
+4
-1
@@ -188,6 +188,7 @@ func renderExtras(cfg *config.Config) render.Extras {
|
||||
h := &render.StatsHooks{Channel: netip.MustParseAddrPort(cfg.Stats.StatisticsChannel)}
|
||||
if cfg.Stats.QueryLog {
|
||||
h.LogFile, h.LogVersions, h.LogSize = cfg.Stats.LogFile, cfg.Stats.LogVersions, cfg.Stats.LogSize
|
||||
h.NoRateLimitLog = !cfg.Stats.RateLimitLog
|
||||
}
|
||||
x.Stats = h
|
||||
}
|
||||
@@ -333,7 +334,9 @@ func serveCmd() *cobra.Command {
|
||||
TOTPRequire: a.cfg.TOTP.Require, TOTPIssuer: a.cfg.TOTP.IssuerName(),
|
||||
Metrics: server.Metrics{Enabled: a.cfg.Metrics.Enabled, Listen: a.cfg.Metrics.Listen,
|
||||
Allow: a.cfg.Metrics.AllowPrefixes(), Token: a.cfg.Metrics.Token},
|
||||
Certs: cm,
|
||||
Certs: cm,
|
||||
Resolvers: a.cfg.ACME.Resolvers,
|
||||
RateLimitLog: a.cfg.Stats.Enabled && a.cfg.Stats.QueryLog && a.cfg.Stats.RateLimitLog,
|
||||
HTTPReq: server.HTTPReq{
|
||||
Enabled: a.cfg.ACME.HTTPReq.Enabled,
|
||||
AllowPlainHTTP: !a.cfg.ACME.HTTPReq.RequireHTTPS,
|
||||
|
||||
Reference in new issue
Block a user