Method: Async::DNS::StreamHandler#handle_connection

Defined in:
lib/async/dns/handler.rb

#handle_connection(socket) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/async/dns/handler.rb', line 117

def handle_connection(socket)
	transport = Transport.new(socket)
	
	while input_data = transport.read_chunk
		response = process_query(input_data, remote_address: socket.remote_address)
		length = transport.write_message(response)
		
		@logger.debug "<#{response.id}> Wrote #{length} bytes via TCP..."
	end
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