class DoHClient::CLI
Public Instance Methods
act_as_server()
click to toggle source
# File lib/doh_client/cli.rb, line 23 def act_as_server port = options[:port] interfaces = [[:udp, "0.0.0.0", port], [:tcp, "0.0.0.0", port]] server = DoHClient::Server.new(interfaces) puts "Starting DNS server 0.0.0.0:#{port} (tcp/udp)" begin server.run rescue Interrupt puts "\nStopping DNS server..." ensure puts "Stopped" end end
resolve(name)
click to toggle source
# File lib/doh_client/cli.rb, line 16 def resolve(name) hash = resolver.resolve(name, options) puts hash.to_json end
resolver()
click to toggle source
# File lib/doh_client/cli.rb, line 38 def resolver case options[:resolver] when "google" DoHClient::Client::Google when "cloudflare" DoHClient::Client::Cloudflare else DoHClient::Client::Google end end
with_error_handling() { || ... }
click to toggle source
# File lib/doh_client/cli.rb, line 49 def with_error_handling yield rescue ResponseError => e puts "Warning: #{e}" rescue ArgumentError => _ puts "Warning: #{e}" end