Bug#940581: Unrecognized country Kosovo

2019-09-18 Thread Patrick Matthäi
Am 17.09.2019 um 17:44 schrieb Pat Suwalski:
> On 2019-09-17 11:00 a.m., Patrick Matthäi wrote:
>> Could you test the patch below? It should restore the behaviour for
>> those IPs. then they are (again) listed as "serbia":
>
> That patch did not help. I looked into it further, and the error is
> triggered on the other "Unrecognized country code" circa line 1100.
>
> This very similar patch makes it work:
>
> --- geoip-csv-to-dat.cpp.orig    2019-09-17 07:31:42.0 -0400
> +++ geoip-csv-to-dat.cpp    2019-09-17 11:34:59.180224941 -0400
> @@ -1103,6 +1109,9 @@
>  if (csv_fields[CSV_FIELD_COUNTRY_CODE] == "AN") {
>  csv_fields[CSV_FIELD_COUNTRY_CODE] = "CW";
>  }
> +    else if (csv_fields[CSV_FIELD_COUNTRY_CODE] == "XK") {
> +    csv_fields[CSV_FIELD_COUNTRY_CODE] = "RS";
> +    }
>
>  const int countryid =
> GeoIP_id_by_code(csv_fields[CSV_FIELD_COUNTRY_CODE].c_str());
>  if (countryid == 0) {
>
>
> Note, the other patch circa line 873 is not needed. So, perhaps there
> is some nicer solution to fix this method, but the special case does
> work.

Thanks for testing, I have adopted your patch. I didnt had the time to
test it yesterday, but hmm for what I have got the code on the other
lines... ;-)


-- 
/*
Mit freundlichem Gruß / With kind regards,
 Patrick Matthäi
 GNU/Linux Debian Developer

  Blog: http://www.linux-dev.org/
E-Mail: pmatth...@debian.org
patr...@linux-dev.org
*/



Bug#940581: Unrecognized country Kosovo

2019-09-17 Thread Pat Suwalski

On 2019-09-17 11:00 a.m., Patrick Matthäi wrote:

Could you test the patch below? It should restore the behaviour for
those IPs. then they are (again) listed as "serbia":


That patch did not help. I looked into it further, and the error is 
triggered on the other "Unrecognized country code" circa line 1100.


This very similar patch makes it work:

--- geoip-csv-to-dat.cpp.orig   2019-09-17 07:31:42.0 -0400
+++ geoip-csv-to-dat.cpp2019-09-17 11:34:59.180224941 -0400
@@ -1103,6 +1109,9 @@
if (csv_fields[CSV_FIELD_COUNTRY_CODE] == "AN") {
csv_fields[CSV_FIELD_COUNTRY_CODE] = "CW";
}
+   else if (csv_fields[CSV_FIELD_COUNTRY_CODE] == "XK") {
+   csv_fields[CSV_FIELD_COUNTRY_CODE] = "RS";
+   }

 	const int countryid = 
GeoIP_id_by_code(csv_fields[CSV_FIELD_COUNTRY_CODE].c_str());

if (countryid == 0) {


Note, the other patch circa line 873 is not needed. So, perhaps there is 
some nicer solution to fix this method, but the special case does work.


--Pat



Bug#940581: Unrecognized country Kosovo

2019-09-17 Thread Patrick Matthäi
Am 17.09.2019 um 16:40 schrieb Pat Suwalski:
> Package: geoip-bin
> Version: 1.6.12-4
>
> I was trying out the fix for another issue, generating a fresh
> geoip-database package using the latest version of the tools (and lib
> and -dev).
sick, just uploaded a new version..
>
> It fails on interpreting the new (unofficial?) XK country code for
> Kosovo:
>
> # Building geoip v4 country database.
> /usr/lib/geoip/geoip-generator -v -4 \
> --info="$(date -u +'GEO-106FREE %Y%m%d Build' -d 'Tue Sep 17
> 10:14:06 EDT 2019')" \
> -o /tmp/geoip-database-20190917/tmp/GeoIP.dat GeoIPCountryWhois.csv
> /usr/lib/geoip/geoip-generator: Reading CSV and building the trie
> /usr/lib/geoip/geoip-generator:GeoIPCountryWhois.csv:30816:
> Unrecognized country code: XK
> make[1]: *** [debian/rules:16: override_dh_install] Error 65
> make[1]: Leaving directory '/tmp/geoip-database-20190917'
> make: *** [debian/rules:8: binary] Error 2
>
> This seems odd to me, as the "Country-Locations" files do have the entry:
>
> 831053,en,EU,Europe,XK,Kosovo,0
>
> /usr/share/geoip/countryInfo.txt from geoip-bin also contains the XK
> entry.

This is only for the v2 => v1 conversion

>
> I assume geoip-csv-to-dat.cpp uses some other source for the country
> data that does not include it.
Yes, the geoip API itself
>
> grepping out the handful of "831053" lines from
> GeoLite2-Country-Blocks-IPv4.csv allows the package to build.

Could you test the patch below? It should restore the behaviour for
those IPs. then they are (again) listed as "serbia":


Index: src/geoip-csv-to-dat.cpp
===
--- src/geoip-csv-to-dat.cpp    (Revision 8838)
+++ src/geoip-csv-to-dat.cpp    (Arbeitskopie)
@@ -873,11 +873,18 @@

    // Country ID
    int country_id;
-   if (info[1] != "AN")
+
+   if (info[1] == "AN") {
+   country_id = GeoIP_id_by_code("CW");
+   }
+   else if (info[1] == "XK") {
+   country_id = GeoIP_id_by_code("RS");
+   }
+   else {
    country_id = GeoIP_id_by_code(info[1].c_str());
-   else
-   country_id = GeoIP_id_by_code("CW");
+   }

+
    if (country_id == 0) {
    error(EX_DATAERR, 1, dat_file_name.c_str(),
input_line_number,
  "Unrecognized country code: %s", info[1].c_str());

-- 
/*
Mit freundlichem Gruß / With kind regards,
 Patrick Matthäi
 GNU/Linux Debian Developer

  Blog: http://www.linux-dev.org/
E-Mail: pmatth...@debian.org
patr...@linux-dev.org
*/



Bug#940581: Unrecognized country Kosovo

2019-09-17 Thread Pat Suwalski

Package: geoip-bin
Version: 1.6.12-4

I was trying out the fix for another issue, generating a fresh 
geoip-database package using the latest version of the tools (and lib 
and -dev).


It fails on interpreting the new (unofficial?) XK country code for Kosovo:

# Building geoip v4 country database.
/usr/lib/geoip/geoip-generator -v -4 \
	--info="$(date -u +'GEO-106FREE %Y%m%d Build' -d 'Tue Sep 17 10:14:06 
EDT 2019')" \

-o /tmp/geoip-database-20190917/tmp/GeoIP.dat GeoIPCountryWhois.csv
/usr/lib/geoip/geoip-generator: Reading CSV and building the trie
/usr/lib/geoip/geoip-generator:GeoIPCountryWhois.csv:30816: Unrecognized 
country code: XK

make[1]: *** [debian/rules:16: override_dh_install] Error 65
make[1]: Leaving directory '/tmp/geoip-database-20190917'
make: *** [debian/rules:8: binary] Error 2

This seems odd to me, as the "Country-Locations" files do have the entry:

831053,en,EU,Europe,XK,Kosovo,0

/usr/share/geoip/countryInfo.txt from geoip-bin also contains the XK entry.

I assume geoip-csv-to-dat.cpp uses some other source for the country 
data that does not include it.


grepping out the handful of "831053" lines from 
GeoLite2-Country-Blocks-IPv4.csv allows the package to build.