https://github.com/implydata/hostbook
Scala GeoIP lookups
https://github.com/implydata/hostbook
Last synced: 5 months ago
JSON representation
Scala GeoIP lookups
- Host: GitHub
- URL: https://github.com/implydata/hostbook
- Owner: implydata
- License: apache-2.0
- Created: 2015-09-12T20:59:13.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-04-01T20:08:11.000Z (about 6 years ago)
- Last Synced: 2024-04-14T20:22:59.889Z (about 2 years ago)
- Language: Scala
- Size: 23.4 KB
- Stars: 5
- Watchers: 48
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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}.")
}
}
```