| Server IP : 38.180.95.123 / Your IP : 216.73.216.230 Web Server : nginx/1.28.2 System : Linux v970193243.local 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : playbazecasino.com ( 1013) PHP Version : 8.4.23 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/share/doc/python3-dnspython/examples/ |
Upload File : |
#!/usr/bin/python
import argparse
import sys
import dns.exception
import dns.message
def main():
parser = argparse.ArgumentParser(
description="Read sequence of DNS wire formats prefixed with 2-byte "
"length field - like from TCP socket - and print the messages. This "
"format is used e.g. by dnsperf -B option and dnsgen."
)
parser.add_argument("infile")
args = parser.parse_args()
ok_msgs = 0
bad_msgs = 0
with open(args.infile, "rb") as infile:
while True:
offset = infile.tell()
len_wire = infile.read(2)
if len(len_wire) == 0: # end of file - expected
break
if len(len_wire) == 1:
raise ValueError("incomplete length preamble, offset", offset)
len_msg = int.from_bytes(len_wire, byteorder="big", signed=False)
print(f"; msg offset 0x{offset + 2:x}, length {len_msg} bytes")
msg_wire = infile.read(len_msg)
if len(msg_wire) != len_msg:
raise ValueError(
f"incomplete message: expected {len_msg} != got {len(msg_wire)}, "
f"length field offset 0x{offset:x}",
)
try:
msg = dns.message.from_wire(msg_wire)
ok_msgs += 1
print(msg)
except dns.exception.DNSException as ex:
print(f"; invalid message, skipping: {ex}")
bad_msgs += 1
print(f"; read {ok_msgs} valid and {bad_msgs} invalid messages")
if bad_msgs:
sys.exit(1)
if __name__ == "__main__":
main()