dnspython  1.16.0
About: dnspython is a DNS toolkit (for Python 2.x) that supports almost all record types.
  Fossies Dox: dnspython-1.16.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

CAA.py
Go to the documentation of this file.
1 # Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
2 
3 # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
4 #
5 # Permission to use, copy, modify, and distribute this software and its
6 # documentation for any purpose with or without fee is hereby granted,
7 # provided that the above copyright notice and this permission notice
8 # appear in all copies.
9 #
10 # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
16 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18 import struct
19 
20 import dns.exception
21 import dns.rdata
22 import dns.tokenizer
23 
24 
26 
27  """CAA (Certification Authority Authorization) record
28 
29  @ivar flags: the flags
30  @type flags: int
31  @ivar tag: the tag
32  @type tag: string
33  @ivar value: the value
34  @type value: string
35  @see: RFC 6844"""
36 
37  __slots__ = ['flags', 'tag', 'value']
38 
39  def __init__(self, rdclass, rdtype, flags, tag, value):
40  super(CAA, self).__init__(rdclass, rdtype)
41  self.flags = flags
42  self.tag = tag
43  self.value = value
44 
45  def to_text(self, origin=None, relativize=True, **kw):
46  return '%u %s "%s"' % (self.flags,
49 
50  @classmethod
51  def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
52  flags = tok.get_uint8()
53  tag = tok.get_string().encode()
54  if len(tag) > 255:
55  raise dns.exception.SyntaxError("tag too long")
56  if not tag.isalnum():
57  raise dns.exception.SyntaxError("tag is not alphanumeric")
58  value = tok.get_string().encode()
59  return cls(rdclass, rdtype, flags, tag, value)
60 
61  def to_wire(self, file, compress=None, origin=None):
62  file.write(struct.pack('!B', self.flags))
63  l = len(self.tag)
64  assert l < 256
65  file.write(struct.pack('!B', l))
66  file.write(self.tag)
67  file.write(self.value)
68 
69  @classmethod
70  def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None):
71  (flags, l) = struct.unpack('!BB', wire[current: current + 2])
72  current += 2
73  tag = wire[current: current + l]
74  value = wire[current + l:current + rdlen - 2]
75  return cls(rdclass, rdtype, flags, tag, value)
dns.exception.SyntaxError
Definition: exception.py:113
dns.rdtypes.ANY.CAA.CAA.tag
tag
Definition: CAA.py:42
dns.rdtypes.ANY.CAA.CAA.value
value
Definition: CAA.py:43
dns.rdtypes.ANY.CAA.CAA.__init__
def __init__(self, rdclass, rdtype, flags, tag, value)
Definition: CAA.py:39
dns.rdtypes.ANY.CAA.CAA.from_wire
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None)
Definition: CAA.py:70
dns.rdtypes.ANY.CAA.CAA.flags
flags
Definition: CAA.py:41
dns.rdtypes.ANY.CAA.CAA.from_text
def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True)
Definition: CAA.py:51
dns.rdtypes.ANY.CAA.CAA
Definition: CAA.py:25
dns.rdata._escapify
def _escapify(qstring)
Definition: rdata.py:65
dns.rdata
Definition: rdata.py:1
dns.rdtypes.ANY.CAA.CAA.to_text
def to_text(self, origin=None, relativize=True, **kw)
Definition: CAA.py:45
dns.rdtypes.ANY.CAA.CAA.to_wire
def to_wire(self, file, compress=None, origin=None)
Definition: CAA.py:61
dns.tokenizer
Definition: tokenizer.py:1
dns.exception
Definition: exception.py:1
dns.rdata.Rdata
Definition: rdata.py:95