mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 12:18:16 +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
@ -35,9 +35,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TXTStrings returns a TXT record value as one or more quoted strings, taking the max
|
// 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 {
|
func TXTStrings(s string) string {
|
||||||
r := ""
|
if len(s) <= 255 {
|
||||||
|
return `"` + s + `"`
|
||||||
|
}
|
||||||
|
|
||||||
|
r := "(\n"
|
||||||
for len(s) > 0 {
|
for len(s) > 0 {
|
||||||
n := len(s)
|
n := len(s)
|
||||||
if n > 255 {
|
if n > 255 {
|
||||||
@ -46,9 +51,10 @@ func TXTStrings(s string) string {
|
|||||||
if r != "" {
|
if r != "" {
|
||||||
r += " "
|
r += " "
|
||||||
}
|
}
|
||||||
r += `"` + s[:n] + `"`
|
r += "\t\t\"" + s[:n] + "\"\n"
|
||||||
s = s[n:]
|
s = s[n:]
|
||||||
}
|
}
|
||||||
|
r += "\t)"
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user