@@ -25,6 +25,7 @@ const (
2525 EDNS0PADDING = 0xc // EDNS0 padding (See RFC 7830)
2626 EDNS0EDE = 0xf // EDNS0 extended DNS errors (See RFC 8914)
2727 EDNS0REPORTING = 0x12 // EDNS0 reporting (See RFC 9567)
28+ EDNS0ZONEVERSION = 0x13 // EDNS0 Zone Version (See RFC 9660)
2829 EDNS0LOCALSTART = 0xFDE9 // Beginning of range reserved for local/experimental use (See RFC 6891)
2930 EDNS0LOCALEND = 0xFFFE // End of range reserved for local/experimental use (See RFC 6891)
3031 _DO = 1 << 15 // DNSSEC OK
@@ -63,6 +64,8 @@ func makeDataOpt(code uint16) EDNS0 {
6364 return new (EDNS0_ESU )
6465 case EDNS0REPORTING :
6566 return new (EDNS0_REPORTING )
67+ case EDNS0ZONEVERSION :
68+ return new (EDNS0_ZONEVERSION )
6669 default :
6770 e := new (EDNS0_LOCAL )
6871 e .Code = code
@@ -132,6 +135,8 @@ func (rr *OPT) String() string {
132135 s += "\n ; ESU: " + o .String ()
133136 case * EDNS0_REPORTING :
134137 s += "\n ; REPORT-CHANNEL: " + o .String ()
138+ case * EDNS0_ZONEVERSION :
139+ s += "\n ; ZONEVERSION: " + o .String ()
135140 }
136141 }
137142 return s
@@ -906,3 +911,48 @@ func (e *EDNS0_REPORTING) unpack(b []byte) error {
906911 e .AgentDomain = domain
907912 return nil
908913}
914+
915+ // EDNS0_ZONEVERSION implements the EDNS0 Zone Version option (RFC 9660).
916+ type EDNS0_ZONEVERSION struct {
917+ // always EDNS0ZONEVERSION (19)
918+ Code uint16
919+ // An unsigned 1-octet Label Count indicating
920+ // the number of labels for the name of the zone that VERSION value refers to.
921+ LabelCount uint8
922+ // An unsigned 1-octet type number distinguishing the format and meaning of version.
923+ // 0 SOA-SERIAL, 1-245 Unassigned, 246-255 Reserved for private use, see RFC 9660.
924+ Type uint8
925+ // An opaque octet string conveying the zone version data (VERSION).
926+ Version string
927+ }
928+
929+ func (e * EDNS0_ZONEVERSION ) Option () uint16 { return EDNS0ZONEVERSION }
930+ func (e * EDNS0_ZONEVERSION ) String () string { return e .Version }
931+ func (e * EDNS0_ZONEVERSION ) copy () EDNS0 {
932+ return & EDNS0_ZONEVERSION {e .Code , e .LabelCount , e .Type , e .Version }
933+ }
934+ func (e * EDNS0_ZONEVERSION ) pack () ([]byte , error ) {
935+ b := []byte {
936+ // first octet label count
937+ e .LabelCount ,
938+ // second octet is type
939+ e .Type ,
940+ }
941+ if len (e .Version ) > 0 {
942+ b = append (b , []byte (e .Version )... )
943+ }
944+ return b , nil
945+ }
946+ func (e * EDNS0_ZONEVERSION ) unpack (b []byte ) error {
947+ if len (b ) < 2 {
948+ return ErrBuf
949+ }
950+ e .LabelCount = b [0 ]
951+ e .Type = b [1 ]
952+ if len (b ) > 2 {
953+ e .Version = string (b [2 :])
954+ } else {
955+ e .Version = ""
956+ }
957+ return nil
958+ }
0 commit comments