| 1 |
// Package dnsjson implements the RR and RRset as defined in RFC 8427. The message type is not implemented. |
| 2 |
// [codeberg.org/miekg/dns.MarshalJSON] and [codeberg.org/miekg/dns.UnmarshalJSON] are the primary interface of this package. |
| 3 |
// As an example the RRs: |
| 4 |
// |
| 5 |
// - www.example.org. IN A 127.0.0.1 |
| 6 |
// - www.example.org. IN A 127.0.0.2 |
| 7 |
// |
| 8 |
// Will be converted into the following JSON: |
| 9 |
// |
| 10 |
// { |
| 11 |
// "NAME": "www.example.org.", |
| 12 |
// "TTL": 3600, |
| 13 |
// "TYPEname": "A", |
| 14 |
// "CLASSname": "IN", |
| 15 |
// "rrSet": [ |
| 16 |
// { |
| 17 |
// "RDATAHEX": "7f000001" |
| 18 |
// }, |
| 19 |
// { |
| 20 |
// "RDATAHEX": "7f000002" |
| 21 |
// } |
| 22 |
// ] |
| 23 |
// } |
| 24 |
package dnsjson |
| 25 |
|
| 26 |
import "codeberg.org/miekg/dns/pkg/pool" |
| 27 |
|
| 28 |
// RR represents a DNS RR as specified in RFC 8427. |
| 29 |
type RR struct { |
| 30 |
Name string `json:"NAME"` // Name is the owner name of the RR. |
| 31 |
TTL uint32 `json:"TTL"` // TTL is the time-to-live of the RR. |
| 32 |
TypeName string `json:"TYPEname,omitempty"` // TypeName is the string representation of the type. If takes precedence of Type. |
| 33 |
Type uint16 `json:"TYPE,omitempty"` // Type is the type of the RR. |
| 34 |
ClassName string `json:"CLASSname,omitempty"` // ClassName is the string representation of the class. It takes precedence over Class. |
| 35 |
Class uint16 `json:"CLASS,omitempty"` // Class is the class of the RR, this is not set, class IN is assumed. |
| 36 |
RdataHex string `json:"RDATAHEX,omitempty"` |
| 37 |
RRset []RRset `json:"rrSet,omitempty"` |
| 38 |
} |
| 39 |
|
| 40 |
// RRset represents a DNS RRset as specified in RFC 8427. |
| 41 |
type RRset struct { |
| 42 |
RdataHex string `json:"RDATAHEX"` |
| 43 |
} |
| 44 |
|
| 45 |
// Pool pools allocations to encode/decode to wire format. |
| 46 |
var Pool = pool.New(8192) |