Initialize a Parser *wire*, a ``bytes`` contains the data to be parsed, and possibly other data. Typically it is the whole message or a slice of it. *current*, an `int`, the offset within *wire* where parsing should begin.
(self, wire: bytes, current: int = 0)
| 12 | """Helper class for parsing DNS wire format.""" |
| 13 | |
| 14 | def __init__(self, wire: bytes, current: int = 0): |
| 15 | """Initialize a Parser |
| 16 | |
| 17 | *wire*, a ``bytes`` contains the data to be parsed, and possibly other data. |
| 18 | Typically it is the whole message or a slice of it. |
| 19 | |
| 20 | *current*, an `int`, the offset within *wire* where parsing should begin. |
| 21 | """ |
| 22 | self.wire = wire |
| 23 | self.current = 0 |
| 24 | self.end = len(self.wire) |
| 25 | if current: |
| 26 | self.seek(current) |
| 27 | self.furthest = current |
| 28 | |
| 29 | def remaining(self) -> int: |
| 30 | return self.end - self.current |