Skip to content

Commit

Permalink
Tentatively support other file formats (.mmdb, .gz and .tgz)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-andrade committed Aug 6, 2019
1 parent 595af49 commit 7477a1c
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 54 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ towards MaxMind.

#### Usage

Clone the repository and run `make console` to bring up a
shell.
Clone the repository and run `make console` to bring up a shell.

##### 1\. Start the database loader

``` erlang
URL = "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz",
ok = locus:start_loader(country, URL).

% URL can also be a local path, e.g. "/opt/MaxMind/GeoLite2-Country.tar.gz"
% URL can also be a local path, e.g. "/usr/share/GeoIP/GeoLite2-City.mmdb"
```

##### 2\. Wait for the database to load (optional)
Expand Down Expand Up @@ -102,9 +101,12 @@ ok = locus:start_loader(country, URL).

##### File Formats

- Only gzip-compressed tarballs are supported as of this moment
- The first file to be found, within the tarball, with an .mmdb
extension, is the one that's chosen for loading
- gzip-compressed tarballs (`.tar.gz`, `.tgz`)
- tarballs (`.tar`)
- MMDB files (`.mmdb`)
- gzip-compressed MMDB files (`.mmdb.gz`)
- For tarballs, the first file to be found with an `.mmdb` extension
is the one that's chosen for loading
- The implementation of [MaxMind DB
format](https://maxmind.github.io/MaxMind-DB/) is mostly complete

Expand Down Expand Up @@ -135,8 +137,7 @@ the `locus` CLI utility:
1. Run `make cli` to build the script, named `locus`, which will be
deployed to the current directory.

2. Run
analysis:
2. Run analysis:

``` shell
./locus analyze https://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz
Expand Down Expand Up @@ -223,7 +224,7 @@ The API reference can be found on [HexDocs](https://hexdocs.pm/locus/).
##### Tested setup
- Erlang/OTP 17.4 or newer
- Erlang/OTP 18.0 or newer
- rebar3
##### License
Expand Down Expand Up @@ -266,8 +267,7 @@ released under the Apache License 2.0.
- [geoip](https://github.com/manifest/geoip): Returns the location of
an IP address; based on the ipinfodb.com web service
- [geolite2data](https://hex.pm/packages/geolite2data): Periodically
fetches the free MaxMind GeoLite2
databases
fetches the free MaxMind GeoLite2 databases
- [ip2location-erlang](https://github.com/ip2location/ip2location-erlang):
Uses IP2Location geolocation database
Expand All @@ -286,8 +286,7 @@ released under the Apache License 2.0.
location to a Plug connection based upon the client IP address by
using MaxMind's GeoIP2 database
- [tz\_world](https://hex.pm/packages/tz_world): Resolve timezones
from a location efficiently using PostGIS and
Ecto
from a location efficiently using PostGIS and Ecto

-----

Expand Down
9 changes: 6 additions & 3 deletions doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Clone the repository and run `make console' to bring up a shell.
URL = "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz",
ok = locus:start_loader(country, URL).

% URL can also be a local path, e.g. "/opt/MaxMind/GeoLite2-Country.tar.gz"
% URL can also be a local path, e.g. "/usr/share/GeoIP/GeoLite2-City.mmdb"
</pre>

<h5>2. Wait for the database to load (optional)</h5>
Expand Down Expand Up @@ -103,8 +103,11 @@ ok = locus:start_loader(country, URL).
<h5 id="file-formats">File Formats</h5>

<ul>
<li>Only gzip-compressed tarballs are supported as of this moment</li>
<li>The first file to be found, within the tarball, with an .mmdb extension, is the one that's chosen for loading</li>
<li>gzip-compressed tarballs (`.tar.gz', `.tgz')</li>
<li>tarballs (`.tar')</li>
<li>MMDB files (`.mmdb')</li>
<li>gzip-compressed MMDB files (`.mmdb.gz')</li>
<li>For tarballs, the first file to be found with an `.mmdb' extension is the one that's chosen for loading</li>
<li>The implementation of <a target="_parent" href="https://maxmind.github.io/MaxMind-DB/">MaxMind DB format</a>
is mostly complete</li>
</ul>
Expand Down
Loading

0 comments on commit 7477a1c

Please sign in to comment.