An open API service indexing awesome lists of open source software.

https://github.com/implydata/hostbook

Scala GeoIP lookups
https://github.com/implydata/hostbook

Last synced: 5 months ago
JSON representation

Scala GeoIP lookups

Awesome Lists containing this project

README

          

## hostbook

This is a Scala library that helps you do GeoIP lookups with the
[MaxMind GeoLite2](https://www.maxmind.com/en/geoip2-services-and-databases) databases

NOTE: The GeoLite2 data created by MaxMind, available from [Maxmind](http://www.maxmind.com) is not downloable at the link provided in this repository. Please download the database directly from Maxmind after reading and agreeing to their terms of service

```scala
import io.imply.hostbook.GeoLookup
import java.io.File

object Example
{
def main(args: Array[String]) {
val file = new File("geodb")
val geo = GeoLookup.fromFreeDownloadableDatabase(file)
val result = geo.lookup("206.190.36.45")
println(s"IP is from ${result.cityName.orNull}, ${result.regionName.orNull}, ${result.countryName.orNull}.")
}
}
```