Skip to content

v6.ipinfo.io doesn't work for IPv6, but ipinfo.io does #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Geo-IPinfo/lib/Geo/IPinfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ my %valid_fields = (
domains => 1,
);
my $base_url = 'https://ipinfo.io/';
my $base_url_ipv6 = 'https://v6.ipinfo.io/';
my $country_flag_url = 'https://cdn.ipinfo.io/static/images/countries-flags/';
my $cache_ttl = 0;
my $custom_cache = 0;
Expand Down Expand Up @@ -1062,7 +1061,7 @@ sub new {
$token = defined $token ? $token : '';

$self->{base_url} = $base_url;
$self->{base_url_ipv6} = $base_url_ipv6;
$self->{base_url_ipv6} = $base_url;
$self->{ua} = LWP::UserAgent->new;
$self->{ua}->ssl_opts( 'verify_hostname' => 0 );
$self->{ua}->default_headers(
Expand Down Expand Up @@ -1273,7 +1272,7 @@ sub _lookup_info_from_source {
} else {
$url = $self->{base_url} . $key;
}

my $response = $self->{ua}->get($url);

if ( $response->is_success ) {
Expand Down
8 changes: 7 additions & 1 deletion Geo-IPinfo/t/01-usage.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
use Test::More;

if ( $ENV{RELEASE_TESTING} ) {
plan tests => 7;
plan tests => 9;
}
else {
plan( skip_all => "Basic usage tests not required for installation" );
Expand Down Expand Up @@ -35,3 +35,9 @@ is(
);
is( $ip->field( "192.168.0.1", "city" ),
undef, "field() return 'undef' when getting fields of private IPs" );

IPv6: {
my $h = $ip->info("2001:4860:4860::8888");
isa_ok $h, 'Geo::Details', "info() return a hash when querying a valid IPv6";
is $h->city, 'Mountain View', 'Google city is correct';
}