]> git.ipfire.org Git - location/libloc.git/log
location/libloc.git
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>
2 years agostringpool: Make functions properly private
Michael Tremer [Thu, 30 Sep 2021 09:23:29 +0000 (09:23 +0000)] 
stringpool: Make functions properly private

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agotest: Build an internal library for tests
Michael Tremer [Thu, 30 Sep 2021 09:21:00 +0000 (09:21 +0000)] 
test: Build an internal library for tests

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Drop useless loc_network_match_asn function
Michael Tremer [Wed, 29 Sep 2021 18:22:51 +0000 (18:22 +0000)] 
network: Drop useless loc_network_match_asn function

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Drop redundant loc_network_match_flag
Michael Tremer [Wed, 29 Sep 2021 18:21:31 +0000 (18:21 +0000)] 
network: Drop redundant loc_network_match_flag

There is loc_network_has_flag which does exactly the same

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoconfigure: Enable -fno-semantic-interposition by default
Michael Tremer [Wed, 29 Sep 2021 18:17:31 +0000 (18:17 +0000)] 
configure: Enable -fno-semantic-interposition by default

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodatabase: Make IP address const for lookup
Michael Tremer [Sat, 4 Sep 2021 15:11:48 +0000 (15:11 +0000)] 
database: Make IP address const for lookup

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Ensure changelog distribution is tagged
Valters Jansons [Thu, 23 Sep 2021 10:23:50 +0000 (13:23 +0300)] 
debian: Ensure changelog distribution is tagged

UNRELEASED should not be left as-is when actually releasing.
The latest changelog entry now point at unstable instead.

The simple d/genchangelog.sh now does `dch -r ''` automatically
to ensure this distribution update doesn't get lost along the way
on future invocations.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoBump release to 0.9.8 0.9.8
Michael Tremer [Tue, 21 Sep 2021 10:30:19 +0000 (10:30 +0000)] 
Bump release to 0.9.8

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoMove include files to /usr/include/libloc
Michael Tremer [Sat, 4 Sep 2021 13:38:44 +0000 (13:38 +0000)] 
Move include files to /usr/include/libloc

There was a discrepancy between the paths in the build environment and
the installed headers which could not be included in any third-party
software.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation: Implement listing bogons
Michael Tremer [Thu, 2 Sep 2021 13:25:37 +0000 (13:25 +0000)] 
location: Implement listing bogons

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agopython: Permit passing family to database enumerator
Michael Tremer [Thu, 2 Sep 2021 13:22:23 +0000 (13:22 +0000)] 
python: Permit passing family to database enumerator

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agonetwork: Move some helper functions into network.h
Michael Tremer [Thu, 2 Sep 2021 13:20:16 +0000 (13:20 +0000)] 
network: Move some helper functions into network.h

These are used in multiple places, but there is no good place where
those should go, yet.

To make them usable in more places, I am temporarily moving them here.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: Braindead me accidentally forgot a "break" statement
Peter Müller [Sun, 8 Aug 2021 21:31:58 +0000 (23:31 +0200)] 
location-importer.in: Braindead me accidentally forgot a "break" statement

This one apparently went down the drain between these two patches:
- https://patchwork.ipfire.org/project/location/patch/20210522125758.28770-1-peter.mueller@ipfire.org/
- https://patchwork.ipfire.org/project/location/patch/aefd1904-4b38-f5cf-ab1d-9d69636cf914@ipfire.org/

Due to other safeguards, the current damage in production is limited to:

location=# SELECT * FROM networks WHERE country = 'ZZ';
      network       | country | original_countries | source
--------------------+---------+--------------------+--------
 130.195.64.0/19    | ZZ      | {ZZ}               | APNIC
 130.195.96.0/19    | ZZ      | {ZZ}               | APNIC
 122.252.24.0/21    | ZZ      | {ZZ}               | APNIC
 2406:840:10::/48   | ZZ      | {ZZ}               | APNIC
 2406:840:fd0f::/48 | ZZ      | {ZZ}               | APNIC
(5 rows)

Fixes: #12673
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: Attempt to provide meaningful AS names if organisation handles...
Peter Müller [Mon, 19 Jul 2021 21:34:40 +0000 (21:34 +0000)] 
location-importer.in: Attempt to provide meaningful AS names if organisation handles are missing

A decent amount of autnum objects - especially, but not exclusively in
the APNIC sector - does not contain a link to an organisation handle.

In such cases, this patch is going to use the first description line of
the atunum object in question (if available) as a string for its name.
The overwhelming majority of affected ASNs contains a valuable
information there, so this is almost as good as having an organisation
handle linked to it.

Fixes: #12660
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Clean up 0.9.7 changelog
Valters Jansons [Sun, 11 Jul 2021 16:50:24 +0000 (19:50 +0300)] 
debian: Clean up 0.9.7 changelog

- Update for maintainer name and email address, as to reflect who
  actually prepared this release of the package. It was not me,
  but I was selected due to having the first commit on the package.

  To mitigate against this, when running the `debchange --release`
  (`dch -r`) command, environment variables DEBFULLNAME and DEBEMAIL
  should be configured properly for the current user.

- Removal of NMU comment on my name, as I am not really doing a
  non-maintainer upload. I would say the 'NMU' message is fairly
  useless on this repository, as it is self-maintained here.

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agostringpool: Avoid memory leak if mmap() fails
Michael Tremer [Sun, 11 Jul 2021 12:27:43 +0000 (12:27 +0000)] 
stringpool: Avoid memory leak if mmap() fails

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agostringpool: Slightly refactor initialization to help the compiler understand
Michael Tremer [Sun, 11 Jul 2021 12:21:31 +0000 (12:21 +0000)] 
stringpool: Slightly refactor initialization to help the compiler understand

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agostringpool: Do not call strlen() on potential NULL pointer
Michael Tremer [Sun, 11 Jul 2021 12:10:48 +0000 (12:10 +0000)] 
stringpool: Do not call strlen() on potential NULL pointer

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agostringpool: Allow adding empty strings
Michael Tremer [Sun, 11 Jul 2021 11:56:50 +0000 (11:56 +0000)] 
stringpool: Allow adding empty strings

This is what we do when we initialize the stringpool

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agowriter: Break when a network cound not be allocated
Michael Tremer [Sun, 11 Jul 2021 11:44:28 +0000 (11:44 +0000)] 
writer: Break when a network cound not be allocated

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoconfigure: Add option to enable GCC's -fanalyzer
Michael Tremer [Sun, 11 Jul 2021 11:37:44 +0000 (11:37 +0000)] 
configure: Add option to enable GCC's -fanalyzer

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter: Do not try to initialise a column that cannot be NULL with NULL
Michael Tremer [Fri, 9 Jul 2021 18:30:28 +0000 (18:30 +0000)] 
importer: Do not try to initialise a column that cannot be NULL with NULL

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoBump version to 0.9.7 0.9.7
Michael Tremer [Fri, 9 Jul 2021 17:12:55 +0000 (17:12 +0000)] 
Bump version to 0.9.7

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Attribute all maintainers in changlog
Valters Jansons [Sun, 13 Jun 2021 16:16:25 +0000 (19:16 +0300)] 
debian: Attribute all maintainers in changlog

This commit further builds on historical changelog modifications,
to properly attribute all authors of the commits.

An additional d/genchangelog.sh script has been added. This allows
generation of changelog entries, internally using `debchange` (`dch`).
The script accepts an argument, which is the commit range to generate
entries for. Each commit's subject line (first line of body) is used,
along with author name and email. This information is added to the
changelog. Automatic detection (via `debchange` built-in functionality)
is used to determine whether these entries should be added to an
existing version number. If there is no UNRELEASED version, then a new
version is automatically tagged.

The new version tag will usually need to be modified, for example,
replacing an automatically generated 0.9.6-2 with 0.9.7-1.

The final release change (s/UNRELEASED/unstable/) needs to be done
manually as well, when the Git tag is actually being tagged.
`dch -r` can be useful for this particular purpose.

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-import.in: optimise regular expression for filtering ASN allocations to...
Peter Müller [Sun, 20 Jun 2021 10:43:07 +0000 (12:43 +0200)] 
location-import.in: optimise regular expression for filtering ASN allocations to other RIRs when parsing ARIN AS names file

https://lists.ipfire.org/pipermail/location/2021-June/000394.html

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 agodebian: Add dpkg's symbols file
Valters Jansons [Fri, 11 Jun 2021 07:51:07 +0000 (10:51 +0300)] 
debian: Add dpkg's symbols file

There are muiltiple standards of listing symbols throughout the Linux
ecosystem. For `dpkg`, a d/package.symbols file tracks symbols, and in
which version they were added in. This is then used to allow dependency
checks/resolution.

See man:dpkg-gensymbols(1) for details about the generation,
and man:dpkg-shlibdeps(1) for how the symbols file ends up being used.

This commit adds a d/libloc1.symbols file, containing the current state
of the symbols. There is now also a d/gensymbols.sh script, which
generates this symbols file. The script tries to determine what Git
tags need to be checked for changes in symbols, by looking at current
maximum version referenced in symbols file.

After checking tags, the current revision is also processed, to allow
building symbols file for a yet unreleased version (prior to tagging it).
This is to allow symbols changes to be included in a tag.

Do keep in mind, that for the workflow above, when running the script,
the d/changelog file should contain information about what version the
current revision will be released at (potentially tagged as UNRELEASED
in the d/changelog file). Otherwise, if there is no version tagged,
the `dpkg-gensymbols` tool will use the old version information,
in turn incorrectly attributing new symbols to an old version.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agocountries: Fix matching invalid country codes
Michael Tremer [Thu, 10 Jun 2021 09:37:22 +0000 (09:37 +0000)] 
countries: Fix matching invalid country codes

When an invalid country code is entered, loc_country_new returns an
error which is interpreted as a match to the list since we check for a
non-zero return code.

Any invalid country codes are now silently ignored and not considered a
match.

Fixes: #12620 - "location list-networks-by-cc" returns garbage
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: import additional IP information for Amazon AWS IP networks
Peter Müller [Tue, 8 Jun 2021 09:55:41 +0000 (09:55 +0000)] 
location-importer.in: import additional IP information for Amazon AWS IP networks

Amazon publishes information regarding some of their IP networks
primarily used for AWS cloud services in a machine-readable format. To
improve libloc lookup results for these, we have little choice other
than importing and parsing them.

Unfortunately, there seems to be no machine-readable list of the
locations of their data centers or availability zones available. If
there _is_ any, please let the author know.

The second version of this patch adds a meaningful description for the
"source" column in the overrides tables, to make introduced changes
less intransparent.

Fixes: #12594
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: add source column for overrides as well
Peter Müller [Tue, 8 Jun 2021 09:55:40 +0000 (09:55 +0000)] 
location-importer.in: add source column for overrides as well

This allows us to track changes introduced by IP feeds from 3rd parties,
such as Amazon AWS, on the SQL server side.

In order not to break existing tables (which would required TRUNCATE),
there currently is no constraint set for the new column, but "NOT NULL"
is planned in the future.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: Import (technical) AS names from ARIN
Peter Müller [Tue, 8 Jun 2021 17:03:07 +0000 (17:03 +0000)] 
location-importer.in: Import (technical) AS names from ARIN

ARIN and LACNIC, unfortunately, do not seem to publish data containing
human readable AS names. For the former, we at least have a list of
tecnical names, which this patch fetches and inserts into the autnums
table.

While some of them do not seem to be suitable for human consumption (i.
e. being very cryptic), providing these data might be helpful
neverthelesss.

The second version of this patch contains some additional remarks on
efficient Python coding style from Michael, doing things more "pythonic".

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoImplement an additional flag for hostile networks safe to drop
Peter Müller [Fri, 4 Jun 2021 15:57:30 +0000 (17:57 +0200)] 
Implement an additional flag for hostile networks safe to drop

This patch implements an additional flag intended for networks and
Autonomous Systems being considered hostile. While libloc does not and
should not be an opinionated database, reality shows it is being used
this way.

Hereby, we assign "XD" (drop) as a custom country code for networks
being flagged this way. According to ISO, "XA" to "XZ" are reserved for
"user-assgined codes" (https://www.iso.org/glossary-for-iso-3166.html),
so this is a safe thing to do.

This patch does not interfere with "A1" to "A3", which we currently
assign outside standardised country code ranges for historical reasons.

Neither does it specify any policy or source for tagging networks with a
"drop" flag. Doing so is beyond the scope of this - technical -
approach.

To avoid confusions with the SQL "DROP" command, "is_drop" will be used
as a column name for database operations.

Thanks to Michael for his remarks and ideas during the run-up.

Cc: 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 agolocation-importer.in: track original countries more pythonic
Peter Müller [Wed, 2 Jun 2021 21:00:22 +0000 (23:00 +0200)] 
location-importer.in: track original countries more pythonic

https://lists.ipfire.org/pipermail/location/2021-May/000377.html

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 agolocation-importer.in: track original countries as well
Peter Müller [Sun, 30 May 2021 08:50:04 +0000 (10:50 +0200)] 
location-importer.in: track original countries as well

This helps us to determine how many network objects have more than one
country set, and what their original country code set looked like.

The third version of this patch uses ALTER TABLE to add the column for
original countries, preventing existing SQL setups from breaking, and is
correctly based against the current "master" branch.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agoimporter.py: add source information for RIR data feeds
Peter Müller [Sat, 22 May 2021 20:33:52 +0000 (20:33 +0000)] 
importer.py: add source information for RIR data feeds

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: keep track of sources for networks, ASNs, and organisations
Peter Müller [Sat, 22 May 2021 20:33:51 +0000 (20:33 +0000)] 
location-importer.in: keep track of sources for networks, ASNs, and organisations

This allows us to trace back concrete changes or anomalies to their RIR
source, without having to parse everything again. Further, it enables
adding 3rd party sources such as IP feeds from Amazon, without loosing
track of the changes introduced by them.

The second version of this patchset uses ALTER TABLE to add the source
columns, avoiding breaking existing SQL setups.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation.in: fix search_networks() function call
Peter Müller [Sun, 16 May 2021 20:35:15 +0000 (22:35 +0200)] 
location.in: fix search_networks() function call

Fixes: #12617
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agolocation-importer.in: emit warnings due to unknown country code for valid networks...
Peter Müller [Mon, 3 May 2021 17:14:29 +0000 (19:14 +0200)] 
location-importer.in: emit warnings due to unknown country code for valid networks only

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>
2 years agodebian: Drop unintended files from location-python
Valters Jansons [Fri, 16 Apr 2021 13:06:10 +0000 (16:06 +0300)] 
debian: Drop unintended files from location-python

_location.la gets built and installed to site-packages/, however
an .la file is not expected to reside in the Python root. Additionally,
the dependency library listed does not have its respective .la file
installed. Further complicating the situation, dh-python moves the
site-packages/ files to dist-packages/ silently which then results in
a broken libdir left behind in the .la file.

The only reason the file is there is that it gets built inside the
source directory, which gets copied entirely to location-python package
as-is. Considering the situation, this commit ensures the .la files is
not packaged by deleting it from the package files subdirectory.

location-importer package pulls in two Python (.py) files from the
source directory. These files should not be included in the
location-python package as a result.

Resolves: lintian:
  unknown-file-in-python-module-directory,
  incorrect-libdir-in-la-file,
  non-empty-dependency_libs-in-la-file,
  binaries-have-file-conflict

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2 years agodebian: Add all temporary files to Gitignore
Valters Jansons [Fri, 16 Apr 2021 13:06:05 +0000 (16:06 +0300)] 
debian: Add all temporary files to Gitignore

New packages have been added since the inception of the .gitignore and
as a result during build we see directories such as location-importer/
and files such as location-importer.debhelper.log.

This commit ensures all temporary subdirectories, and additional
generic build artifact files, are ignored by Git.

The subdirectory exceptions to this rule are:

- d/patches/ which may be used by Quilt
  considering the source format is '3.0 (quilt)',

- d/source/ for the format file,

- d/tests/ which may be used by autopkgtest
  to specify what test suites exist for the source.
  See: https://salsa.debian.org/ci-team/autopkgtest/-/raw/debian/5.16/doc/README.package-tests.rst

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agosystemd: Add Documentation= to location-update
Valters Jansons [Fri, 16 Apr 2021 13:06:12 +0000 (16:06 +0300)] 
systemd: Add Documentation= to location-update

Systemd units are expected to provide some documentation information
such as manpages, or direct links, which provide more details about
that unit. This commit simply links location-update.service to the
manual for location(8) followed by a fallback to the online manual.

See: https://manpages.debian.org/buster/systemd/systemd.unit.5.en.html#%5BUNIT%5D_SECTION_OPTIONS

Resolves: lintian: systemd-service-file-missing-documentation-key

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Add watch configuration for uscan
Valters Jansons [Fri, 16 Apr 2021 13:06:11 +0000 (16:06 +0300)] 
debian: Add watch configuration for uscan

Packages defined as '3.0 (quilt)' are expected to provide information
about how the latest upstream information can be obtained,
as a special d/watch file. This can then get used by uscan(1).

To see how the metadata is utilized, and how the network requests
are made behind the scenes, you can locally run:
$ uscan --no-download --verbose --debug

Resolves: lintian: debian-watch-file-is-missing

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Set 'Multi-Arch: foreign' hint for Python
Valters Jansons [Fri, 16 Apr 2021 13:06:07 +0000 (16:06 +0300)] 
debian: Set 'Multi-Arch: foreign' hint for Python

Due to the invocation of py3compile (via dh-python) in location-importer
and location-python packages, those packages have different bytecode for
varying architectures, and as a result are not 'Multi-Arch: same'.

Resolves: lintian: multi-arch-same-package-calls-pycompile

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Add examples/python/ to documentation
Valters Jansons [Fri, 16 Apr 2021 13:06:09 +0000 (16:06 +0300)] 
debian: Add examples/python/ to documentation

Resolves: lintian: package-does-not-install-examples

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Update copyright format link to use HTTPS
Valters Jansons [Fri, 16 Apr 2021 13:06:08 +0000 (16:06 +0300)] 
debian: Update copyright format link to use HTTPS

Resolves: lintian: insecure-copyright-format-uri

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Move libloc1 to 'libs' section
Valters Jansons [Fri, 16 Apr 2021 13:06:06 +0000 (16:06 +0300)] 
debian: Move libloc1 to 'libs' section

Resolves: lintian: wrong-section-according-to-package-name

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agopo: Update translations
Valters Jansons [Thu, 15 Apr 2021 11:42:13 +0000 (14:42 +0300)] 
po: Update translations

POTFILES.in should not contain src/python/__init__.py file as it
is not present in the committed tree. It has its respective .in file
which is present instead.

This commit further ensures po/POTFILES.in generator avoids such
files that Git ignores (using git-check-ignore during find).

Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Rework historical changelog
Valters Jansons [Mon, 12 Apr 2021 13:01:45 +0000 (16:01 +0300)] 
debian: Rework historical changelog

Rewriting history is generally considered a "not-so-good" thing,
however here the historical data does not align with best practises
and therefore it is beneficial to provide a better example going
forward.

There is only one initial release. Everything following that should
list some kind of release notes or changelog, or at the very least
just say something along the lines of "New version" rather than
"Initial release".

In this commit, the Git history is used for this task,
filtering out "Makefile" changes as to retain only changes
that are visible to users, excluding building tooling.

For Debian packages, upon release, the target distribution should be
updated to "unstable" (or "experimental" if preferred for any reason)
when a release is finalized. During development, an invalid
distribution name is expected to be there for tracking unreleased
changes. That is why "UNRELEASED" is the standard way of specifying
ongoing development, being an invalid distribution name itself.

The "(Closes: #XXXXXX)" tag is intended for linking to Debian bug
tracker, such as linking to the initial Intent to Package ticket,
or later update/bugfix tickets. There does not appear to be a bug
tracker in use for this task here, and the XXXXXX bug ticket number
does not take you anywhere. It's therefore better to just remove it.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Add missing '<' in copyright
Valters Jansons [Mon, 12 Apr 2021 12:57:24 +0000 (15:57 +0300)] 
debian: Add missing '<' in copyright

The email address information should be inside brackets. This
commit ensures the missing bracket character issue is remedied.
Reviewed-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Add intltoolize to dh_auto_configure
Valters Jansons [Tue, 6 Apr 2021 11:13:31 +0000 (14:13 +0300)] 
debian: Add intltoolize to dh_auto_configure

Debian has automated building tools that handle source trees directly.
It is expected that you can pick up a source tarball, and with the
appropriate debian/ subtree, a successful build can be produced using
the `debuild` tool. This depends on all the build steps having been
included as part of the debian/rules file (see: `man debuild`).

This commit ensures there is no need to manually run autogen.sh
on a locally extracted source tarball prior to building for Debian.
This is accomplished by adding the `intltoolize` command to the
override_dh_auto_configure step in d/rules.

There is no need to add the `autoreconf` command due to dh-autoreconf
always handling that prior to the dh_auto_configure step.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoBump version to 0.9.6 0.9.6
Michael Tremer [Wed, 31 Mar 2021 14:07:07 +0000 (14:07 +0000)] 
Bump version to 0.9.6

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoRevert "Makefile.am: Do not provide PREFIX value for perl build."
Michael Tremer [Wed, 31 Mar 2021 14:04:48 +0000 (14:04 +0000)] 
Revert "Makefile.am: Do not provide PREFIX value for perl build."

This reverts commit d39d928b4db79e9c32d68d49de47be8b55b3ca92.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agolocation-importer.in: skip networks with unknown country codes
Peter Müller [Tue, 30 Mar 2021 15:47:10 +0000 (17:47 +0200)] 
location-importer.in: skip networks with unknown country codes

There is no sense in parsing and storting networks whose country codes
cannot be found in the ISO-3166-x country code table. This avoids side
effects in applications using the location database, and introduces
another sanity check to compensate bogus RIR data.

On location02, this affects some networks from APNIC (country code: ZZ)
as well as a bunch of smaller allocations within the RIPE region still
tagged to CS or YU (Yugoslavia). To my surprise, no network tagged as SU
(Soviet Union) was found - while the NIC for .su TLD is still
operational. :-)

Applying this patch causes the countries to be processed before
update_whois() is called. In case no countries are present in the SQL
table, this check is silently omitted.

Fixes: #12510
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agolocation-importer.in: process unaligned IP ranges in RIR data files correctly
Peter Müller [Mon, 29 Mar 2021 20:24:36 +0000 (22:24 +0200)] 
location-importer.in: process unaligned IP ranges in RIR data files correctly

The IP range given in an inetnum object apparently not necessarily
matches distinct subnet boundaries. As a result, the current attempt to
calculate its CIDR mask resulted in faulty subnets not covering the
entire IP range.

This patch leaves the task of enumerating subnets to the ipaddress
module itself, which handles things much more robust. Since the output
may contain of several subnets, a list for the inetnum key is necessary
as well as a loop over them when conducting the SQL statements.

Fixes: #12595
Cc: 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>
3 years agodatabase: Free mmapped countries section
Michael Tremer [Mon, 22 Mar 2021 11:42:43 +0000 (11:42 +0000)] 
database: Free mmapped countries section

This was a potential memory leak.

Reported-by: Gisle Vanem <gisle.vanem@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoMakefile.am: Honor DESTDIR when installing perl bindings
Stefan Schantl [Sat, 27 Feb 2021 19:21:10 +0000 (20:21 +0100)] 
Makefile.am: Honor DESTDIR when installing perl bindings

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoMakefile.am: Do not specify CC and LD when building perl module.
Stefan Schantl [Tue, 23 Feb 2021 20:15:57 +0000 (21:15 +0100)] 
Makefile.am: Do not specify CC and LD when building perl module.

Specifing the CC and LD flags is not required because perl MakeMaker
takes care of this.

Fixes #12574.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoMakefile.am: Do not provide PREFIX value for perl build.
Stefan Schantl [Mon, 22 Feb 2021 20:07:21 +0000 (21:07 +0100)] 
Makefile.am: Do not provide PREFIX value for perl build.

This caused to gain the following error when building:

Only one of PREFIX or INSTALL_BASE can be given. Not both.

Using INSTALLDIRS=vendor is the common way to get the modules installed
into the right directories.

Fixes #12573.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agolocation-importer.in: reduce log noise for unusable networks
Peter Müller [Sat, 16 Jan 2021 18:09:39 +0000 (19:09 +0100)] 
location-importer.in: reduce log noise for unusable networks

These are nothing to worry about, which is why debug log facility is
more suitable here than informational or warning.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agolocation-importer.in: delete 6to4 IPv6 space as well
Peter Müller [Sat, 16 Jan 2021 18:05:33 +0000 (19:05 +0100)] 
location-importer.in: delete 6to4 IPv6 space as well

2002::/16 is an anycast prefix for 6to4 scenarios, as specified in RFC
3068. We currently process an announcement from Hurricane Electric for
it, and since it is an anycast network, multiple entities across the
world announce it as well.

Thereof, it does not make sense to include it in the database - as of
today, we do not have a country for it, either.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agolocation-importer.in: fix typo
Peter Müller [Wed, 23 Dec 2020 14:10:52 +0000 (15:10 +0100)] 
location-importer.in: fix typo

Fixes: #12549
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agolocation: Fix list-networks-by-as
Michael Tremer [Mon, 21 Dec 2020 16:25:46 +0000 (16:25 +0000)] 
location: Fix list-networks-by-as

Fixes: #12554
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodebian: Sync version 0.9.5
Michael Tremer [Wed, 2 Dec 2020 17:40:30 +0000 (17:40 +0000)] 
debian: Sync version

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agodatabase: Restart flatten algorithm from the top when a network was dropped
Michael Tremer [Tue, 1 Dec 2020 16:58:29 +0000 (16:58 +0000)] 
database: Restart flatten algorithm from the top when a network was dropped

We used to simply take the first element from the stack after we have
split a network. That is wrong because it is not passing through any
filters and no further subnet checks. It could have therefore been
that the tree was not entirely flat.

Reported-by: Arne Fitzenreiter <arne_f@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Exit find operation early when the list is empty
Michael Tremer [Fri, 27 Nov 2020 15:40:20 +0000 (15:40 +0000)] 
network-list: Exit find operation early when the list is empty

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agopython: Do not check whether an integer is larger than 32 bit on 32 bit arches
Michael Tremer [Fri, 27 Nov 2020 15:37:22 +0000 (15:37 +0000)] 
python: Do not check whether an integer is larger than 32 bit on 32 bit arches

This cannot happen and generated a compiler warning

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agopython: PyList_Size returns ssize_t which is signed
Michael Tremer [Fri, 27 Nov 2020 15:33:06 +0000 (15:33 +0000)] 
python: PyList_Size returns ssize_t which is signed

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoSilence compiler formatting warnings for size_t
Michael Tremer [Fri, 27 Nov 2020 15:31:39 +0000 (15:31 +0000)] 
Silence compiler formatting warnings for size_t

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoconfigure: Adjust man-pages switch with documentation
Michael Tremer [Fri, 27 Nov 2020 15:27:08 +0000 (15:27 +0000)] 
configure: Adjust man-pages switch with documentation

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoas-list/country-list: Set elements list to zero after freeing it
Michael Tremer [Thu, 26 Nov 2020 10:19:26 +0000 (10:19 +0000)] 
as-list/country-list: Set elements list to zero after freeing it

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Add greater elements after the current one
Michael Tremer [Thu, 26 Nov 2020 10:14:18 +0000 (10:14 +0000)] 
network-list: Add greater elements after the current one

The list was otherwise not sorted

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Add more networks to test
Michael Tremer [Thu, 26 Nov 2020 10:14:08 +0000 (10:14 +0000)] 
network-list: Add more networks to test

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork: Copy flags when split into subnets
Michael Tremer [Thu, 26 Nov 2020 09:54:07 +0000 (09:54 +0000)] 
network: Copy flags when split into subnets

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoconfigure: Bump version to 0.9.5
Michael Tremer [Wed, 25 Nov 2020 20:00:46 +0000 (20:00 +0000)] 
configure: Bump version to 0.9.5

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Use clear function to tidy up
Michael Tremer [Wed, 25 Nov 2020 15:24:43 +0000 (15:24 +0000)] 
network-list: Use clear function to tidy up

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Include network header
Michael Tremer [Wed, 25 Nov 2020 15:17:42 +0000 (15:17 +0000)] 
network-list: Include network header

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork: Remove deprecated sort call
Michael Tremer [Wed, 25 Nov 2020 15:17:21 +0000 (15:17 +0000)] 
network: Remove deprecated sort call

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork: Massively improve performance on exclude
Michael Tremer [Wed, 25 Nov 2020 15:16:06 +0000 (15:16 +0000)] 
network: Massively improve performance on exclude

When we check the result for any overlaps, we can cut this short
by walking through both lists from start to end and remember the
last network that we checked.

The next one will by definition be strictly greater and therefore
we do not need to check anything before this any more.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork: Call subnet function with the correct order of arguments
Michael Tremer [Wed, 25 Nov 2020 15:15:33 +0000 (15:15 +0000)] 
network: Call subnet function with the correct order of arguments

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork: Add more excluded networks straight to the to_check list
Michael Tremer [Wed, 25 Nov 2020 15:14:31 +0000 (15:14 +0000)] 
network: Add more excluded networks straight to the to_check list

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork: Do not execute with an error when the excluded result will be empty
Michael Tremer [Wed, 25 Nov 2020 15:13:08 +0000 (15:13 +0000)] 
network: Do not execute with an error when the excluded result will be empty

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetworks: Remove comparing family
Michael Tremer [Wed, 25 Nov 2020 15:11:21 +0000 (15:11 +0000)] 
networks: Remove comparing family

Everything is encoded in IPv6 anyways...

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetworks: Add tests for overlaps function
Michael Tremer [Wed, 25 Nov 2020 14:44:56 +0000 (14:44 +0000)] 
networks: Add tests for overlaps function

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Remove useless comment
Michael Tremer [Wed, 25 Nov 2020 14:44:23 +0000 (14:44 +0000)] 
network-list: Remove useless comment

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Show index when listing networks
Michael Tremer [Wed, 25 Nov 2020 14:43:58 +0000 (14:43 +0000)] 
network-list: Show index when listing networks

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Do not half list when popping the first element
Michael Tremer [Wed, 25 Nov 2020 14:42:26 +0000 (14:42 +0000)] 
network-list: Do not half list when popping the first element

The list was unfortunately halved in size every time an element
was taken from it, which was great for performance, but shortened
the result substantially.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Set elements pointer to NULL so that we know it is empty
Michael Tremer [Wed, 25 Nov 2020 14:41:39 +0000 (14:41 +0000)] 
network-list: Set elements pointer to NULL so that we know it is empty

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agonetwork-list: Check last element before doing binary search
Michael Tremer [Tue, 24 Nov 2020 19:39:35 +0000 (19:39 +0000)] 
network-list: Check last element before doing binary search

This is helpful because very often we walk through a list in
order and are most interested in the last element.

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