mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:44:37 +03:00
switch to slog.Logger for logging, for easier reuse of packages by external software
we don't want external software to include internal details like mlog. slog.Logger is/will be the standard. we still have mlog for its helper functions, and its handler that logs in concise logfmt used by mox. packages that are not meant for reuse still pass around mlog.Log for convenience. we use golang.org/x/exp/slog because we also support the previous Go toolchain version. with the next Go release, we'll switch to the builtin slog.
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/mjl-/mox/dkim"
|
||||
"github.com/mjl-/mox/dns"
|
||||
"github.com/mjl-/mox/mlog"
|
||||
"github.com/mjl-/mox/publicsuffix"
|
||||
"github.com/mjl-/mox/spf"
|
||||
"github.com/mjl-/mox/store"
|
||||
@ -12,9 +13,9 @@ import (
|
||||
|
||||
// Alignment compares the msgFromDomain with the dkim and spf results, and returns
|
||||
// a validation, one of: Strict, Relaxed, None.
|
||||
func alignment(ctx context.Context, msgFromDomain dns.Domain, dkimResults []dkim.Result, spfStatus spf.Status, spfIdentity *dns.Domain) store.Validation {
|
||||
func alignment(ctx context.Context, log mlog.Log, msgFromDomain dns.Domain, dkimResults []dkim.Result, spfStatus spf.Status, spfIdentity *dns.Domain) store.Validation {
|
||||
var strict, relaxed bool
|
||||
msgFromOrgDomain := publicsuffix.Lookup(ctx, msgFromDomain)
|
||||
msgFromOrgDomain := publicsuffix.Lookup(ctx, log.Logger, msgFromDomain)
|
||||
|
||||
// todo: should take temperror and permerror into account.
|
||||
for _, dr := range dkimResults {
|
||||
@ -25,12 +26,12 @@ func alignment(ctx context.Context, msgFromDomain dns.Domain, dkimResults []dkim
|
||||
strict = true
|
||||
break
|
||||
} else {
|
||||
relaxed = relaxed || msgFromOrgDomain == publicsuffix.Lookup(ctx, dr.Sig.Domain)
|
||||
relaxed = relaxed || msgFromOrgDomain == publicsuffix.Lookup(ctx, log.Logger, dr.Sig.Domain)
|
||||
}
|
||||
}
|
||||
if !strict && spfStatus == spf.StatusPass {
|
||||
strict = msgFromDomain == *spfIdentity
|
||||
relaxed = relaxed || msgFromOrgDomain == publicsuffix.Lookup(ctx, *spfIdentity)
|
||||
relaxed = relaxed || msgFromOrgDomain == publicsuffix.Lookup(ctx, log.Logger, *spfIdentity)
|
||||
}
|
||||
if strict {
|
||||
return store.ValidationStrict
|
||||
|
Reference in New Issue
Block a user