paulc / dnslib

A Python library to encode/decode DNS wire-format packets
https://github.com/paulc/dnslib
BSD 2-Clause "Simplified" License
295 stars 84 forks source link

Exception not treated in server #18

Closed brunobg closed 3 years ago

brunobg commented 3 years ago

I'm getting exceptions like this:

Exception happened during processing of request from ('xxxxxxxxxxx', 48736) 
Traceback (most recent call last): 
  File "/usr/lib/python3.6/socketserver.py", line 654, in process_request_thread 
    self.finish_request(request, client_address) 
  File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 
  File "/usr/lib/python3.6/socketserver.py", line 724, in __init__ 
    self.handle() 
  File "/usr/local/lib/python3.6/dist-packages/dnslib/server.py", line 135, in handle 
    new_data = self.request.recv(8192) 
ConnectionResetError: [Errno 104] Connection reset by peer 

I suggest a try/except on the first part of https://github.com/paulc/dnslib/blob/master/dnslib/server.py#L126 to handle this.

Might be related to https://github.com/paulc/dnslib/issues/16.

paulc commented 3 years ago

Fixed (hopefully) in 0.9.16