mirror of
https://github.com/mjl-/mox.git
synced 2025-01-14 01:06:27 +03:00
format long multi-string dkim txt records for rsa 2048 as a mult-line record, enclosed in ()'s
more easily readable, though still long
This commit is contained in:
parent
40040542f6
commit
14d09bb308
1 changed files with 9 additions and 3 deletions
|
@ -35,9 +35,14 @@ import (
|
|||
)
|
||||
|
||||
// TXTStrings returns a TXT record value as one or more quoted strings, taking the max
|
||||
// length of 255 characters for a string into account.
|
||||
// length of 255 characters for a string into account. In case of multiple
|
||||
// strings, a multi-line record is returned.
|
||||
func TXTStrings(s string) string {
|
||||
r := ""
|
||||
if len(s) <= 255 {
|
||||
return `"` + s + `"`
|
||||
}
|
||||
|
||||
r := "(\n"
|
||||
for len(s) > 0 {
|
||||
n := len(s)
|
||||
if n > 255 {
|
||||
|
@ -46,9 +51,10 @@ func TXTStrings(s string) string {
|
|||
if r != "" {
|
||||
r += " "
|
||||
}
|
||||
r += `"` + s[:n] + `"`
|
||||
r += "\t\t\"" + s[:n] + "\"\n"
|
||||
s = s[n:]
|
||||
}
|
||||
r += "\t)"
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue