debian/0000755000000000000000000000000012237144162007170 5ustar debian/control0000644000000000000000000000521712237144036010600 0ustar Source: geoip Section: net Priority: optional Homepage: http://www.maxmind.com/ Maintainer: Patrick Matthäi Build-Depends: debhelper (>= 9), chrpath, zlib1g-dev, autotools-dev, hardening-wrapper, dh-autoreconf, libtool Standards-Version: 3.9.5 Package: libgeoip1 Section: libs Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends} Recommends: geoip-database Suggests: geoip-bin Multi-Arch: same Description: non-DNS IP-to-country resolver library GeoIP is a C library that enables the user to find the country that any IP address or hostname originates from. It uses a file based database. . This database simply contains IP blocks as keys, and countries as values and it should be more complete and accurate than using reverse DNS lookups. . This package contains the shared library. Package: libgeoip-dev Section: libdevel Architecture: any Depends: ${misc:Depends}, libgeoip1 (= ${binary:Version}), geoip-bin (= ${binary:Version}) Description: Development files for the GeoIP library GeoIP is a C library that enables the user to find the country that any IP address or hostname originates from. It uses a file based database. . This database simply contains IP blocks as keys, and countries as values and it should be more complete and accurate than using reverse DNS lookups. . This package contains the development files. Package: geoip-bin Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends} Replaces: libgeoip1 (<= 1.4.4.dfsg-2) Multi-Arch: foreign Description: IP lookup command line tools that use the GeoIP library GeoIP is a C library that enables the user to find the country that any IP address or hostname originates from. It uses a file based database. . This database simply contains IP blocks as keys, and countries as values and it should be more complete and accurate than using reverse DNS lookups. . This package contains the command line utilities to resolve the IP numbers using the GeoIP library. Package: geoip-dbg Section: debug Architecture: any Priority: extra Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, geoip-bin (= ${binary:Version}) | libgeoip1 (= ${binary:Version}) Description: debugging symbols for the GeoIP packages GeoIP is a C library that enables the user to find the country that any IP address or hostname originates from. It uses a file based database. . This database simply contains IP blocks as keys, and countries as values and it should be more complete and accurate than using reverse DNS lookups. . This package contains the debugging symbols for the libgeoip1 and geoip-bin package. debian/changelog0000644000000000000000000006307412237144036011054 0ustar geoip (1.6.0-1) unstable; urgency=low * New upstream release. - The tool geoipupdate has been removed. - README has been renamed to README.md. * Bump Standards-Version to 3.9.5 (no changes needed). * Don't explicitly request xz compression - dpkg 1.17 does this by default. * Fix lintian error pkg-config-multi-arch-wrong-dir. * Remove old touch hack from debian/rules. -- Patrick Matthäi Fri, 08 Nov 2013 12:16:41 +0100 geoip (1.5.1-2) unstable; urgency=low * Do not overwrite DEB_BUILD_OPTIONS. Closes: #718808 * Build geoip-csv-to-dat with debugging symbols. -- Patrick Matthäi Tue, 13 Aug 2013 10:53:19 +0200 geoip (1.5.1-1) unstable; urgency=low * New upstream release. * Merge 1.5.0-3~bpo60+1 and 1.5.0-3~bpo70+1 changelog. * Update debian/watch to use the new location on GitHub. * Build with nocheck and remove patches. The new GeoIP tests would depend on geoip-database. -- Patrick Matthäi Thu, 18 Jul 2013 13:31:35 +0200 geoip (1.5.0-3~bpo70+1) wheezy-backports; urgency=low * Rebuild for wheezy-backports. -- Patrick Matthäi Thu, 11 Jul 2013 11:34:53 +0200 geoip (1.5.0-3~bpo60+1) squeeze-backports-sloppy; urgency=low * Rebuild for squeeze-backports-sloppy. - Remove multiarch support. -- Patrick Matthäi Thu, 11 Jul 2013 10:46:59 +0200 geoip (1.5.0-3) unstable; urgency=low * Add patch 01-disable-name-test to disable name lookup tests at build time, which requires internet connectivity. Closes: #708732 -- Patrick Matthäi Sat, 18 May 2013 21:02:34 +0200 geoip (1.5.0-2) unstable; urgency=low * Uploading to unstable. -- Patrick Matthäi Sun, 05 May 2013 20:34:02 +0200 geoip (1.5.0-1) experimental; urgency=low * New upstream release. - Use geoip.pc from upstream. * No longer build a dfsg version, since the GeoIP.dat file is not used at all. * Maxmind has got the opinion, that directory listing should be leaved disabled, so on removing content from debian/watch. Much thanks, Maxmind! * Use wildcards in libgeoip1 lintian overrides. -- Patrick Matthäi Thu, 28 Mar 2013 11:15:58 +0100 geoip (1.4.8+dfsg-5) experimental; urgency=low * Bump Standards-Version to 3.9.4 (no changes needed). * Migrate package from cdbs to debhelper. * Switch to xz compression and add a Pre-Depends on dpkg. * Add new geoip-dbg package. -- Patrick Matthäi Mon, 31 Dec 2012 10:22:56 +0100 geoip (1.4.8+dfsg-4) unstable; urgency=low * Add multiarch support. * Add lintian override for false positive hardening-no-fortify-functions usr/lib/geoip/geoip-generator. * Wrap all debian/control fields. -- Patrick Matthäi Wed, 11 Jul 2012 21:15:46 +0200 geoip (1.4.8+dfsg-3) unstable; urgency=low * Sync 1.4.8+dfsg-2~bpo60+1 changelog. * Bump Standards-Version to 3.9.3 (no changes needed). -- Patrick Matthäi Sat, 25 Feb 2012 22:01:26 +0100 geoip (1.4.8+dfsg-2~bpo60+1) squeeze-backports; urgency=low * Rebuild for squeeze-backports. -- Patrick Matthäi Thu, 16 Feb 2012 11:30:48 +0100 geoip (1.4.8+dfsg-2) unstable; urgency=low * Apply patch from Sebastian Carneiro, to fix the broken libtool. Closes: #638395 -- Patrick Matthäi Fri, 26 Aug 2011 21:09:59 +0200 geoip (1.4.8+dfsg-1) unstable; urgency=low * New upstream release. * Overwrite no-symbols-control-file lintian warnings. -- Patrick Matthäi Sat, 25 Jun 2011 14:00:58 +0200 geoip (1.4.7+dfsg-2) unstable; urgency=low * Build with hardening-wrapper. -- Patrick Matthäi Sat, 30 Apr 2011 16:12:59 +0200 geoip (1.4.7+dfsg-1) unstable; urgency=low * New upstream release. * Wrap build dependencies. -- Patrick Matthäi Sat, 16 Apr 2011 12:58:12 +0200 geoip (1.4.7~beta14+dfsg-1) unstable; urgency=low * New upstream beta release. * Bump Standards-Version to 3.9.2 (no changes needed). * Convert the deprecated AN country code to CW in the geoip-generator. This fixes a FTBFS at the geoip-database package. * Fix lintian warning description-synopsis-starts-with-article. -- Patrick Matthäi Tue, 12 Apr 2011 20:29:20 +0200 geoip (1.4.7~beta13+dfsg-1) unstable; urgency=low * New upstream beta release. -- Patrick Matthäi Fri, 01 Apr 2011 20:35:40 +0200 geoip (1.4.7~beta12+dfsg-1) unstable; urgency=low * New upstream beta release. -- Patrick Matthäi Tue, 15 Mar 2011 19:55:07 +0100 geoip (1.4.7~beta11+dfsg-1) unstable; urgency=low * New upstream beta release. -- Patrick Matthäi Thu, 10 Mar 2011 20:26:15 +0100 geoip (1.4.7~beta10+dfsg-4) unstable; urgency=low * Uploading to unstable. -- Patrick Matthäi Sun, 06 Feb 2011 16:30:26 +0100 geoip (1.4.7~beta10+dfsg-3) experimental; urgency=low * Drop geoip-database package, it will be split to an extra source package. Closes: #610161 -- Patrick Matthäi Tue, 18 Jan 2011 21:38:37 +0100 geoip (1.4.7~beta10+dfsg-2) experimental; urgency=low * Install our database generator scripts to /usr/lib/geoip/ with the geoip-bin package and set geoip-bin as a dependency for libgeoip-dev. This change prepares the split of the library and database package. * Remove database update script examples. They are superseded by the geoip-database-contrib package. -- Patrick Matthäi Sat, 15 Jan 2011 19:21:55 +0100 geoip (1.4.7~beta10+dfsg-1) experimental; urgency=low * New upstream beta release. * Update both databases to the 4.1.2011 version. -- Patrick Matthäi Wed, 12 Jan 2011 21:07:24 +0100 geoip (1.4.7~beta9+dfsg-1) experimental; urgency=low * New upstream beta release. * Merge 1.4.7~beta6+dfsg-1~bpo50+1 changelog. * Remove temporary directory at the end of the database update scripts. Closes: #601965 * Bump Standards-Version to 3.9.1 (no changes needed). * Update both databases to the 2.11.2010 version. * Bump debhelper to version 7. * Some little format fixes in debian/README.Debian-source. * Update my copyright. -- Patrick Matthäi Mon, 08 Nov 2010 19:56:14 +0100 geoip (1.4.7~beta6+dfsg-1~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. - Revert the 3.0 (quilt) format. -- Patrick Matthäi Fri, 16 Jul 2010 20:40:41 +0200 geoip (1.4.7~beta6+dfsg-1) unstable; urgency=low * New upstream beta release. -- Patrick Matthäi Wed, 14 Jul 2010 12:49:43 +0200 geoip (1.4.7~beta5+dfsg-2) unstable; urgency=low * Bump Standards-Version to 3.9.0. - Replace Conflicts with Breaks. * Update both databases to the 2.7.2010 version. -- Patrick Matthäi Thu, 08 Jul 2010 18:32:18 +0200 geoip (1.4.7~beta5+dfsg-1) unstable; urgency=low * New upstream beta release. * Merge 1.4.7~beta3+dfsg-2~bpo50+1 changelog. * Update IPv4 database to the 2.6.2010 version. -- Patrick Matthäi Thu, 03 Jun 2010 21:06:48 +0200 geoip (1.4.7~beta3+dfsg-2~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. * Switch back to the 1.0 format. -- Patrick Matthäi Thu, 13 May 2010 11:09:06 +0200 geoip (1.4.7~beta3+dfsg-2) unstable; urgency=low * Mangle +dfsg instead of .dfsg in debian/watch. * Generate the version number in geoip.pc on build time. * Update both databases to the 3.5.2010 version. -- Patrick Matthäi Tue, 11 May 2010 13:27:08 +0200 geoip (1.4.7~beta3+dfsg-1) unstable; urgency=low * New upstream beta release. - Drop all patches, they have been merged by upstream. - Change version in debian/geoip.pc. * Add lintian overrides for the false positives spelling errors. * Update both databases to the 2.4.2010 version. * Mention in README.Debian, that the geoip-bin package is needed for having the configuration file. Closes: #579449 -- Patrick Matthäi Thu, 29 Apr 2010 18:58:54 +0200 geoip (1.4.6.dfsg-19) unstable; urgency=low * Update IPv6 database to the 8.2.2010 version. * Drop patch 03-map_ipv6to4_tunnel_ips_to_v4_db, add script v4-to-v6-layout and build the IPv6 database now from a converted v4tov6 and IPv6 database. * Rediff hunky 04-asnum_to_utf8 patch. -- Patrick Matthäi Mon, 08 Feb 2010 14:58:57 +0100 geoip (1.4.6.dfsg-18) unstable; urgency=low * Fix little spelling error in README.Debian. Thanks lintian. * Bump Standards-Version to 3.8.4 (no changes needed). * Add patch 04-asnum_to_utf8.diff, which converts ASNum records from latin-1 to UTF-8. Much thanks for this patch to Piotr Kaczuba. Closes: #567825 * Add patch 05-free_record_after_use.diff, which frees the GeoIP record, after it has been used. Thanks again for this patch to Piotr Kaczuba. Closes: #567828 * Update IPv4 database to the 2.2.2010 version. -- Patrick Matthäi Wed, 03 Feb 2010 19:00:54 +0100 geoip (1.4.6.dfsg-17) unstable; urgency=low * Add new revision of the 03-map_ipv6to4_tunnel_ips_to_v4_db.diff patch, which also fixes a memory leak. Thanks again to Stephen Gran. * Update both databases to the 6.1.2010 version. -- Patrick Matthäi Fri, 08 Jan 2010 12:07:35 +0100 geoip (1.4.6.dfsg-16) unstable; urgency=low * Map IPv6 6to4 addresses to the IPv4 database. Much thanks for the patch to Stephen Gran . Closes: #561886 * Merge 1.4.6.dfsg-15~bpo50+1 changelog. -- Patrick Matthäi Mon, 21 Dec 2009 20:36:13 +0100 geoip (1.4.6.dfsg-15~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. * Do not use DebSrc 3.0. -- Patrick Matthäi Sun, 20 Dec 2009 11:56:39 +0100 geoip (1.4.6.dfsg-15) unstable; urgency=low * Update both databases to the 2.12.2009 version. -- Patrick Matthäi Sun, 06 Dec 2009 20:40:58 +0100 geoip (1.4.6.dfsg-14) unstable; urgency=low * Update both databases to the 2.11.2009 version. * Note in debian/copyright, from where the databases are downloaded. * Convert package to the 3.0 (quilt) format and drop dpatch. -- Patrick Matthäi Fri, 13 Nov 2009 13:19:13 +0100 geoip (1.4.6.dfsg-13) unstable; urgency=low * Merge 1.4.6.dfsg-12~bpo40+1 and 1.4.6.dfsg-12~bpo50+1 changelog. * Fix patch description for the 02-add_asnum_support. Thanks to Kalle Olavi Niemitalo. Closes: #547629 * Update GeoIP Country v4 database to the 1.10.2009 version. * Update GeoIP Country v6 database to the 2.10.2009 version. * Update debian/README.Debian and note there, that the example scripts for downloading databases is not secure. Closes: #546945 -- Patrick Matthäi Mon, 05 Oct 2009 18:36:29 +0200 geoip (1.4.6.dfsg-12~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. -- Patrick Matthäi Sat, 12 Sep 2009 20:04:55 +0200 geoip (1.4.6.dfsg-12~bpo40+1) etch-backports; urgency=low * Rebuild for etch-backports. -- Patrick Matthäi Sat, 12 Sep 2009 20:08:25 +0200 geoip (1.4.6.dfsg-12) unstable; urgency=high * All files in debian/databases/ are licensed under the terms of the Open Data License. * Add missing license for debian/src/geoip-csv-to-dat.cpp. Closes: #545678 -- Patrick Matthäi Tue, 08 Sep 2009 18:20:50 +0200 geoip (1.4.6.dfsg-11) unstable; urgency=low * Remove deprecated debian/mkgeoip_country_v4.pl build script. * Double the dollar sign in debian/rules for the info argument. Only one sign breaks the version string in the database. -- Patrick Matthäi Mon, 07 Sep 2009 13:14:19 +0200 geoip (1.4.6.dfsg-10) unstable; urgency=low * Add src/geoip-csv-to-dat.cpp and build IPv4 and IPv6 database from source with the rewritten c++ build script. -- Patrick Matthäi Mon, 07 Sep 2009 12:27:18 +0200 geoip (1.4.6.dfsg-9) unstable; urgency=low * Adopt optimizing of the database from Kalle Olavi Niemitalo. * Update GeoIPCountryWhois.csv to the state of the 1. Sep 2009. -- Patrick Matthäi Wed, 02 Sep 2009 19:06:17 +0200 geoip (1.4.6.dfsg-8) unstable; urgency=high * Fix typo in long description of geoip-database, s/Ceo/Geo/. Closes: #541454 * Bump Standards-Version to 3.8.3. - Update debian/README.source. * Remove deprecated build date in long descriptions. * Build the GeoIP.dat from source (csv) now, with the reverse engineered build script debian/mkgeoip_country_v4.pl. Much much thanks to Kalle Olavi Niemitalo for doing this job! Closes: #543865 * Move geolitecityupdate.sh to debian/scripts/. * Add geoliteasnum.sh, geolitecountryv4.sh and geolitecountryv6.sh as examples. Now you can update all your databases about cron. This also fixes #535570, because the script will get the most up to date database with the missing netblock. Closes: #535570 * Add missing OPEN DATA LICENSE for debian/databases/GeoIPCountryWhois.csv and data/GeoIP.dat to debian/copyright. Closes: #543866 -- Patrick Matthäi Thu, 27 Aug 2009 18:13:39 +0200 geoip (1.4.6.dfsg-7) unstable; urgency=low * Merge 1.4.6.dfsg-6~bpo50+1 changelog. * Replace old email artifact from debian/copyright. * Add patch 02-add_asnum_support from Piotr Kaczuba to add support for the ASNUM edition. Closes: #535852 -- Patrick Matthäi Thu, 13 Aug 2009 18:34:11 +0200 geoip (1.4.6.dfsg-6~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. -- Patrick Matthäi Sat, 25 Jul 2009 23:32:06 +0200 geoip (1.4.6.dfsg-6) unstable; urgency=high * Merge 1.4.6.dfsg-5~bpo50+1 and 1.4.4.dfsg-3+lenny1 changelog. * Bump Standards-Version to 3.8.2 (no changes needed). * Add missing versioned replaces, because of the clashing /etc/GeoIP.conf.default file in libgeoip1 and geoip-bin. Also bump severity to high. Closes: #534459 -- Patrick Matthäi Wed, 15 Jul 2009 00:27:50 +0200 geoip (1.4.6.dfsg-5~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. -- Patrick Matthäi Mon, 08 Jun 2009 11:05:08 +0200 geoip (1.4.6.dfsg-5) unstable; urgency=low * Downgrade dependency from libgeoip1 on geoip-database to recommends. Closes: #530803 * Add 01-fix_exit_code_and_v_flag.dpatch, which adds a missing break and lets geoipupdate exit with a former exit code. Thanks to Thom May for his patch. Closes: #530778 * Set the right (>= ${source:Version}) shlibs if a package is built against libgeoip1. Thanks to Stephen Gran. Closes: #530801 -- Patrick Matthäi Thu, 28 May 2009 21:47:25 +0200 geoip (1.4.6.dfsg-4) unstable; urgency=low * Fix long description of geoip-database. It does not contain any binaries, just the free GeoLiteCountry database. Thanks Alex Hermann. Closes: #525421 * Merge 1.4.4.dfsg-1~bpo40+1 and 1.4.6.dfsg-2~bpo50+1 changelog. -- Patrick Matthäi Thu, 14 May 2009 12:12:04 +0200 geoip (1.4.6.dfsg-3) unstable; urgency=low * Bump Standards-Version to 3.8.1 (no changes needed). * Change my email address. * Remove DM-Upload-Allowed control field. * Add an example script to get weekly an update of the GeoIP city database. Closes: #511552 * Refer in debian/copyright to the LGPL-2 file instead of LGPL. This fixes the lintian warning copyright-refers-to-symlink-license. * Add my own copyright for the packaging to debian/copyright. -- Patrick Matthäi Wed, 22 Apr 2009 15:39:47 +0200 geoip (1.4.6.dfsg-2~bpo50+1) lenny-backports; urgency=low * Rebuild for lenny-backports. -- Patrick Matthäi Tue, 24 Mar 2009 21:38:25 +0200 geoip (1.4.6.dfsg-2) unstable; urgency=low * Also increment the version in the geoip.pc file. -- Patrick Matthäi Wed, 4 Mar 2009 19:17:35 +0200 geoip (1.4.6.dfsg-1) unstable; urgency=low * New upstream release. - Drop all patches. They have been merged by upstream. -- Patrick Matthäi Tue, 3 Mar 2009 21:26:58 +0200 geoip (1.4.5.dfsg-4) unstable; urgency=low * Uploading to unstable. -- Patrick Matthäi Tue, 17 Feb 2009 18:18:59 +0200 geoip (1.4.5.dfsg-3) experimental; urgency=low * Add missing conflicts against libgeoip (<< 1.4.5.dfsg) to the new geoip-database package. Closes: #513318 * Fix binary-control-field-duplicates-source warning. Thanks lintian. -- Patrick Matthäi Mon, 2 Feb 2009 19:04:49 +0200 geoip (1.4.5.dfsg-2) experimental; urgency=low * Add missing ${misc:Depends}. Thanks lintian. * Add for all install files the destination dir explicity. * Add geoip.pc file for pkgconfig. Closes: #508099 -- Patrick Matthäi Sat, 6 Dec 2008 23:29:36 +0200 geoip (1.4.5.dfsg-1) experimental; urgency=low * New upstream release. - Rediff of 01-manpages-fix. - Drop 02-manpage-typo-path-fix (merged upstream). - Add 02-add-geoiplookup6-man patch from upstream CVS. It adds a missing manual page in this release. - Add again chrpath (RPATH issue is back). - Updated shlibs.local. * Move the GeoIP database to NEW package geoip-database. Thanks lintian. * We can deliver now Makefile.{netware,win32}. The non dfsg-free statements are removed. -- Patrick Matthäi Sun, 9 Nov 2008 20:53:00 +0200 geoip (1.4.4.dfsg-3+lenny1) stable; urgency=low * Change my email address. * Add missing versioned replaces, because of the clashing /etc/GeoIP.conf.default file in libgeoip1 and geoip-bin. Closes: #534459 -- Patrick Matthäi Wed, 15 Jul 2009 00:03:07 +0200 geoip (1.4.4.dfsg-3) unstable; urgency=low * Removed chrpath because we do not need it anymore at GeoIP. * Moved /etc/GeoIP.conf.default from libgeoip1 to geoip-bin because geoipupdate needs the configuration. -- Patrick Matthäi Sun, 6 Jul 2008 19:26:31 +0200 geoip (1.4.4.dfsg-2) unstable; urgency=low * Added 02-manpage-typo-path-fix.dpatch which fixes an non-existent path on Debian and a typo reported by A. Costa. Closes: #488922 * Added missing dpatch information in 01-manpages-fix.dpatch. * Added DM-Upload-Allowed control field. * Some long description tune ups. Using new paragraphs instead of double spaces. * Removed versioned suggesting from libgeoip1 on geoip-bin. * Added Debian versionmangle in debian/watch to remove the dfsg tag. Thanks lintian. * Bumped Standards-Version to 3.8.0. - Added README.source. -- Patrick Matthäi Wed, 2 Jul 2008 18:37:00 +0200 geoip (1.4.4.dfsg-1~bpo40+1) etch-backports; urgency=low * Rebuild for etch-backports. -- Patrick Matthäi Fri, 15 May 2008 20:28:03 +0100 geoip (1.4.4.dfsg-1) unstable; urgency=low * New upstream release. - Updated shlibs.local file. * Removed *.links file. It is now handled by better *.install files. * Changed documented sed removal command in README.Debian-source. -- Patrick Matthäi Wed, 23 Jan 2008 18:17:00 +0100 geoip (1.4.3.dfsg-1) unstable; urgency=low * Created an DFSG tarball, for more informations read README.Debian-source. * Added debian/README.Debian-source, which will be installed as doc, too. * Changed license from GPL to LGPL in debian/copyright, it has been changed with the new upstream release. Closes: #456190 * Bumped Standards-Version to 3.7.3. * Changed Section of libgeoip-dev from devel to libdevel. -- Patrick Matthäi Wed, 19 Dec 2007 20:55:00 +0100 geoip (1.4.3-1) unstable; urgency=low * New upstream release. Closes: #394319, #397938, #426292 * Set me as the new maintainer of this package. Closes: #411676 * Using now cdbs at build time and make the package binNMU safe. Closes: #408612 * Changed debian/compat to 5 instead of 4. * debian/control: Control uses now the new homepage field and setted the standards version to 3.7.2. * Removed not needed debian/*.dirs files. * Added cdbs, dpatch and chrpath to the build dependencies. * Removed useless whitespaces in debian/copyright. -- Patrick Matthäi Fri, 26 Oct 2007 16:10:30 +0200 geoip (1.3.17-1.1) unstable; urgency=high * Non-maintainer upload by security team. * Added patch for CVE-2007-0159: libgeoip1: "GeoIP_update_database_general()" Remote Directory Traversal Vulnerability (Closes: #406628) * Removed automatically copying of config.status and config.sub - this creates a bloated diff for security updates. -- Neil McGovern Sat, 27 Jan 2007 10:23:23 +0000 geoip (1.3.17-1) unstable; urgency=low * The latest upstream version -- Marek Habersack Fri, 26 May 2006 23:15:29 +0200 geoip (1.3.16-1) unstable; urgency=low * The latest upstream version -- Marek Habersack Tue, 9 May 2006 21:28:24 +0200 geoip (1.3.14-2) unstable; urgency=low * geoip_1.3.14-1(unstable/arm/grieg): needs libtool update for arm (Closes: #343461) Updated the libtool version to the latest available in Debian. -- Marek Habersack Fri, 16 Dec 2005 12:46:08 +0100 geoip (1.3.14-1) unstable; urgency=low * New upstream version 1.3.14 (Closes: #334417) -- Marek Habersack Sun, 30 Oct 2005 23:52:05 +0100 geoip (1.3.13-1) unstable; urgency=low * The latest upstream version * Updated the Standards-Version. No changes. -- Marek Habersack Tue, 23 Aug 2005 11:30:59 +0200 geoip (1.3.11-1) unstable; urgency=high * The latest upstream release * Closes: #315425: geoip(GNU/k*BSD): FTBFS: out of date libtool scripts * Closes: #261263: exporting does not work. geoipexport has been removed since it is out of date and doesn't support the current database format. -- Marek Habersack Tue, 19 Jul 2005 13:40:35 +0200 geoip (1.3.10-1) unstable; urgency=low * Closes: #305143: New upstream version 1.3.10 * Closes: #291242: No manual page geoipexportlocations.1 * Closes: #266448: Error un geoipupdate -- Marek Habersack Tue, 14 Jun 2005 02:55:41 +0200 geoip (1.3.8-1) unstable; urgency=low * The latest upstream version -- Marek Habersack Sun, 14 Nov 2004 05:07:31 +0100 geoip (1.3.6-1) unstable; urgency=high * The latest upstream release. Upstream changes * Made GeoIP City code thread safe * Fixed bug with geoipupdate read in product ids * Added support for GeoIP Netspeed lookup * Fix memleak in lookupaddress (Ludwig Nussel/SUSE) * Add prototype for _full_path_to to make 64bit clean (Ludwig Nussel/SUSE) * Add return values to test programs (Ludwig Nussel/SUSE) -- Marek Habersack Mon, 6 Sep 2004 16:49:36 +0200 geoip (1.3.5-1) unstable; urgency=low * The latest upstream version * Modified the geoiplookup(1) manpage to match the program behavior (closes: Bug#258378) * Fixed geoipexportlocations to check the number of arguments it is passed (closes: Bug#258379) * Changed the location of the SYSCONFDIR (closes: Bug#258380) -- Marek Habersack Fri, 9 Jul 2004 17:39:58 +0200 geoip (1.3.2-1) unstable; urgency=low * The latest upstream release * Updated the standards version. No changes. -- Marek Habersack Tue, 4 May 2004 15:45:28 +0200 geoip (1.3.1-1) unstable; urgency=low * The latest upstream release (closes: Bug#228225) -- Marek Habersack Sat, 17 Jan 2004 16:33:28 +0100 geoip (1.3.0-1) unstable; urgency=low * Latest upstream release. * This release contains an important API change: 1.3.x and above users for GeoIP Region database GeoIPRegion.region is no longer a pointer but an in-structure array so test the first byte of region == 0 rather testing if the region pointer is NULL. -- Marek Habersack Tue, 21 Oct 2003 03:22:18 +0200 geoip (1.2.2-1) unstable; urgency=low * Latest upstream release. Upstream changes: * Added support for GeoIP ISP Edition identifier * Fixed bug in GeoIP_database_info (Jason Linhart) * Added support for GeoIP AS Number Edition ! renamed GeoIP_org_by_* functions to GeoIP_name_by_* to reduce confusion since these functions are used by GeoIP ISP and GeoIP ASNum as well as GeoIP Organization * Added support for GeoIP Proxy Edition ! renamed GeoIP_country_id_by_* functions to GeoIP_id_by_* -- Marek Habersack Tue, 2 Sep 2003 20:10:26 -0400 geoip (1.2.0-1) unstable; urgency=low * Latest upstream release. -- Marek Habersack Thu, 22 May 2003 02:32:41 +0200 geoip (1.1.9-1) unstable; urgency=low * Latest upstream release. * First upload to Debian. -- Marek Habersack Fri, 28 Mar 2003 22:42:24 +0100 geoip (1.1.1-1) unstable; urgency=low * Initial Release. -- Marek Habersack Mon, 11 Nov 2002 19:25:35 +0100 debian/docs0000644000000000000000000000001712237144036010041 0ustar README.md TODO debian/geoip-bin.manpages0000644000000000000000000000004212237144036012552 0ustar debian/tmp/usr/share/man/man1/*.1 debian/libgeoip1.install0000644000000000000000000000004312237144036012430 0ustar debian/tmp/usr/lib/*/libGeoIP.so.* debian/README.Debian0000644000000000000000000000135012237144036011230 0ustar geoip for Debian ---------------- The library comes with a free country database which does not contain all the information that can be accessible via the GeoIP API. To find other database editions, please visit http://www.maxmind.com/ (all of them except for the one included in the package require you to purchase a license from MaxMind) If you have obtained the license, you must install the geoip-bin package and copy the /etc/GeoIP.conf.default file to /etc/GeoIP.conf and edit it entering the licensing data. Updating databases ------------------ If you need to update your database very frequency, then you can install the geoip-database-contrib package. -- Patrick Matthäi Sat, 15 Jan 2011 19:13:05 +0100 debian/copyright0000644000000000000000000000774312237144036011136 0ustar This package was debianized by Marek Habersack on Mon, 11 Nov 2002 19:25:35 +0100. This file has been changed on Wed, 19 Dec 2007 20:55:00 +0100 from Patrick Matthäi . It was downloaded from http://www.maxmind.com/download/geoip/api/c/ Here you can get the databases: http://geolite.maxmind.com/download/geoip/database/ Upstream Author: T.J. Mather Copyright: (C) 2007 MaxMind LLC License (debian/src/geoip-csv-to-dat.cpp): Copyright (c) 2009 Kalle Olavi Niemitalo. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. License (data/GeoIP.dat): OPEN DATA LICENSE All advertising materials and documentation mentioning features or use of this database must display the following acknowledgment: "This product includes GeoLite data created by MaxMind, available from http://maxmind.com/" Redistribution and use with or without modification, are permitted provided that the following conditions are met: 1. Redistributions must retain the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 2. All advertising materials and documentation mentioning features or use of this database must display the following acknowledgement: "This product includes GeoLite data created by MaxMind, available from http://maxmind.com/" 3. "MaxMind" may not be used to endorse or promote products derived from this database without specific prior written permission. THIS DATABASE IS PROVIDED BY MAXMIND, INC ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MAXMIND BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DATABASE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License (everything else): This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA On Debian GNU/Linux systems, the complete text of the GNU Lesser General Public License can be found in `/usr/share/common-licenses/LGPL-2'. The Debian packaging is © 2009-2010, Patrick Matthäi and is licensed under the LGPL-2, see above. debian/geoip-bin.install0000644000000000000000000000016512237144036012433 0ustar debian/tmp/usr/bin/* usr/bin/ debian/tmp/geoip-generator usr/lib/geoip/ debian/src/v4-to-v6-layout.pl usr/lib/geoip/ debian/libgeoip1.lintian-overrides0000644000000000000000000000013712237144036014424 0ustar libgeoip1: spelling-error-in-binary libgeoip1: no-symbols-control-file usr/lib/*/libGeoIP.so.* debian/libgeoip-dev.examples0000644000000000000000000000004312237144036013273 0ustar test/Makefile* test/*.txt test/*.c debian/watch0000644000000000000000000000015012237144036010215 0ustar version=3 https://github.com/maxmind/geoip-api-c/releases \ /maxmind/geoip-api-c/archive/v(.+)\.tar\.gz debian/src/0000755000000000000000000000000012237144036007757 5ustar debian/src/geoip-csv-to-dat.cpp0000644000000000000000000005417312237144036013557 0ustar /* geoip-csv-to-dat - convert a country database from CSV to GeoIP binary format * * Copyright (c) 2009 Kalle Olavi Niemitalo. * Copyright (c) 2011 Patrick Matthäi * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define _GNU_SOURCE 1 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Format of GeoIP Country database files // ====================================== // // 1. Binary trie mapping IP addresses to countries. // 2. Optional unused data. // 3. Optional database-info block. // 4. Optional structure-info block. // // Binary trie // ----------- // // The trie treats IP addresses as bit sequences and maps them to // numbers. In the country database, each such number is 0xFFFF00 + // the the country ID that GeoIP_id_by_ipnum() would return. The // meanings of country IDs are hardcoded in libGeoIP and cannot be // overridden by the database. // // The root node of the trie is at the beginning of the file, and the // other nodes then follow it. Each node has the same size and // consists of two little-endian pointers that correspond to the two // possible values of a bit. In the country database, the pointers are // 24-bit, and each node is thus 6 bytes long. // // Each pointer is one of: // - The number that the whole lookup should return, i.e. 0xFFFF00 + id // in the country database. // - The number of the node that should be examined next, counting from // 0 at the beginning of the file. Pointing back to nodes with // smaller numbers is allowed, but loops are not allowed. // // Optional unused data // -------------------- // // The file format seems to permit extra data between the binary trie // and the optional blocks. // // Optional database-info block // ---------------------------- // // Near the end of the file, there may be a three-byte tag (0x00 0x00 // 0x00) followed by at most DATABASE_INFO_MAX_SIZE - 1 = 99 bytes of // text that describes the database. GeoIP_database_info() returns // this text and appends a terminating '\0'. // // The GeoLite Country IPv4 database downloadable from MaxMind // includes this database-info block. // // Optional structure-info block // ----------------------------- // // At the very end of the file, there may be a three-byte tag (0xFF // 0xFF 0xFF) followed by at most STRUCTURE_INFO_MAX_SIZE - 1 = 19 // bytes. The first byte is the database type, // e.g. GEOIP_COUNTRY_EDITION = 1 or GEOIP_COUNTRY_EDITION_V6 = 12, // possibly with 105 added to it. Type-specific information then // follows. There is no type-specific information for the country // editions. // // The GeoLite Country IPv4 database downloadable from MaxMind does // not include this structure-info block. namespace { class binary_trie { public: typedef uint_fast32_t edge_type; explicit binary_trie(edge_type leaf); void set_range( const uint8_t range_min[], const uint8_t range_max[], std::size_t bit_count, edge_type leaf); void reorder_depth_first(); void reorder_in_blocks(std::size_t bytes_per_block); void write_binary(std::ostream &dat_stream) const; private: struct node { edge_type edges[2]; }; std::vector nodes; // This could be std::vector but that seems slower. typedef std::vector bits_vector; void set_range_in_node( const bits_vector *min_bits, const bits_vector *max_bits, std::size_t bit_pos, edge_type edit_node, edge_type leaf); void set_range_in_edge( const bits_vector *min_bits, const bits_vector *max_bits, std::size_t bit_pos, edge_type edit_node, bool bit, edge_type leaf); void reorder( const std::vector &old_to_new, const std::vector &new_to_old); }; } /** Construct a binary trie and its root node. * * \param leaf * Both edges of the root node will initially point to this leaf. * The caller should provide a value that means nothing was found. */ binary_trie::binary_trie(edge_type leaf) { const node node = {{ leaf, leaf }}; nodes.push_back(node); } /** Edit the trie so it maps a range of bit sequences to the same * leaf. * * \param range_min * The first bit sequence in the range. Eight bits are packed in each * byte. The most significant bit of the whole sequence is in the * most significant bit of the first byte. * * \param range_max * The last bit sequence in the range. * * \param bit_count * The number of bits in both sequences. * * \param leaf * The leaf to which all the bit sequences in the range should be * mapped. */ void binary_trie::set_range( const uint8_t range_min[], const uint8_t range_max[], std::size_t bit_count, edge_type leaf) { bits_vector min_bits(bit_count); bits_vector max_bits(bit_count); for (std::size_t i = 0; i < bit_count; ++i) { std::size_t byte_pos = i / 8; uint8_t mask = 1 << ((~i) % 8); min_bits[i] = ((range_min[byte_pos] & mask) != 0); max_bits[i] = ((range_max[byte_pos] & mask) != 0); } set_range_in_node(&min_bits, &max_bits, 0, 0, leaf); } /** Edit a node in the trie so it maps a range of bit sequences to the * same leaf. * * \param min_bits * The first bit sequence in the range, or NULL if unbounded. * * \param max_bits * The last bit sequence in the range, or NULL if unbounded. * * \param bit_pos * Which bit in the sequences corresponds to \a edit_node. * * \param edit_node * The node to be modified. * * \param leaf * The leaf to which all the bit sequences in the range should be * mapped. */ void binary_trie::set_range_in_node( const bits_vector *min_bits, const bits_vector *max_bits, std::size_t bit_pos, edge_type edit_node, edge_type leaf) { if (!min_bits || (*min_bits)[bit_pos] == false) { set_range_in_edge(min_bits, (max_bits && (*max_bits)[bit_pos] == false) ? max_bits : NULL, bit_pos + 1, edit_node, false, leaf); } if (!max_bits || (*max_bits)[bit_pos] == true) { set_range_in_edge((min_bits && (*min_bits)[bit_pos] == true) ? min_bits : NULL, max_bits, bit_pos + 1, edit_node, true, leaf); } } /** Edit an edge in the trie so it maps a range of bit sequences to * the same leaf. * * \param min_bits * The first bit sequence in the range, or NULL if unbounded. * * \param max_bits * The last bit sequence in the range, or NULL if unbounded. * * \param bit_pos * Which bit in the sequences corresponds to \a bit. * * \param edit_node * The node in which the edge to be modified is located. * * \param bit * Which edge of \a edit_node should be modified. * * \param leaf * The leaf to which all the bit sequences in the range should be * mapped. */ void binary_trie::set_range_in_edge( const bits_vector *min_bits, const bits_vector *max_bits, std::size_t bit_pos, edge_type edit_node, bool bit, edge_type leaf) { // Check if the range fills this edge entirely. bool entire = true; if (min_bits && std::find(min_bits->begin() + bit_pos, min_bits->end(), true) != min_bits->end()) entire = false; if (max_bits && std::find(max_bits->begin() + bit_pos, max_bits->end(), false) != max_bits->end()) entire = false; if (entire) { nodes[edit_node].edges[bit] = leaf; } else { edge_type next = nodes[edit_node].edges[bit]; if (next >= nodes.size()) { const node new_node = {{ next, next }}; next = nodes.size(); nodes.push_back(new_node); nodes[edit_node].edges[bit] = next; } set_range_in_node(min_bits, max_bits, bit_pos, next, leaf); } } /** Renumber the nodes in depth-first order. */ void binary_trie::reorder_depth_first() { std::vector old_to_new, new_to_old; std::stack depth_first; old_to_new.resize(nodes.size(), -1); new_to_old.reserve(nodes.size()); depth_first.push(0); while (!depth_first.empty()) { const edge_type edge = depth_first.top(); depth_first.pop(); if (edge < nodes.size()) { old_to_new[edge] = new_to_old.size(); new_to_old.push_back(edge); depth_first.push(nodes[edge].edges[1]); depth_first.push(nodes[edge].edges[0]); } } reorder(old_to_new, new_to_old); } /** Renumber the nodes to make lookups use CPU and disk caches more * effectively. * * First group the nodes into blocks so that each block contains the * root of a subtrie and as many levels of its descendants as will * fit. This way, after the root is paged in, the next few lookup * steps need not page in anything else. Then, sort the nodes of each * block in depth-first order. That should give each lookup almost * 1/2 chance to find the next node immediately adjacent. * * With a block size of 1024 bytes, this renumbering reduces the time * required for random lookups by about 1.1%, compared to a plain * depth-first order. However, it's still 2.3% slower than the * database optimized by MaxMind. */ void binary_trie::reorder_in_blocks( std::size_t bytes_per_block) { const edge_type none = -1; std::vector old_to_new, new_to_old; ssize_t bytes_left = bytes_per_block; old_to_new.resize(nodes.size(), none); new_to_old.reserve(nodes.size()); for (edge_type subtrie = 0; subtrie < nodes.size(); ++subtrie) { // If subtrie has already been added to the output, // ignore it. if (old_to_new[subtrie] != none) continue; // Walk breadth-first from subtrie until we have a // block full of nodes or the subtrie runs out. Don't // add these nodes immediately to the output, however. // Instead just list them in nodes_in_block. std::set nodes_in_block; std::queue breadth_first; breadth_first.push(subtrie); if (bytes_left <= 0) bytes_left += bytes_per_block; while (bytes_left > 0 && !breadth_first.empty()) { edge_type edge = breadth_first.front(); breadth_first.pop(); if (edge >= nodes.size()) continue; // Let the last node of the block straddle the // block boundary. That's better than making // the hotter first node do so. bytes_left -= 6; nodes_in_block.insert(edge); breadth_first.push(nodes[edge].edges[0]); breadth_first.push(nodes[edge].edges[1]); } // Add the nodes from nodes_in_block to the output in // depth-first order. This assumes they are all // reachable from subtrie. std::stack depth_first; depth_first.push(subtrie); while (!depth_first.empty()) { edge_type edge = depth_first.top(); depth_first.pop(); if (nodes_in_block.find(edge) == nodes_in_block.end()) continue; old_to_new[edge] = new_to_old.size(); new_to_old.push_back(edge); depth_first.push(nodes[edge].edges[1]); depth_first.push(nodes[edge].edges[0]); } } reorder(old_to_new, new_to_old); } void binary_trie::reorder( const std::vector &old_to_new, const std::vector &new_to_old) { std::vector new_nodes; new_nodes.reserve(new_to_old.size()); for (std::vector::const_iterator it = new_to_old.begin(); it != new_to_old.end(); ++it) { node new_node; for (int bit = 0; bit <= 1; ++bit) { edge_type old_edge = nodes[*it].edges[bit]; if (old_edge < nodes.size()) new_node.edges[bit] = old_to_new[old_edge]; else new_node.edges[bit] = old_edge; } new_nodes.push_back(new_node); } swap(new_nodes, nodes); } /** Write the trie to a stream in GeoIP binary format. */ void binary_trie::write_binary(std::ostream &dat_stream) const { for (std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { union { uint8_t bytes[6]; char chars[6]; } binary = {{ (it->edges[0] ) & 0xFF, (it->edges[0] >> 8) & 0xFF, (it->edges[0] >> 16) & 0xFF, (it->edges[1] ) & 0xFF, (it->edges[1] >> 8) & 0xFF, (it->edges[1] >> 16) & 0xFF }}; dat_stream.write(binary.chars, 6); if (dat_stream.bad()) return; } } namespace { void csv_line_to_vector( const std::string &line, std::vector &fields) { fields.clear(); std::vector field; bool quoted = false; bool spaces_after_comma = false; for (std::string::const_iterator it = line.begin(); it != line.end(); ++it) { if (*it == '"') { quoted = !quoted; spaces_after_comma = false; } else if (*it == ',' && !quoted) { fields.push_back(std::string(field.begin(), field.end())); field.clear(); spaces_after_comma = true; } else if (*it == ' ' && spaces_after_comma) { } else { field.push_back(*it); spaces_after_comma = false; } } fields.push_back(std::string(field.begin(), field.end())); } /** Load ranges of IP addresses from a CSV-formatted stream to * a trie. * * \param trie * Load the ranges to this trie, overwriting original values. * * \param csv_file_name * The name of the file that \a csv_stream is reading. * This string is used only for error messages. * * \param csv_stream * Load the ranges from this stream. * * \param address_family * The type of IP addresses in the CSV data: either AF_INET * for IPv4 or AF_INET6 for IPv6. */ void csv_stream_to_trie( binary_trie &trie, const char *csv_file_name, std::istream &csv_stream, int address_family) { enum { CSV_FIELD_MIN_TEXT, CSV_FIELD_MAX_TEXT, CSV_FIELD_MIN_DECIMAL, CSV_FIELD_MAX_DECIMAL, CSV_FIELD_COUNTRY_CODE, CSV_FIELD_COUNTRY_NAME, CSV_FIELDS }; std::string csv_line; std::vector csv_fields; int csv_line_number = 0; while (getline(csv_stream, csv_line)) { ++csv_line_number; csv_line_to_vector(csv_line, csv_fields); if (csv_fields.size() != CSV_FIELDS) { error_at_line(EX_DATAERR, 0, csv_file_name, csv_line_number, "Wrong number of fields"); } if (csv_fields[CSV_FIELD_COUNTRY_CODE] == "AN") { csv_fields[CSV_FIELD_COUNTRY_CODE] = "CW"; } const int countryid = GeoIP_id_by_code(csv_fields[CSV_FIELD_COUNTRY_CODE].c_str()); if (countryid == 0) { error_at_line(EX_DATAERR, 0, csv_file_name, csv_line_number, "Unrecognized country code: %s", csv_fields[CSV_FIELD_COUNTRY_CODE].c_str()); } const binary_trie::edge_type leaf = 0xFFFF00 + countryid; union { struct in_addr inet; uint8_t inetbytes[4]; struct in6_addr inet6; } minaddr, maxaddr; if (inet_pton(address_family, csv_fields[CSV_FIELD_MIN_TEXT].c_str(), &minaddr) <= 0) { error_at_line(EX_DATAERR, 0, csv_file_name, csv_line_number, "Cannot parse minimum address: %s", csv_fields[CSV_FIELD_MIN_TEXT].c_str()); } if (inet_pton(address_family, csv_fields[CSV_FIELD_MAX_TEXT].c_str(), &maxaddr) <= 0) { error_at_line(EX_DATAERR, 0, csv_file_name, csv_line_number, "Cannot parse maximum address: %s", csv_fields[CSV_FIELD_MAX_TEXT].c_str()); } switch (address_family) { case AF_INET: trie.set_range(minaddr.inetbytes, maxaddr.inetbytes, 32, leaf); break; case AF_INET6: trie.set_range(minaddr.inet6.s6_addr, maxaddr.inet6.s6_addr, 128, leaf); break; default: abort(); } } if (csv_stream.bad()) { error(EX_IOERR, errno, "%s", csv_file_name); } } /** Load ranges of IP addresses from a CSV-formatted file or * standard input to a trie. * * \param trie * Load the ranges to this trie, overwriting original values. * * \param csv_file_name * The name of the CSV file that should be read, or "-" for * standard input. * * \param address_family * The type of IP addresses in the CSV data: either AF_INET * for IPv4 or AF_INET6 for IPv6. */ void csv_file_to_trie( binary_trie &trie, const char *csv_file_name, int address_family) { if (std::strcmp(csv_file_name, "-") == 0) { csv_stream_to_trie(trie, csv_file_name, std::cin, address_family); } else { std::ifstream csv_stream(csv_file_name, std::ios::in); if (!csv_stream) { error(EX_NOINPUT, errno, "%s", csv_file_name); } csv_stream_to_trie(trie, csv_file_name, csv_stream, address_family); } } /** Write a GeoIP binary database to a stream. * * \param trie * Mapping from IP addresses to country codes or other values. * * \param dat_file_name * The name of the file that \a dat_stream is writing. * This string is used only for error messages. * * \param dat_stream * Write the database to this stream. * * \param database_info * Copyright or other information about the database, or NULL. * GeoIP_database_info() will return this string. * * \param address_family * The type of IP addresses in the database: either AF_INET * for IPv4 or AF_INET6 for IPv6. */ void write_dat_stream( const binary_trie &trie, const char *dat_file_name, std::ostream &dat_stream, const char *database_info, int address_family) { trie.write_binary(dat_stream); if (dat_stream.bad()) { error(EX_IOERR, errno, "%s", dat_file_name); } if (database_info) { const char tag[3] = { 0, 0, 0 }; dat_stream.write(tag, 3); dat_stream.write(database_info, std::strlen(database_info)); if (dat_stream.bad()) { error(EX_IOERR, errno, "%s", dat_file_name); } } switch (address_family) { case AF_INET: { const char structure_info[4] = { 0xFF, 0xFF, 0xFF, 1 }; dat_stream.write(structure_info, 4); break; } case AF_INET6: { const char structure_info[4] = { 0xFF, 0xFF, 0xFF, 12 }; dat_stream.write(structure_info, 4); break; } default: abort(); } if (dat_stream.bad()) { error(EX_IOERR, errno, "%s", dat_file_name); } } /** Write a GeoIP binary database to a file or standard output. * * \param trie * Mapping from IP addresses to country codes or other values. * * \param csv_file_name * The name of the file that should be written, or "-" for * standard output. * * \param database_info * Copyright or other information about the database, or NULL. * GeoIP_database_info() will return this string. * * \param address_family * The type of IP addresses in the database: either AF_INET * for IPv4 or AF_INET6 for IPv6. */ void write_dat_file( const binary_trie &trie, const char *dat_file_name, const char *database_info, int address_family) { if (std::strcmp(dat_file_name, "-") == 0) { write_dat_stream(trie, dat_file_name, std::cout, database_info, address_family); } else { std::ofstream dat_stream( dat_file_name, std::ios::out | std::ios::binary); if (!dat_stream) { error(EX_CANTCREAT, errno, "%s", dat_file_name); } write_dat_stream(trie, dat_file_name, dat_stream, database_info, address_family); } } struct cmdline { const char *csv_file_name; const char *dat_file_name; int address_family; const char *database_info; bool verbose; cmdline(int argc, char **argv); }; } cmdline::cmdline(int argc, char **argv): csv_file_name("-"), dat_file_name("-"), address_family(AF_INET), database_info(NULL), verbose(false) { enum { OPT_HELP = -2 }; static const struct option long_options[] = { { "inet", no_argument, NULL, '4' }, { "inet6", no_argument, NULL, '6' }, { "info", required_argument, NULL, 'i' }, { "output", required_argument, NULL, 'o' }, { "verbose", no_argument, NULL, 'v' }, { "help", no_argument, NULL, OPT_HELP }, { NULL, 0, NULL, 0 } }; static const char *const usage = "\ Usage: %s [OPTION] [CSV-FILE]...\n\ Convert a country database from CSV to GeoIP binary format.\n\ \n\ -4, --inet addresses are IPv4 (default)\n\ -6, --inet6 addresses are IPv6\n\ -i, --info=TEXT add copyright or other info TEXT to output\n\ -o, --output=FILE write the binary data to FILE, not stdout\n\ -v, --verbose show what is going on\n\ --help display this help and exit\n"; for (;;) { int optret = getopt_long(argc, argv, "46i:o:v", long_options, NULL); if (optret == -1) break; switch (optret) { case '4': address_family = AF_INET; break; case '6': address_family = AF_INET6; break; case 'i': database_info = optarg; if (std::strlen(database_info) > 99) { error(EX_USAGE, 0, "Database info must not be longer than 99 bytes"); } break; case 'o': dat_file_name = optarg; break; case 'v': verbose = true; break; case OPT_HELP: std::printf(usage, program_invocation_name); std::exit(EX_OK); case '?': std::fprintf(stderr, "Try `%s --help' for more information.\n", program_invocation_name); std::exit(EX_USAGE); default: std::abort(); } } if (optind < argc) csv_file_name = argv[optind++]; if (optind < argc) { error(EX_USAGE, 0, "Only one non-option argument is allowed"); } } int main(int argc, char **argv) { cmdline cmdline(argc, argv); std::ostream *verbose_stream; if (!cmdline.verbose) verbose_stream = NULL; else if (strcmp(cmdline.dat_file_name, "-") == 0) verbose_stream = &std::cerr; else verbose_stream = &std::cout; if (verbose_stream) { *verbose_stream << program_invocation_name << ": Reading CSV and building the trie" << std::endl; } binary_trie trie(0xFFFF00); csv_file_to_trie(trie, cmdline.csv_file_name, cmdline.address_family); if (verbose_stream) { *verbose_stream << program_invocation_name << ": Optimizing" << std::endl; } trie.reorder_depth_first(); trie.reorder_in_blocks(1024); if (verbose_stream) { *verbose_stream << program_invocation_name << ": Writing output" << std::endl; } write_dat_file(trie, cmdline.dat_file_name, cmdline.database_info, cmdline.address_family); if (verbose_stream) { *verbose_stream << program_invocation_name << ": All done" << std::endl; } } debian/src/v4-to-v6-layout.pl0000755000000000000000000000103012237144036013126 0ustar #!/usr/bin/perl use warnings; use strict; # Script from Boris Zentner (Maxmind) # This script converts the IPv4 csv database to the same # format as the IPv6 database. sub _x { sprintf("%02x%02x:%02x%02x", split(/\./, $_[0])); } while(){ chomp; my($f, $t, $tail) = split /,/, $_, 3; for($t, $f){ s/^"//; s/"$//; } my $xxxxf = _x($f); my $xxxxt = _x($t); print <<__OUT__; "::$f", "::$t", $tail "::ffff:$f", "::ffff:$t", $tail "2002:${xxxxf}::", "2002:${xxxxt}:ffff:ffff:ffff:ffff:ffff", $tail __OUT__ } exit(0); debian/rules0000755000000000000000000000126412237144036010253 0ustar #!/usr/bin/make -f #export DH_VERBOSE=1 export DEB_BUILD_HARDENING=1 export DEB_BUILD_OPTIONS+=nocheck DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) DEB_UPSTREAM_VERSION := $(shell dpkg-parsechangelog|grep "^Version:"|cut -d" " -f2|rev|cut -d- -f2-|rev|cut -d':' -f2) %: dh $@ --with autoreconf override_dh_auto_install: $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp # Build the build script. g++ -g debian/src/geoip-csv-to-dat.cpp -o debian/tmp/geoip-generator -lGeoIP \ -I $(CURDIR)/debian/tmp/usr/include/ -L $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/ chrpath -d -k debian/tmp/usr/bin/geoip* override_dh_strip: dh_strip --dbg-package=geoip-dbg debian/geoip-bin.lintian-overrides0000644000000000000000000000011012237144036014411 0ustar geoip-bin: hardening-no-fortify-functions usr/lib/geoip/geoip-generator debian/libgeoip-dev.install0000644000000000000000000000017712237144036013133 0ustar debian/tmp/usr/include/*.h usr/include/ debian/tmp/usr/lib/*/*.a debian/tmp/usr/lib/*/*.so debian/tmp/usr/lib/*/pkgconfig/*.pc debian/source/0000755000000000000000000000000012237144036010470 5ustar debian/source/format0000644000000000000000000000001412237144036011676 0ustar 3.0 (quilt) debian/clean0000644000000000000000000000001712237144036010173 0ustar data/GeoIP.dat debian/compat0000644000000000000000000000000212237144036010366 0ustar 9