Class: Async::DNS::StreamHandler
- Inherits:
-
GenericHandler
- Object
- GenericHandler
- Async::DNS::StreamHandler
- Defined in:
- lib/async/dns/handler.rb
Instance Attribute Summary
Attributes inherited from GenericHandler
Instance Method Summary collapse
Methods inherited from GenericHandler
#error_response, #initialize, #process_query
Constructor Details
This class inherits a constructor from Async::DNS::GenericHandler
Instance Method Details
#handle_connection(socket) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/async/dns/handler.rb', line 118 def handle_connection(socket) context = Async::Task.current input_data = StreamTransport.read_chunk(socket) response = process_query(input_data, remote_address: socket.remote_address) length = StreamTransport.(socket, response) @logger.debug "<#{response.id}> Wrote #{length} bytes via TCP..." rescue EOFError => error @logger.warn "<> Error: TCP session ended prematurely!" rescue Errno::ECONNRESET => error @logger.warn "<> Error: TCP connection reset by peer!" rescue Errno::EPIPE @logger.warn "<> Error: TCP session failed due to broken pipe!" rescue DecodeError @logger.warn "<> Error: Could not decode incoming TCP data!" end |
#run(task: Async::Task.current) ⇒ Object
112 113 114 115 116 |
# File 'lib/async/dns/handler.rb', line 112 def run(task: Async::Task.current) @endpoint.accept do |client, address| handle_connection(client) end end |