]> git.ipfire.org Git - location/libloc.git/log
location/libloc.git
17 months agoimporter: Fix parsing gzipped content on invalid Content-Type header
Michael Tremer [Fri, 2 Dec 2022 11:06:01 +0000 (11:06 +0000)] 
importer: Fix parsing gzipped content on invalid Content-Type header

RIPE seems to have misconfigured their webserver which now sends
application/octet-stream for all gzipped files instead of
application/x-gzip or similar which is what the importer would expect.

Instead of only checking the content type, we will now test whether we
see the gzip magic and try to decompress the file then.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoconfigure: Bump version to 0.9.16 0.9.16
Michael Tremer [Sat, 29 Oct 2022 13:25:36 +0000 (13:25 +0000)] 
configure: Bump version to 0.9.16

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoconfigure: Drop superfluous bracket
Michael Tremer [Sat, 29 Oct 2022 13:23:08 +0000 (13:23 +0000)] 
configure: Drop superfluous bracket

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoInstall Perl files to Perl vendor directory
Petr Písař [Tue, 4 Oct 2022 11:51:21 +0000 (13:51 +0200)] 
Install Perl files to Perl vendor directory

On Fedora, the original code placed files into /usr/lib64/perl5/5.36/.
That location is not recognized by Fedora perl.

It also supresses installation and uninstallaion of packlist and perlocal
inventory files. They cannot be reliably uninstalled without
corrupting them.

Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agodatabase: Fix check if a signature is set
Michael Tremer [Sat, 29 Oct 2022 13:12:23 +0000 (13:12 +0000)] 
database: Fix check if a signature is set

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agowriter: Assign correct file descriptor for private keys
Michael Tremer [Sat, 29 Oct 2022 13:12:06 +0000 (13:12 +0000)] 
writer: Assign correct file descriptor for private keys

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agowriter: Fix typo in signature variable
Michael Tremer [Sat, 29 Oct 2022 13:11:48 +0000 (13:11 +0000)] 
writer: Fix typo in signature variable

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agodatabase: Correct error code on verification
Michael Tremer [Fri, 21 Oct 2022 10:42:41 +0000 (10:42 +0000)] 
database: Correct error code on verification

If the first signature check returned an error, the error code was
overwritten by the second signature check, returning an overall
incorrect result.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoCreate the database with read-only permissions for everyone
Michael Tremer [Fri, 21 Oct 2022 10:26:25 +0000 (10:26 +0000)] 
Create the database with read-only permissions for everyone

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoMove location manual from section 8 to section 1 in location-update.service
Petr Písař [Thu, 6 Oct 2022 11:28:51 +0000 (13:28 +0200)] 
Move location manual from section 8 to section 1 in location-update.service

It's a tool a non-superuser can use. It's installed into /usr/bin.

Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoRemove shebangs from Python modules
Petr Písař [Tue, 4 Oct 2022 14:16:07 +0000 (16:16 +0200)] 
Remove shebangs from Python modules

Shebangs only belong to standalone executables.

Fixes: #12956
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoMove location manual from section 8 to section 1
Petr Písař [Thu, 6 Oct 2022 11:28:51 +0000 (13:28 +0200)] 
Move location manual from section 8 to section 1

It's a tool a non-superuser can use. It's installed into /usr/bin.

Fixes: #12957
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agotests: Drop the test database and use the distributed one
Michael Tremer [Thu, 20 Oct 2022 13:35:55 +0000 (13:35 +0000)] 
tests: Drop the test database and use the distributed one

Fixes: #12958
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agodatabase: Ship a recent default database
Michael Tremer [Thu, 20 Oct 2022 13:23:14 +0000 (13:23 +0000)] 
database: Ship a recent default database

The database can easily be updated using "make update-database" which
will have to be executed before every release.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoDeclare make dependencies for Perl binding
Petr Písař [Wed, 19 Oct 2022 09:50:23 +0000 (11:50 +0200)] 
Declare make dependencies for Perl binding

Running make in parallel (make -j5) randomly failed with:

/bin/sh ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.  -include ./config.h -DSYSCONFDIR=\""/etc"\" -I./src  -Wall -Wchar-subscripts -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wsign-compare -Wstrict-prototypes -Wtype-limits  -fno-semantic-interposition -ffunction-sections -fdata-sections -DLIBLOC_PRIVATE -fvisibility=hidden -g -O2 -c -o src/libloc_internal_la-database.lo `test -f 'src/database.c' || echo './'`src/database.c
/usr/bin/ld: cannot find -lloc: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:482: blib/arch/auto/Location/Location.so] Error 1
make[2]: *** [Makefile:2982: build-perl] Error 2

That's because build-perl did not depend on libloc library.

A similar issue was with running tests and installing files. Moreover,
thess two targets rebuilt Perl binding from scratch.

This patch make the dependencies explicit and turns build-perl into
non-PHONY.

Fixes: #12961
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
18 months agoRevert "perl: Remove RPATH"
Michael Tremer [Mon, 17 Oct 2022 13:56:49 +0000 (13:56 +0000)] 
Revert "perl: Remove RPATH"

This reverts commit fb574759cbd3a60e64ed2674f514037b9085f078.

Suggested-by: Petr Pisar <ppisar@redhat.com>
Fixes: #12955
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoexport: Fix generating file names for ipset output
Michael Tremer [Tue, 4 Oct 2022 08:47:03 +0000 (08:47 +0000)] 
export: Fix generating file names for ipset output

The tag that is being used in the filename was set after creating the
filename. The order has now been fixed and the export works fine for me.

Fixes: #12944
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoMakefile: Reset Python path
Michael Tremer [Sat, 1 Oct 2022 11:56:31 +0000 (11:56 +0000)] 
Makefile: Reset Python path

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agowriter: Add an empty string to the stringpool
Michael Tremer [Tue, 27 Sep 2022 16:28:44 +0000 (16:28 +0000)] 
writer: Add an empty string to the stringpool

This is useful when we have some offset that isn't initialised. It will
point to the start of the string pool which is some random string that
happened to be added first.

An empty string at least signifies better that something is unset.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agopython: Export __version__ in location module
Michael Tremer [Mon, 26 Sep 2022 23:10:43 +0000 (23:10 +0000)] 
python: Export __version__ in location module

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoconfigure: Fix incorrect database path
Michael Tremer [Tue, 27 Sep 2022 09:54:45 +0000 (09:54 +0000)] 
configure: Fix incorrect database path

Reported-by: Jochen Sprickerhof <jochen@sprickerhof.de>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoimporter: Fix potential SQL command injection
Michael Tremer [Tue, 27 Sep 2022 09:20:05 +0000 (09:20 +0000)] 
importer: Fix potential SQL command injection

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agolocation-importer.in: Add new Amazon region codes
Peter Müller [Mon, 26 Sep 2022 18:33:29 +0000 (18:33 +0000)] 
location-importer.in: Add new Amazon region codes

Note that the precise location of "ap-southeast-6" is currently
undocumented. However, all IPv4 networks allocated are not routed at the
time of writing, hence our allocation of Asia/Pacific should be
acceptable for the time being.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agolocation-importer.in: Conduct sanity checks per DROP list
Peter Müller [Mon, 26 Sep 2022 18:26:44 +0000 (18:26 +0000)] 
location-importer.in: Conduct sanity checks per DROP list

Previously, the lack of distinction between different DROP lists caused
only the last one to be persisted. The second version of this patch
incorporates suggestions from Michael on the first version.

Tested-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoconfigure: Bump version to 0.9.15 0.9.15
Michael Tremer [Mon, 26 Sep 2022 15:39:58 +0000 (15:39 +0000)] 
configure: Bump version to 0.9.15

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agopython: Add new open() interface to easily open a database
Michael Tremer [Tue, 13 Sep 2022 12:06:24 +0000 (12:06 +0000)] 
python: Add new open() interface to easily open a database

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoconfigure: Make the default database path configurable
Michael Tremer [Tue, 13 Sep 2022 11:56:28 +0000 (11:56 +0000)] 
configure: Make the default database path configurable

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agowriter: Flush everything to disk after writing finishes
Michael Tremer [Fri, 9 Sep 2022 14:28:27 +0000 (14:28 +0000)] 
writer: Flush everything to disk after writing finishes

This might solve a race in the testsuite.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agoRevert "database: Increase page size to 64k"
Michael Tremer [Fri, 9 Sep 2022 14:22:45 +0000 (14:22 +0000)] 
Revert "database: Increase page size to 64k"

This reverts commit 8a330e5575d9f39d2b7716b238e894a650e9605a.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 months agotests: country: Don't crash when a country could not be found
Michael Tremer [Fri, 9 Sep 2022 14:21:42 +0000 (14:21 +0000)] 
tests: country: Don't crash when a country could not be found

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agocountry: Drop unused CC_LEN
Michael Tremer [Thu, 1 Sep 2022 14:56:54 +0000 (14:56 +0000)] 
country: Drop unused CC_LEN

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoFix compilation on MacOS X
Michael Tremer [Tue, 23 Aug 2022 13:59:48 +0000 (14:59 +0100)] 
Fix compilation on MacOS X

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoconfigure: Check for madvise
Michael Tremer [Tue, 23 Aug 2022 13:20:10 +0000 (13:20 +0000)] 
configure: Check for madvise

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agotests: Add signing key to verify signatures
Michael Tremer [Tue, 23 Aug 2022 13:19:57 +0000 (13:19 +0000)] 
tests: Add signing key to verify signatures

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Initialize r on create
Michael Tremer [Tue, 23 Aug 2022 13:15:40 +0000 (13:15 +0000)] 
database: Initialize r on create

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Drop debug line
Michael Tremer [Tue, 23 Aug 2022 13:06:50 +0000 (13:06 +0000)] 
database: Drop debug line

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Drop unused offset variable in objects
Michael Tremer [Tue, 23 Aug 2022 13:05:29 +0000 (13:05 +0000)] 
database: Drop unused offset variable in objects

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Encourage the compiler to inline some functions
Michael Tremer [Tue, 23 Aug 2022 13:04:16 +0000 (13:04 +0000)] 
database: Encourage the compiler to inline some functions

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Call madvise() to tell the kernel that we will randomly access the data
Michael Tremer [Tue, 23 Aug 2022 13:02:50 +0000 (13:02 +0000)] 
database: Call madvise() to tell the kernel that we will randomly access the data

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Read all data from the large mmap()
Michael Tremer [Tue, 23 Aug 2022 12:56:10 +0000 (12:56 +0000)] 
database: Read all data from the large mmap()

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agohexdump: Don't try to dump any empty memory
Michael Tremer [Tue, 23 Aug 2022 12:54:12 +0000 (12:54 +0000)] 
hexdump: Don't try to dump any empty memory

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Read header from mapped data
Michael Tremer [Tue, 23 Aug 2022 12:11:26 +0000 (12:11 +0000)] 
database: Read header from mapped data

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Map the entire database into memory as a whole
Michael Tremer [Tue, 23 Aug 2022 10:12:13 +0000 (10:12 +0000)] 
database: Map the entire database into memory as a whole

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Check if this version of libloc supports the database format
Michael Tremer [Tue, 23 Aug 2022 10:01:19 +0000 (10:01 +0000)] 
database: Check if this version of libloc supports the database format

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Refactor checking magic
Michael Tremer [Tue, 23 Aug 2022 09:56:49 +0000 (09:56 +0000)] 
database: Refactor checking magic

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Break opening procedure into smaller parts
Michael Tremer [Tue, 23 Aug 2022 09:50:27 +0000 (09:50 +0000)] 
database: Break opening procedure into smaller parts

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Refactor error handling on create
Michael Tremer [Tue, 23 Aug 2022 09:46:33 +0000 (09:46 +0000)] 
database: Refactor error handling on create

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agotests: database: Expand test coverage
Michael Tremer [Tue, 23 Aug 2022 09:40:34 +0000 (09:40 +0000)] 
tests: database: Expand test coverage

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agopython: Export DatabaseEnumerator type
Michael Tremer [Tue, 23 Aug 2022 09:40:21 +0000 (09:40 +0000)] 
python: Export DatabaseEnumerator type

This is useful for tests

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: country: Return better error codes
Michael Tremer [Tue, 23 Aug 2022 09:35:54 +0000 (09:35 +0000)] 
database: country: Return better error codes

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agostringpool: Drop function to find next offset
Michael Tremer [Mon, 22 Aug 2022 17:42:59 +0000 (17:42 +0000)] 
stringpool: Drop function to find next offset

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agotests: Add some simple database tests
Michael Tremer [Mon, 22 Aug 2022 17:32:43 +0000 (17:32 +0000)] 
tests: Add some simple database tests

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Fall back when mmap() isn't available
Michael Tremer [Mon, 22 Aug 2022 17:28:30 +0000 (17:28 +0000)] 
database: Fall back when mmap() isn't available

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agostringpool: Implement mmap as optional
Michael Tremer [Mon, 22 Aug 2022 17:26:26 +0000 (17:26 +0000)] 
stringpool: Implement mmap as optional

This patch will allow mmap() to fail and will make the reader
fall back to read from the given file descriptor.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agopython: Fix errors for Database.lookup()
Michael Tremer [Mon, 22 Aug 2022 17:07:41 +0000 (17:07 +0000)] 
python: Fix errors for Database.lookup()

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Improve error reporting when the magic cannot be read
Michael Tremer [Mon, 22 Aug 2022 14:06:53 +0000 (14:06 +0000)] 
database: Improve error reporting when the magic cannot be read

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agopython: Correctly raise any errors when opening the database
Michael Tremer [Mon, 22 Aug 2022 13:45:44 +0000 (13:45 +0000)] 
python: Correctly raise any errors when opening the database

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Increase page size to 64k
Michael Tremer [Mon, 22 Aug 2022 10:37:29 +0000 (10:37 +0000)] 
database: Increase page size to 64k

Since libloc is currently only using mmap() to map any databases into
memory, all mapped address range needs to be page aligned.

In the past, every database was aligned to a 4k page boundary. Some
architectures use 64k pages by default which could therefore not open
the database.

This patch changes the alignment to 64k which should hopefully be a
good common denominator. However, older database cannot be opened.

If we would ever have to support an architecture which's page size
is not evenly fitting into 64k, we will have to implement an
alternative to mmap.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Log any errors when mmap() fails
Michael Tremer [Mon, 22 Aug 2022 10:21:55 +0000 (10:21 +0000)] 
database: Log any errors when mmap() fails

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Do not try to unmap failed mappings
Michael Tremer [Mon, 22 Aug 2022 10:20:08 +0000 (10:20 +0000)] 
database: Do not try to unmap failed mappings

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agodatabase: Use MAP_PRIVATE with mmap()
Michael Tremer [Tue, 16 Aug 2022 10:58:53 +0000 (10:58 +0000)] 
database: Use MAP_PRIVATE with mmap()

We do not have any changes that need to be propagated down to the file.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agowriter: Check if stringpool has been initialized before free
Michael Tremer [Tue, 16 Aug 2022 10:35:15 +0000 (10:35 +0000)] 
writer: Check if stringpool has been initialized before free

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoconfigure: Replace obsolete AC_PROG_CC_STDC macro
Michael Tremer [Tue, 16 Aug 2022 10:31:14 +0000 (10:31 +0000)] 
configure: Replace obsolete AC_PROG_CC_STDC macro

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoCheck return value of fread() when reading header
Michael Tremer [Tue, 16 Aug 2022 10:30:56 +0000 (10:30 +0000)] 
Check return value of fread() when reading header

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agocron: Add a cronjob if systemd is not available
Michael Tremer [Tue, 16 Aug 2022 09:20:44 +0000 (09:20 +0000)] 
cron: Add a cronjob if systemd is not available

This will allow us to build this package when systemd is not available
(e.g. on Debian kfreebsd/hurd).

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months ago*_unref: Always expect a valid pointer
Michael Tremer [Mon, 15 Aug 2022 18:42:45 +0000 (18:42 +0000)] 
*_unref: Always expect a valid pointer

Those functions have been very inconsistent in that way that some
happily accepted a NULL pointer and others didn't.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agocountry: Refactor storing country code and continent code
Michael Tremer [Mon, 15 Aug 2022 18:38:02 +0000 (18:38 +0000)] 
country: Refactor storing country code and continent code

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoDon't abuse errno as return code
Michael Tremer [Mon, 15 Aug 2022 18:12:10 +0000 (18:12 +0000)] 
Don't abuse errno as return code

errno is not either set properly, or left set properly by any function
that we have called.

Return codes should either be zero or non-zero for functions unless they
are some value.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoReplace strerror(errno) with %m in format string throughout
Michael Tremer [Mon, 15 Aug 2022 17:45:12 +0000 (17:45 +0000)] 
Replace strerror(errno) with %m in format string throughout

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agolocation-importer.in: Fix dangling variable
Peter Müller [Sun, 14 Aug 2022 16:02:55 +0000 (16:02 +0000)] 
location-importer.in: Fix dangling variable

This fixes:

Traceback (most recent call last):
  File "/usr/bin/location-importer", line 1607, in <module>
    main()
  File "/usr/bin/location-importer", line 1605, in main
    c.run()
  File "/usr/bin/location-importer", line 140, in run
    ret = args.func(args)
  File "/usr/bin/location-importer", line 1234, in handle_update_overrides
    self._update_overrides_for_spamhaus_drop()
  File "/usr/bin/location-importer", line 1504, in _update_overrides_for_spamhaus_drop
    for sline in t.readlines():
NameError: name 't' is not defined

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoconfigure: Bump release to 0.9.14 0.9.14
Michael Tremer [Sun, 14 Aug 2022 12:26:12 +0000 (12:26 +0000)] 
configure: Bump release to 0.9.14

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoMakefile: Pack all debian files into the tarball
Michael Tremer [Sun, 14 Aug 2022 12:23:30 +0000 (12:23 +0000)] 
Makefile: Pack all debian files into the tarball

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoimporter: Import all sources in alphabetical order
Michael Tremer [Fri, 12 Aug 2022 15:49:13 +0000 (15:49 +0000)] 
importer: Import all sources in alphabetical order

To generate deterministic results

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoimporter: Tolerate that data might exist from other RIRs
Michael Tremer [Fri, 12 Aug 2022 15:47:29 +0000 (15:47 +0000)] 
importer: Tolerate that data might exist from other RIRs

Since we are breaking the import into smaller chunks now, it might be
that some data already exists in the database. This is now being
ignored and data won't be replaced.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agopython: Fix missing bracket
Michael Tremer [Fri, 12 Aug 2022 15:47:20 +0000 (15:47 +0000)] 
python: Fix missing bracket

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoimporter: Import each source individually
Michael Tremer [Fri, 12 Aug 2022 15:39:37 +0000 (15:39 +0000)] 
importer: Import each source individually

When importing source data fails for one source, we won't import
anything at all.

This patch changes that behaviour so that we will import all data one
after the other but continue if there was a problem with one source.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoimporter: Try to make parsing blocks faster
Michael Tremer [Fri, 12 Aug 2022 15:38:08 +0000 (15:38 +0000)] 
importer: Try to make parsing blocks faster

This patch changes the order of some operations and drops a few
redundant ones (potentiall).

That should allow us to parse blocked data faster.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agopython: database: Return None if no description/vendor/license set
Michael Tremer [Fri, 12 Aug 2022 15:37:32 +0000 (15:37 +0000)] 
python: database: Return None if no description/vendor/license set

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoimporter: Move importing extended sources/ARIN into transaction
Michael Tremer [Fri, 12 Aug 2022 13:56:17 +0000 (13:56 +0000)] 
importer: Move importing extended sources/ARIN into transaction

All imports should have been conducted in one large transaction so that
we can remove any previous data.

This was not the case because of an indentation issue and could have
caused that the transaction was commited without all data being
successfully re-imported.

Fixes: #12852
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
20 months agoimporter: Change download behaviour
Michael Tremer [Fri, 12 Aug 2022 13:51:20 +0000 (13:51 +0000)] 
importer: Change download behaviour

The downloader used to open a connection to the web server hosting our
content which would have been decompressed (if necessary) on the fly and
also been parsed on the fly so that it could have been fed into the
database easily.

Some webservers do not seem to be patient enough to keep the connection
open if things take a little bit longer than usual. That caused the
import to fail.

This patch changes the behaviour that we would download all content
first, store it locally, and then start processing it.

Fixes: #12852
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Cc: Peter Müller <peter.mueller@ipfire.org>
20 months agoimporter: Actually perform the Spamhaus sanity check
Michael Tremer [Fri, 12 Aug 2022 13:47:08 +0000 (13:47 +0000)] 
importer: Actually perform the Spamhaus sanity check

The check block was indented incorrectly and would have never been
executed.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
21 months agoUse buster_backport for new debhelper
Jochen Sprickerhof [Fri, 8 Jul 2022 12:01:51 +0000 (14:01 +0200)] 
Use buster_backport for new debhelper

21 months agoImprovements from Debian packaging
Jochen Sprickerhof [Fri, 8 Jul 2022 11:47:39 +0000 (13:47 +0200)] 
Improvements from Debian packaging

21 months agoMerge location-importer into location package
Jochen Sprickerhof [Wed, 6 Jul 2022 08:40:42 +0000 (10:40 +0200)] 
Merge location-importer into location package

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
21 months agoRename Python package to python3-location
Jochen Sprickerhof [Tue, 5 Jul 2022 21:30:29 +0000 (23:30 +0200)] 
Rename Python package to python3-location

To comply with the Debian Python policy. Also add a transitional package
with the old name.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
22 months agolocation-importer: AS names starting with "DNIC" actually are valid
Peter Müller [Sun, 5 Jun 2022 09:25:45 +0000 (09:25 +0000)] 
location-importer: AS names starting with "DNIC" actually are valid

These are all assigned to the US Department of Defense.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
22 months agolocation-importer: Only delete override data if we are sure to have a valid replacement
Peter Müller [Sun, 5 Jun 2022 10:04:50 +0000 (10:04 +0000)] 
location-importer: Only delete override data if we are sure to have a valid replacement

The current way of truncating all override data straight away leaves us
with no data at all, should a source turn out to be unreachable or
returning bogus files (yes, Cloudflare, I _am_ looking at you).

It is therefore better to only delete data we know to have a valid
replacement for, rather than just dropping the source altogether.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
22 months agoexport: Don't fail when output stream isn't seekable
Michael Tremer [Thu, 23 Jun 2022 13:04:59 +0000 (13:04 +0000)] 
export: Don't fail when output stream isn't seekable

For the ipset format, we will rewrite the header after we know the total
number of entries that have been written in order to optimise the hash
table.

When the output stream isn't seekable, we cannot write the header again
which is being fixed in this patch.

Fixes: #12885
Reported-by: Jon Murphy <jon.murphy@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
22 months agoverify: Show message on success
Michael Tremer [Thu, 23 Jun 2022 12:59:47 +0000 (12:59 +0000)] 
verify: Show message on success

Fixes: #12887
Reported-by: Jon Murphy <jon.murphy@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Drop using functools
Michael Tremer [Thu, 14 Apr 2022 20:45:23 +0000 (20:45 +0000)] 
export: Drop using functools

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodownloader: Fetch __version__ from C module
Michael Tremer [Thu, 14 Apr 2022 20:44:29 +0000 (20:44 +0000)] 
downloader: Fetch __version__ from C module

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoMake sources around that we can run tests without location installed
Michael Tremer [Thu, 14 Apr 2022 18:31:56 +0000 (18:31 +0000)] 
Make sources around that we can run tests without location installed

In order to run the test suite, we need to make the Python module
loadable from the build directory so that we first of all test the right
code and that it just works without running "make install" first.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoRevert "configure: Require Python >= 3.9"
Michael Tremer [Thu, 14 Apr 2022 17:11:49 +0000 (17:11 +0000)] 
Revert "configure: Require Python >= 3.9"

This reverts commit 643b8d062ac11efef6c74cf8af7281079e2533e9.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoconfigure: Bump version to 0.9.13 0.9.13
Michael Tremer [Tue, 12 Apr 2022 12:16:20 +0000 (12:16 +0000)] 
configure: Bump version to 0.9.13

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agotests: Import test database
Michael Tremer [Tue, 12 Apr 2022 12:26:02 +0000 (12:26 +0000)] 
tests: Import test database

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years ago.gitignore: Ignore *.db files only in main directory
Michael Tremer [Tue, 12 Apr 2022 12:25:40 +0000 (12:25 +0000)] 
.gitignore: Ignore *.db files only in main directory

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Enable flattening for everything
Michael Tremer [Mon, 11 Apr 2022 17:57:22 +0000 (17:57 +0000)] 
export: Enable flattening for everything

When performing checks, it is useful to be able to rely on a flat
network plan so that any larger parent networks in some countries/ASes
won't match any subnets.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoconfigure: Require Python >= 3.9
Michael Tremer [Wed, 30 Mar 2022 15:48:44 +0000 (15:48 +0000)] 
configure: Require Python >= 3.9

We are using a couple of newer Python features which are only available
from 3.9 onwards.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agotests: List Python test cases as scripts
Michael Tremer [Wed, 30 Mar 2022 15:48:19 +0000 (15:48 +0000)] 
tests: List Python test cases as scripts

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agotests: Break after exporting 1000 networks
Michael Tremer [Wed, 30 Mar 2022 15:29:49 +0000 (15:29 +0000)] 
tests: Break after exporting 1000 networks

Otherwise this test runs for forever

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>