クエリの最大長っていくつだろう?
require 'socket' HOST = '8.8.8.8' # Google DNS Server sock = UDPSocket.open sock.bind('', 53) def proxy(msg) s = UDPSocket.open s.send(msg, 0, HOST, 53) msg = s.recvfrom(1024)[0] s.close return msg end loop do msg, (afam, port, host, ip) = sock.recvfrom(1024) puts "recv: #{msg.inspect}" sock.send(proxy(msg), 0, ip, port) end