summaryrefslogtreecommitdiff
path: root/vendor/github.com/miekg/dns/edns.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2025-03-24 10:50:19 +0000
committerLibravatar GitHub <noreply@github.com>2025-03-24 10:50:19 +0000
commita844f322eebec4ece384aedeb54b7276bccd1884 (patch)
treedea88ff03598bb04a347fdf9aba163f3754e3015 /vendor/github.com/miekg/dns/edns.go
parent[chore]: Bump github.com/jackc/pgx/v5 from 5.7.2 to 5.7.3 (#3935) (diff)
downloadgotosocial-a844f322eebec4ece384aedeb54b7276bccd1884.tar.xz
[chore]: Bump github.com/miekg/dns from 1.1.63 to 1.1.64 (#3936)
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.63 to 1.1.64. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.63...v1.1.64) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/miekg/dns/edns.go')
-rw-r--r--vendor/github.com/miekg/dns/edns.go35
1 files changed, 30 insertions, 5 deletions
diff --git a/vendor/github.com/miekg/dns/edns.go b/vendor/github.com/miekg/dns/edns.go
index 0447fd826..91793b906 100644
--- a/vendor/github.com/miekg/dns/edns.go
+++ b/vendor/github.com/miekg/dns/edns.go
@@ -27,6 +27,7 @@ const (
EDNS0LOCALSTART = 0xFDE9 // Beginning of range reserved for local/experimental use (See RFC 6891)
EDNS0LOCALEND = 0xFFFE // End of range reserved for local/experimental use (See RFC 6891)
_DO = 1 << 15 // DNSSEC OK
+ _CO = 1 << 14 // Compact Answers OK
)
// makeDataOpt is used to unpack the EDNS0 option(s) from a message.
@@ -75,7 +76,11 @@ type OPT struct {
func (rr *OPT) String() string {
s := "\n;; OPT PSEUDOSECTION:\n; EDNS: version " + strconv.Itoa(int(rr.Version())) + "; "
if rr.Do() {
- s += "flags: do; "
+ if rr.Co() {
+ s += "flags: do, co; "
+ } else {
+ s += "flags: do; "
+ }
} else {
s += "flags:; "
}
@@ -195,14 +200,34 @@ func (rr *OPT) SetDo(do ...bool) {
}
}
-// Z returns the Z part of the OPT RR as a uint16 with only the 15 least significant bits used.
+// Co returns the value of the CO (Compact Answers OK) bit.
+func (rr *OPT) Co() bool {
+ return rr.Hdr.Ttl&_CO == _CO
+}
+
+// SetCo sets the CO (Compact Answers OK) bit.
+// If we pass an argument, set the CO bit to that value.
+// It is possible to pass 2 or more arguments, but they will be ignored.
+func (rr *OPT) SetCo(co ...bool) {
+ if len(co) == 1 {
+ if co[0] {
+ rr.Hdr.Ttl |= _CO
+ } else {
+ rr.Hdr.Ttl &^= _CO
+ }
+ } else {
+ rr.Hdr.Ttl |= _CO
+ }
+}
+
+// Z returns the Z part of the OPT RR as a uint16 with only the 14 least significant bits used.
func (rr *OPT) Z() uint16 {
- return uint16(rr.Hdr.Ttl & 0x7FFF)
+ return uint16(rr.Hdr.Ttl & 0x3FFF)
}
-// SetZ sets the Z part of the OPT RR, note only the 15 least significant bits of z are used.
+// SetZ sets the Z part of the OPT RR, note only the 14 least significant bits of z are used.
func (rr *OPT) SetZ(z uint16) {
- rr.Hdr.Ttl = rr.Hdr.Ttl&^0x7FFF | uint32(z&0x7FFF)
+ rr.Hdr.Ttl = rr.Hdr.Ttl&^0x3FFF | uint32(z&0x3FFF)
}
// EDNS0 defines an EDNS0 Option. An OPT RR can have multiple options appended to it.