| 1 |
package dns |
| 2 |
|
| 3 |
import "fmt" |
| 4 |
|
| 5 |
// DSO option codes. All DSO types and constants in this package carry the Stateful prefix. |
| 6 |
const ( |
| 7 |
StatefulNone uint16 = 0x0 |
| 8 |
StatefulKEEPALIVE uint16 = 0x1 |
| 9 |
StatefulRETRYDELAY uint16 = 0x2 |
| 10 |
StatefulDPADDING uint16 = 0x3 |
| 11 |
StatefulSUBSCRIBE uint16 = 0x40 |
| 12 |
StatefulPUSH uint16 = 0x41 |
| 13 |
StatefulUNSUBSCRIBE uint16 = 0x42 |
| 14 |
StatefulRECONFIRM uint16 = 0x43 |
| 15 |
) |
| 16 |
|
| 17 |
// TODO: for string we want to be able parse them with New() at some point... |
| 18 |
// string output is terrible at the moment, must look way more like RRs. |
| 19 |
// builderPool usage! |
| 20 |
|
| 21 |
// KEEPALIVE, see RFC 8490, section 7.1. |
| 22 |
// This record must be put in the stateful section. |
| 23 |
type KEEPALIVE struct { |
| 24 |
Timeout uint32 |
| 25 |
Interval uint32 |
| 26 |
} |
| 27 |
|
| 28 |
func (d *KEEPALIVE) String() string { |
| 29 |
return fmt.Sprintf("timeout %dms, interval %dms", d.Timeout, d.Interval) |
| 30 |
} |
| 31 |
|
| 32 |
func (d *KEEPALIVE) Data() RDATA { return d } |
| 33 |
|
| 34 |
// RETRYDELAY, see RFC 8490, section 7.2. |
| 35 |
// This record must be put in the stateful section. |
| 36 |
type RETRYDELAY struct { |
| 37 |
Delay uint32 |
| 38 |
} |
| 39 |
|
| 40 |
func (d *RETRYDELAY) String() string { |
| 41 |
return fmt.Sprintf("delay %dms", d.Delay) |
| 42 |
} |
| 43 |
|
| 44 |
func (d *RETRYDELAY) Data() RDATA { return d } |
| 45 |
|
| 46 |
// DPADDING option is used to add padding, see RRC 8490 section 7.3. |
| 47 |
// This record must be put in the stateful section. |
| 48 |
type DPADDING struct { |
| 49 |
Padding string `dns:"hex"` |
| 50 |
} |
| 51 |
|
| 52 |
func (d *DPADDING) String() string { |
| 53 |
return fmt.Sprintf("padding %s", d.Padding) |
| 54 |
} |
| 55 |
|
| 56 |
func (d *DPADDING) Data() RDATA { return d } |
| 57 |
|
| 58 |
/* |
| 59 |
TODO(miek): commented out because rdata with full blown RRs isn't supported. |
| 60 |
// SUBSCRIBE, see RFC 8765. |
| 61 |
type SUBSCRIBE struct { |
| 62 |
RR RR // RR is one without rdata, only name, class, and type are significant. |
| 63 |
} |
| 64 |
|
| 65 |
func (d *SUBSCRIBE) String() string { return d.RR.String() } |
| 66 |
|
| 67 |
// PUSH, see RFC 8765. |
| 68 |
type PUSH struct { |
| 69 |
RRs []RR |
| 70 |
} |
| 71 |
|
| 72 |
func (d *PUSH) String() string { |
| 73 |
s := "" |
| 74 |
for i := range d.RRs { |
| 75 |
s += d.RRs[i].String() |
| 76 |
if i < len(d.RRs) { |
| 77 |
s += "\n" |
| 78 |
} |
| 79 |
} |
| 80 |
return s |
| 81 |
} |
| 82 |
|
| 83 |
// UNSUBSSCRIBE, see RFC 8765. |
| 84 |
type UNSUBSCRIBE struct { |
| 85 |
ID uint16 |
| 86 |
} |
| 87 |
|
| 88 |
func (d *UNSUBSCRIBE) String() string { return fmt.Sprintf("%d", d.ID) } |
| 89 |
|
| 90 |
// RECONFIRM, see RFC 8765. |
| 91 |
type RECONFIRM struct { |
| 92 |
RR RR |
| 93 |
} |
| 94 |
|
| 95 |
func (d *RECONFIRM) String() string { return d.RR.String() } |
| 96 |
*/ |