aboutsummaryrefslogtreecommitdiff
path: root/request/edns0.go
blob: 89eb6b4682ceb2fa85a7d40da1e4731baed8896e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package request

import (
	"github.com/coredns/coredns/plugin/pkg/edns"

	"github.com/miekg/dns"
)

func supportedOptions(o []dns.EDNS0) []dns.EDNS0 {
	var supported = make([]dns.EDNS0, 0, 3)
	// For as long as possible try avoid looking up in the map, because that need an Rlock.
	for _, opt := range o {
		switch code := opt.Option(); code {
		case dns.EDNS0NSID:
			fallthrough
		case dns.EDNS0EXPIRE:
			fallthrough
		case dns.EDNS0COOKIE:
			fallthrough
		case dns.EDNS0TCPKEEPALIVE:
			fallthrough
		case dns.EDNS0PADDING:
			supported = append(supported, opt)
		default:
			if edns.SupportedOption(code) {
				supported = append(supported, opt)
			}
		}
	}
	return supported
}