From c9d4d99a43fe8a8ae10315a86fb7ada9a4e5d599 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 17 Oct 2020 07:41:18 +0200 Subject: sync with Fedora and rename to IP2location rebuild for #remirepo with release = 0 to manage update from old version --- IP2Location-8.0.9-adebc0ef.patch | 711 ------------------------------- IP2Location-8.0.9-rpmlint.patch | 877 --------------------------------------- IP2Location.spec | 12 +- 3 files changed, 10 insertions(+), 1590 deletions(-) delete mode 100644 IP2Location-8.0.9-adebc0ef.patch delete mode 100644 IP2Location-8.0.9-rpmlint.patch diff --git a/IP2Location-8.0.9-adebc0ef.patch b/IP2Location-8.0.9-adebc0ef.patch deleted file mode 100644 index bb3940a..0000000 --- a/IP2Location-8.0.9-adebc0ef.patch +++ /dev/null @@ -1,711 +0,0 @@ -diff --git a/README.md b/README.md -index 85a3d1f..806b3cd 100644 ---- a/README.md -+++ b/README.md -@@ -46,6 +46,12 @@ For more details, please visit: - * Use the IPv4 BIN file if you just need to query IPv4 addresses. - * Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses. - -+# NOTES -+If you encountered **error while loading shared libraries** in linux platform, that could be due to the shared library was saved into **usr/local/lib** that might not be the default library path. You can run the below command -+``` -+ldconfig /usr/local/lib -+``` -+ - # Support - Email: support@ip2location.com. - URL: [https://www.ip2location.com](https://www.ip2location.com) -diff --git a/contrib/IP2Location.spec b/contrib/IP2Location.spec -index 7b76cb8..8fed016 100644 ---- a/contrib/IP2Location.spec -+++ b/contrib/IP2Location.spec -@@ -3,12 +3,10 @@ - Name: IP2Location - Summary: C library for mapping IP address to geolocation information - Version: %{version} --Release: 5%{?dist} --Group: System Environment/Libraries -+Release: 6%{?dist} - License: MIT - URL: http://www.ip2location.com/ --Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}.tar.gz --BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -+Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}/%{name}-%{version}.tar.gz - BuildRequires: libtool - - -@@ -26,7 +24,6 @@ the included downloader. - - %package devel - Summary: Static library and header files for the ip2location library --Group: Development/C - Requires: %{name} = %{version}-%{release} - Provides: %{name}-devel = %{version}-%{release} - -@@ -51,63 +48,60 @@ perl -pi -e 's/-Wno-unused-result//' configure.ac - - %build - sh ./bootstrap --autoreconf -fi -+autoreconf -fiv - - %configure --disable-static --make clean --make %{?_smp_mflags} COPTS="$RPM_OPT_FLAGS" -+%make_build COPTS="$RPM_OPT_FLAGS" - - # convert CSV to BIN - make -C data convert - -+ - %check - LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH make check - - - %install --rm -rf %{buildroot} -- --make install DESTDIR=%{buildroot} -+%make_install - - # cleanup - rm -f %{buildroot}%{_libdir}/*.*a - - # tools - install -d %{buildroot}%{_datadir}/%{name}/tools --cp tools/download.pl %{buildroot}%{_datadir}/%{name}/tools -+install -pm 0755 tools/download.pl %{buildroot}%{_datadir}/%{name}/tools - - # database directory - install -d %{buildroot}%{_datadir}/%{name}/ - - --%post -p /sbin/ldconfig -- --%postun -p /sbin/ldconfig -- -- --%clean --rm -rf %{buildroot} -- - %files --%defattr(644,root,root,755) -+%license COPYING LICENSE.TXT - --%doc AUTHORS ChangeLog COPYING README.md LICENSE.TXT NEWS INSTALL LICENSE.TXT -+%doc AUTHORS ChangeLog README.md NEWS - --%attr(755,-,-) %{_libdir}/*.so* -+%{_libdir}/libIP2Location.so.1 -+%{_libdir}/libIP2Location.so.1.0.0 - --%attr(755,-,-) %{_datadir}/%{name}/tools/* -+%{_datadir}/%{name}/tools/ - - %dir %{_datadir}/%{name}/ - - - %files devel --%defattr(-,root,root) --%{_includedir}/* -+%{_includedir}/IP2Loc*.h -+%{_libdir}/libIP2Location.so - - %doc Developers_Guide.txt - - - %changelog -+* Fri Aug 28 2020 Peter Bieringer -+- fix spec file according to BZ#1873302 -+ -+* Sat Oct 5 2019 Peter Bieringer - 8.0.9-5 -+- update version to 8.0.9 -+ - * Sun Feb 26 2017 Peter Bieringer - 8.0.4-5 - - update to 8.0.4 - - add some fixes related to move to github -diff --git a/contrib/IP2Location.spec.in b/contrib/IP2Location.spec.in -index b544e8a..be95898 100644 ---- a/contrib/IP2Location.spec.in -+++ b/contrib/IP2Location.spec.in -@@ -3,12 +3,10 @@ - Name: IP2Location - Summary: C library for mapping IP address to geolocation information - Version: %{version} --Release: 5%{?dist} --Group: System Environment/Libraries -+Release: 6%{?dist} - License: MIT - URL: http://www.ip2location.com/ --Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}.tar.gz --BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -+Source0: https://github.com/chrislim2888/IP2Location-C-Library/archive/%{version}/%{name}-%{version}.tar.gz - BuildRequires: libtool - - -@@ -26,7 +24,6 @@ the included downloader. - - %package devel - Summary: Static library and header files for the ip2location library --Group: Development/C - Requires: %{name} = %{version}-%{release} - Provides: %{name}-devel = %{version}-%{release} - -@@ -51,63 +48,60 @@ perl -pi -e 's/-Wno-unused-result//' configure.ac - - %build - sh ./bootstrap --autoreconf -fi -+autoreconf -fiv - - %configure --disable-static --make clean --make %{?_smp_mflags} COPTS="$RPM_OPT_FLAGS" -+%make_build COPTS="$RPM_OPT_FLAGS" - - # convert CSV to BIN - make -C data convert - -+ - %check - LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH make check - - - %install --rm -rf %{buildroot} -- --make install DESTDIR=%{buildroot} -+%make_install - - # cleanup - rm -f %{buildroot}%{_libdir}/*.*a - - # tools - install -d %{buildroot}%{_datadir}/%{name}/tools --cp tools/download.pl %{buildroot}%{_datadir}/%{name}/tools -+install -pm 0755 tools/download.pl %{buildroot}%{_datadir}/%{name}/tools - - # database directory - install -d %{buildroot}%{_datadir}/%{name}/ - - --%post -p /sbin/ldconfig -- --%postun -p /sbin/ldconfig -- -- --%clean --rm -rf %{buildroot} -- - %files --%defattr(644,root,root,755) -+%license COPYING LICENSE.TXT - --%doc AUTHORS ChangeLog COPYING README.md LICENSE.TXT NEWS INSTALL LICENSE.TXT -+%doc AUTHORS ChangeLog README.md NEWS - --%attr(755,-,-) %{_libdir}/*.so* -+%{_libdir}/libIP2Location.so.1 -+%{_libdir}/libIP2Location.so.1.0.0 - --%attr(755,-,-) %{_datadir}/%{name}/tools/* -+%{_datadir}/%{name}/tools/ - - %dir %{_datadir}/%{name}/ - - - %files devel --%defattr(-,root,root) --%{_includedir}/* -+%{_includedir}/IP2Loc*.h -+%{_libdir}/libIP2Location.so - - %doc Developers_Guide.txt - - - %changelog -+* Fri Aug 28 2020 Peter Bieringer -+- fix spec file according to BZ#1873302 -+ -+* Sat Oct 5 2019 Peter Bieringer - 8.0.9-5 -+- update version to 8.0.9 -+ - * Sun Feb 26 2017 Peter Bieringer - 8.0.4-5 - - update to 8.0.4 - - add some fixes related to move to github -diff --git a/libIP2Location/IP2Loc_DBInterface.c b/libIP2Location/IP2Loc_DBInterface.c -index 647ea69..2130e99 100644 ---- a/libIP2Location/IP2Loc_DBInterface.c -+++ b/libIP2Location/IP2Loc_DBInterface.c -@@ -271,9 +271,13 @@ uint32_t IP2Location_read32(FILE *handle, uint32_t position) - { - fseek(handle, position-1, 0); - temp = fread(&byte1, 1, 1, handle); -+ if (temp == 0) { return 0; }; - temp = fread(&byte2, 1, 1, handle); -+ if (temp == 0) { return 0; }; - temp = fread(&byte3, 1, 1, handle); -+ if (temp == 0) { return 0; }; - temp = fread(&byte4, 1, 1, handle); -+ if (temp == 0) { return 0; }; - } - else - { -@@ -295,6 +299,7 @@ uint8_t IP2Location_read8(FILE *handle, uint32_t position) - { - fseek(handle, position-1, 0); - temp = fread(&ret, 1, 1, handle); -+ if (temp == 0) { return 0; }; - } - else - { -@@ -309,13 +314,16 @@ char *IP2Location_readStr(FILE *handle, uint32_t position) - char *str = 0; - uint8_t *cache_shm = cache_shm_ptr; - size_t temp; -+ - if (DB_access_type == IP2LOCATION_FILE_IO && handle != NULL) - { - fseek(handle, position, 0); - temp = fread(&size, 1, 1, handle); -+ if (temp == 0) { return ""; }; - str = (char *)malloc(size+1); - memset(str, 0, size+1); - temp = fread(str, size, 1, handle); -+ if (temp == 0) { return ""; }; - } - else - { -@@ -341,9 +349,13 @@ float IP2Location_readFloat(FILE *handle, uint32_t position) - { - fseek(handle, position-1, 0); - temp = fread(p+3, 1, 1, handle); -+ if (temp == 0) { return 0.0; }; - temp = fread(p+2, 1, 1, handle); -+ if (temp == 0) { return 0.0; }; - temp = fread(p+1, 1, 1, handle); -+ if (temp == 0) { return 0.0; }; - temp = fread(p, 1, 1, handle); -+ if (temp == 0) { return 0.0; }; - } - else - { -@@ -357,6 +369,7 @@ float IP2Location_readFloat(FILE *handle, uint32_t position) - { - fseek(handle, position-1, 0); - temp = fread(&ret, 4, 1, handle); -+ if (temp == 0) { return 0.0; }; - } - else - { -@@ -365,5 +378,3 @@ float IP2Location_readFloat(FILE *handle, uint32_t position) - #endif - return ret; - } -- -- -diff --git a/libIP2Location/IP2Location.c b/libIP2Location/IP2Location.c -index fbe7fe0..a036580 100644 ---- a/libIP2Location/IP2Location.c -+++ b/libIP2Location/IP2Location.c -@@ -61,7 +61,6 @@ uint8_t USAGETYPE_POSITION[25] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - static int IP2Location_initialize(IP2Location *loc); - static IP2LocationRecord *IP2Location_new_record(); - static uint32_t IP2Location_ip2no(char* ip); --static struct in6_addr_local IP2Location_ipv6_to_no(char* ipaddr); - static int IP2Location_ip_is_ipv4 (char* ipaddr); - static int IP2Location_ip_is_ipv6 (char* ipaddr); - static IP2LocationRecord *IP2Location_get_record(IP2Location *loc, char *ip, uint32_t mode); -@@ -151,8 +150,8 @@ static int IP2Location_initialize(IP2Location *loc) - loc->ipv6databasecount = IP2Location_read32(loc->filehandle, 14); - loc->ipv6databaseaddr = IP2Location_read32(loc->filehandle, 18); - -- loc->ipv4indexbaseaddr = IP2Location_read32(loc->filehandle, 22); -- loc->ipv6indexbaseaddr = IP2Location_read32(loc->filehandle, 26); -+ loc->ipv4indexbaseaddr = IP2Location_read32(loc->filehandle, 22); -+ loc->ipv6indexbaseaddr = IP2Location_read32(loc->filehandle, 26); - - return 0; - } -@@ -381,47 +380,77 @@ static IP2LocationRecord *IP2Location_read_record(IP2Location *loc, uint32_t row - - if ((mode & COUNTRYSHORT) && (COUNTRY_POSITION[dbtype] != 0)) - { -- record->country_short = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))); -+ if (!record->country_short) -+ { -+ record->country_short = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))); -+ } - } - else - { -- record->country_short = strdup(NOT_SUPPORTED); -+ if (!record->country_short) -+ { -+ record->country_short = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & COUNTRYLONG) && (COUNTRY_POSITION[dbtype] != 0)) - { -- record->country_long = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))+3); -+ if (!record->country_long) -+ { -+ record->country_long = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (COUNTRY_POSITION[dbtype]-1))+3); -+ } - } - else - { -- record->country_long = strdup(NOT_SUPPORTED); -+ if (!record->country_long) -+ { -+ record->country_long = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & REGION) && (REGION_POSITION[dbtype] != 0)) - { -- record->region = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (REGION_POSITION[dbtype]-1))); -+ if (!record->region) -+ { -+ record->region = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (REGION_POSITION[dbtype]-1))); -+ } - } - else - { -- record->region = strdup(NOT_SUPPORTED); -+ if (!record->region) -+ { -+ record->region = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & CITY) && (CITY_POSITION[dbtype] != 0)) - { -- record->city = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (CITY_POSITION[dbtype]-1))); -+ if (!record->city) -+ { -+ record->city = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (CITY_POSITION[dbtype]-1))); -+ } - } - else - { -- record->city = strdup(NOT_SUPPORTED); -+ if (!record->city) -+ { -+ record->city = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & ISP) && (ISP_POSITION[dbtype] != 0)) - { -- record->isp = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ISP_POSITION[dbtype]-1))); -+ if (!record->isp) -+ { -+ record->isp = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ISP_POSITION[dbtype]-1))); -+ } - } - else - { -- record->isp = strdup(NOT_SUPPORTED); -+ if (!record->isp) -+ { -+ record->isp = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & LATITUDE) && (LATITUDE_POSITION[dbtype] != 0)) -@@ -444,108 +473,174 @@ static IP2LocationRecord *IP2Location_read_record(IP2Location *loc, uint32_t row - - if ((mode & DOMAIN_) && (DOMAIN_POSITION[dbtype] != 0)) - { -- record->domain = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (DOMAIN_POSITION[dbtype]-1))); -+ if (!record->domain) -+ { -+ record->domain = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (DOMAIN_POSITION[dbtype]-1))); -+ } - } - else - { -- record->domain = strdup(NOT_SUPPORTED); -+ if (!record->domain) -+ { -+ record->domain = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & ZIPCODE) && (ZIPCODE_POSITION[dbtype] != 0)) - { -- record->zipcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ZIPCODE_POSITION[dbtype]-1))); -+ if (!record->zipcode) -+ { -+ record->zipcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ZIPCODE_POSITION[dbtype]-1))); -+ } - } - else - { -- record->zipcode = strdup(NOT_SUPPORTED); -+ if (!record->zipcode) -+ { -+ record->zipcode = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & TIMEZONE) && (TIMEZONE_POSITION[dbtype] != 0)) - { -- record->timezone = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (TIMEZONE_POSITION[dbtype]-1))); -+ if (!record->timezone) -+ { -+ record->timezone = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (TIMEZONE_POSITION[dbtype]-1))); -+ } - } - else - { -- record->timezone = strdup(NOT_SUPPORTED); -+ if (!record->timezone) -+ { -+ record->timezone = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & NETSPEED) && (NETSPEED_POSITION[dbtype] != 0)) - { -- record->netspeed = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (NETSPEED_POSITION[dbtype]-1))); -+ if (!record->netspeed) -+ { -+ record->netspeed = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (NETSPEED_POSITION[dbtype]-1))); -+ } - } - else - { -- record->netspeed = strdup(NOT_SUPPORTED); -+ if (!record->netspeed) -+ { -+ record->netspeed = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & IDDCODE) && (IDDCODE_POSITION[dbtype] != 0)) - { -- record->iddcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (IDDCODE_POSITION[dbtype]-1))); -+ if (!record->iddcode) -+ { -+ record->iddcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (IDDCODE_POSITION[dbtype]-1))); -+ } - } - else - { -- record->iddcode = strdup(NOT_SUPPORTED); -+ if (!record->iddcode) -+ { -+ record->iddcode = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & AREACODE) && (AREACODE_POSITION[dbtype] != 0)) - { -- record->areacode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (AREACODE_POSITION[dbtype]-1))); -+ if (!record->areacode) -+ { -+ record->areacode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (AREACODE_POSITION[dbtype]-1))); -+ } - } - else - { -- record->areacode = strdup(NOT_SUPPORTED); -+ if (!record->areacode) -+ { -+ record->areacode = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & WEATHERSTATIONCODE) && (WEATHERSTATIONCODE_POSITION[dbtype] != 0)) - { -- record->weatherstationcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONCODE_POSITION[dbtype]-1))); -+ if (!record->weatherstationcode) -+ { -+ record->weatherstationcode = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONCODE_POSITION[dbtype]-1))); -+ } - } - else - { -- record->weatherstationcode = strdup(NOT_SUPPORTED); -+ if (!record->weatherstationcode) -+ { -+ record->weatherstationcode = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & WEATHERSTATIONNAME) && (WEATHERSTATIONNAME_POSITION[dbtype] != 0)) - { -- record->weatherstationname = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONNAME_POSITION[dbtype]-1))); -+ if (!record->weatherstationname) -+ { -+ record->weatherstationname = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (WEATHERSTATIONNAME_POSITION[dbtype]-1))); -+ } - } - else - { -- record->weatherstationname = strdup(NOT_SUPPORTED); -+ if (!record->weatherstationname) -+ { -+ record->weatherstationname = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & MCC) && (MCC_POSITION[dbtype] != 0)) - { -- record->mcc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MCC_POSITION[dbtype]-1))); -+ if (!record->mcc) -+ { -+ record->mcc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MCC_POSITION[dbtype]-1))); -+ } - } - else - { -- record->mcc = strdup(NOT_SUPPORTED); -+ if (!record->mcc) -+ { -+ record->mcc = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & MNC) && (MNC_POSITION[dbtype] != 0)) - { -- record->mnc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MNC_POSITION[dbtype]-1))); -+ if (!record->mnc) -+ { -+ record->mnc = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MNC_POSITION[dbtype]-1))); -+ } - } - else - { -- record->mnc = strdup(NOT_SUPPORTED); -+ if (!record->mnc) -+ { -+ record->mnc = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & MOBILEBRAND) && (MOBILEBRAND_POSITION[dbtype] != 0)) - { -- record->mobilebrand = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MOBILEBRAND_POSITION[dbtype]-1))); -+ if (!record->mobilebrand) -+ { -+ record->mobilebrand = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (MOBILEBRAND_POSITION[dbtype]-1))); -+ } - } - else - { -- record->mobilebrand = strdup(NOT_SUPPORTED); -+ if (!record->mobilebrand) -+ { -+ record->mobilebrand = strdup(NOT_SUPPORTED); -+ } - } - - if ((mode & ELEVATION) && (ELEVATION_POSITION[dbtype] != 0)) - { - char *mem = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (ELEVATION_POSITION[dbtype]-1))); -- record->elevation = atof(mem); -- free(mem); -+ record->elevation = atof(mem); -+ free(mem); - } - else - { -@@ -554,11 +649,17 @@ static IP2LocationRecord *IP2Location_read_record(IP2Location *loc, uint32_t row - - if ((mode & USAGETYPE) && (USAGETYPE_POSITION[dbtype] != 0)) - { -- record->usagetype = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (USAGETYPE_POSITION[dbtype]-1))); -+ if (!record->usagetype) -+ { -+ record->usagetype = IP2Location_readStr(handle, IP2Location_read32(handle, rowaddr + 4 * (USAGETYPE_POSITION[dbtype]-1))); -+ } - } - else - { -- record->usagetype = strdup(NOT_SUPPORTED); -+ if (!record->usagetype) -+ { -+ record->usagetype = strdup(NOT_SUPPORTED); -+ } - } - return record; - } -@@ -658,7 +759,7 @@ static IP2LocationRecord *IP2Location_get_ipv4_record(IP2Location *loc, char *ip - { - mid = (uint32_t)((low + high) >> 1); - ipfrom = IP2Location_read32(handle, baseaddr + mid * dbcolumn * 4); -- ipto = IP2Location_read32(handle, baseaddr + (mid + 1) * dbcolumn * 4); -+ ipto = IP2Location_read32(handle, baseaddr + (mid + 1) * dbcolumn * 4); - - if ((ipno >= ipfrom) && (ipno < ipto)) - { -@@ -683,17 +784,17 @@ static IP2LocationRecord *IP2Location_get_ipv4_record(IP2Location *loc, char *ip - static IP2LocationRecord *IP2Location_get_record(IP2Location *loc, char *ipstring, uint32_t mode) - { - ipv_t parsed_ipv = IP2Location_parse_addr(ipstring); -- if (parsed_ipv.ipversion == 4) -- { -- //process IPv4 -- return IP2Location_get_ipv4_record(loc, ipstring, mode, parsed_ipv); -- } -+ if (parsed_ipv.ipversion == 4) -+ { -+ //process IPv4 -+ return IP2Location_get_ipv4_record(loc, ipstring, mode, parsed_ipv); -+ } - if (parsed_ipv.ipversion == 6) - { -- //process IPv6 -+ //process IPv6 - return IP2Location_get_ipv6_record(loc, ipstring, mode, parsed_ipv); - } -- else -+ else - { - return IP2Location_bad_record(INVALID_IPV4_ADDRESS); - } -diff --git a/libIP2Location/IP2Location.h b/libIP2Location/IP2Location.h -index b425362..34e9ada 100644 ---- a/libIP2Location/IP2Location.h -+++ b/libIP2Location/IP2Location.h -@@ -56,7 +56,7 @@ extern "C" { - #include "IP2Loc_DBInterface.h" - - /* API version changes only if functions are added (release) or changed (minor/major) */ --#define API_VERSION 8.0.8 -+#define API_VERSION 8.0.9 - - - #define API_VERSION_MAJOR 8 -diff --git a/test/test-IP2Location.c b/test/test-IP2Location.c -index f48eb3f..9ad08a2 100644 ---- a/test/test-IP2Location.c -+++ b/test/test-IP2Location.c -@@ -38,7 +38,10 @@ int main () { - f = fopen("country_test_ipv4_data.txt","r"); - - while (fscanf(f, "%s", ipAddress) != EOF) { -- fscanf(f, "%s", expectedCountry); -+ if (fscanf(f, "%s", expectedCountry) == EOF) { -+ printf("Unexpected EOF, input file broken: country_test_ipv6_data.txt\n"); -+ return -1; -+ }; - record = IP2Location_get_all(IP2LocationObj, ipAddress); - if (record != NULL) { - if (strcmp(expectedCountry,record->country_short) != 0) { -@@ -86,7 +89,10 @@ int main () { - f = fopen("country_test_ipv6_data.txt","r"); - - while (fscanf(f, "%s", ipAddress) != EOF) { -- fscanf(f, "%s", expectedCountry); -+ if (fscanf(f, "%s", expectedCountry) == EOF) { -+ printf("Unexpected EOF, input file broken: country_test_ipv6_data.txt\n"); -+ return -1; -+ }; - record = IP2Location_get_all(IP2LocationObj, ipAddress); - if (strcmp(expectedCountry,record->country_short) != 0) { - fprintf(stdout,"Test IP Address %s (Test %d) failed. We got %s but expected %s,\n",ipAddress,test_num,record->country_short,expectedCountry); diff --git a/IP2Location-8.0.9-rpmlint.patch b/IP2Location-8.0.9-rpmlint.patch deleted file mode 100644 index dd8e038..0000000 --- a/IP2Location-8.0.9-rpmlint.patch +++ /dev/null @@ -1,877 +0,0 @@ -diff --git a/NEWS b/NEWS -index e69de29..670672f 100644 ---- a/NEWS -+++ b/NEWS -@@ -0,0 +1 @@ -+2020-09-08/pbiering: package finally on Fedora buildsystem: https://koji.fedoraproject.org/koji/packageinfo?packageID=32132 -diff --git a/README b/README -index b43a113..ce9d994 100644 ---- a/README -+++ b/README -@@ -40,6 +40,10 @@ Sample BIN Databases - Download free IP2Location LITE databases at https://lite.ip2location.com - Download IP2Location sample databases at https://www.ip2location.com/developers - -+Packages for Fedora/Enterprise Linux can be found here -+ https://koji.fedoraproject.org/koji/packageinfo?packageID=32132 -+ https://src.fedoraproject.org/rpms/IP2Location -+ - Support - - Email: support@ip2location.com. -diff --git a/README.md b/README.md -index 806b3cd..a0485d7 100644 ---- a/README.md -+++ b/README.md -@@ -52,6 +52,10 @@ If you encountered **error while loading shared libraries** in linux platform, t - ldconfig /usr/local/lib - ``` - -+# Packages for Fedora/Enterprise Linux can be found here -+https://koji.fedoraproject.org/koji/packageinfo?packageID=32132 -+https://src.fedoraproject.org/rpms/IP2Location -+ - # Support - Email: support@ip2location.com. - URL: [https://www.ip2location.com](https://www.ip2location.com) -diff --git a/tools/download.pl b/tools/download.pl -index 77772cf..11f0803 100644 ---- a/tools/download.pl -+++ b/tools/download.pl -@@ -1,418 +1,418 @@ --#!/usr/bin/perl -w --############################################################################### --# IP2Location Download Client --############################################################################### --# Perl script to download IP2Location(tm) batabase from the server. --# Note: User subscription login and password required. --# --# There is no warranty or guarantee conveyed by the author/copyright holder of --# this script. By obtaining, installing, and using this program, you agree and --# understand that the author and copyright holder are not responsible for any --# damages caused under any conditions due to the malfunction of the script(s) --# on your server or otherwise. --# --# REVISION HISTORY --# ================ --# 1.0.0 Initial Release --# 1.1.0 Support IP2Location DB11 + DB12 + DB13 + DB14 --# 1.2.0 Change URL to IP2Location.com --# 2.0.0 Support IP2Location DB15 + DB16 + DB17 + DB18 --# Support IP2Proxy PX1 --# Support Command Prompt in Windows as EXE --# 2.1.0 Support Proxy Server --# 2.2.0 Support CIDR + ACL --# 3.0.0 Support IP2Location DB19 + DB20 --# 3.1.0 Support New Web Site Structure --# 4.0.0 Support DB21 + DB22 + DB23 + DB24 --# Support Download via SSL --# Support LITE DBs. --# 5.0.0 Support DB1-DB24 IPV6 --# Support LITE IPV6 --# Update New Download URL --# 6.0.0 Support IP2Proxy PX2-PX4 --# Support -showall switch --# 7.0.0 Support IP2Proxy PX1BIN-PX4BIN --# Support LITE ASN --# --# Copyright (C) 2005-2017 IP2Location.com. All rights reserved. --# --############################################################################### --use strict; --use Getopt::Long; --$|++; --eval("use LWP;"); die "[ERROR] LWP library required.\n" if $@; -- --my $VERSION = "7.0.0"; --my $opt_package = ""; --my $opt_login = ""; --my $opt_password = ""; --my $opt_output = ""; --my $opt_proxy = ""; --my $help = 0; --my $ssl = 0; --my $showall = 0; -- --my $result = GetOptions('package=s' => \$opt_package, -- 'login:s' => \$opt_login, -- 'password:s' => \$opt_password, -- 'output:s' => \$opt_output, -- 'proxy:s' => \$opt_proxy, -- 'help' => \$help, -- 'showall' => \$showall, -- 'ssl' => \$ssl); -- --if ($help) { -- &print_help; -- exit(0); --} -- --if ($showall) { -- &print_showall; -- exit(0); --} -- --my $final_data = ""; --my $total_size = 0; --my $expiry_date = ""; --my $database_version = ""; --my $https = ($ssl) ? 's' : ''; -- --my $urlversion = "http" . $https . "://www.ip2location.com/downloads/downloaderversion.txt"; --my $urlinfo = "http" . $https . "://www.ip2location.com/download-info"; --my $url = "http" . $https . "://www.ip2location.com/download"; -- --my $login = ''; --my $password = ''; --my $filename = ''; --my $output = ''; --my $package = ''; --my $proxy = ''; -- --if ($opt_package ne "") { -- $package = $opt_package; --} else { -- &print_help; -- print "[Error] Missing -package command line switch or parameter.\n"; -- exit(0); --} -- --if ($opt_login ne "") { -- $login = $opt_login; --} else { -- &print_help; -- print "[Error] Missing -login command line switch or parameter.\n"; -- exit(0); --} -- --if ($opt_password ne "") { -- $password = $opt_password; --} else { -- &print_help; -- print "[Error] Missing -password command line switch or parameter.\n"; -- exit(0); --} -- --if ($opt_proxy ne "") { -- $proxy = lc($opt_proxy); --} -- --$package = uc($package); -- --if ($package eq "DB1") { $filename = "IPCountry-FULL.zip"; $output = "IP-COUNTRY-FULL.ZIP"; } --elsif ($package eq "DB2") { $filename = "IPISP-FULL.zip"; $output = "IP-COUNTRY-ISP-FULL.ZIP"; } --elsif ($package eq "DB3") { $filename = "IP-COUNTRY-REGION-CITY-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB4") { $filename = "IP-COUNTRY-REGION-CITY-ISP-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB5") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB6") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB7") { $filename = "IP-COUNTRY-REGION-CITY-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB8") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB9") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB10") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB11") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB12") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB13") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB14") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB15") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB16") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB17") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB18") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB19") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB20") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB21") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB22") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB23") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB24") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-FULL.ZIP"; $output = $filename; } --elsif ($package eq "DB1BIN") { $filename = "IP-COUNTRY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB2BIN") { $filename = "IP-COUNTRY-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB3BIN") { $filename = "IP-COUNTRY-REGION-CITY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB4BIN") { $filename = "IP-COUNTRY-REGION-CITY-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB5BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB6BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB7BIN") { $filename = "IP-COUNTRY-REGION-CITY-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB8BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB9BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB10BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB11BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB12BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB13BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB14BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB15BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB16BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB17BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB18BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB19BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB20BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB21BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB22BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB23BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB24BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB1CIDR") { $filename = "IP2LOCATION-IP-COUNTRY-CIDR.ZIP"; $output = $filename; } --elsif ($package eq "DB1ACL") { $filename = "IP2LOCATION-IP-COUNTRY-ACL.ZIP"; $output = $filename; } --elsif ($package eq "DB1LITE") { $filename = "IP2LOCATION-LITE-DB1.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB3LITE") { $filename = "IP2LOCATION-LITE-DB3.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB5LITE") { $filename = "IP2LOCATION-LITE-DB5.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB9LITE") { $filename = "IP2LOCATION-LITE-DB9.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB11LITE") { $filename = "IP2LOCATION-LITE-DB11.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB1LITEBIN") { $filename = "IP2LOCATION-LITE-DB1.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB3LITEBIN") { $filename = "IP2LOCATION-LITE-DB3.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB5LITEBIN") { $filename = "IP2LOCATION-LITE-DB5.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB9LITEBIN") { $filename = "IP2LOCATION-LITE-DB9.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB11LITEBIN") { $filename = "IP2LOCATION-LITE-DB11.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB1IPV6") { $filename = "IPV6-COUNTRY.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB2IPV6") { $filename = "IPV6-COUNTRY-ISP.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB3IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB4IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB5IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB6IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB7IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB8IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB9IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB10IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB11IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB12IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB13IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB14IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB15IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB16IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB17IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB18IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB19IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB20IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB21IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB22IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB23IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB24IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB1BINIPV6") { $filename = "IPV6-COUNTRY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB2BINIPV6") { $filename = "IPV6-COUNTRY-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB3BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB4BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB5BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB6BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB7BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB8BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB9BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB10BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB11BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB12BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB13BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB14BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB15BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB16BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB17BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB18BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB19BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB20BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB21BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB22BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB23BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB24BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB1LITEIPV6") { $filename = "IP2LOCATION-LITE-DB1-IPV6.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB3LITEIPV6") { $filename = "IP2LOCATION-LITE-DB3-IPV6.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB5LITEIPV6") { $filename = "IP2LOCATION-LITE-DB5-IPV6.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB9LITEIPV6") { $filename = "IP2LOCATION-LITE-DB9-IPV6.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB11LITEIPV6") { $filename = "IP2LOCATION-LITE-DB11-IPV6.CSV.ZIP"; $output = $filename; } --elsif ($package eq "DB1LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB1-IPV6.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB3LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB3-IPV6.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB5LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB5-IPV6.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB9LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB9-IPV6.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DB11LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB11-IPV6.BIN.ZIP"; $output = $filename; } --elsif ($package eq "PX1") { $filename = "PX1-IP-COUNTRY.ZIP"; $output = $filename; } --elsif ($package eq "PX2") { $filename = "PX2-IP-PROXYTYPE-COUNTRY.ZIP"; $output = $filename; } --elsif ($package eq "PX3") { $filename = "PX3-IP-PROXYTYPE-COUNTRY-REGION-CITY.ZIP"; $output = $filename; } --elsif ($package eq "PX4") { $filename = "PX4-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.ZIP"; $output = $filename; } --elsif ($package eq "PX1BIN") { $filename = "PX1-IP-COUNTRY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "PX2BIN") { $filename = "PX2-IP-PROXYTYPE-COUNTRY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "PX3BIN") { $filename = "PX3-IP-PROXYTYPE-COUNTRY-REGION-CITY.BIN.ZIP"; $output = $filename; } --elsif ($package eq "PX4BIN") { $filename = "PX4-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.BIN.ZIP"; $output = $filename; } --elsif ($package eq "DBASNLITE") { $filename = "IP2LOCATION-LITE-ASN.ZIP"; $output = $filename; } --else { -- print "[Error] Unknown -package command line parameter."; -- exit(0); --} -- --if ($opt_output ne "") { -- $output = $opt_output; --} -- --&check_info(); --&download(); --&check_update(); -- --sub check_info() { -- my $ua; -- my $response; -- my $message; -- my @data; -- my $localpackage = $package; -- -- if ($package eq "DB1CIDR") { -- $localpackage = "DB1"; -- } elsif ($package eq "DB1ACL") { -- $localpackage = "DB1"; -- } -- -- $ua = LWP::UserAgent->new( ); -- if ($proxy ne "") { -- $ua->proxy('http', $proxy); -- } -- -- $response = $ua->get($urlinfo . "?email=$login\&password=$password\&productcode=$localpackage"); -- $message = $response->content(); -- @data = split(/\;/, $message); -- -- if (!defined($data[0])) { -- print "[Error] No information data. Please contact support\@ip2location.com."; -- exit(0); -- } else { -- if ($data[0] eq "OK") { -- $total_size = $data[3]; -- $expiry_date = $data[1]; -- $database_version = $data[2]; -- } elsif ($data[0] eq "EXPIRED") { -- print "[Error] This download account has been expired since $data[1]. Please visit http://www.ip2location.com to renew the subscription."; -- exit(0); -- } elsif ($data[0] eq "INVALID") { -- print "[Error] Invalid account name or password."; -- exit(0); -- } elsif ($data[0] eq "NOPERMISSION") { -- print "[Error] This download account could not download required database because of permission issue."; -- exit(0); -- } else { -- print "[Error] Unknown issue $message. Please contact support\@ip2location.com."; -- exit(0); -- } -- } --} -- --sub download() { -- print_header(); -- print "Downloading ", $output, " ...\n"; -- -- my $ua; -- my $response; -- -- $ua = LWP::UserAgent->new( ); -- if ($proxy ne "") { -- $ua->proxy('http', $proxy); -- } -- push @{ $ua->requests_redirectable }, 'POST'; -- -- my %form; -- -- $form{'login'} = $login; -- $form{'password'} = $password; -- $form{'btnDownload'} = "btnDownload"; -- -- $response = $ua->post($url . "?productcode=$package", \%form, ':content_cb' => \&callback ); -- -- if ($response->is_success) { -- } else { -- die "[Error] Error while downloading. ($response->status_line)"; -- } -- -- open OUT1, ">$output" or die "[Error] Unable to write $output to drive. Please check the file system permission or free diskspace."; -- binmode(OUT1); -- print OUT1 $final_data; -- close OUT1; --} -- --sub check_update() { -- my $ua; -- my $response; -- my $message; -- $ua = LWP::UserAgent->new(); -- if ($proxy ne "") { -- $ua->proxy('http', $proxy); -- } -- $response = $ua->get($urlversion); -- $message = $response->content(); -- -- my $thisversion = $VERSION; -- $thisversion =~ s/\.//g; -- $message =~ s/\.//g; -- -- if ($message > $thisversion) { -- print "[IMPORTANT] New script version detected. Please download the latest version from http://www.ip2location.com/downloads/ip2location-downloader.zip"; -- } --} -- --sub callback { -- my ($data, $response, $protocol) = @_; -- $final_data .= $data; -- print progress_bar( length($final_data), $total_size, 25, '=' ); --} -- --sub progress_bar { -- my ( $got, $total, $width, $char ) = @_; -- $width ||= 25; $char ||= '='; -- my $num_width = length($total); -- sprintf "|%-${width}s| Got %${num_width}s bytes of %s (%.2f%%)\r", -- $char x (($width-1)*$got/$total). '>', -- $got, $total, 100*$got/+$total; --} -- --sub print_help { -- print_header(); -- print < -login -password -- -output -proxy -ssl -- -- package - Database Package (Example: DB1, DB1BIN, DB1IPV6, DB1BINIPV6, -- DB1LITE, DB1LITEBIN, DB1LITEIPV6, -- DB1LITEBINIPV6, PX1, PX1BIN or -- DBASNLITE) -- login - Login -- password - Password -- proxy - Proxy Server with Port (Optional) -- output - Output Filename (Optional) -- showall - Show All Package Code (Optional) -- ssl - Download via SSL (Optional); May require additional libraries. -- --Please contact support\@ip2location.com for technical support. -- --HELP --} -- --sub print_header { -- print <
\$opt_package, -+ 'login:s' => \$opt_login, -+ 'password:s' => \$opt_password, -+ 'output:s' => \$opt_output, -+ 'proxy:s' => \$opt_proxy, -+ 'help' => \$help, -+ 'showall' => \$showall, -+ 'ssl' => \$ssl); -+ -+if ($help) { -+ &print_help; -+ exit(0); -+} -+ -+if ($showall) { -+ &print_showall; -+ exit(0); -+} -+ -+my $final_data = ""; -+my $total_size = 0; -+my $expiry_date = ""; -+my $database_version = ""; -+my $https = ($ssl) ? 's' : ''; -+ -+my $urlversion = "http" . $https . "://www.ip2location.com/downloads/downloaderversion.txt"; -+my $urlinfo = "http" . $https . "://www.ip2location.com/download-info"; -+my $url = "http" . $https . "://www.ip2location.com/download"; -+ -+my $login = ''; -+my $password = ''; -+my $filename = ''; -+my $output = ''; -+my $package = ''; -+my $proxy = ''; -+ -+if ($opt_package ne "") { -+ $package = $opt_package; -+} else { -+ &print_help; -+ print "[Error] Missing -package command line switch or parameter.\n"; -+ exit(0); -+} -+ -+if ($opt_login ne "") { -+ $login = $opt_login; -+} else { -+ &print_help; -+ print "[Error] Missing -login command line switch or parameter.\n"; -+ exit(0); -+} -+ -+if ($opt_password ne "") { -+ $password = $opt_password; -+} else { -+ &print_help; -+ print "[Error] Missing -password command line switch or parameter.\n"; -+ exit(0); -+} -+ -+if ($opt_proxy ne "") { -+ $proxy = lc($opt_proxy); -+} -+ -+$package = uc($package); -+ -+if ($package eq "DB1") { $filename = "IPCountry-FULL.zip"; $output = "IP-COUNTRY-FULL.ZIP"; } -+elsif ($package eq "DB2") { $filename = "IPISP-FULL.zip"; $output = "IP-COUNTRY-ISP-FULL.ZIP"; } -+elsif ($package eq "DB3") { $filename = "IP-COUNTRY-REGION-CITY-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB4") { $filename = "IP-COUNTRY-REGION-CITY-ISP-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB5") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB6") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB7") { $filename = "IP-COUNTRY-REGION-CITY-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB8") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB9") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB10") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB11") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB12") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB13") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB14") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB15") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB16") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB17") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB18") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB19") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB20") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB21") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB22") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB23") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB24") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-FULL.ZIP"; $output = $filename; } -+elsif ($package eq "DB1BIN") { $filename = "IP-COUNTRY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB2BIN") { $filename = "IP-COUNTRY-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB3BIN") { $filename = "IP-COUNTRY-REGION-CITY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB4BIN") { $filename = "IP-COUNTRY-REGION-CITY-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB5BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB6BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB7BIN") { $filename = "IP-COUNTRY-REGION-CITY-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB8BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB9BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB10BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB11BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB12BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB13BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB14BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB15BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB16BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB17BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB18BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB19BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB20BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB21BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB22BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB23BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB24BIN") { $filename = "IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB1CIDR") { $filename = "IP2LOCATION-IP-COUNTRY-CIDR.ZIP"; $output = $filename; } -+elsif ($package eq "DB1ACL") { $filename = "IP2LOCATION-IP-COUNTRY-ACL.ZIP"; $output = $filename; } -+elsif ($package eq "DB1LITE") { $filename = "IP2LOCATION-LITE-DB1.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB3LITE") { $filename = "IP2LOCATION-LITE-DB3.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB5LITE") { $filename = "IP2LOCATION-LITE-DB5.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB9LITE") { $filename = "IP2LOCATION-LITE-DB9.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB11LITE") { $filename = "IP2LOCATION-LITE-DB11.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB1LITEBIN") { $filename = "IP2LOCATION-LITE-DB1.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB3LITEBIN") { $filename = "IP2LOCATION-LITE-DB3.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB5LITEBIN") { $filename = "IP2LOCATION-LITE-DB5.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB9LITEBIN") { $filename = "IP2LOCATION-LITE-DB9.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB11LITEBIN") { $filename = "IP2LOCATION-LITE-DB11.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB1IPV6") { $filename = "IPV6-COUNTRY.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB2IPV6") { $filename = "IPV6-COUNTRY-ISP.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB3IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB4IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB5IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB6IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB7IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB8IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB9IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB10IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB11IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB12IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB13IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB14IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB15IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB16IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB17IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB18IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB19IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB20IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB21IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB22IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB23IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB24IPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB1BINIPV6") { $filename = "IPV6-COUNTRY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB2BINIPV6") { $filename = "IPV6-COUNTRY-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB3BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB4BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB5BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB6BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB7BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB8BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB9BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB10BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB11BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB12BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB13BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB14BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB15BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB16BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB17BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED-WEATHER.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB18BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB19BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB20BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB21BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB22BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB23BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB24BINIPV6") { $filename = "IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB1LITEIPV6") { $filename = "IP2LOCATION-LITE-DB1-IPV6.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB3LITEIPV6") { $filename = "IP2LOCATION-LITE-DB3-IPV6.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB5LITEIPV6") { $filename = "IP2LOCATION-LITE-DB5-IPV6.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB9LITEIPV6") { $filename = "IP2LOCATION-LITE-DB9-IPV6.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB11LITEIPV6") { $filename = "IP2LOCATION-LITE-DB11-IPV6.CSV.ZIP"; $output = $filename; } -+elsif ($package eq "DB1LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB1-IPV6.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB3LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB3-IPV6.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB5LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB5-IPV6.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB9LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB9-IPV6.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DB11LITEBINIPV6") { $filename = "IP2LOCATION-LITE-DB11-IPV6.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "PX1") { $filename = "PX1-IP-COUNTRY.ZIP"; $output = $filename; } -+elsif ($package eq "PX2") { $filename = "PX2-IP-PROXYTYPE-COUNTRY.ZIP"; $output = $filename; } -+elsif ($package eq "PX3") { $filename = "PX3-IP-PROXYTYPE-COUNTRY-REGION-CITY.ZIP"; $output = $filename; } -+elsif ($package eq "PX4") { $filename = "PX4-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.ZIP"; $output = $filename; } -+elsif ($package eq "PX1BIN") { $filename = "PX1-IP-COUNTRY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "PX2BIN") { $filename = "PX2-IP-PROXYTYPE-COUNTRY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "PX3BIN") { $filename = "PX3-IP-PROXYTYPE-COUNTRY-REGION-CITY.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "PX4BIN") { $filename = "PX4-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.BIN.ZIP"; $output = $filename; } -+elsif ($package eq "DBASNLITE") { $filename = "IP2LOCATION-LITE-ASN.ZIP"; $output = $filename; } -+else { -+ print "[Error] Unknown -package command line parameter."; -+ exit(0); -+} -+ -+if ($opt_output ne "") { -+ $output = $opt_output; -+} -+ -+&check_info(); -+&download(); -+&check_update(); -+ -+sub check_info() { -+ my $ua; -+ my $response; -+ my $message; -+ my @data; -+ my $localpackage = $package; -+ -+ if ($package eq "DB1CIDR") { -+ $localpackage = "DB1"; -+ } elsif ($package eq "DB1ACL") { -+ $localpackage = "DB1"; -+ } -+ -+ $ua = LWP::UserAgent->new( ); -+ if ($proxy ne "") { -+ $ua->proxy('http', $proxy); -+ } -+ -+ $response = $ua->get($urlinfo . "?email=$login\&password=$password\&productcode=$localpackage"); -+ $message = $response->content(); -+ @data = split(/\;/, $message); -+ -+ if (!defined($data[0])) { -+ print "[Error] No information data. Please contact support\@ip2location.com."; -+ exit(0); -+ } else { -+ if ($data[0] eq "OK") { -+ $total_size = $data[3]; -+ $expiry_date = $data[1]; -+ $database_version = $data[2]; -+ } elsif ($data[0] eq "EXPIRED") { -+ print "[Error] This download account has been expired since $data[1]. Please visit http://www.ip2location.com to renew the subscription."; -+ exit(0); -+ } elsif ($data[0] eq "INVALID") { -+ print "[Error] Invalid account name or password."; -+ exit(0); -+ } elsif ($data[0] eq "NOPERMISSION") { -+ print "[Error] This download account could not download required database because of permission issue."; -+ exit(0); -+ } else { -+ print "[Error] Unknown issue $message. Please contact support\@ip2location.com."; -+ exit(0); -+ } -+ } -+} -+ -+sub download() { -+ print_header(); -+ print "Downloading ", $output, " ...\n"; -+ -+ my $ua; -+ my $response; -+ -+ $ua = LWP::UserAgent->new( ); -+ if ($proxy ne "") { -+ $ua->proxy('http', $proxy); -+ } -+ push @{ $ua->requests_redirectable }, 'POST'; -+ -+ my %form; -+ -+ $form{'login'} = $login; -+ $form{'password'} = $password; -+ $form{'btnDownload'} = "btnDownload"; -+ -+ $response = $ua->post($url . "?productcode=$package", \%form, ':content_cb' => \&callback ); -+ -+ if ($response->is_success) { -+ } else { -+ die "[Error] Error while downloading. ($response->status_line)"; -+ } -+ -+ open OUT1, ">$output" or die "[Error] Unable to write $output to drive. Please check the file system permission or free diskspace."; -+ binmode(OUT1); -+ print OUT1 $final_data; -+ close OUT1; -+} -+ -+sub check_update() { -+ my $ua; -+ my $response; -+ my $message; -+ $ua = LWP::UserAgent->new(); -+ if ($proxy ne "") { -+ $ua->proxy('http', $proxy); -+ } -+ $response = $ua->get($urlversion); -+ $message = $response->content(); -+ -+ my $thisversion = $VERSION; -+ $thisversion =~ s/\.//g; -+ $message =~ s/\.//g; -+ -+ if ($message > $thisversion) { -+ print "[IMPORTANT] New script version detected. Please download the latest version from http://www.ip2location.com/downloads/ip2location-downloader.zip"; -+ } -+} -+ -+sub callback { -+ my ($data, $response, $protocol) = @_; -+ $final_data .= $data; -+ print progress_bar( length($final_data), $total_size, 25, '=' ); -+} -+ -+sub progress_bar { -+ my ( $got, $total, $width, $char ) = @_; -+ $width ||= 25; $char ||= '='; -+ my $num_width = length($total); -+ sprintf "|%-${width}s| Got %${num_width}s bytes of %s (%.2f%%)\r", -+ $char x (($width-1)*$got/$total). '>', -+ $got, $total, 100*$got/+$total; -+} -+ -+sub print_help { -+ print_header(); -+ print < -login -password -+ -output -proxy -ssl -+ -+ package - Database Package (Example: DB1, DB1BIN, DB1IPV6, DB1BINIPV6, -+ DB1LITE, DB1LITEBIN, DB1LITEIPV6, -+ DB1LITEBINIPV6, PX1, PX1BIN or -+ DBASNLITE) -+ login - Login -+ password - Password -+ proxy - Proxy Server with Port (Optional) -+ output - Output Filename (Optional) -+ showall - Show All Package Code (Optional) -+ ssl - Download via SSL (Optional); May require additional libraries. -+ -+Please contact support\@ip2location.com for technical support. -+ -+HELP -+} -+ -+sub print_header { -+ print <
- 8.2.0-0 +- sync with Fedora and rename to IP2location +- rebuild for #remirepo with release = 0 + to manage update from old version + +* Wed Oct 07 2020 Peter Bieringer - 8.2.0-12 +- update version to 8.2.0 (soname: 3) + * Tue Oct 6 2020 Remi Collet - 8.1.3-0 - sync with Fedora and rename to IP2location - rebuild for #remirepo with release = 0 -- cgit