| 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 dns.exception |
| 19 |
import dns.immutable |
| 20 |
import dns.ipv6 |
| 21 |
import dns.rdata |
| 22 |
import dns.tokenizer |
| 23 |
|
| 24 |
|
| 25 |
@dns.immutable.immutable |
| 26 |
class AAAA(dns.rdata.Rdata): |
| 27 |
"""AAAA record.""" |
| 28 |
|
| 29 |
__slots__ = ["address"] |
| 30 |
|
| 31 |
def __init__(self, rdclass, rdtype, address): |
| 32 |
super().__init__(rdclass, rdtype) |
| 33 |
self.address = self._as_ipv6_address(address) |
| 34 |
|
| 35 |
def to_text(self, origin=None, relativize=True, **kw): |
| 36 |
return self.address |
| 37 |
|
| 38 |
@classmethod |
| 39 |
def from_text( |
| 40 |
cls, rdclass, rdtype, tok, origin=None, relativize=True, relativize_to=None |
| 41 |
): |
| 42 |
address = tok.get_identifier() |
| 43 |
return cls(rdclass, rdtype, address) |
| 44 |
|
| 45 |
def _to_wire(self, file, compress=None, origin=None, canonicalize=False): |
| 46 |
file.write(dns.ipv6.inet_aton(self.address)) |
| 47 |
|
| 48 |
@classmethod |
| 49 |
def from_wire_parser(cls, rdclass, rdtype, parser, origin=None): |
| 50 |
address = parser.get_remaining() |
| 51 |
return cls(rdclass, rdtype, address) |