mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
wrap long dkim dns records at 100 characters instead of 255 for better display (no line-wrap)
This commit is contained in:
parent
361bc2b516
commit
c66fa64b8b
2 changed files with 9 additions and 11 deletions
4
main.go
4
main.go
|
@ -2132,8 +2132,8 @@ The DNS should be configured as a TXT record at $selector._domainkey.$domain.
|
|||
fmt.Print("<selector>._domainkey.<your.domain.> TXT ")
|
||||
for record != "" {
|
||||
s := record
|
||||
if len(s) > 255 {
|
||||
s, record = record[:255], record[255:]
|
||||
if len(s) > 100 {
|
||||
s, record = record[:100], record[100:]
|
||||
} else {
|
||||
record = ""
|
||||
}
|
||||
|
|
|
@ -34,19 +34,18 @@ import (
|
|||
"github.com/mjl-/mox/tlsrpt"
|
||||
)
|
||||
|
||||
// TXTStrings returns a TXT record value as one or more quoted strings, taking the max
|
||||
// length of 255 characters for a string into account. In case of multiple
|
||||
// strings, a multi-line record is returned.
|
||||
// TXTStrings returns a TXT record value as one or more quoted strings, each max
|
||||
// 100 characters. In case of multiple strings, a multi-line record is returned.
|
||||
func TXTStrings(s string) string {
|
||||
if len(s) <= 255 {
|
||||
if len(s) <= 100 {
|
||||
return `"` + s + `"`
|
||||
}
|
||||
|
||||
r := "(\n"
|
||||
for len(s) > 0 {
|
||||
n := len(s)
|
||||
if n > 255 {
|
||||
n = 255
|
||||
if n > 100 {
|
||||
n = 100
|
||||
}
|
||||
if r != "" {
|
||||
r += " "
|
||||
|
@ -578,10 +577,9 @@ func DomainRecords(domConf config.Domain, domain dns.Domain, hasDNSSEC bool) ([]
|
|||
return nil, fmt.Errorf("making DKIM DNS TXT record: %v", err)
|
||||
}
|
||||
|
||||
if len(txt) > 255 {
|
||||
if len(txt) > 100 {
|
||||
records = append(records,
|
||||
"; NOTE: Ensure the next record is added in DNS as a single record, it consists",
|
||||
"; of multiple strings (max size of each is 255 bytes).",
|
||||
"; NOTE: The following strings must be added to DNS as single record.",
|
||||
)
|
||||
}
|
||||
s := fmt.Sprintf("%s._domainkey.%s. TXT %s", name, d, TXTStrings(txt))
|
||||
|
|
Loading…
Reference in a new issue