|
7 | 7 |
|
8 | 8 | import enum |
9 | 9 | import socket |
10 | | -from typing import TYPE_CHECKING, Any, cast |
| 10 | +from typing import TYPE_CHECKING, Any |
11 | 11 |
|
12 | 12 | from ._exceptions import AbstractMethodException |
13 | 13 | from ._utils.net import _is_v6_address |
14 | 14 | from ._utils.time import current_time_millis |
15 | | -from .const import _CLASS_MASK, _CLASS_UNIQUE, _CLASSES, _TYPE_ANY, _TYPES |
| 15 | +from .const import _CLASS_MASK, _CLASS_UNIQUE, _TYPE_ANY |
16 | 16 |
|
17 | 17 | _LEN_BYTE = 1 |
18 | 18 | _LEN_SHORT = 2 |
@@ -58,24 +58,6 @@ def __eq__(self, other: Any) -> bool: |
58 | 58 | """Equal when key, type and class match.""" |
59 | 59 | return isinstance(other, DNSEntry) and self._dns_entry_matches(other) |
60 | 60 |
|
61 | | - def entry_to_string(self, hdr: str, other: bytes | str | None) -> str: |
62 | | - return "{}[{},{}{},{}]{}".format( |
63 | | - hdr, |
64 | | - self.get_type(self.type), |
65 | | - self.get_class_(self.class_), |
66 | | - "-unique" if self.unique else "", |
67 | | - self.name, |
68 | | - f"={cast(Any, other)}" if other is not None else "", |
69 | | - ) |
70 | | - |
71 | | - @staticmethod |
72 | | - def get_class_(class_: int) -> str: |
73 | | - return _CLASSES.get(class_, f"?({class_})") |
74 | | - |
75 | | - @staticmethod |
76 | | - def get_type(t: int) -> str: |
77 | | - return _TYPES.get(t, f"?({t})") |
78 | | - |
79 | 61 | def _dns_entry_matches(self, other: DNSEntry) -> bool: |
80 | 62 | return self.key == other.key and self.type == other.type and self.class_ == other.class_ |
81 | 63 |
|
@@ -190,10 +172,6 @@ def suppressed_by(self, msg: DNSIncoming) -> bool: |
190 | 172 | return True |
191 | 173 | return False |
192 | 174 |
|
193 | | - def to_string(self, other: bytes | str) -> str: |
194 | | - arg = f"{self.ttl}/{int(self.get_remaining_ttl(current_time_millis()))},{cast(Any, other)}" |
195 | | - return DNSEntry.entry_to_string(self, "record", arg) |
196 | | - |
197 | 175 | def write(self, out: DNSOutgoing) -> None: |
198 | 176 | raise AbstractMethodException(f"{type(self).__name__} is missing write") |
199 | 177 |
|
@@ -303,9 +281,6 @@ def __hash__(self) -> int: |
303 | 281 | """Hash to compare like DNSHinfo.""" |
304 | 282 | return self._hash |
305 | 283 |
|
306 | | - def __repr__(self) -> str: |
307 | | - return self.to_string(self.cpu + " " + self.os) |
308 | | - |
309 | 284 | def write(self, out: DNSOutgoing) -> None: |
310 | 285 | """Write the rdata to an outgoing packet.""" |
311 | 286 | out.write_character_string(self.cpu.encode("utf-8")) |
@@ -478,9 +453,6 @@ def __hash__(self) -> int: |
478 | 453 | """Hash to compare like DNSService.""" |
479 | 454 | return self._hash |
480 | 455 |
|
481 | | - def __repr__(self) -> str: |
482 | | - return self.to_string(f"{self.server}:{self.port}") |
483 | | - |
484 | 456 | def write(self, out: DNSOutgoing) -> None: |
485 | 457 | out.write_short(self.priority) |
486 | 458 | out.write_short(self.weight) |
|
0 commit comments