"Fossies" - the Fresh Open Source Software Archive

Member "pdns-auth-4.2.0/regression-tests.nobackend/edns1/test-edns.py" (27 Aug 2019, 844 Bytes) of package /linux/misc/dns/pdns-auth-4.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "test-edns.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 4.1.13_vs_4.2.0.

    1 #!/usr/bin/env python
    2 
    3 from __future__ import print_function
    4 import socket
    5 
    6 # TODO use dnspython to parse/check
    7 
    8 MESSAGE=b"\xaf\x03\x00\x20\x00\x01\x00\x00\x00\x00\x00\x01\x04\x75\x6e\x69\x74\x04\x74\x65\x73\x74\x00\x00\x06\x00\x01\x00\x00\x29\x10\x00\x00\x64\x00\x00\x00\x10\x00\x0a\x00\x08\x39\x70\xad\xaf\xca\xa8\x96\xca\x00\x64\x00\x00"
    9 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
   10 
   11 sock.bind(("127.0.0.1",5502))
   12 sock.sendto(MESSAGE, ("127.0.0.1", 5501))
   13 
   14 data, addr = sock.recvfrom(512)
   15 
   16 # make sure data is correct
   17 EXPECT=b"\xaf\x03\x84\x00\x00\x01\x00\x00\x00\x00\x00\x01\x04\x75\x6e\x69\x74\x04\x74\x65\x73\x74\x00\x00\x06\x00\x01\x00\x00\x29\x04\xd0\x01\x00\x00\x00\x00\x00"
   18 
   19 if (data != EXPECT):
   20   print("Invalid EDNS response, expected extended RCODE=BADVERS, no SOA, and OPT version 0")
   21 else:
   22   print("EDNS response OK")