1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import struct
17
18 import dns.exception
19 import dns.rdata
20 import dns.tokenizer
21
22 -class CAA(dns.rdata.Rdata):
23 """CAA (Certification Authority Authorization) record
24
25 @ivar flags: the flags
26 @type flags: int
27 @ivar tag: the tag
28 @type tag: string
29 @ivar value: the value
30 @type value: string
31 @see: RFC 6844"""
32
33 __slots__ = ['flags', 'tag', 'value']
34
35 - def __init__(self, rdclass, rdtype, flags, tag, value):
40
41 - def to_text(self, origin=None, relativize=True, **kw):
42 return '%u %s "%s"' % (self.flags,
43 dns.rdata._escapify(self.tag),
44 dns.rdata._escapify(self.value))
45
46 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
47 flags = tok.get_uint8()
48 tag = tok.get_string()
49 if len(tag) > 255:
50 raise dns.exception.SyntaxError("tag too long")
51 if not tag.isalnum():
52 raise dns.exception.SyntaxError("tag is not alphanumeric")
53 value = tok.get_string()
54 return cls(rdclass, rdtype, flags, tag, value)
55
56 from_text = classmethod(from_text)
57
58 - def to_wire(self, file, compress = None, origin = None):
59 file.write(chr(self.flags))
60 l = len(self.tag)
61 assert l < 256
62 file.write(chr(l))
63 file.write(self.tag)
64 file.write(self.value)
65
66 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
72
73 from_wire = classmethod(from_wire)
74