GlbDNS/Resolver/ShowLocation.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 38 CC 2 SCAR 11.0
CC
2
Cov
0%
request
6.0
new
2.0
BEGIN
2.0
CRAP 3.0
1 package GlbDNS::Resolver::ShowLocation;
2 use strict;
3 use warnings;
4 use List::Util qw(shuffle);
5 use Net::DNS::RR::TXT;
6 use Geo::IP;
7 my $gi = Geo::IP->open_type( GEOIP_CITY_EDITION_REV1, GEOIP_STANDARD);
8  
9 sub new {
10 my $class = shift;
11 return bless {}, $class
12 }
13  
14 sub request {
15 my ($self, $glbdns, $qname, $qclass, $qtype, $peerhost, $query) = @_;
16 $qname = lc($qname);
17 if ($qname =~/glbdns-show-calling-location/) {
18 my @ans;
19 my $record = $gi->record_by_addr($peerhost);
20 return ("NOERROR", [
21 Net::DNS::RR::TXT->new({
22 name => "$qname",
23 ttl => 1,
24 class => "IN",
25 type => "TXT",
26 txtdata => "LAT: " . $record->latitude . " LON: " . $record->longitude . " CITY: " . $record->city})
27 ], [], [],{ aa => 1});
28 }
29 return ();
30 }
31  
32 1;