MCPcopy Create free account
hub / github.com/foxcpp/maddy / fieldsToSign

Method fieldsToSign

internal/modify/dkim/dkim.go:222–253  ·  view source on GitHub ↗
(h *textproto.Header)

Source from the content-addressed store, hash-verified

220}
221
222func (m *Modifier) fieldsToSign(h *textproto.Header) []string {
223 // Filter out duplicated fields from configs so they
224 // will not cause panic() in go-msgauth internals.
225 seen := make(map[string]struct{})
226
227 res := make([]string, 0, len(m.oversignHeader)+len(m.signHeader))
228 for _, key := range m.oversignHeader {
229 if _, ok := seen[strings.ToLower(key)]; ok {
230 continue
231 }
232 seen[strings.ToLower(key)] = struct{}{}
233
234 // Add to signing list once per each key use.
235 for field := h.FieldsByKey(key); field.Next(); {
236 res = append(res, key)
237 }
238 // And once more to "oversign" it.
239 res = append(res, key)
240 }
241 for _, key := range m.signHeader {
242 if _, ok := seen[strings.ToLower(key)]; ok {
243 continue
244 }
245 seen[strings.ToLower(key)] = struct{}{}
246
247 // Add to signing list once per each key use.
248 for field := h.FieldsByKey(key); field.Next(); {
249 res = append(res, key)
250 }
251 }
252 return res
253}
254
255type state struct {
256 m *Modifier

Callers 2

TestFieldsToSignFunction · 0.95
RewriteBodyMethod · 0.80

Implementers 4

Modifierinternal/testutils/modifier.go
Groupinternal/modify/group.go
replaceAddrinternal/modify/replace_addr.go
Modifierinternal/modify/dkim/dkim.go

Calls 1

NextMethod · 0.45

Tested by 1

TestFieldsToSignFunction · 0.76