Skip to contentSkip to conversation

geoip: script fixes

PATCH Applied Jeremy Sowden 2 participants 9 messages Nov 22, 2020 – Nov 24, 2020 netfilter

lore
Share & tools
lore
#0 lore raw

cover geoip: script fixes

A couple of fixes and some man-pages for the MaxMind geoip scripts.

Jeremy Sowden (4):
geoip: remove superfluous xt_geoip_fetch_maxmind script.
geoip: fix man-page typo'.
geoip: add man-pages for MaxMind scripts.
geoip: use correct download URL for MaxMind DB's.

 geoip/Makefile.am              |  6 ++-
 geoip/xt_geoip_build_maxmind.1 | 40 ++++++++++++++
 geoip/xt_geoip_dl_maxmind      | 12 ++++-
 geoip/xt_geoip_dl_maxmind.1    | 22 ++++++++
 geoip/xt_geoip_fetch.1         |  2 +-
 geoip/xt_geoip_fetch_maxmind   | 95 ----------------------------------
 6 files changed, 77 insertions(+), 100 deletions(-)
 create mode 100644 geoip/xt_geoip_build_maxmind.1
 create mode 100644 geoip/xt_geoip_dl_maxmind.1
 delete mode 100755 geoip/xt_geoip_fetch_maxmind
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/4 geoip: remove superfluous xt_geoip_fetch_maxmind script.

xt_geoip_fetch and xt_geoip_fetch_maxmind are identical. Remove the latter.

---
 geoip/Makefile.am            |  2 +-
 geoip/xt_geoip_fetch_maxmind | 95 ------------------------------------
 2 files changed, 1 insertion(+), 96 deletions(-)
 delete mode 100755 geoip/xt_geoip_fetch_maxmind
geoip/Makefile.am +1 -1
index 7bbf3bcf3815..5323c82eb7c4 100644
@@ -1,6 +1,6 @@
 # -*- Makefile -*-
 
-bin_SCRIPTS = xt_geoip_fetch xt_geoip_fetch_maxmind
+bin_SCRIPTS = xt_geoip_fetch
 
 pkglibexec_SCRIPTS = xt_geoip_build xt_geoip_build_maxmind xt_geoip_dl xt_geoip_dl_maxmind
 
geoip/xt_geoip_fetch_maxmind deleted +0 -95

95 lines not on this page · raw message

Signature · 1 line
2.29.2
#2 lore raw

PATCH 2/4 geoip: fix man-page typo'.

In reply to Jeremy Sowden
---
 geoip/xt_geoip_fetch.1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
geoip/xt_geoip_fetch.1 +1 -1
index 7280c74b9ab5..5d1ae48ae42e 100644
@@ -9,7 +9,7 @@ xt_geoip_fetch \(em dump a country database to stdout
 .SH Description
 .PP
 xt_geoip_fetch unpacks a country's IPv4 or IPv6 databases and dumps
-them to standard output as a sorted, non-overlaping list of ranges (which
+them to standard output as a sorted, non-overlapping list of ranges (which
 is how they're represented in the database) suitable for browsing or
 further processing.
 .PP Options
Signature · 1 line
2.29.2
#3 lore raw

Re: [PATCH xtables-addons 2/4] geoip: fix man-page typo'.

Quoted 2 lines · Jeremy Sowden

Subject: geoip: fix man-page typo'.

Rhetoric: How much more interpunction do you want to add to the subject lines?
Neither apostrophe nor period belong into it.

#4 lore raw

PATCH 3/4 geoip: add man-pages for MaxMind scripts.

In reply to Jeremy Sowden
---
 geoip/Makefile.am              |  4 +++-
 geoip/xt_geoip_build_maxmind.1 | 40 ++++++++++++++++++++++++++++++++++
 geoip/xt_geoip_dl_maxmind.1    | 22 +++++++++++++++++++
 3 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 geoip/xt_geoip_build_maxmind.1
 create mode 100644 geoip/xt_geoip_dl_maxmind.1
geoip/Makefile.am +3 -1
index 5323c82eb7c4..8c0b6af80054 100644
@@ -4,4 +4,6 @@ bin_SCRIPTS = xt_geoip_fetch
 
 pkglibexec_SCRIPTS = xt_geoip_build xt_geoip_build_maxmind xt_geoip_dl xt_geoip_dl_maxmind
 
-man1_MANS = xt_geoip_build.1 xt_geoip_dl.1 xt_geoip_fetch.1
+man1_MANS = xt_geoip_build.1 xt_geoip_dl.1 \
+	    xt_geoip_build_maxmind.1 xt_geoip_dl_maxmind.1 \
+	    xt_geoip_fetch.1
geoip/xt_geoip_build_maxmind.1 new file +40 -0
new file mode 100644
index 000000000000..e20e44848b82
@@ -0,0 +1,40 @@
+.TH xt_geoip_build_maxmind 1 "2010-12-17" "xtables-addons" "xtables-addons"
+.SH Name
+.PP
+xt_geoip_build_maxmind \(em convert GeoIP.csv to packed format for xt_geoip
+.SH Syntax
+.PP
+\fI/usr/libexec/xt_geoip/\fP\fBxt_geoip_build_maxmind\fP [\fB\-D\fP
+\fItarget_dir\fP] [\fB\-S\fP \fIsource_dir\fP]
+.SH Description
+.PP
+xt_geoip_build_maxmind is used to build packed raw representations of the range
+database that the xt_geoip module relies on. Since kernel memory is precious,
+much of the preprocessing is done in userspace by this very building tool. One
+file is produced for each country, so that no more addresses than needed are
+required to be loaded into memory. The ranges in the packed database files are
+also ordered, as xt_geoip relies on this property for its bisection approach to
+work.
+.PP
+Since the script is usually installed to the libexec directory of the
+xtables-addons package and this is outside $PATH (on purpose), invoking the
+script requires it to be called with a path.
+.PP Options
+.TP
+\fB\-D\fP \fItarget_dir\fP
+Specifies the target directory into which the files are to be put. Defaults to ".".
+.TP
+\fB\-S\fP \fIsource_dir\fP
+Specifies the source directory of the MaxMind CSV files. Defaults to ".".
+.TP
+\fB\-s\fP
+"System mode". Equivalent to \fB\-D /usr/share/xt_geoip\fP.
+.SH Application
+.PP
+Shell commands to build the databases and put them to where they are expected
+(usually run as root):
+.PP
+xt_geoip_build_maxmind \-s
+.SH See also
+.PP
+xt_geoip_dl_maxmind(1)
geoip/xt_geoip_dl_maxmind.1 new file +22 -0
new file mode 100644
index 000000000000..00a73d7ee90d
@@ -0,0 +1,22 @@
+.TH xt_geoip_dl_maxmind 1 "2010-12-17" "xtables-addons" "xtables-addons"
+.SH Name
+.PP
+xt_geoip_dl_maxmind \(em download MaxMind GeoIP database files
+.SH Syntax
+.PP
+\fI/usr/libexec/xt_geoip/\fP\fBxt_geoip_dl_maxmind\fP [\fI licence-key file\fP]
+.SH Description
+.PP
+Downloads the MaxMind GeoLite2 databases for IPv4 and IPv6 and unpacks them to
+the current directory.  The alternate \fBxt_geoip_dl\fP script can be
+used for the DB-IP Country Lite databases.
+.PP
+Since the script is usually installed to the libexec directory of the
+xtables-addons package and this is outside $PATH (on purpose), invoking the
+script requires it to be called with a path.
+.SH Options
+.PP
+None.
+.SH See also
+.PP
+xt_geoip_build_maxmind(1)
Signature · 1 line
2.29.2
#5 lore raw

PATCH 4/4 geoip: use correct download URL for MaxMind DB's.

In reply to Jeremy Sowden

The download URL for the GeoLite2 DB's has changed and includes a licence-key. Update the download script to read the key from file or stdin and use the correct URL.

---
 geoip/xt_geoip_dl_maxmind | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
geoip/xt_geoip_dl_maxmind +10 -1
index 1de60442a804..d5640336c1c0 100755
@@ -1,7 +1,16 @@
 #!/bin/sh
 
+if [ $# -eq 1 ]; then
+    exec <$1
+elif [ $# -ne 0 ]; then
+    echo $(basename $0) [ licence_key_file ] 1>&2
+    exit 1
+fi
+
+read licence_key
+
 rm -rf GeoLite2-Country-CSV_*
 
-wget -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip
+wget -q -OGeoLite2-Country-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${licence_key}&suffix=zip"
 unzip -q GeoLite2-Country-CSV.zip
 rm -f GeoLite2-Country-CSV.zip
Signature · 1 line
2.29.2
#6 lore raw
In reply to Jeremy Sowden
Quoted 7 lines · Jeremy Sowden

A couple of fixes and some man-pages for the MaxMind geoip scripts.

Jeremy Sowden (4):
geoip: remove superfluous xt_geoip_fetch_maxmind script.
geoip: fix man-page typo'.
geoip: add man-pages for MaxMind scripts.
geoip: use correct download URL for MaxMind DB's.

Applied.

#7 lore raw
Quoted 10 lines · Jan Engelhardt
Quoted 7 lines · Jeremy Sowden

A couple of fixes and some man-pages for the MaxMind geoip scripts.

Jeremy Sowden (4):
geoip: remove superfluous xt_geoip_fetch_maxmind script.
geoip: fix man-page typo'.
geoip: add man-pages for MaxMind scripts.
geoip: use correct download URL for MaxMind DB's.

Applied.

Thanks! I only see 1-3 in your tree, however. Was there something wrong with the fourth patch or did it just get mislaid?

J.

#8 lore raw
Quoted 11 lines · Jeremy Sowden
Quoted 8 lines · Jan Engelhardt
Quoted 5 lines · Jeremy Sowden

Jeremy Sowden (4):
geoip: remove superfluous xt_geoip_fetch_maxmind script.
geoip: fix man-page typo'.
geoip: add man-pages for MaxMind scripts.
geoip: use correct download URL for MaxMind DB's.

Applied.

Thanks! I only see 1-3 in your tree, however.

Indeed, now it's there.