Dnstap Protocol Buffers implementation in Python
Project description
Dnstap Protocol Buffers implementation in Python
Dnstap Protocol Buffers implementation in Python, more informations on dnstap http://dnstap.info/. This library is based on the following protocol buffers schema.
Installation
This module can be installed from pypi website
pip install dnstap_pb
Decoder
Example to use the Dnstap decoder
import dnstap_pb
# dnstap decoder
dnstap = dnstap_pb.Dnstap()
payload = b'\n\x08dnsdist1\x12\rdnsdist 1.5.0r[\x08\x05\x10\x01\x18\x01"\x04\n\x00\x00\xd2*\x04\n\x00\x00\xd20\xe6\xae\x0385@\x8e\x8f\xc6\xff\x05M\x1cf,\x15R6\xda\xba\x01 \x00\x01\x00\x00\x00\x00\x00\x01\x03www\x06google\x02fr\x00\x00\x01\x00\x01\x00\x00)\x10\x00\x00\x00\x00\x00\x00\x0c\x00\n\x00\x08\xe68\xe3\x8e\x7f\x01\xdexx\x01'
dnstap.ParseFromString(payload)
dm = dnstap.message
print(dm)
type: CLIENT_QUERY
socket_family: INET
socket_protocol: UDP
query_address: "\n\000\000\322"
response_address: "\n\000\000\322"
query_port: 60218
response_port: 53
query_time_sec: 1609664434
query_time_nsec: 533617553
query_message: "\221W\001 \000\001\000\000\000\000\000\001\003www\006google\002fr\000\000\001\000\001\000\000)\020\000\000\000\000\000\000\014\000\n\000\010\273\257\370\014_\001\341-"
Encoder
Example to use the Dnstap encoder
import dnstap_pb
# dnstap encoder
dnstap = dnstap_pb.Dnstap()
# clear all fields
dnstap.Clear()
# constructs the message
dnstap.type = 1
dnstap.version = b"0.1.0"
dnstap.identity = b"dnstap_python"
dnstap.message.type = dnstap_pb.dnstap_pb2._MESSAGE_TYPE.values_by_name["CLIENT_QUERY"].number
dnstap.message.socket_protocol = dnstap_pb.dnstap_pb2._SOCKETPROTOCOL.values_by_name["UDP"].number
dnstap.message.socket_family = dnstap_pb.dnstap_pb2._SOCKETFAMILY.values_by_name["INET"].number
# serialize the dnstap message to binary
payload = dnstap.SerializeToString()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dnstap_pb-0.1.0.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file dnstap_pb-0.1.0.tar.gz
.
File metadata
- Download URL: dnstap_pb-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 834655e6ea380e0d1ebf21311d49fc80500c3ccc81eba4b163cc501f3182bb54 |
|
MD5 | 75a0e7955b534a7e770794328fd66c66 |
|
BLAKE2b-256 | f2c36934842b30dc8cd38a651e98b2ba26e283c6cef0fde41f6cb7ad72f1d492 |
File details
Details for the file dnstap_pb-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: dnstap_pb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0599b61bfb4a7dcf3cc4772f920f10ba0acb6382f04c034dbc3c216d64cb3805 |
|
MD5 | 2318e29dfc287af3647d2fd6b1c2b76a |
|
BLAKE2b-256 | f1a24169546e3ef225608b01e9dcc8e2250757410bcf966d199c5485a3cb9156 |