Skip to content

CandleCandle/mmdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

Use pony-stable

  • stable add [github CandleCandle/mmdb | local-git <local path>]
  • stable fetch to fetch your dependencies
  • use "mmdb" to include this package
  • stable env ponyc to compile your application

Test

Build and run tests with: stable env ponyc -o bin test/ && ./bin/test

Example

use "mmdb"
use "files"
use logger = "logger"

actor Main
  new create(env: Env) =>
    try
      let path = FilePath(env.root as AmbientAuth, env.args(1)?)?
      let file = File.open(path)

      let log = logger.StringLogger(logger.Error, env.out)
      let parser: Parser val = recover val Parser(file.read(file.size()), log) end
      let reader: Reader val = recover val Reader.create(parser, log)? end
      let result: Field = reader.resolve(U128.from[U32]( 0x08080808 )) // 8.8.8.8, Google's open DNS.

      Dump(env.out, result)
    end

Compile with: stable env ponyc -o bin -b mmdb-example . Run with: ./bin/mmdb-example <path to mmdb file> The MMDB files can be found (at time of writing) from https://dev.maxmind.com/geoip/geoip2/geolite2/#Databases

Notes

This follows the spec from https://maxmind.github.io/MaxMind-DB/

At time of writing, none of the example databases contain byte arrays, booleans or "data container" type fields, therefore these data types are currently left unimplemented.

About

Maxmind Database reader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages