Class: SharedTools::Tools::DnsTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::DnsTool
- Defined in:
- lib/shared_tools/tools/dns_tool.rb
Overview
DNS lookup tool supporting A, AAAA, MX, TXT, NS, CNAME, reverse, all-records, external IP detection, and WHOIS database queries.
Constant Summary collapse
- WHOIS_PORT =
43- WHOIS_TIMEOUT =
10- IANA_WHOIS =
'whois.iana.org'- ARIN_WHOIS =
'whois.arin.net'- IP_SERVICES =
%w[ https://api.ipify.org https://ifconfig.me/ip https://icanhazip.com ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(action:, host: nil) ⇒ Hash
Results.
-
#initialize(logger: nil) ⇒ DnsTool
constructor
A new instance of DnsTool.
Constructor Details
Class Method Details
.name ⇒ Object
23 |
# File 'lib/shared_tools/tools/dns_tool.rb', line 23 def self.name = 'dns_tool' |
Instance Method Details
#execute(action:, host: nil) ⇒ Hash
Returns results.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/shared_tools/tools/dns_tool.rb', line 135 def execute(action:, host: nil) @logger.info("DnsTool#execute action=#{action} host=#{host}") case action.to_s.downcase when 'a' then lookup_a(host) when 'aaaa' then lookup_aaaa(host) when 'mx' then lookup_mx(host) when 'txt' then lookup_txt(host) when 'ns' then lookup_ns(host) when 'cname' then lookup_cname(host) when 'reverse' then lookup_reverse(host) when 'all' then lookup_all(host) when 'external_ip' then lookup_external_ip when 'ip_location' then lookup_ip_location(host) when 'whois' then lookup_whois(host) else { success: false, error: "Unknown action '#{action}'. Use: a, aaaa, mx, txt, ns, cname, reverse, all, external_ip, ip_location, whois" } end rescue => e @logger.error("DnsTool error for #{host}: #{e.}") { success: false, host: host, error: e. } end |