Check out our main project at safing/portmaster
This repository contains a simple CSV to mmdb converter. It contains a simple HTTP server (written in Go) and a converter script (written in Perl).
The convert.pl
script requires a CSV input file (without a header line) in the following
format:
ip-range,ASN,Country,ISP-Name
for example,
185.199.108.0/23,3659,US,Github
The easiest way to use the mmdb-converter is to use docker, just build the container and run it:
# Clone the repository
git clone https://github.com/safing/mmdb-converter
# Enter the repository
cd mmdb-converter
# Build the docker container
docker build -t mmdb-converter .
Once the container is built (this may take a while), run it using:
docker run --rm -p 8080:8080 mmdb-converter
Finally, post a CSV file to the correct endpoint to get it converted to MMDB:
For IPv4:
curl -X POST --data '@csvfile' -H'Content-Type: text/csv' http://localhost:8080/convert/v4 -o mydb.mmdb
For IPv6:
curl -X POST --data '@csvfile' -H'Content-Type: text/csv' http://localhost:8080/convert/v6 -o mydb.mmdb
To directly use convert.pl make sure to have perl5
installed. Then, install
all dependencies fom cpanfile. Use whatever CPAN manager you're used
to. For example, with cpanm and carton:
# Execute from within the repository folder
sudo cpanm carton
carton install
The convert.plg
script requires 3 arguments, an input CSV file, the filename for the MMDB file the
the expected IP version (4
or 6
).
For example:
# -I is required if installed via carton.
perl -I ./local/lib/perl5/ ./convert.pl ./input.csv ./output.mmdb 6
This repository is licensed under a BSD 3-Clause "New" or "Revised" License. See LICENSE for more information.