Go to the latest version of this document.

# ``twisted`.`names`.`dns`.`_DecodeContext``

class documentation

`class _DecodeContext: (source)`

Constructor: `_DecodeContext(maxJumps)`

View In Hierarchy

Mutable state shared between the `IEncodable` decoders invoked while reading a single DNS message.

The primary purpose is to bound the total number of compression-pointer jumps taken across every name in the message, defending against packets that fan out thousands of records pointing to deeply chained pointers.

This class is private. External callers must not rely on it; the per-message scope is installed and torn down by `Message.decode` through `_decodeContextVar`.

Method | `__init__` | Undocumented
Method | `registerJump` | Record that a compression pointer has been followed.
Class Variable | `__slots__` | Undocumented
Instance Variable | `jumps` | The number of compression pointers followed so far.
Instance Variable | `maxJumps` | The inclusive upper bound on `jumps`. Exceeding it causes `registerJump` to raise `DNSDecodeError`.

def __init__(self, maxJumps: `int` = 1000): (source)

Undocumented

def registerJump(self): (source)

Record that a compression pointer has been followed.

The check is performed before any further bytes are read so the caller fails fast as soon as the aggregate limit is breached, even if additional records remain in the buffer.

Raises
`DNSDecodeError` | if the cumulative number of jumps exceeds `maxJumps`.

__slots__: `tuple[str, ...]` = (source)

Undocumented

jumps: `int` = (source)

The number of compression pointers followed so far.

maxJumps = (source)

The inclusive upper bound on `jumps`. Exceeding it causes `registerJump` to raise `DNSDecodeError`.