Skip to content

Instantly share code, notes, and snippets.

@samleb
Created September 9, 2010 00:39
Show Gist options
  • Select an option

  • Save samleb/571135 to your computer and use it in GitHub Desktop.

Select an option

Save samleb/571135 to your computer and use it in GitHub Desktop.
{
"host": {
"ipv4": "123.45.67.89",
"hostname": "the.host.name", // or `null` if reverse DNS lookup failed
"addr": {
/* if IP is in a private range (e.g. 192.168.0.1) */
"city": "private",
"country": "private"
"geo": {
"latitude": null,
"longitude": null
}
/* otherwise
(depending on geocoding accuracy, any of these may be `null`) */
"city": "The City",
"country": "THE COUNTRY (CODE)",
"geo": {
"latitude": 12.3456,
"longitude": 34.5678
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<host>
<ipv4>123.45.67.89</ipv4>
<!-- if reverse DNS lookup succeeds -->
<hostname>the.host.name</hostname>
<!-- otherwise -->
<hostname nil="true"></hostname>
<!-- end -->
<addr>
<!-- if IP is in a private range (e.g. 192.168.0.1) -->
<city type="symbol">private</city>
<country type="symbol">private</country>
<geo>
<latitude nil="true"></latitude>
<longitude nil="true"></longitude>
</geo>
<!-- otherwise
(depending on geocoding accuracy, any of these may be empty with `nil="true"`) -->
<city>The City</city>
<country>THE COUNTRY (CODE)</country>
<geo>
<latitude type="float">12.34567</latitude>
<longitude type="float">34.56789</longitude>
</geo>
</addr>
</host>
ipv4: 123.45.67.89
# Any of the following may be empty if anything fails
hostname: the.host.name
city: The City
country: THE COUNTRY (CODE)
latitude: 12.34567
longitude: 34.56789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment