Plain text network data dumper
A TextDumper can be used to log network traffic into a file that can be converted to a PCAP-NG file as described in its header.
Currently, this discards information like addresses; it is unknown how that information can be transferred into a dump reader easily while simultaneously staying at application level and staying ignorant of particular underlying protocols’ data structures.
It could previously be used stand-alone (outside of the asyncio transport/protocol mechanisms) when instanciated only with an output file (the
sendto()were used), but with the
datagram_msg_received()substitute method, this is probably impractical now.
To use it between an asyncio transport and protocol, use the :meth:endpointfactory method.
This method returns a function suitable for passing to an asyncio loop’s .create_datagram_endpoint method. It will place the TextDumper between the object and the transport, transparently dumping network traffic and passing it on together with other methods defined in the protocol/transport interface.
If you need the actual protocol after generating the endpoint (which when using this method returns a TextDumper instead of an actual_protocol), you can access it using the protocol property.
datagram_msg_received(data, ancdata, flags, address)¶
sendmsg(data, ancdata, flags, address)¶
Called when a connection is made.
The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.
Called when the connection is lost or closed.
The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).