location-importer: Fix parsing LACNIC-flavoured inetnums

Message ID 5e2c3c46-f8e5-8b2a-45bf-04c925f65f73@ipfire.org
State Accepted
Commit 2ad36187d81f561223fde1f71cfd51035f5086e0
Headers
Series location-importer: Fix parsing LACNIC-flavoured inetnums |

Commit Message

Peter Müller March 1, 2022, 9:52 p.m. UTC
  My fault, again. :-/

Reported-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 src/python/location-importer.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Michael Tremer March 2, 2022, 4:37 p.m. UTC | #1
Thank you. Does this mean we are getting closer to tagging another release?

-Michael

> On 1 Mar 2022, at 21:52, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> My fault, again. :-/
> 
> Reported-by: Michael Tremer <michael.tremer@ipfire.org>
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
> src/python/location-importer.in | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/python/location-importer.in b/src/python/location-importer.in
> index 83fb5c7..fe13482 100644
> --- a/src/python/location-importer.in
> +++ b/src/python/location-importer.in
> @@ -3,7 +3,7 @@
> #                                                                             #
> # libloc - A library to determine the location of someone on the Internet     #
> #                                                                             #
> -# Copyright (C) 2020-2021 IPFire Development Team <info@ipfire.org>           #
> +# Copyright (C) 2020-2022 IPFire Development Team <info@ipfire.org>           #
> #                                                                             #
> # This library is free software; you can redistribute it and/or               #
> # modify it under the terms of the GNU Lesser General Public                  #
> @@ -691,9 +691,9 @@ class CLI(object):
> 
> 						# How many octets do we need to add?
> 						# (LACNIC does not seem to have a /8 or greater assigned, so the following should suffice.)
> -						if ldigits == 2:
> +						if ldigits == 1:
> 							start_address = start_address[0] + ".0.0/" + start_address[1]
> -						elif ldigits == 3:
> +						elif ldigits == 2:
> 							start_address = start_address[0] + ".0/" + start_address[1]
> 						else:
> 							log.warning("Could not recover IPv4 address from line in LACNIC DB format: %s" % line)
> -- 
> 2.34.1
  
Peter Müller March 2, 2022, 4:41 p.m. UTC | #2
Hello Michael,

> Thank you. Does this mean we are getting closer to tagging another release?

actually, I was thinking of putting this straight into production without tagging another
release. For the latter, I would like to have some additional bugs resolved.

That is, of course, unless the xt_geoip/ipset changes introduced in Core Update 165 / 166
require an updated libloc and/or we don't want to ship a bunch of patches on top of the current
one.

Thanks, and best regards,
Peter Müller

> 
> -Michael
> 
>> On 1 Mar 2022, at 21:52, Peter Müller <peter.mueller@ipfire.org> wrote:
>>
>> My fault, again. :-/
>>
>> Reported-by: Michael Tremer <michael.tremer@ipfire.org>
>> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
>> ---
>> src/python/location-importer.in | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/python/location-importer.in b/src/python/location-importer.in
>> index 83fb5c7..fe13482 100644
>> --- a/src/python/location-importer.in
>> +++ b/src/python/location-importer.in
>> @@ -3,7 +3,7 @@
>> #                                                                             #
>> # libloc - A library to determine the location of someone on the Internet     #
>> #                                                                             #
>> -# Copyright (C) 2020-2021 IPFire Development Team <info@ipfire.org>           #
>> +# Copyright (C) 2020-2022 IPFire Development Team <info@ipfire.org>           #
>> #                                                                             #
>> # This library is free software; you can redistribute it and/or               #
>> # modify it under the terms of the GNU Lesser General Public                  #
>> @@ -691,9 +691,9 @@ class CLI(object):
>>
>> 						# How many octets do we need to add?
>> 						# (LACNIC does not seem to have a /8 or greater assigned, so the following should suffice.)
>> -						if ldigits == 2:
>> +						if ldigits == 1:
>> 							start_address = start_address[0] + ".0.0/" + start_address[1]
>> -						elif ldigits == 3:
>> +						elif ldigits == 2:
>> 							start_address = start_address[0] + ".0/" + start_address[1]
>> 						else:
>> 							log.warning("Could not recover IPv4 address from line in LACNIC DB format: %s" % line)
>> -- 
>> 2.34.1
>
  
Michael Tremer March 2, 2022, 4:44 p.m. UTC | #3
Hello,

> On 2 Mar 2022, at 16:41, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> Hello Michael,
> 
>> Thank you. Does this mean we are getting closer to tagging another release?
> 
> actually, I was thinking of putting this straight into production without tagging another
> release. For the latter, I would like to have some additional bugs resolved.

Do we do this?

> That is, of course, unless the xt_geoip/ipset changes introduced in Core Update 165 / 166
> require an updated libloc and/or we don't want to ship a bunch of patches on top of the current
> one.

Yes, the changes that I committed today and yesterday will bring massive performance improvements and so should at least land in 166.

Best,
-Michael

> 
> Thanks, and best regards,
> Peter Müller
> 
>> 
>> -Michael
>> 
>>> On 1 Mar 2022, at 21:52, Peter Müller <peter.mueller@ipfire.org> wrote:
>>> 
>>> My fault, again. :-/
>>> 
>>> Reported-by: Michael Tremer <michael.tremer@ipfire.org>
>>> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
>>> ---
>>> src/python/location-importer.in | 6 +++---
>>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/src/python/location-importer.in b/src/python/location-importer.in
>>> index 83fb5c7..fe13482 100644
>>> --- a/src/python/location-importer.in
>>> +++ b/src/python/location-importer.in
>>> @@ -3,7 +3,7 @@
>>> #                                                                             #
>>> # libloc - A library to determine the location of someone on the Internet     #
>>> #                                                                             #
>>> -# Copyright (C) 2020-2021 IPFire Development Team <info@ipfire.org>           #
>>> +# Copyright (C) 2020-2022 IPFire Development Team <info@ipfire.org>           #
>>> #                                                                             #
>>> # This library is free software; you can redistribute it and/or               #
>>> # modify it under the terms of the GNU Lesser General Public                  #
>>> @@ -691,9 +691,9 @@ class CLI(object):
>>> 
>>> 						# How many octets do we need to add?
>>> 						# (LACNIC does not seem to have a /8 or greater assigned, so the following should suffice.)
>>> -						if ldigits == 2:
>>> +						if ldigits == 1:
>>> 							start_address = start_address[0] + ".0.0/" + start_address[1]
>>> -						elif ldigits == 3:
>>> +						elif ldigits == 2:
>>> 							start_address = start_address[0] + ".0/" + start_address[1]
>>> 						else:
>>> 							log.warning("Could not recover IPv4 address from line in LACNIC DB format: %s" % line)
>>> -- 
>>> 2.34.1
>>
  

Patch

diff --git a/src/python/location-importer.in b/src/python/location-importer.in
index 83fb5c7..fe13482 100644
--- a/src/python/location-importer.in
+++ b/src/python/location-importer.in
@@ -3,7 +3,7 @@ 
 #                                                                             #
 # libloc - A library to determine the location of someone on the Internet     #
 #                                                                             #
-# Copyright (C) 2020-2021 IPFire Development Team <info@ipfire.org>           #
+# Copyright (C) 2020-2022 IPFire Development Team <info@ipfire.org>           #
 #                                                                             #
 # This library is free software; you can redistribute it and/or               #
 # modify it under the terms of the GNU Lesser General Public                  #
@@ -691,9 +691,9 @@  class CLI(object):
 
 						# How many octets do we need to add?
 						# (LACNIC does not seem to have a /8 or greater assigned, so the following should suffice.)
-						if ldigits == 2:
+						if ldigits == 1:
 							start_address = start_address[0] + ".0.0/" + start_address[1]
-						elif ldigits == 3:
+						elif ldigits == 2:
 							start_address = start_address[0] + ".0/" + start_address[1]
 						else:
 							log.warning("Could not recover IPv4 address from line in LACNIC DB format: %s" % line)