/lib/DDG/Spice/DNS.pm

https://github.com/pardocz/zeroclickinfo-spice · Perl · 69 lines · 59 code · 9 blank · 1 comment · 2 complexity · 75769d3c9906c25c5859d79fa983259f MD5 · raw file

  1. package DDG::Spice::DNS;
  2. # ABSTRACT: Gets IP address of given domain name.
  3. use DDG::Spice;
  4. use Data::Validate::Domain qw(is_domain);
  5. spice to => 'http://pro.viewdns.info/dnsrecord/?domain=$2&recordtype=$1&apikey={{ENV{DDG_SPICE_VIEWDNS_APIKEY}}}&output=json';
  6. spice wrap_jsonp_callback => 1;
  7. primary_example_queries 'MX records duckduckgo.com';
  8. primary_example_queries 'dns records duckduckgo.com';
  9. description 'IP address of domain';
  10. name 'DNS';
  11. attribution github => ['https://www.github.com/OndroNR', 'Ondrej Galbavy'],
  12. twitter => ['https://www.twitter.com/OndroNR', 'Ondrej Galbavy'];
  13. triggers any => 'dns', 'record', 'records', 'dig', 'nslookup';
  14. spice from => '(.*)/(.*)';
  15. my $record_types = join '|', qw/
  16. any
  17. a
  18. aaaa
  19. afsdb
  20. apl
  21. caa
  22. cert
  23. cname
  24. dhcid
  25. dlv
  26. dname
  27. dnskey
  28. ds
  29. hip
  30. ipseckey
  31. key
  32. kx
  33. loc
  34. mx
  35. ns
  36. nsec
  37. nsec3
  38. nsec3param
  39. rrsig
  40. rp
  41. sig
  42. soa
  43. spf
  44. srv
  45. sshfp
  46. ta
  47. tkey
  48. tlsa
  49. tsig
  50. tx
  51. /;
  52. handle query_lc => sub {
  53. s/(dig\s+)?(?:($record_types)\s+)?(dns\s+)?(records?|dns)?\s*//;
  54. my $record = defined $2 ? $2 : 'any';
  55. return if not defined $2 and not defined $1
  56. and not (defined $3 and defined $4);
  57. return uc $record, $_ if is_domain $_;
  58. return;
  59. };
  60. 1;