Skip to content
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

Difference of behaviour between IPv4 and IPv6 #38

Open
bortzmeyer opened this issue Sep 4, 2022 · 1 comment
Open

Difference of behaviour between IPv4 and IPv6 #38

bortzmeyer opened this issue Sep 4, 2022 · 1 comment

Comments

@bortzmeyer
Copy link
Contributor

GeoIP.lookup accepts IP addresses as strings or as Erlang IP address (for instance {204, 62, 14, 153} and it is documented (for instance the example GeoIP.lookup({8, 8, 8, 8})` ). But it is true only for IPv4. IPv6 addresses are only accepted as strings.

iex(2)> GeoIP.lookup({204, 62, 14, 153})                
{:ok,
 %{
   city: "New York City",
   country: "US",
   hostname: "ada.bortzmeyer.org",
   ip: "204.62.14.153",
   loc: "40.7143,-74.0060",
   org: "AS46636 NatCoWeb Corp.",
   postal: "10004",
   readme: "https://ipinfo.io/missingauth",
   region: "New York",
   timezone: "America/New_York"
 }}
iex(3)> GeoIP.lookup({8193, 19352, 3520, 65, 534, 16127, 65063, 15679}) 
{:error,
 %GeoIP.Error{
   id: nil,
   reason: "{\n  \"status\": 404,\n  \"error\": {\n    \"title\": \"Wrong ip\",\n    \"message\": \"Please provide a valid IP address\"\n  }\n}"
 }}

The test suite apparently only tests with IPv4 addresses.

@iloveitaly
Copy link
Collaborator

Nice catch! Want to submit a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants