]> git.ipfire.org Git - location/libloc.git/log
location/libloc.git
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>
2 years agonetwork: loc_network_subnets: Use correct prefix
Michael Tremer [Wed, 30 Mar 2022 15:19:10 +0000 (15:19 +0000)] 
network: loc_network_subnets: Use correct prefix

The prefix is being stored as a total number of bits now since it is
easier for any bitwise maths later. This is however causing an incorrect
prefix being computed when splitting a network into two subnets for
IPv4.

To get the correct prefix, loc_network_prefix must be called.

Introduced in 1fd09d0b09756649968fec42c737c88b92e4f11f

Reported-by: Valter Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Add more debugging output when running exclude
Michael Tremer [Wed, 30 Mar 2022 15:18:35 +0000 (15:18 +0000)] 
network: Add more debugging output when running exclude

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Log a more useful message on invalid prefix
Michael Tremer [Wed, 30 Mar 2022 15:15:00 +0000 (15:15 +0000)] 
network: Log a more useful message on invalid prefix

If loc_network_subnets is being called with some invalid input, we just
fail without logging a useful message or setting errno accordingly.

This is being changed with this patch.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodatabase: Allocate subnets list only once
Michael Tremer [Wed, 30 Mar 2022 14:58:36 +0000 (14:58 +0000)] 
database: Allocate subnets list only once

This is a performance improvement when exporting networks flattened. For
the subnet search, we allocate an empty list many times which is often
not required.

This patch changes this behaviour that (if needed) the lists will be
allocated and will stay around and cleared if necessary.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agotests: Add a simple test that lists all networks
Michael Tremer [Wed, 30 Mar 2022 14:57:13 +0000 (14:57 +0000)] 
tests: Add a simple test that lists all networks

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoBump version to 0.9.12 0.9.12
Michael Tremer [Wed, 23 Mar 2022 20:13:06 +0000 (20:13 +0000)] 
Bump version to 0.9.12

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Set default prefix if none is given
Michael Tremer [Wed, 9 Mar 2022 13:55:48 +0000 (13:55 +0000)] 
address: Set default prefix if none is given

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoRefactor parsing IP addresses
Michael Tremer [Wed, 9 Mar 2022 11:42:47 +0000 (11:42 +0000)] 
Refactor parsing IP addresses

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agowriter: I forgot to initalize the country list
Michael Tremer [Wed, 9 Mar 2022 11:09:25 +0000 (11:09 +0000)] 
writer: I forgot to initalize the country list

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter: Improve performance of network export query
Michael Tremer [Wed, 9 Mar 2022 10:29:11 +0000 (10:29 +0000)] 
importer: Improve performance of network export query

This patch moves the subqueries out of the large query, so that the
database will materialize them for faster lookup.

We also drop the "UNION ALL" and replace it with just "UNION" because we
do not want any duplicate networks. That will save us many iterations
later on.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agowriter: Use country list internally
Michael Tremer [Wed, 9 Mar 2022 10:26:41 +0000 (10:26 +0000)] 
writer: Use country list internally

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agocountry-list: Grow like AS list
Michael Tremer [Wed, 9 Mar 2022 10:19:10 +0000 (10:19 +0000)] 
country-list: Grow like AS list

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork-list: Grow just like the AS list
Michael Tremer [Wed, 9 Mar 2022 10:17:55 +0000 (10:17 +0000)] 
network-list: Grow just like the AS list

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agowriter: Use AS list internally
Michael Tremer [Wed, 9 Mar 2022 10:17:26 +0000 (10:17 +0000)] 
writer: Use AS list internally

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoas-list: Grow faster to avoid too many re-allocations
Michael Tremer [Wed, 9 Mar 2022 10:15:49 +0000 (10:15 +0000)] 
as-list: Grow faster to avoid too many re-allocations

When we add a large number of ASes to the list, we will constantly
re-allocate the whole list because we are only growing it by 64 entries
at a time.

This patch changes that we will double the list in size every time we
run out of space and we will start with 1024 elements.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agobogons: Skip any subnets of former networks
Michael Tremer [Mon, 7 Mar 2022 16:26:16 +0000 (16:26 +0000)] 
bogons: Skip any subnets of former networks

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agobogons: Add gaps that are only one address wide
Michael Tremer [Mon, 7 Mar 2022 16:05:45 +0000 (16:05 +0000)] 
bogons: Add gaps that are only one address wide

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Add some simple tests
Michael Tremer [Mon, 7 Mar 2022 16:05:28 +0000 (16:05 +0000)] 
address: Add some simple tests

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Fix buffer overwrite
Michael Tremer [Mon, 7 Mar 2022 16:01:21 +0000 (16:01 +0000)] 
address: Fix buffer overwrite

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Fix decrementing IP addresses
Michael Tremer [Mon, 7 Mar 2022 16:00:49 +0000 (16:00 +0000)] 
address: Fix decrementing IP addresses

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Simplify functions
Michael Tremer [Mon, 7 Mar 2022 15:23:34 +0000 (15:23 +0000)] 
address: Simplify functions

This patch improves looping through the octets of an IP address and
avoids that we will read anything that isn't for us.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork-list: Remove debugging line
Michael Tremer [Mon, 7 Mar 2022 14:48:33 +0000 (14:48 +0000)] 
network-list: Remove debugging line

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork-list: summarize: Break when we exhausted the network range
Michael Tremer [Mon, 7 Mar 2022 14:48:12 +0000 (14:48 +0000)] 
network-list: summarize: Break when we exhausted the network range

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork-list: Simplify debugging output on summarize
Michael Tremer [Mon, 7 Mar 2022 14:47:44 +0000 (14:47 +0000)] 
network-list: Simplify debugging output on summarize

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Prevent under/overflow when incrementing/decrementing
Michael Tremer [Mon, 7 Mar 2022 14:47:12 +0000 (14:47 +0000)] 
address: Prevent under/overflow when incrementing/decrementing

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Initialize all bits of IP addresses
Michael Tremer [Mon, 7 Mar 2022 13:22:15 +0000 (13:22 +0000)] 
address: Initialize all bits of IP addresses

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agostrings: Statically allocate all address/network strings
Michael Tremer [Mon, 7 Mar 2022 13:21:29 +0000 (13:21 +0000)] 
strings: Statically allocate all address/network strings

This helps us to write less code and spend less time allocating and
freeing memory.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Pass prefix in native length
Michael Tremer [Mon, 7 Mar 2022 12:22:14 +0000 (12:22 +0000)] 
network: Pass prefix in native length

When creating an IPv4 subnet, the prefix had to be mapped to the mapped
syntax (i.e. add 96). This doesn't seem too intuitive to me.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Rename increment/decrement functions and modify address in place
Michael Tremer [Mon, 7 Mar 2022 12:02:06 +0000 (12:02 +0000)] 
address: Rename increment/decrement functions and modify address in place

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddresses: Use loc_address_family which is now available
Michael Tremer [Mon, 7 Mar 2022 11:55:59 +0000 (11:55 +0000)] 
addresses: Use loc_address_family which is now available

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Rename in6_addr_get_bit/in6_addr_set_bit to loc_address_*
Michael Tremer [Mon, 7 Mar 2022 11:54:26 +0000 (11:54 +0000)] 
address: Rename in6_addr_get_bit/in6_addr_set_bit to loc_address_*

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Rename in6_addr_cmp into loc_address_cmp
Michael Tremer [Mon, 7 Mar 2022 11:51:17 +0000 (11:51 +0000)] 
address: Rename in6_addr_cmp into loc_address_cmp

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoMove all address convenience functions into their own header
Michael Tremer [Mon, 7 Mar 2022 11:49:21 +0000 (11:49 +0000)] 
Move all address convenience functions into their own header

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agobogons: Don't consider a network legitimate without a country code
Michael Tremer [Mon, 7 Mar 2022 11:33:53 +0000 (11:33 +0000)] 
bogons: Don't consider a network legitimate without a country code

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agobogons: Reset after we have reached the end
Michael Tremer [Mon, 7 Mar 2022 11:30:01 +0000 (11:30 +0000)] 
bogons: Reset after we have reached the end

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddress: Correctly subtract IPv4 addresses
Michael Tremer [Mon, 7 Mar 2022 11:27:31 +0000 (11:27 +0000)] 
address: Correctly subtract IPv4 addresses

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork-list: Cap prefix length based on family
Michael Tremer [Mon, 7 Mar 2022 11:27:11 +0000 (11:27 +0000)] 
network-list: Cap prefix length based on family

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agobogons: Refactor algorithms
Michael Tremer [Mon, 7 Mar 2022 11:12:17 +0000 (11:12 +0000)] 
bogons: Refactor algorithms

This changes that we won't compare one network with the previous one,
but instead we will look for gaps starting from the first possible to
the last possible IP address.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoaddresses: Implement subtraction for IPv4
Michael Tremer [Mon, 7 Mar 2022 11:07:55 +0000 (11:07 +0000)] 
addresses: Implement subtraction for IPv4

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Implement bit length function for IPv4
Michael Tremer [Mon, 7 Mar 2022 10:01:23 +0000 (10:01 +0000)] 
network: Implement bit length function for IPv4

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Allow creating any valid networks
Michael Tremer [Sun, 6 Mar 2022 15:08:47 +0000 (15:08 +0000)] 
network: Allow creating any valid networks

Formerly, we did not allow creating special networks like ::1/128, ::/0,
127.0.0.0/8, and so on.

In order to represent all bogons, we will have to allow this.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork-list: Rewrite summarize algorithm
Michael Tremer [Sun, 6 Mar 2022 15:06:17 +0000 (15:06 +0000)] 
network-list: Rewrite summarize algorithm

The former algorithm did a lot of trial and error which is slow and
probably returned wrong results.

This one determines the correct prefix size quickly.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Drop functions moved in an earlier commit
Michael Tremer [Sun, 6 Mar 2022 15:05:17 +0000 (15:05 +0000)] 
network: Drop functions moved in an earlier commit

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Add function that counts the bit length of an addres
Michael Tremer [Sun, 6 Mar 2022 14:28:26 +0000 (14:28 +0000)] 
network: Add function that counts the bit length of an addres

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Move a couple of helper functions into headers
Michael Tremer [Sat, 5 Mar 2022 16:00:43 +0000 (16:00 +0000)] 
network: Move a couple of helper functions into headers

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation: Fix output of list-* commands
Michael Tremer [Sat, 5 Mar 2022 14:26:48 +0000 (14:26 +0000)] 
location: Fix output of list-* commands

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter: Skip empty lines
Michael Tremer [Sat, 5 Mar 2022 13:26:23 +0000 (13:26 +0000)] 
importer: Skip empty lines

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter: Silently ignore any table headers
Michael Tremer [Sat, 5 Mar 2022 13:15:36 +0000 (13:15 +0000)] 
importer: Silently ignore any table headers

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter: Correctly hande response codes from Bird
Michael Tremer [Sat, 5 Mar 2022 13:15:07 +0000 (13:15 +0000)] 
importer: Correctly hande response codes from Bird

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodatabase: Return something when no filter criteria is configured
Michael Tremer [Sat, 5 Mar 2022 12:04:44 +0000 (12:04 +0000)] 
database: Return something when no filter criteria is configured

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter: Parse aggregated networks
Michael Tremer [Sat, 5 Mar 2022 11:56:40 +0000 (11:56 +0000)] 
importer: Parse aggregated networks

This patch adds code to parse any aggregated networks.

Bird does not automatically show the last ASN of the path, but we can
collect all networks that we can see without any ASN and perform
"show route <network> all" on them to gather this information.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoBump release to 0.9.11 0.9.11
Michael Tremer [Thu, 3 Mar 2022 10:41:22 +0000 (10:41 +0000)] 
Bump release to 0.9.11

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Sightly refactor export logic
Michael Tremer [Thu, 3 Mar 2022 09:33:42 +0000 (09:33 +0000)] 
export: Sightly refactor export logic

This patch moves creating the "tag" (formerly known as prefix) into the
writer class, so that we can modify it based on what output format we
have.

ipset and nftables will need disjunct names for IPv6 and IPv4 because
they cannot handle mixed sets.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Fix filtering logic
Michael Tremer [Thu, 3 Mar 2022 08:48:14 +0000 (08:48 +0000)] 
export: Fix filtering logic

It is possible to filter for what kind of network should be exported.

This worked well when the filter list only contained country codes, or
when it only contained ASNs. If there was a mix, only networks that
match both (i.e. virtually nothing) matched.

This patch fixes that we will use for either of them.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer: Fix parsing LACNIC-flavoured inetnums
Peter Müller [Tue, 1 Mar 2022 21:52:39 +0000 (21:52 +0000)] 
location-importer: Fix parsing LACNIC-flavoured inetnums

My fault, again. :-/

Reported-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoipset: The minimum hashsize is 64
Michael Tremer [Wed, 2 Mar 2022 10:58:51 +0000 (10:58 +0000)] 
ipset: The minimum hashsize is 64

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Allow exporting to stdout
Michael Tremer [Wed, 2 Mar 2022 10:53:04 +0000 (10:53 +0000)] 
export: Allow exporting to stdout

This is useful if you want to pipe output straight into another program.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation: Print proper error message for any uncaught exceptions
Michael Tremer [Wed, 2 Mar 2022 10:50:34 +0000 (10:50 +0000)] 
location: Print proper error message for any uncaught exceptions

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Conditionally enable flattening
Michael Tremer [Wed, 2 Mar 2022 10:26:41 +0000 (10:26 +0000)] 
export: Conditionally enable flattening

By default, we enabled flattening of the network tree when we export it.

However, this is only required for xt_geoip since the other formats can
deal with overlapping networks and would even benefit from a shorter
list.

Therefore this is now only enabled when needed which results in shorter
export times (9 seconds instead of 2.5 minutes) and the full ipset is
about 20% smaller when loaded into memory than before.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoipset: Set maxelem to a fixed size
Michael Tremer [Wed, 2 Mar 2022 10:18:16 +0000 (10:18 +0000)] 
ipset: Set maxelem to a fixed size

When we try to load a changed set which might have more entries, a
previous maxelem could have been smaller preventing us from adding new
entries.

We also cannot run the "create" command with a changed maxelem
parameter which is why this patch set the value to something that should
be large enough for everything.

The downside of this is also, that we cannot modify the hashsize when we
reload a set, which is probably okay, since sets should not change too
much in size and therefore will only run *slightly* less efficient - if
at all.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoipset: Fix hash type for IPv6
Michael Tremer [Tue, 1 Mar 2022 13:01:23 +0000 (13:01 +0000)] 
ipset: Fix hash type for IPv6

IPv6 exports could not be loaded because sets were created as type
"inet" instead of "inet6" which is fixed by this patch.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoipset: Optimise hash table size
Michael Tremer [Tue, 1 Mar 2022 12:44:21 +0000 (12:44 +0000)] 
ipset: Optimise hash table size

ipset uses a hash table internally which can be dynamically sized to
chose whether more space efficiency or performance is required.

Previously to this patch, we always set the size of the hash table to
1024 buckets. Having large sets with almost half a million entries, this
is not performing well since we will spend a lot of time in searching
the linked list.

This will probably perform even slower on systems with smaller cache
sizes like the IPFire Mini Appliance.

Having more buckets that are sparesely filled, will result in less
memory fetches at the cost of more wastage. Throughout the whole IPv4
set, this ranges from about 50 MB for a factor of 4, to about 100 MB for
a factor of 0.75.

Since memory of this quantity is cheap and since we want to increase
throughput, I have chosen to set the fill factor to 0.75.

Logistically, it is a little bit complicated to know this in advance
when we have to write the header, so we will write the entire file
first, and then come back to write the header again. This is required to
keep memory consumption down during the export.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Remove prefix when exporting countries.
Stefan Schantl [Thu, 24 Feb 2022 17:52:13 +0000 (18:52 +0100)] 
export: Remove prefix when exporting countries.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoBump release to 0.9.10 0.9.10
Michael Tremer [Wed, 16 Feb 2022 08:54:50 +0000 (08:54 +0000)] 
Bump release to 0.9.10

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoexport: Make ipset files easily reloadable
Michael Tremer [Fri, 11 Feb 2022 17:14:02 +0000 (17:14 +0000)] 
export: Make ipset files easily reloadable

This change allows to "restore" a file multiple times without problems.

If the set already exists, the create command will skip it and we will
flush any existing content to load the new one.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: Do not make things more complicated than they are
Peter Müller [Sat, 18 Dec 2021 12:57:45 +0000 (13:57 +0100)] 
location-importer.in: Do not make things more complicated than they are

Suggested-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: Add country code for AWS's "il-central-1" zone
Peter Müller [Fri, 11 Feb 2022 09:57:47 +0000 (09:57 +0000)] 
location-importer.in: Add country code for AWS's "il-central-1" zone

Reported-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoman: Add man pages for all loc_database_* functions
Michael Tremer [Sun, 2 Jan 2022 14:59:07 +0000 (14:59 +0000)] 
man: Add man pages for all loc_database_* functions

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoMakefile: Split man pages into multiple lists
Michael Tremer [Sun, 2 Jan 2022 14:19:21 +0000 (14:19 +0000)] 
Makefile: Split man pages into multiple lists

This isn't pretty but makes substitution rules easier and working
correctly.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoman: Add man page for loc_database_new
Michael Tremer [Sun, 2 Jan 2022 14:16:01 +0000 (14:16 +0000)] 
man: Add man page for loc_database_new

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoman: Add pages for top level functions
Michael Tremer [Sun, 2 Jan 2022 11:55:00 +0000 (11:55 +0000)] 
man: Add pages for top level functions

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer: Replace "UK" with "GB"
Peter Müller [Sun, 12 Dec 2021 09:11:43 +0000 (10:11 +0100)] 
location-importer: Replace "UK" with "GB"

Apparently, LACNIC does not to proper input validation on supplied
country codes, so people can use "UK", while they probably mean "GB"
instead.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer: Improve regex for catching historic/orphaned data
Peter Müller [Sun, 12 Dec 2021 09:05:15 +0000 (10:05 +0100)] 
location-importer: Improve regex for catching historic/orphaned data

This silences a bunch of warnings due to allocations at APNIC having
country code set to "ZZ", which are completely irrelevant to us.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoProcess LACNIC geofeed as well
Peter Müller [Sat, 11 Dec 2021 21:59:22 +0000 (22:59 +0100)] 
Process LACNIC geofeed as well

This improves country code accurarcy for suballocations within IP space
managed by LACNIC, as the delegated-extended-latest file only provides
country code information at the top level of an allocated network.

Sadly, lacnic.db.gz does not contain descriptions or names of Autonomous
Systems within the space maintained by LACNIC.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer: Set "is_drop" to "True" even in case of conflicts
Peter Müller [Sat, 11 Dec 2021 18:01:54 +0000 (19:01 +0100)] 
location-importer: Set "is_drop" to "True" even in case of conflicts

Previously, any present override for a given network or ASN would have
caused the SQL statement not to conduct anything at all. Since "is_drop"
is the only flag being actually set here, it makes sense to do so in
case of already present overrides as well.

The effect of this is limited: Our own override files are always
considered at last, so in case of conflicts they will be the ultima
ratio. This is an intended behaviour, but slipped my mind when I filed
bug #12728, so this patch can only be seen as a partial solution - the
rest is not a bug, but a feature. :-)

Partially fixes: #12728

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Fix broken build
Michael Tremer [Tue, 23 Nov 2021 11:08:16 +0000 (11:08 +0000)] 
debian: Fix broken build

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Remove riscv64 which doesn't build
Michael Tremer [Tue, 23 Nov 2021 10:20:05 +0000 (10:20 +0000)] 
debian: Remove riscv64 which doesn't build

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoRevert "debian: dh no longer knows "--with python3""
Michael Tremer [Tue, 23 Nov 2021 10:12:41 +0000 (10:12 +0000)] 
Revert "debian: dh no longer knows "--with python3""

This reverts commit 2ca0603f557dc47c3aba2ccc2aa6447ee61e1a03.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Add builds for Debian Bookworm and riscv64
Michael Tremer [Sat, 20 Nov 2021 15:30:01 +0000 (15:30 +0000)] 
debian: Add builds for Debian Bookworm and riscv64

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: dh no longer knows "--with python3"
Michael Tremer [Sat, 20 Nov 2021 15:25:42 +0000 (15:25 +0000)] 
debian: dh no longer knows "--with python3"

This does not seem to be necessary any more since the build works fine
without the switch.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoBump release to 0.9.9 0.9.9
Michael Tremer [Sat, 20 Nov 2021 15:13:33 +0000 (15:13 +0000)] 
Bump release to 0.9.9

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Update libloc1.symbols
Michael Tremer [Sat, 20 Nov 2021 15:11:04 +0000 (15:11 +0000)] 
debian: Update libloc1.symbols

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: Add Spamhaus DROP lists
Peter Müller [Mon, 1 Nov 2021 18:24:37 +0000 (19:24 +0100)] 
location-importer.in: Add Spamhaus DROP lists

A while ago, it was discussed whether or not libloc should become an
"opinionated database", i. e. including any information on a network's
reputation.

In general, this idea was dismissed as libloc is neither intended nor
suitable for such tasks, and we do not want to make (political?)
decisions like these for various reasons. All we do is to provide a
useful location database in a neutral way, and leave it up to our users
on how to react on certain results.

However, there is a problematic area. Take AS55303 as an example: We
_know_ this is to be a dirty network, tampering with RIR data and
hijacking IP space, and strongly recommend against processing any
connection originating from or directed to it.

Since it appears to be loaded with proxies used by miscreants for
abusive purposes, all we can do at the time of writing is to flag it
as "anonymous proxy", but we lack possibility of telling our users
something like "this is not a safe area". The very same goes for known
bulletproof ISPs, IP hijackers, and so forth.

This patch therefore suggests to populate the "is_drop" flag introduced
in libloc 0.9.8 (albeit currently unused in production) with the
contents of Spamhaus' DROP lists (https://www.spamhaus.org/drop/), to
have at least the baddest of the bad covered. The very same lists are,
in fact, included in popular IPS rulesets as well - a decent amount of
IPFire users is therefore likely to have them already enabled, but in a
very costly way.

It is not planned to go further, partly because there is no other feed
publicly available, which would come with the same intention,
volatility, and FP rate.

The third version of this patch makes use of an auxiliary function to
sanitise ASNs, hence avoiding boilerplate code, and treats any line
starting with a semicolon as a comment, which should be sufficient.
Further, extracting ASNs from the ASN-DROP feed is done in a more clear
way, avoiding code snippets hard to read.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer: Introduce auxiliary function to sanitise ASNs
Peter Müller [Mon, 1 Nov 2021 18:24:14 +0000 (19:24 +0100)] 
location-importer: Introduce auxiliary function to sanitise ASNs

The third version of this patch does this in an even more Pythonic way.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter.py: Import JPNIC feed as well
Peter Müller [Sat, 23 Oct 2021 06:54:23 +0000 (08:54 +0200)] 
importer.py: Import JPNIC feed as well

This adds names for - at the time of writing - 421 ASNs which were missing
before, as JPNIC does not mirror (all) information back to APNIC.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation.txt: Improve manpage
Peter Müller [Sun, 10 Oct 2021 16:45:48 +0000 (18:45 +0200)] 
location.txt: Improve manpage

* Document "location version" feature.
* Improve section for reporting bugs in order to make bug reporting
  easier.

Fixes: #12698
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Rename "match" functions to "matches"
Michael Tremer [Thu, 30 Sep 2021 10:36:56 +0000 (10:36 +0000)] 
network: Rename "match" functions to "matches"

Gramatically, this makes more sense.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Make loc_network_match_country_code match special countries
Michael Tremer [Thu, 30 Sep 2021 10:34:09 +0000 (10:34 +0000)] 
network: Make loc_network_match_country_code match special countries

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agocountry: Make country codes beginning with X invalid
Michael Tremer [Thu, 30 Sep 2021 10:23:11 +0000 (10:23 +0000)] 
country: Make country codes beginning with X invalid

According to ISO3166, they are only allowed for "private use".

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agocountry: Add function that returns flags for special country
Michael Tremer [Thu, 30 Sep 2021 10:19:46 +0000 (10:19 +0000)] 
country: Add function that returns flags for special country

This allows for libloc to be better integrated into third-party
software.

If we would add extra flags, we would be able to extend it in libloc
without touching any third-party software.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoRemove overwriting default CPPFLAGS for libloc-internal
Michael Tremer [Thu, 30 Sep 2021 09:39:33 +0000 (09:39 +0000)] 
Remove overwriting default CPPFLAGS for libloc-internal

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoRemove LOC_EXPORT from loc_network_to_database_v1/loc_network_new_from_database_v1
Michael Tremer [Thu, 30 Sep 2021 09:29:22 +0000 (09:29 +0000)] 
Remove LOC_EXPORT from loc_network_to_database_v1/loc_network_new_from_database_v1

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoMake loc_network_tree_* functions propertly private
Michael Tremer [Thu, 30 Sep 2021 09:26:20 +0000 (09:26 +0000)] 
Make loc_network_tree_* functions propertly private

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