location-importer.in: emit warnings due to unknown country code for valid networks... master
authorPeter Müller <peter.mueller@ipfire.org>
Mon, 3 May 2021 17:14:29 +0000 (19:14 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 May 2021 12:39:58 +0000 (12:39 +0000)
This reduces log spam in case of processing RIR database, checking for
networks with unknown country codes assigned. If we would not have
written into the database, there is no need to warn about them.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
debian/.gitignore
debian/rules
src/python/location-importer.in
src/systemd/location-update.service.in

index 0faf920..8190b92 100644 (file)
@@ -2,9 +2,10 @@
 /autoreconf.*
 /debhelper-build-stamp
 /files
-/libloc/
-/libloc-dev/
-/libloc-perl/
-/tmp
+/*/
 *.debhelper
+*.log
 *.substvars
+!/patches/
+!/source/
+!/tests/
index 8893b7b..05b88fd 100755 (executable)
@@ -18,3 +18,11 @@ override_dh_perl:
 
 override_dh_systemd_enable:
        dh_systemd_enable location-update.timer
+
+override_dh_install:
+       dh_install
+       # lintian: unknown-file-in-python-module-directory
+       rm debian/location-python/usr/lib/python3*/site-packages/_location.la
+       # linitan: binaries-have-file-conflict (d/location-importer.install)
+       rm debian/location-python/usr/lib/python3*/site-packages/location/database.py
+       rm debian/location-python/usr/lib/python3*/site-packages/location/importer.py
index 1e08458..e5f55af 100644 (file)
@@ -623,16 +623,19 @@ class CLI(object):
                if not inetnum or not "country" in inetnum:
                        return
 
-               # Skip objects with unknown country codes
-               if validcountries and inetnum.get("country") not in validcountries:
-                       log.warning("Skipping network with bogus country '%s': %s" % \
-                               (inetnum.get("country"), inetnum.get("inet6num") or inetnum.get("inetnum")))
-                       return
-
                # Iterate through all networks enumerated from above, check them for plausibility and insert
                # them into the database, if _check_parsed_network() succeeded
                for single_network in inetnum.get("inet6num") or inetnum.get("inetnum"):
                        if self._check_parsed_network(single_network):
+
+                               # Skip objects with unknown country codes - to avoid log spam for invalid or too small
+                               # networks, this check is - kinda ugly - done at this point
+                               if validcountries and inetnum.get("country") not in validcountries:
+                                       log.warning("Skipping network with bogus country '%s': %s" % \
+                                               (inetnum.get("country"), inetnum.get("inet6num") or inetnum.get("inetnum")))
+                                       break
+
+                               # Everything is fine here, run INSERT statement...
                                self.db.execute("INSERT INTO _rirdata(network, country) \
                                        VALUES(%s, %s) ON CONFLICT (network) DO UPDATE SET country = excluded.country",
                                        "%s" % single_network, inetnum.get("country"),
index daae2c5..1c8e116 100644 (file)
@@ -1,5 +1,6 @@
 [Unit]
 Description=Automatic Location Database Updater
+Documentation=man:location(8) https://man-pages.ipfire.org/libloc/location.html
 Requires=network.target
 
 [Service]