Skip to content

implydata/hostbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hostbook

This is a Scala library that helps you do GeoIP lookups with the MaxMind GeoLite2 databases

NOTE: The GeoLite2 data created by MaxMind, available from Maxmind 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

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}.")
  }
}