├── .github └── dependabot.yml ├── .gitignore ├── .travis.yml ├── Changes.md ├── LICENSE ├── README.md ├── dev-bin ├── generate_regionName.pl └── generate_timeZone.pl ├── examples ├── ASNumLookup.java ├── ASNumLookupV6.java ├── CityLookup.java ├── CityLookupV6.java ├── CountryLookup.java ├── CountryLookupV6.java ├── DomainLookup.java ├── NetSpeedCellLookup.java ├── NetspeedLookup.java ├── OrgLookup.java └── RegionLookup.java ├── pom.xml └── src ├── main └── java │ └── com │ └── maxmind │ └── geoip │ ├── Country.java │ ├── DatabaseInfo.java │ ├── InvalidDatabaseException.java │ ├── Location.java │ ├── LookupService.java │ ├── Region.java │ ├── regionName.java │ └── timeZone.java └── test ├── java └── com │ └── maxmind │ └── geoip │ ├── ASNumLookupTest.java │ ├── CityLookupIdxTest.java │ ├── CityLookupTest.java │ ├── CityLookupV6Test.java │ ├── CountryLookupTest.java │ ├── CountryLookupV6Test.java │ ├── DomainLookupTest.java │ ├── NetSpeedCellLookupTest.java │ └── OrgLookupTest.java └── resources └── GeoIP ├── GeoIP-113.csv ├── GeoIP-124.csv ├── GeoIP-134.csv ├── GeoIP-139.csv ├── GeoIP-174.csv ├── GeoIP-178.csv ├── GeoIP-ASNum.csv ├── GeoIP-UserType.csv ├── GeoIP.csv ├── GeoIP.dat ├── GeoIPASNum.dat ├── GeoIPCity-Corrupt.dat ├── GeoIPCity.dat ├── GeoIPDistance.csv ├── GeoIPDistance.dat ├── GeoIPDomain.dat ├── GeoIPISP.dat ├── GeoIPNetSpeedCell.dat ├── GeoIPOrg.dat ├── GeoIPUserType.dat ├── GeoIPv6.csv ├── GeoIPv6.dat ├── GeoLiteCityv6-no-addr.csv ├── GeoLiteCityv6.csv └── GeoLiteCityv6.dat /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *~ 3 | 4 | # Package Files # 5 | *.jar 6 | *.war 7 | *.ear 8 | 9 | reports 10 | target/ 11 | .classpath 12 | .project 13 | .settings 14 | /GeoIP/ 15 | geoip-test-databases.tar.gz 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dist: trusty 3 | sudo: false 4 | addons: 5 | coverity_scan: 6 | project: 7 | description: Build submitted via Travis CI 8 | name: maxmind/geoip-api-java 9 | notification_email: dev-ci@maxmind.com 10 | build_command_prepend: mvn clean 11 | build_command: mvn -DskipTests=true compile 12 | branch_pattern: .*coverity.* 13 | language: java 14 | matrix: 15 | include: 16 | - jdk: openjdk7 17 | - jdk: openjdk8 18 | - jdk: oraclejdk8 19 | env: RUN_SNYK=true 20 | env: 21 | global: 22 | - secure: d72scMGybGfXPuGKwvFXOF+3fq9d/FV5CDN1uAD5GW1r+vV0dZkKnoG3ZZ7bwikOIei4Z5zQ1oVhnPhHOS2ReCxmui1uwcGJnwl1Pwpmq/zei2sNsqyPMGA3q0v87g8wr5G+l3cRPDMBlqtjjuYHfbvyXPbYf0qTJ9NDWybg40s= 23 | - secure: a31E7Z7LbCoy4zVi/kQx44QoiyMwf1sQPYnGfjizZbiyUpVdBnkRo92dkcbHm44hApQPGGq8ZFXiIFlOKLyRAHAun6d+0bzanMMLPpXSXYomFVQENTXVvP+Obz9gvtevAAyN9T2YTL6r+omd4WPPKyDGOQpC+vcKbOIOc6rnq2U= 24 | before_install: 25 | - "if [[ $RUN_SNYK && $SNYK_TOKEN ]]; then sudo apt-get install -y nodejs; fi" 26 | - "if [[ $RUN_SNYK && $SNYK_TOKEN ]]; then npm install -g snyk; fi" 27 | install: 28 | - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 29 | - "if [[ $RUN_SNYK && $SNYK_TOKEN ]]; then snyk test --org=maxmind; fi" 30 | after_success: 31 | - "if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' && $RUN_SNYK && $SNYK_TOKEN ]]; then snyk monitor --org=maxmind --project-name=maxmind/geoip-api-java; fi" 32 | notifications: 33 | email: 34 | on_failure: always 35 | on_success: change 36 | recipients: 37 | - dev-ci@maxmind.com 38 | slack: 39 | rooms: 40 | secure: "e4/3Esjo65Quf7MN2mXKLY0CJ23iBFPdTGdGdhE8RVPzfR2/c+YzISSOGbDFGkuQyq2kDuK94PZ3JC7xT2Cy86DEIfCc3ws46qcknrRwbCZSXLH0gTYC748JKgdaGvXxjzwCyEIoAv67EiUPPFIm+R6d01P2h4JvGpAXSvD13DM=\n" 41 | -------------------------------------------------------------------------------- /Changes.md: -------------------------------------------------------------------------------- 1 | Changes 2 | ======= 3 | 4 | 1.3.1 (2016-02-08) 5 | ------------------ 6 | 7 | * `getAllCountryNames()` and `getAllCountryCodes()` were added to the 8 | `LookupService`. These return all country names and codes known to the 9 | GeoIP reader. Pull request by nguillaumin. GitHub #33. 10 | 11 | 1.3.0 (2016-01-21) 12 | ------------------ 13 | 14 | * `LookupService` will now throw an `InvalidDatabaseException` if there is a 15 | problem with the database. This is a unchecked, runtime exception in order 16 | to not introduce an API change. Previously `LookupService` would swallow 17 | exceptions, either returning `null` or an invalid value or throwing an 18 | exception such as `ArrayIndexOutOfBoundsException` cause by the invalid 19 | state. 20 | * When using `GEOIP_MEMORY_CACHE`, the number of allocations has been reduced, 21 | providing a moderate performance increase. 22 | * Minor code clean-up and de-duplication. 23 | 24 | 1.2.15 (2015-07-17) 25 | ------------------- 26 | 27 | * Several threading synchronization issues were fixed. 28 | * Target version was decreased to 1.5 for increased compatibility. 29 | * Minor code cleanup. 30 | * Region and timezone data were updated. 31 | 32 | 1.2.14 (2014-07-23) 33 | ------------------- 34 | 35 | * OSGi metadata was added to the jar. (Miguel Ángel Pastor Olivar) 36 | * Regions were updated. 37 | 38 | 1.2.13 (2014-04-30) 39 | ------------------- 40 | 41 | * Previously no checks were done to ensure that an organization name did not 42 | exceed the 300 character maximum. If an organization name did exceed this 43 | maximum, an `ArrayIndexOutOfBoundsException` was thrown. 44 | * A potential string comparison issue was fixed in `getLocation`. 45 | * Documentation and test fixes. 46 | 47 | 1.2.12 (2014-03-10) 48 | ------------------- 49 | 50 | * Code and examples for the non-functional distributed lookup service were 51 | removed. 52 | * A bug that could cause an `ArrayIndexOutOfBoundsException` when using 53 | `GEOIP_INDEX_CACHE` was fixed. On the last node, the reader would attempt 54 | to read beyond the end of the buffer due to the incorrect record length 55 | being used. 56 | 57 | 1.2.11 (2013-09-19) 58 | ------------------- 59 | 60 | * Fix IPv6 lookups with ffff prefix. (Boris Zentner ) 61 | * File reorganization and unit tests ( Travis Pinney ) 62 | 63 | 1.2.10 (2013-05-23) 64 | ------------------- 65 | 66 | * First release to the Maven Central Repository 67 | 68 | 1.2.9 (2013-02-19) 69 | ------------------ 70 | 71 | * Update FIPS codes 20130208 ( Boris Zentner ) 72 | * Add new country South Sudan ( Boris Zentner ) 73 | 74 | 1.2.8 (2013-04-13) 75 | ------------------ 76 | 77 | * Fix: Close the database file without exceptions whether it is 78 | open(STANDARD) or not(MEMORY_CACHE) in conjunction with the 79 | CHECK_CACHE option. (Lorenzo Crosby) 80 | 81 | 1.2.7 (2012-04-10) 82 | ------------------ 83 | 84 | * Update timezones ( Boris Zentner ) 85 | * Update FIPS codes 20120402 ( Boris Zentner ) 86 | 87 | 1.2.6 (2012-03-28) 88 | ------------------ 89 | 90 | * Update country codes, FIPS codes and timezone ( Boris Zentner ) 91 | 92 | 1.2.5 (2011-08-23) 93 | ------------------ 94 | 95 | * Fix small buffer issue when java tries to read over the EOF ( Boris Zentner ) 96 | * Add support for new database types NETSPEED_EDITION_REV1_V6, 97 | NETSPEED_EDITION_REV1, ASNUM_EDITION_V6, CITY_EDITION_REV1_V6, 98 | ISP_EDITION_V6, ORG_EDITION_V6, DOMAIN_EDITION, DOMAIN_EDITION_V6 ( Boris Zentner ) 99 | * Add new examples CityLookupTestV6 and ASNumLookupTestV6 ( Boris Zentner ) 100 | 101 | 1.2.4 (2010-08-13) 102 | ------------------ 103 | 104 | * Update FIPS codes 20100810 ( Boris Zentner ) 105 | * Simplify init code in class LookupServices ( Boris Zentner ) 106 | * Big timezone update ( Boris Zentner ) 107 | * Update FIPS codes 20100530 ( Boris Zentner ) 108 | * Update FIPS codes 20100510 ( Boris Zentner ) 109 | * Add IPv6 support via getCountryV6 ( Boris Zentner ) 110 | * Add example for IPv6 lookups: CountryLookupTestV6 ( Boris Zentner ) 111 | * Fix DatabaseInfo string ( Boris Zentner ) 112 | * Add netmask and last_netmask methods ( Boris Zentner ) 113 | * Remove static keyword from objects that are reinitialized in the init() 114 | method. ( Tony Jacobs ) 115 | * Replace nearly all calls to file.read() with file.readFully() ( Tony Jacobs ) 116 | * Synchronized 100% of the calls to file ( Tony Jacobs ) 117 | * Use Integer.valueOf() instead of new Integer() to reduce memory consumption. 118 | ( Tony Jacobs ) 119 | * Use explicit imports instead of import java.io.*; and the like. ( Tony 120 | Jacobs ) 121 | * Fix array length in distributed service setup ( quarz12h ) 122 | * Sync with recent FIPS codes 20090723 ( Boris Zentner ) 123 | 124 | 1.2.3 (2009-05-11) 125 | ------------------- 126 | 127 | * Sync with recent FIPS codes 20090511 ( Boris Zentner ) 128 | * Fixed spelling of Kazakhstan, was Kazakstan ( Boris Zentner ) 129 | * Fix rare out of range error, when the last entry of the Org/ISP/Domain 130 | database is copied ( MEMORY_CACHE only ). ( Boris Zentner ) 131 | * Update timezones for Australia 132 | * Remove "\n" from RegionLookupTest.java. println add already a newline 133 | ( Boris Zentner ) 134 | * Change regionName.java and generate_regionName.pl to support FIPS codes 135 | with letters ( Boris Zentner ). 136 | * Sync with recent FIPS codes Jan 14th, 2009 ( Boris Zentner ) 137 | * remove dma_code from city records. use metro_code instead. ( Boris Zentner ) 138 | 139 | 1.2.2 (2008-03-22) 140 | ------------------ 141 | 142 | * Added BL/Saint Barthelemy, MF/Saint Martin (ISO-3166-1 additions) 143 | * Updated timeZone.java ( Boris Zentner ) 144 | * Add missing \n to admin/generate_timeZone.pl ( Boris Zentner ) 145 | * Fix refresh databaseInfo in combination with GEOIP_CHECK_CACHE ( Boris 146 | Zentner, Glenn Pedersen ) 147 | * Changed license from GPL to LGPL, to allow commercial programs to include GeoIP API 148 | 149 | 1.2.1 (2007-06-19) 150 | ------------------ 151 | 152 | * Made GeoIP ASNum database work with Java API 153 | * Added timeZone and regionName classes to lookup timezone and region name 154 | from country code and region code (Frank Mather) 155 | 156 | 1.2.0 (2007-01-10) 157 | ------------------ 158 | 159 | * Added support for GEOIP_CHECK_CACHE (Frank Mather) 160 | * Allow database to be closed in memory cache mode 161 | * Replaced CS/Serbia and Montenegro with RS/Serbia, removed ZR/Zaire, added ME/Montenegro 162 | * Added AX/Aland Islands, GG/Guernsey, IM/Isle of Man, JE/Jersey (ISO-3166-1 changes) 163 | * Added support for GEOIP_INDEX_CACHE (Frank Mather) 164 | * close filehandle after data is read into memory for MemoryCache mode 165 | * Added BenchmarkGeoIP.java (Frank Mather) 166 | 167 | 1.1.8 (2006-08-18) 168 | ------------------ 169 | 170 | * Increased FULL_RECORD_LENGTH from 50 to 60, fixes Array out 171 | ArrayOutOfBounds=50 for long city names in GeoIP City databases before July 172 | 2006 173 | * TP/East Timor changed to TL/Timor-Leste, reflecting changes in ISO-3166 174 | * Removed hashmap initialization for local database 175 | * Replaced Yugoslavia with Serbia and Montenegro 176 | 177 | 1.1.7 (2004-10-06) 178 | ------------------ 179 | 180 | * Specified ISO-8859-1 encoding for City, ISP and Organization field string 181 | (Yan Zhang Chen) 182 | 183 | 1.1.6 (2004-09-09) 184 | ------------------ 185 | 186 | * Fixed problem with postalCode, city and region fields 187 | returning null char (Frank Mather) 188 | * Added support for GeoIP Netspeed Database (Frank Mather) 189 | * Added support for GEOIP_MEMORY_CACHE (Frank Mather) 190 | 191 | 1.1.5 (2004-06-03) 192 | ------------------ 193 | 194 | * Added support for MaxMind GeoIP Region (Frank Mather) 195 | * Windows compatibility fix for CountryLookupTest.java (Hanan Al-Shargi) 196 | * Country name fixes 197 | 198 | 1.1.4 (2003-10-21) 199 | ------------------ 200 | 201 | * Added support for distributed queries (Frank Mather) 202 | * Massive code cleanup (Matt Tucker) 203 | * Added support for DMA code and Area codes (Frank Mather) 204 | 205 | 1.1.3 (2003-06-09) 206 | ------------------ 207 | 208 | * Added support for GeoIP Organization and ISP databases 209 | * Changed Taiwan, Province of China to Taiwan 210 | 211 | 1.1.2 (2002-12-16) 212 | ------------------ 213 | * Added support for postal codes in GeoIP City (beta) 214 | 215 | 1.1.1 (2002-10-31) 216 | ------------------ 217 | 218 | * Added support for GeoIP Full Edition, renamed CountryLookup class 219 | to Lookup 220 | 221 | 1.1.0 (2002-10-28) 222 | ------------------ 223 | 224 | * API Change!!! Return null instead of '--' if country can not be found 225 | * rewrote seekCountry to use loop instead of recursion for faster performance 226 | * Fixed error when looking Anonymous Proxies 227 | 228 | 1.0.4 (2002-09-11) 229 | ------------------ 230 | 231 | * Added close method to clean up filehandles (Jeroen Nijenhuis) 232 | 233 | 0.3.0 (2002-09-04) 234 | ------------------ 235 | 236 | * Added support for satellite providers 237 | 238 | 0.2.1 (2002-06-03) 239 | ------------------ 240 | 241 | * Added support for anonymous proxies 242 | 243 | 0.1.2 (2002-04-14) 244 | ------------------ 245 | 246 | * Added public to CountryLookup class (Noel Bergman), should 247 | now be accessible outside of GeoIP package. 248 | 249 | 0.1.1 (2002-04-09) 250 | ------------------ 251 | 252 | * Initial Release 253 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GeoIP Legacy Java API # 2 | 3 | ## End of Life ## 4 | 5 | MaxMind will be retiring the GeoIP Legacy databases at the end of May 6 | 2022. Until then, this library will only receive critical security and bug 7 | fixes. Support for this library will end completely with the last release of 8 | the legacy GeoIP databases. 9 | 10 | We recommend that you upgrade to our GeoIP2 databases. You can read these 11 | from Java using [our GeoIP2 Java API](https://github.com/maxmind/GeoIP2-java). 12 | 13 | See [our blog post](https://blog.maxmind.com/2020/06/01/retirement-of-geoip-legacy-downloadable-databases-in-may-2022/) 14 | for more information. 15 | 16 | ## Define Your Dependencies ## 17 | 18 | We recommend installing this package with Maven. To do this, add the dependency to your pom.xml: 19 | 20 | ```xml 21 | 22 | com.maxmind.geoip 23 | geoip-api 24 | 1.3.1 25 | 26 | ``` 27 | 28 | ## Building Manually ## 29 | 30 | ### Installation ### 31 | mvn clean install 32 | 33 | ### Packaging ### 34 | mvn package 35 | 36 | The jar file will be in the `target` directory. 37 | 38 | ### Testing ### 39 | mvn test 40 | 41 | ## IP Geolocation Usage ## 42 | 43 | IP geolocation is inherently imprecise. Locations are often near the center of 44 | the population. Any location provided by a GeoIP database or web service 45 | should not be used to identify a particular address or household. 46 | 47 | ## Memory Caching and Other Options ## 48 | 49 | The following options can be passed as the second parameter to the 50 | `LookupService` constructor. 51 | 52 | * `GEOIP_STANDARD` - Read database from file system. Uses the least memory. 53 | * `GEOIP_MEMORY_CACHE` - Load database into memory. This provides faster 54 | performance but uses more memory 55 | * `GEOIP_CHECK_CACHE` - Check for updated database. If database has been 56 | updated, reload file handle and/or memory cache. 57 | * `GEOIP_INDEX_CACHE` - Cache only the most frequently accessed index portion 58 | of the database, resulting in faster lookups than GEOIP_STANDARD, but less 59 | memory usage than `GEOIP_MEMORY_CACHE`. This is useful for larger databases 60 | such as GeoIP Legacy Organization and GeoIP Legacy City. Note: for GeoIP 61 | Legacy Country, Region and Netspeed databases, `GEOIP_INDEX_CACHE` is 62 | equivalent to `GEOIP_MEMORY_CACHE`. 63 | 64 | These options may be combined. For example: 65 | 66 | ```java 67 | LookupService cl = new LookupService(dbfile, 68 | LookupService.GEOIP_MEMORY_CACHE | LookupService.GEOIP_CHECK_CACHE); 69 | ``` 70 | 71 | ## Thread Safety ## 72 | 73 | As of version 1.1.4 this API is thread safe. 74 | 75 | -------------------------------------------------------------------------------- /dev-bin/generate_regionName.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Used to generate regionName.java 4 | # usage: ./generate_regionName.pl > ../source/com/maxmind/geoip/regionName.java 5 | 6 | use strict; 7 | use warnings; 8 | 9 | use HTTP::Tiny; 10 | use Text::CSV_XS; 11 | 12 | print <<'__JAVA_CODE__'; 13 | package com.maxmind.geoip; 14 | // generated automatically from admin/generate_regionName.pl 15 | public class regionName { 16 | public static String regionNameByCode(String country_code, String region_code) { 17 | String name = null; 18 | int region_code2 = -1; 19 | if (region_code == null) { return null; } 20 | if (region_code.length() == 0) { return null; } 21 | 22 | if ( ((region_code.charAt(0) >= 48 ) && ( region_code.charAt(0) < ( 48 + 10 ))) 23 | && ((region_code.charAt(1) >= 48 ) && ( region_code.charAt(1) < ( 48 + 10 ))) 24 | ){ 25 | // only numbers, that shorten the large switch statements 26 | region_code2 = (region_code.charAt(0)- 48) * 10 + region_code.charAt(1) - 48; 27 | } else if ( ( ((region_code.charAt(0) >= 65) && (region_code.charAt(0) < (65 + 26))) 28 | || ((region_code.charAt(0) >= 48) && (region_code.charAt(0) < (48 + 10)))) 29 | && ( ((region_code.charAt(1) >= 65) && (region_code.charAt(1) < (65 + 26))) 30 | || ((region_code.charAt(1) >= 48) && (region_code.charAt(1) < (48 + 10)))) 31 | ) { 32 | 33 | region_code2 = (region_code.charAt(0) - 48) * (65 + 26 - 48) + region_code.charAt(1) - 48 + 100; 34 | } 35 | 36 | if (region_code2 == -1) {return null;} 37 | 38 | __JAVA_CODE__ 39 | 40 | my $response = HTTP::Tiny->new->get( 41 | 'http://www.maxmind.com/download/geoip/misc/region_codes.csv'); 42 | 43 | die "Failed to download CSV!\n" unless $response->{success}; 44 | 45 | my $csv = Text::CSV_XS->new( { binary => 1 } ); 46 | open my $sh, '<', \$response->{content}; 47 | 48 | my $last_country_code = q{}; 49 | while ( my $row = $csv->getline($sh) ) { 50 | my ( $country_code, $region_code, $name ) = @$row; 51 | 52 | my $region_code2; 53 | if ( $region_code =~ /^\d\d$/ ) { 54 | $region_code2 55 | = ( ord( substr( $region_code, 0, 1 ) ) - 48 ) * 10 56 | + ord( substr( $region_code, 1, 1 ) ) 57 | - 48; 58 | 59 | } 60 | elsif ( $region_code =~ /^[A-Z0-9]{2}$/ ) { 61 | $region_code2 62 | = ( 63 | ( ord( substr( $region_code, 0, 1 ) ) - 48 ) * ( 65 + 26 - 48 ) ) 64 | + ord( substr( $region_code, 1, 1 ) ) 65 | - 48 + 100; 66 | } 67 | elsif ( $region_code =~ /^[A-Z]{2}$/ ) { 68 | $region_code2 69 | = ( 70 | ( ord( substr( $region_code, 0, 1 ) ) - 48 ) * ( 65 + 26 - 48 ) ) 71 | + ord( substr( $region_code, 1, 1 ) ) 72 | - 48 + 100; 73 | } 74 | else { 75 | die "Region code seems wrong $region_code\n"; 76 | } 77 | readcode( 78 | $last_country_code, $country_code, $region_code, $region_code2, 79 | $name 80 | ); 81 | $last_country_code = $country_code; 82 | } 83 | print " }\n"; 84 | print " }\n"; 85 | print " return name;\n"; 86 | print " }\n"; 87 | print "}\n"; 88 | 89 | sub readcode { 90 | my ( 91 | $last_country_code, $country_code, $region_code, $region_code2, 92 | $name 93 | ) = @_; 94 | if ( $country_code ne $last_country_code ) { 95 | if ( $last_country_code ne q{} ) { 96 | print " }\n"; 97 | } 98 | 99 | if ( $last_country_code eq q{} ) { 100 | print ' if (country_code.equals(' . q{"} 101 | . $country_code . q{"} 102 | . ")) {\n"; 103 | } 104 | else { 105 | print ' } else if (country_code.equals(' . qq(") 106 | . $country_code . qq(") 107 | . ")) {\n"; 108 | } 109 | print " switch (region_code2) {\n"; 110 | } 111 | 112 | $name =~ s/\"//g; 113 | $name = q{"} . $name . q{"}; 114 | print ' case ' . $region_code2 . ":\n"; 115 | print " return $name;\n"; 116 | } 117 | 118 | -------------------------------------------------------------------------------- /dev-bin/generate_timeZone.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use autodie; 6 | 7 | use Text::CSV_XS; 8 | 9 | # Used to generate timeZone.java 10 | # usage: ./generate_timeZone.pl > ../source/com/maxmind/geoip/timeZone.java 11 | 12 | my $old_country; 13 | my $old_region; 14 | my $had_region; 15 | 16 | # Obtain timezone.txt from http://www.maxmind.com/timezone.txt 17 | open my $fh, '<', 'timezone.txt' or die $!; 18 | <$fh>; #header 19 | 20 | my $csv = Text::CSV_XS->new( { binary => 1 } ); 21 | 22 | print "package com.maxmind.geoip;\n"; 23 | print "// generated automatically from admin/generate_timeZone.pl\n"; 24 | print "public class timeZone {\n"; 25 | print 26 | " public static String timeZoneByCountryAndRegion(String country, String region) {\n"; 27 | print " String timezone = null;\n"; 28 | print <getline($fh) ) { 38 | my ( $country, $region, $timezone ) = @$row; 39 | die "Wrong timezone\n" unless $timezone; 40 | if ( $country ne $old_country ) { 41 | if ($had_region) { 42 | print " }\n"; 43 | $had_region = ""; 44 | $old_region = ""; 45 | } 46 | if ( $old_country ne "" ) { 47 | print " } else if (" . qq(") . $country . qq(") 48 | . ".equals(country)) {\n"; 49 | } 50 | else { 51 | print " if (" . qq(") . $country . qq(") 52 | . ".equals(country)) {\n"; 53 | } 54 | } 55 | if ( $region ne "" ) { 56 | $had_region = 1; 57 | if ( $old_region ne "" ) { 58 | print " } else if (" . qq(") . $region . qq(") 59 | . ".equals(region)) {\n "; 60 | } 61 | else { 62 | print " if (" . qq(") . $region . qq(") 63 | . ".equals(region)) {\n "; 64 | } 65 | } 66 | elsif ( $old_region ne "" ) { 67 | print " } else {\n "; 68 | } 69 | print qq( timezone = ") . $timezone . qq(") . ";\n"; 70 | $old_country = $country; 71 | $old_region = $region; 72 | } 73 | print " }\n"; 74 | print " return timezone;\n"; 75 | print " }\n"; 76 | print "}\n"; 77 | 78 | close($fh); 79 | 80 | -------------------------------------------------------------------------------- /examples/ASNumLookup.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP Organization and ISP databases */ 5 | /* This example can also be used with the GeoIP Domain and ASNum databases */ 6 | /* Usage: java ASNumLookup 64.4.4.4 */ 7 | 8 | class ASNumLookup { 9 | public static void main(String[] args) { 10 | try { 11 | LookupService asnl = new LookupService("/usr/local/share/GeoIP/GeoIPASNum.dat"); 12 | System.out.println("ASNum: " + asnl.getOrg(args[0])); 13 | asnl.close(); 14 | } 15 | catch (IOException e) { 16 | System.out.println("IO Exception"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/ASNumLookupV6.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP Organization and ISP databases */ 5 | /* This example can also be used with the GeoIP Domain and ASNum databases */ 6 | /* Usage: java ASNumLookupV6 64.4.4.4 */ 7 | 8 | class ASNumLookupV6 { 9 | public static void main(String[] args) { 10 | try { 11 | LookupService asnl = new LookupService("/usr/local/share/GeoIP/GeoIPASNumv6.dat"); 12 | System.out.println("ASNum V6: " + asnl.getOrgV6(args[0])); 13 | asnl.close(); 14 | } 15 | catch (IOException e) { 16 | System.out.println("IO Exception"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/CityLookup.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP City database */ 5 | /* Usage: java CityLookup 64.4.4.4 */ 6 | 7 | class CityLookup { 8 | public static void main(String[] args) { 9 | try { 10 | LookupService cl = new LookupService("/usr/local/share/GeoIP/GeoIPCity.dat", 11 | LookupService.GEOIP_MEMORY_CACHE ); 12 | Location l1 = cl.getLocation("213.52.50.8"); 13 | Location l2 = cl.getLocation(args[0]); 14 | System.out.println("countryCode: " + l2.countryCode + 15 | "\n countryName: " + l2.countryName + 16 | "\n region: " + l2.region + 17 | "\n regionName: " + regionName.regionNameByCode(l2.countryCode, l2.region) + 18 | "\n city: " + l2.city + 19 | "\n postalCode: " + l2.postalCode + 20 | "\n latitude: " + l2.latitude + 21 | "\n longitude: " + l2.longitude + 22 | "\n distance: " + l2.distance(l1) + 23 | "\n distance: " + l1.distance(l2) + 24 | "\n metro code: " + l2.metro_code + 25 | "\n area code: " + l2.area_code + 26 | "\n timezone: " + timeZone.timeZoneByCountryAndRegion(l2.countryCode, l2.region)); 27 | 28 | cl.close(); 29 | } 30 | catch (IOException e) { 31 | System.out.println("IO Exception"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/CityLookupV6.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP City database */ 5 | /* Usage: java CityLookup 64.4.4.4 */ 6 | 7 | class CityLookupV6 { 8 | public static void main(String[] args) { 9 | try { 10 | LookupService cl = new LookupService("/usr/local/share/GeoIP/GeoLiteCityv6.dat", 11 | LookupService.GEOIP_MEMORY_CACHE ); 12 | Location l1 = cl.getLocationV6("::213.52.50.8"); 13 | Location l2 = cl.getLocationV6(args[0]); 14 | System.out.println("countryCode: " + l2.countryCode + 15 | "\n countryName: " + l2.countryName + 16 | "\n region: " + l2.region + 17 | "\n regionName: " + regionName.regionNameByCode(l2.countryCode, l2.region) + 18 | "\n city: " + l2.city + 19 | "\n postalCode: " + l2.postalCode + 20 | "\n latitude: " + l2.latitude + 21 | "\n longitude: " + l2.longitude + 22 | "\n distance: " + l2.distance(l1) + 23 | "\n distance: " + l1.distance(l2) + 24 | "\n metro code: " + l2.metro_code + 25 | "\n area code: " + l2.area_code + 26 | "\n timezone: " + timeZone.timeZoneByCountryAndRegion(l2.countryCode, l2.region)); 27 | 28 | cl.close(); 29 | } 30 | catch (IOException e) { 31 | System.out.println("IO Exception"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/CountryLookup.java: -------------------------------------------------------------------------------- 1 | /* Only works with GeoIP Country Edition */ 2 | /* For Geoip City Edition, use CityLookup.java */ 3 | 4 | import com.maxmind.geoip.*; 5 | import java.io.IOException; 6 | 7 | class CountryLookup { 8 | public static void main(String[] args) { 9 | try { 10 | String sep = System.getProperty("file.separator"); 11 | 12 | // Uncomment for windows 13 | // String dir = System.getProperty("user.dir"); 14 | 15 | // Uncomment for Linux 16 | String dir = "/usr/local/share/GeoIP"; 17 | 18 | String dbfile = dir + sep + "GeoIP.dat"; 19 | // You should only call LookupService once, especially if you use 20 | // GEOIP_MEMORY_CACHE mode, since the LookupService constructor takes up 21 | // resources to load the GeoIP.dat file into memory 22 | //LookupService cl = new LookupService(dbfile,LookupService.GEOIP_STANDARD); 23 | LookupService cl = new LookupService(dbfile,LookupService.GEOIP_MEMORY_CACHE); 24 | 25 | System.out.println(cl.getCountry("151.38.39.114").getCode()); 26 | System.out.println(cl.getCountry("151.38.39.114").getName()); 27 | System.out.println(cl.getCountry("12.25.205.51").getName()); 28 | System.out.println(cl.getCountry("64.81.104.131").getName()); 29 | System.out.println(cl.getCountry("200.21.225.82").getName()); 30 | 31 | cl.close(); 32 | } 33 | catch (IOException e) { 34 | System.out.println("IO Exception"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/CountryLookupV6.java: -------------------------------------------------------------------------------- 1 | /* Only works with GeoIP Country Edition */ 2 | /* For Geoip City Edition, use CityLookup.java */ 3 | 4 | import com.maxmind.geoip.*; 5 | import java.io.IOException; 6 | 7 | class CountryLookupV6 { 8 | public static void main(String[] args) { 9 | try { 10 | String sep = System.getProperty("file.separator"); 11 | 12 | // Uncomment for windows 13 | // String dir = System.getProperty("user.dir"); 14 | 15 | // Uncomment for Linux 16 | String dir = "/usr/local/share/GeoIP"; 17 | 18 | String dbfile = dir + sep + "GeoIPv6.dat"; 19 | // You should only call LookupService once, especially if you use 20 | // GEOIP_MEMORY_CACHE mode, since the LookupService constructor takes up 21 | // resources to load the GeoIP.dat file into memory 22 | //LookupService cl = new LookupService(dbfile,LookupService.GEOIP_STANDARD); 23 | LookupService cl = new LookupService(dbfile,LookupService.GEOIP_MEMORY_CACHE); 24 | 25 | System.out.println(cl.getCountryV6("ipv6.google.com").getCode()); 26 | System.out.println(cl.getCountryV6("::127.0.0.1").getName()); 27 | System.out.println(cl.getCountryV6("::151.38.39.114").getName()); 28 | System.out.println(cl.getCountryV6("::ffff:151.38.39.114").getName()); 29 | System.out.println(cl.getCountryV6("2001:4860:0:1001::68").getName()); 30 | 31 | cl.close(); 32 | } 33 | catch (IOException e) { 34 | System.out.println("IO Exception"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/DomainLookup.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP Domain database */ 5 | /* Usage: java DomainLookup 64.4.4.4 */ 6 | 7 | class DomainLookup { 8 | public static void main(String[] args) { 9 | try { 10 | LookupService gid = new LookupService("/usr/local/share/GeoIP/GeoIPDomain.dat"); 11 | System.out.println("Domain: " + gid.getOrg(args[0])); 12 | gid.close(); 13 | } 14 | catch (IOException e) { 15 | System.out.println("IO Exception"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/NetSpeedCellLookup.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP Organization and ISP databases */ 5 | /* This example can also be used with the GeoIP Domain, NetSpeedCell and ASNum databases */ 6 | /* Usage: java NetSpeedCellLookup 64.4.4.4 */ 7 | 8 | class NetSpeedCellLookup { 9 | public static void main(String[] args) { 10 | try { 11 | LookupService ns = new LookupService("/usr/local/share/GeoIP/GeoIPNetSpeedCell.dat"); 12 | System.out.println("XX: " + ns.getOrg(args[0])); 13 | ns.close(); 14 | } 15 | catch (IOException e) { 16 | System.out.println("IO Exception"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/NetspeedLookup.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP Netspeed database */ 5 | /* Usage: java NetspeedLookup 24.24.24.24 */ 6 | /* The Netspeed database does not return the "cellular" flag. 7 | * Please see the NetSpeedCellLookup.java example if you use the flag. */ 8 | 9 | class NetspeedLookup { 10 | public static void main(String[] args) { 11 | try { 12 | LookupService cl = new LookupService("/usr/local/share/GeoIP/GeoIPNetspeed.dat"); 13 | if (args.length > 0) { 14 | int speed = cl.getID(args[0]); 15 | if (speed == cl.GEOIP_UNKNOWN_SPEED){ 16 | System.out.println("Unknown"); 17 | } else if (speed == cl.GEOIP_DIALUP_SPEED) { 18 | System.out.println("Dialup"); 19 | } else if (speed == cl.GEOIP_CABLEDSL_SPEED) { 20 | System.out.println("Cable/DSL"); 21 | } else if (speed == cl.GEOIP_CORPORATE_SPEED) { 22 | System.out.println("Corporate"); 23 | } 24 | } else { 25 | System.out.println("input a ip address\n"); 26 | } 27 | } 28 | catch (IOException e) { 29 | System.out.println("IO Exception"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/OrgLookup.java: -------------------------------------------------------------------------------- 1 | import com.maxmind.geoip.*; 2 | import java.io.IOException; 3 | 4 | /* sample of how to use the GeoIP Java API with GeoIP Organization and ISP databases */ 5 | /* This example can also be used with the GeoIP Domain and ASNum databases */ 6 | /* Usage: java OrgLookup 64.4.4.4 */ 7 | 8 | class OrgLookup { 9 | public static void main(String[] args) { 10 | try { 11 | LookupService orgl = new LookupService("/usr/local/share/GeoIP/GeoIPOrg.dat"); 12 | LookupService ispl = new LookupService("/usr/local/share/GeoIP/GeoIPISP.dat"); 13 | System.out.println("Organization: " + orgl.getOrg(args[0]) + 14 | "\tISP: " + ispl.getOrg(args[0])); 15 | orgl.close(); 16 | ispl.close(); 17 | } 18 | catch (IOException e) { 19 | System.out.println("IO Exception"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/RegionLookup.java: -------------------------------------------------------------------------------- 1 | /* Requires subscription to MaxMind GeoIP Region database */ 2 | 3 | import com.maxmind.geoip.*; 4 | import java.io.IOException; 5 | 6 | class RegionLookup { 7 | public static void main(String[] args) { 8 | try { 9 | LookupService cl = new LookupService("/usr/local/share/GeoIP/GeoIPRegion.dat"); 10 | Region l = cl.getRegion(args[0]); 11 | System.out.println("Country Code: " + l.countryCode); 12 | System.out.println("Country Name: " + l.countryName); 13 | System.out.println("Region Code: " + l.region); 14 | System.out.println("Region Name: " + regionName.regionNameByCode(l.countryCode,l.region)); 15 | cl.close(); 16 | } 17 | catch (IOException e) { 18 | System.out.println("IO Exception"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | MaxMind GeoIP Legacy API 6 | MaxMind GeoIP Legacy Java API 7 | https://github.com/maxmind/geoip-api-java 8 | 9 | com.maxmind.geoip 10 | geoip-api 11 | 1.3.2-SNAPSHOT 12 | bundle 13 | 14 | 15 | org.sonatype.oss 16 | oss-parent 17 | 7 18 | 19 | 20 | 21 | 22 | Lesser General Public License (LGPL) v 2.1 23 | http://www.gnu.org/licenses/lgpl-2.1.txt 24 | repo 25 | 26 | 27 | 28 | 29 | MaxMind, Inc. 30 | http://www.maxmind.com/ 31 | 32 | 33 | 34 | 35 | bzentner 36 | Boris Zentner 37 | bzentner@maxmind.com 38 | 39 | 40 | 41 | 42 | scm:git:git://github.com:maxmind/geoip-api-java.git 43 | scm:git:git@github.com:maxmind/geoip-api-java.git 44 | 45 | 46 | 47 | UTF-8 48 | 1.5 49 | 4.13.2 50 | 4.5.1 51 | 52 | 53 | 54 | 55 | 56 | org.apache.maven.plugins 57 | maven-compiler-plugin 58 | 3.10.1 59 | 60 | 1.5 61 | 1.5 62 | 63 | 64 | 65 | 66 | org.apache.felix 67 | maven-bundle-plugin 68 | 5.1.6 69 | true 70 | 71 | 72 | com.maxmind.geoip 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | junit 82 | junit 83 | ${junit.version} 84 | test 85 | 86 | 87 | org.mockito 88 | mockito-core 89 | ${mockito.version} 90 | test 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/main/java/com/maxmind/geoip/Country.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Country.java 3 | * 4 | * Copyright (C) 2003 MaxMind LLC. All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package com.maxmind.geoip; 22 | 23 | /** 24 | * Represents a country. 25 | * 26 | * @author Matt Tucker 27 | */ 28 | public class Country { 29 | 30 | private final String code; 31 | private final String name; 32 | 33 | /** 34 | * Creates a new Country. 35 | * 36 | * @param code 37 | * the country code. 38 | * @param name 39 | * the country name. 40 | */ 41 | public Country(String code, String name) { 42 | this.code = code; 43 | this.name = name; 44 | } 45 | 46 | /** 47 | * Returns the ISO two-letter country code of this country. 48 | * 49 | * @return the country code. 50 | */ 51 | public String getCode() { 52 | return code; 53 | } 54 | 55 | /** 56 | * Returns the name of this country. 57 | * 58 | * @return the country name. 59 | */ 60 | public String getName() { 61 | return name; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/maxmind/geoip/DatabaseInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DatabaseInfo.java 3 | * 4 | * Copyright (C) 2003 MaxMind LLC. All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package com.maxmind.geoip; 22 | 23 | import java.text.ParseException; 24 | import java.text.SimpleDateFormat; 25 | import java.util.Date; 26 | 27 | /** 28 | * Encapsulates metadata about the GeoIP database. The database has a date, is a 29 | * premium or standard version, and is one of the following types: 30 | * 31 | *
    32 | *
  • Country edition -- this is the most common version of the database. It 33 | * includes the name of the country and it's ISO country code given an IP 34 | * address. 35 | *
  • Region edition -- includes the country information as well as what U.S. 36 | * state or Canadian province the IP address is from if the IP address is from 37 | * the U.S. or Canada. 38 | *
  • City edition -- includes country, region, city, postal code, latitude, 39 | * and longitude information. 40 | *
  • Org edition -- includes netblock owner. 41 | *
  • ISP edition -- ISP information. 42 | *
43 | * 44 | * @see com.maxmind.geoip.LookupService#getDatabaseInfo() 45 | * @author Matt Tucker 46 | */ 47 | public class DatabaseInfo { 48 | 49 | public static final int COUNTRY_EDITION = 1; 50 | public static final int REGION_EDITION_REV0 = 7; 51 | public static final int REGION_EDITION_REV1 = 3; 52 | public static final int CITY_EDITION_REV0 = 6; 53 | public static final int CITY_EDITION_REV1 = 2; 54 | public static final int ORG_EDITION = 5; 55 | public static final int ISP_EDITION = 4; 56 | public static final int PROXY_EDITION = 8; 57 | public static final int ASNUM_EDITION = 9; 58 | public static final int NETSPEED_EDITION = 10; 59 | public static final int DOMAIN_EDITION = 11; 60 | public static final int COUNTRY_EDITION_V6 = 12; 61 | public static final int ASNUM_EDITION_V6 = 21; 62 | public static final int ISP_EDITION_V6 = 22; 63 | public static final int ORG_EDITION_V6 = 23; 64 | public static final int DOMAIN_EDITION_V6 = 24; 65 | public static final int CITY_EDITION_REV1_V6 = 30; 66 | public static final int CITY_EDITION_REV0_V6 = 31; 67 | public static final int NETSPEED_EDITION_REV1 = 32; 68 | public static final int NETSPEED_EDITION_REV1_V6 = 33; 69 | 70 | private static SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); 71 | 72 | private final String info; 73 | 74 | /** 75 | * Creates a new DatabaseInfo object given the database info String. 76 | * 77 | * @param info 78 | */ 79 | public DatabaseInfo(String info) { 80 | this.info = info; 81 | } 82 | 83 | public int getType() { 84 | if (info == null || info.length() == 0) { 85 | return COUNTRY_EDITION; 86 | } else { 87 | // Get the type code from the database info string and then 88 | // subtract 105 from the value to preserve compatability with 89 | // databases from April 2003 and earlier. 90 | return Integer.parseInt(info.substring(4, 7)) - 105; 91 | } 92 | } 93 | 94 | /** 95 | * Returns true if the database is the premium version. 96 | * 97 | * @return true if the premium version of the database. 98 | */ 99 | public boolean isPremium() { 100 | return !info.contains("FREE"); 101 | } 102 | 103 | /** 104 | * Returns the date of the database. 105 | * 106 | * @return the date of the database. 107 | */ 108 | public Date getDate() { 109 | for (int i = 0; i < info.length() - 9; i++) { 110 | if (Character.isWhitespace(info.charAt(i))) { 111 | String dateString = info.substring(i + 1, i + 9); 112 | try { 113 | synchronized (formatter) { 114 | return formatter.parse(dateString); 115 | } 116 | } catch (ParseException pe) { 117 | } 118 | break; 119 | } 120 | } 121 | return null; 122 | } 123 | 124 | @Override 125 | public String toString() { 126 | return info; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/com/maxmind/geoip/InvalidDatabaseException.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Signals that there was an issue reading from the database file due to 7 | * unexpected data formatting. This generally suggests that the database is 8 | * corrupt or otherwise not in a format supported by the reader. 9 | */ 10 | public final class InvalidDatabaseException extends RuntimeException { 11 | 12 | /** 13 | * @param message A message describing the reason why the exception was thrown. 14 | */ 15 | public InvalidDatabaseException(String message) { 16 | super(message); 17 | } 18 | 19 | /** 20 | * @param message A message describing the reason why the exception was thrown. 21 | * @param cause The cause of the exception. 22 | */ 23 | public InvalidDatabaseException(String message, Throwable cause) { 24 | super(message, cause); 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/com/maxmind/geoip/Location.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Location.java 3 | * 4 | * Copyright (C) 2004 MaxMind LLC. All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Lesser Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package com.maxmind.geoip; 22 | 23 | public class Location { 24 | public String countryCode; 25 | public String countryName; 26 | public String region; 27 | public String city; 28 | public String postalCode; 29 | public float latitude; 30 | public float longitude; 31 | public int dma_code; 32 | public int area_code; 33 | public int metro_code; 34 | 35 | private final static double EARTH_DIAMETER = 2 * 6378.2; 36 | private final static double PI = 3.14159265; 37 | private final static double RAD_CONVERT = PI / 180; 38 | 39 | public double distance(Location loc) { 40 | double deltaLat, deltaLon; 41 | double temp; 42 | 43 | float lat1 = latitude; 44 | float lon1 = longitude; 45 | float lat2 = loc.latitude; 46 | float lon2 = loc.longitude; 47 | 48 | // convert degrees to radians 49 | lat1 *= RAD_CONVERT; 50 | lat2 *= RAD_CONVERT; 51 | 52 | // find the deltas 53 | deltaLat = lat2 - lat1; 54 | deltaLon = (lon2 - lon1) * RAD_CONVERT; 55 | 56 | // Find the great circle distance 57 | temp = Math.pow(Math.sin(deltaLat / 2), 2) + Math.cos(lat1) 58 | * Math.cos(lat2) * Math.pow(Math.sin(deltaLon / 2), 2); 59 | return EARTH_DIAMETER 60 | * Math.atan2(Math.sqrt(temp), Math.sqrt(1 - temp)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/maxmind/geoip/LookupService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * LookupService.java 3 | * 4 | * Copyright (C) 2003 MaxMind LLC. All Rights Reserved. 5 | * 6 | * This library is free software; you can redistribute it and/or modify it under 7 | * the terms of the GNU Lesser General Public License as published by the Free 8 | * Software Foundation; either version 2 of the License, or (at your option) any 9 | * later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 | * details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this library; if not, write to the Free Software Foundation, Inc., 18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package com.maxmind.geoip; 22 | 23 | import java.io.File; 24 | import java.io.IOException; 25 | import java.io.RandomAccessFile; 26 | import java.net.InetAddress; 27 | import java.net.UnknownHostException; 28 | import java.nio.ByteBuffer; 29 | import java.nio.charset.CharacterCodingException; 30 | import java.nio.charset.Charset; 31 | import java.nio.charset.CharsetDecoder; 32 | import java.util.Arrays; 33 | import java.util.List; 34 | 35 | /** 36 | * Provides a lookup service for information based on an IP address. The 37 | * location of a database file is supplied when creating a lookup service 38 | * instance. The edition of the database determines what information is 39 | * available about an IP address. See the DatabaseInfo class for further 40 | * details. 41 | *

42 | * 43 | * The following code snippet demonstrates looking up the country that an IP 44 | * address is from: 45 | * 46 | *

 47 |  * // First, create a LookupService instance with the location of the database.
 48 |  * LookupService lookupService = new LookupService("c:\\geoip.dat");
 49 |  * // Assume we have a String ipAddress (in dot-decimal form).
 50 |  * Country country = lookupService.getCountry(ipAddress);
 51 |  * System.out.println("The country is: " + country.getName());
 52 |  * System.out.println("The country code is: " + country.getCode());
 53 |  * 
54 | * 55 | * In general, a single LookupService instance should be created and then reused 56 | * repeatedly. 57 | *

58 | * 59 | * Tip: Those deploying the GeoIP API as part of a web application may 60 | * find it difficult to pass in a File to create the lookup service, as the 61 | * location of the database may vary per deployment or may even be part of the 62 | * web-application. In this case, the database should be added to the classpath 63 | * of the web-app. For example, by putting it into the WEB-INF/classes directory 64 | * of the web application. The following code snippet demonstrates how to create 65 | * a LookupService using a database that can be found on the classpath: 66 | * 67 | *

 68 |  * String fileName = getClass().getResource("/GeoIP.dat").toExternalForm()
 69 |  *         .substring(6);
 70 |  * LookupService lookupService = new LookupService(fileName);
 71 |  * 
72 | * 73 | * @author Matt Tucker (matt@jivesoftware.com) 74 | */ 75 | public class LookupService { 76 | 77 | /** 78 | * Database file. 79 | */ 80 | private RandomAccessFile file; 81 | private final File databaseFile; 82 | 83 | /** 84 | * Information about the database. 85 | */ 86 | private DatabaseInfo databaseInfo; 87 | 88 | private static final Charset charset = Charset.forName("ISO-8859-1"); 89 | private final CharsetDecoder charsetDecoder = charset.newDecoder(); 90 | 91 | /** 92 | * The database type. Default is the country edition. 93 | */ 94 | private byte databaseType = DatabaseInfo.COUNTRY_EDITION; 95 | 96 | private int[] databaseSegments; 97 | private int recordLength; 98 | 99 | private int dboptions; 100 | private byte[] dbbuffer; 101 | private byte[] index_cache; 102 | private long mtime; 103 | private int last_netmask; 104 | private static final int US_OFFSET = 1; 105 | private static final int CANADA_OFFSET = 677; 106 | private static final int WORLD_OFFSET = 1353; 107 | private static final int FIPS_RANGE = 360; 108 | private static final int COUNTRY_BEGIN = 16776960; 109 | private static final int STATE_BEGIN_REV0 = 16700000; 110 | private static final int STATE_BEGIN_REV1 = 16000000; 111 | private static final int STRUCTURE_INFO_MAX_SIZE = 20; 112 | private static final int DATABASE_INFO_MAX_SIZE = 100; 113 | public static final int GEOIP_STANDARD = 0; 114 | public static final int GEOIP_MEMORY_CACHE = 1; 115 | public static final int GEOIP_CHECK_CACHE = 2; 116 | public static final int GEOIP_INDEX_CACHE = 4; 117 | public static final int GEOIP_UNKNOWN_SPEED = 0; 118 | public static final int GEOIP_DIALUP_SPEED = 1; 119 | public static final int GEOIP_CABLEDSL_SPEED = 2; 120 | public static final int GEOIP_CORPORATE_SPEED = 3; 121 | 122 | private static final int SEGMENT_RECORD_LENGTH = 3; 123 | private static final int STANDARD_RECORD_LENGTH = 3; 124 | private static final int ORG_RECORD_LENGTH = 4; 125 | private static final int MAX_RECORD_LENGTH = 4; 126 | 127 | private static final int MAX_ORG_RECORD_LENGTH = 300; 128 | private static final int FULL_RECORD_LENGTH = 60; 129 | 130 | private final Country UNKNOWN_COUNTRY = new Country("--", "N/A"); 131 | 132 | private static final String[] countryCode = { "--", "AP", "EU", "AD", "AE", 133 | "AF", "AG", "AI", "AL", "AM", "CW", "AO", "AQ", "AR", "AS", "AT", 134 | "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", 135 | "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", 136 | "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", 137 | "CO", "CR", "CU", "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", 138 | "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", 139 | "FK", "FM", "FO", "FR", "SX", "GA", "GB", "GD", "GE", "GF", "GH", 140 | "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", 141 | "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", 142 | "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", 143 | "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", 144 | "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", 145 | "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", 146 | "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", 147 | "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", 148 | "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", 149 | "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", 150 | "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", 151 | "SV", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TM", 152 | "TN", "TO", "TL", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", 153 | "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", 154 | "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", 155 | "AX", "GG", "IM", "JE", "BL", "MF", "BQ", "SS", "O1" }; 156 | 157 | private static final String[] countryName = { "N/A", "Asia/Pacific Region", 158 | "Europe", "Andorra", "United Arab Emirates", "Afghanistan", 159 | "Antigua and Barbuda", "Anguilla", "Albania", "Armenia", "Curacao", 160 | "Angola", "Antarctica", "Argentina", "American Samoa", "Austria", 161 | "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina", 162 | "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", 163 | "Bahrain", "Burundi", "Benin", "Bermuda", "Brunei Darussalam", 164 | "Bolivia", "Brazil", "Bahamas", "Bhutan", "Bouvet Island", 165 | "Botswana", "Belarus", "Belize", "Canada", 166 | "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the", 167 | "Central African Republic", "Congo", "Switzerland", 168 | "Cote D'Ivoire", "Cook Islands", "Chile", "Cameroon", "China", 169 | "Colombia", "Costa Rica", "Cuba", "Cape Verde", "Christmas Island", 170 | "Cyprus", "Czech Republic", "Germany", "Djibouti", "Denmark", 171 | "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia", 172 | "Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", 173 | "Finland", "Fiji", "Falkland Islands (Malvinas)", 174 | "Micronesia, Federated States of", "Faroe Islands", "France", 175 | "Sint Maarten (Dutch part)", "Gabon", "United Kingdom", "Grenada", 176 | "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland", 177 | "Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", 178 | "South Georgia and the South Sandwich Islands", "Guatemala", 179 | "Guam", "Guinea-Bissau", "Guyana", "Hong Kong", 180 | "Heard Island and McDonald Islands", "Honduras", "Croatia", 181 | "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India", 182 | "British Indian Ocean Territory", "Iraq", 183 | "Iran, Islamic Republic of", "Iceland", "Italy", "Jamaica", 184 | "Jordan", "Japan", "Kenya", "Kyrgyzstan", "Cambodia", "Kiribati", 185 | "Comoros", "Saint Kitts and Nevis", 186 | "Korea, Democratic People's Republic of", "Korea, Republic of", 187 | "Kuwait", "Cayman Islands", "Kazakhstan", 188 | "Lao People's Democratic Republic", "Lebanon", "Saint Lucia", 189 | "Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", 190 | "Luxembourg", "Latvia", "Libya", "Morocco", "Monaco", 191 | "Moldova, Republic of", "Madagascar", "Marshall Islands", 192 | "Macedonia", "Mali", "Myanmar", "Mongolia", "Macau", 193 | "Northern Mariana Islands", "Martinique", "Mauritania", 194 | "Montserrat", "Malta", "Mauritius", "Maldives", "Malawi", "Mexico", 195 | "Malaysia", "Mozambique", "Namibia", "New Caledonia", "Niger", 196 | "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway", 197 | "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", 198 | "French Polynesia", "Papua New Guinea", "Philippines", "Pakistan", 199 | "Poland", "Saint Pierre and Miquelon", "Pitcairn Islands", 200 | "Puerto Rico", "Palestinian Territory", "Portugal", "Palau", 201 | "Paraguay", "Qatar", "Reunion", "Romania", "Russian Federation", 202 | "Rwanda", "Saudi Arabia", "Solomon Islands", "Seychelles", "Sudan", 203 | "Sweden", "Singapore", "Saint Helena", "Slovenia", 204 | "Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", 205 | "Senegal", "Somalia", "Suriname", "Sao Tome and Principe", 206 | "El Salvador", "Syrian Arab Republic", "Swaziland", 207 | "Turks and Caicos Islands", "Chad", "French Southern Territories", 208 | "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan", 209 | "Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", 210 | "Tuvalu", "Taiwan", "Tanzania, United Republic of", "Ukraine", 211 | "Uganda", "United States Minor Outlying Islands", "United States", 212 | "Uruguay", "Uzbekistan", "Holy See (Vatican City State)", 213 | "Saint Vincent and the Grenadines", "Venezuela", 214 | "Virgin Islands, British", "Virgin Islands, U.S.", "Vietnam", 215 | "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte", 216 | "Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe", 217 | "Anonymous Proxy", "Satellite Provider", "Other", "Aland Islands", 218 | "Guernsey", "Isle of Man", "Jersey", "Saint Barthelemy", 219 | "Saint Martin", "Bonaire, Saint Eustatius and Saba", "South Sudan", 220 | "Other" }; 221 | 222 | /* init the hashmap once at startup time */ 223 | static { 224 | if (countryCode.length != countryName.length) { 225 | throw new AssertionError("countryCode.length!=countryName.length"); 226 | } 227 | } 228 | 229 | /** 230 | * Create a new lookup service using the specified database file. 231 | * 232 | * @param databaseFile 233 | * String representation of the database file. 234 | * @throws IOException 235 | * if an error occured creating the lookup service from the 236 | * database file. 237 | */ 238 | public LookupService(String databaseFile) throws IOException { 239 | this(new File(databaseFile)); 240 | } 241 | 242 | /** 243 | * Create a new lookup service using the specified database file. 244 | * 245 | * @param databaseFile 246 | * the database file. 247 | * @throws IOException 248 | * if an error occured creating the lookup service from the 249 | * database file. 250 | */ 251 | public LookupService(File databaseFile) throws IOException { 252 | this.databaseFile = databaseFile; 253 | file = new RandomAccessFile(databaseFile, "r"); 254 | init(); 255 | } 256 | 257 | /** 258 | * Create a new lookup service using the specified database file. 259 | * 260 | * @param databaseFile 261 | * String representation of the database file. 262 | * @param options 263 | * database flags to use when opening the database GEOIP_STANDARD 264 | * read database from disk GEOIP_MEMORY_CACHE cache the database 265 | * in RAM and read it from RAM 266 | * @throws IOException 267 | * if an error occured creating the lookup service from the 268 | * database file. 269 | */ 270 | public LookupService(String databaseFile, int options) throws IOException { 271 | this(new File(databaseFile), options); 272 | } 273 | 274 | /** 275 | * Create a new lookup service using the specified database file. 276 | * 277 | * @param databaseFile 278 | * the database file. 279 | * @param options 280 | * database flags to use when opening the database GEOIP_STANDARD 281 | * read database from disk GEOIP_MEMORY_CACHE cache the database 282 | * in RAM and read it from RAM 283 | * @throws IOException 284 | * if an error occured creating the lookup service from the 285 | * database file. 286 | */ 287 | public LookupService(File databaseFile, int options) throws IOException { 288 | this.databaseFile = databaseFile; 289 | file = new RandomAccessFile(databaseFile, "r"); 290 | dboptions = options; 291 | init(); 292 | } 293 | 294 | /** 295 | * Reads meta-data from the database file. 296 | * 297 | * @throws IOException 298 | * if an error occurs reading from the database file. 299 | */ 300 | private synchronized void init() throws IOException { 301 | if (file == null) { 302 | return; 303 | } 304 | if ((dboptions & GEOIP_CHECK_CACHE) != 0) { 305 | mtime = databaseFile.lastModified(); 306 | } 307 | file.seek(file.length() - 3); 308 | byte[] delim = new byte[3]; 309 | byte[] buf = new byte[SEGMENT_RECORD_LENGTH]; 310 | for (int i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) { 311 | file.readFully(delim); 312 | if (delim[0] == -1 && delim[1] == -1 && delim[2] == -1) { 313 | databaseType = file.readByte(); 314 | if (databaseType >= 106) { 315 | // Backward compatibility with databases from April 2003 and 316 | // earlier 317 | databaseType -= 105; 318 | } 319 | // Determine the database type. 320 | if (databaseType == DatabaseInfo.REGION_EDITION_REV0) { 321 | databaseSegments = new int[1]; 322 | databaseSegments[0] = STATE_BEGIN_REV0; 323 | recordLength = STANDARD_RECORD_LENGTH; 324 | } else if (databaseType == DatabaseInfo.REGION_EDITION_REV1) { 325 | databaseSegments = new int[1]; 326 | databaseSegments[0] = STATE_BEGIN_REV1; 327 | recordLength = STANDARD_RECORD_LENGTH; 328 | } else if (databaseType == DatabaseInfo.CITY_EDITION_REV0 329 | || databaseType == DatabaseInfo.CITY_EDITION_REV1 330 | || databaseType == DatabaseInfo.ORG_EDITION 331 | || databaseType == DatabaseInfo.ORG_EDITION_V6 332 | || databaseType == DatabaseInfo.ISP_EDITION 333 | || databaseType == DatabaseInfo.ISP_EDITION_V6 334 | || databaseType == DatabaseInfo.DOMAIN_EDITION 335 | || databaseType == DatabaseInfo.DOMAIN_EDITION_V6 336 | || databaseType == DatabaseInfo.ASNUM_EDITION 337 | || databaseType == DatabaseInfo.ASNUM_EDITION_V6 338 | || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1 339 | || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1_V6 340 | || databaseType == DatabaseInfo.CITY_EDITION_REV0_V6 341 | || databaseType == DatabaseInfo.CITY_EDITION_REV1_V6) { 342 | databaseSegments = new int[1]; 343 | databaseSegments[0] = 0; 344 | if (databaseType == DatabaseInfo.CITY_EDITION_REV0 345 | || databaseType == DatabaseInfo.CITY_EDITION_REV1 346 | || databaseType == DatabaseInfo.ASNUM_EDITION_V6 347 | || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1 348 | || databaseType == DatabaseInfo.NETSPEED_EDITION_REV1_V6 349 | || databaseType == DatabaseInfo.CITY_EDITION_REV0_V6 350 | || databaseType == DatabaseInfo.CITY_EDITION_REV1_V6 351 | || databaseType == DatabaseInfo.ASNUM_EDITION) { 352 | recordLength = STANDARD_RECORD_LENGTH; 353 | } else { 354 | recordLength = ORG_RECORD_LENGTH; 355 | } 356 | file.readFully(buf); 357 | for (int j = 0; j < SEGMENT_RECORD_LENGTH; j++) { 358 | databaseSegments[0] += (unsignedByteToInt(buf[j]) << (j * 8)); 359 | } 360 | } 361 | break; 362 | } else { 363 | file.seek(file.getFilePointer() - 4); 364 | } 365 | } 366 | if ((databaseType == DatabaseInfo.COUNTRY_EDITION) 367 | || (databaseType == DatabaseInfo.COUNTRY_EDITION_V6) 368 | || (databaseType == DatabaseInfo.PROXY_EDITION) 369 | || (databaseType == DatabaseInfo.NETSPEED_EDITION)) { 370 | databaseSegments = new int[1]; 371 | databaseSegments[0] = COUNTRY_BEGIN; 372 | recordLength = STANDARD_RECORD_LENGTH; 373 | } 374 | if ((dboptions & GEOIP_MEMORY_CACHE) == 1) { 375 | int l = (int) file.length(); 376 | dbbuffer = new byte[l]; 377 | file.seek(0); 378 | file.readFully(dbbuffer, 0, l); 379 | databaseInfo = getDatabaseInfo(); 380 | file.close(); 381 | } 382 | if ((dboptions & GEOIP_INDEX_CACHE) != 0) { 383 | int l = databaseSegments[0] * recordLength * 2; 384 | index_cache = new byte[l]; 385 | file.seek(0); 386 | file.readFully(index_cache, 0, l); 387 | } else { 388 | index_cache = null; 389 | } 390 | } 391 | 392 | /** 393 | * Closes the lookup service. 394 | */ 395 | public synchronized void close() { 396 | try { 397 | if (file != null) { 398 | file.close(); 399 | } 400 | file = null; 401 | } catch (IOException e) { 402 | // Here for backward compatibility. 403 | } 404 | } 405 | 406 | /** 407 | * @return The list of all known country names 408 | */ 409 | public List getAllCountryNames() { 410 | return Arrays.asList(Arrays.copyOf(countryName, countryName.length)); 411 | } 412 | 413 | /** 414 | * @return The list of all known country codes 415 | */ 416 | public List getAllCountryCodes() { 417 | return Arrays.asList(Arrays.copyOf(countryCode, countryCode.length)); 418 | } 419 | 420 | /** 421 | * Returns the country the IP address is in. 422 | * 423 | * @param ipAddress 424 | * String version of an IPv6 address, i.e. "::127.0.0.1" 425 | * @return the country the IP address is from. 426 | */ 427 | public Country getCountryV6(String ipAddress) { 428 | InetAddress addr; 429 | try { 430 | addr = InetAddress.getByName(ipAddress); 431 | } catch (UnknownHostException e) { 432 | return UNKNOWN_COUNTRY; 433 | } 434 | return getCountryV6(addr); 435 | } 436 | 437 | /** 438 | * Returns the country the IP address is in. 439 | * 440 | * @param ipAddress 441 | * String version of an IP address, i.e. "127.0.0.1" 442 | * @return the country the IP address is from. 443 | */ 444 | public Country getCountry(String ipAddress) { 445 | InetAddress addr; 446 | try { 447 | addr = InetAddress.getByName(ipAddress); 448 | } catch (UnknownHostException e) { 449 | return UNKNOWN_COUNTRY; 450 | } 451 | return getCountry(addr); 452 | } 453 | 454 | /** 455 | * Returns the country the IP address is in. 456 | * 457 | * @param ipAddress 458 | * the IP address. 459 | * @return the country the IP address is from. 460 | */ 461 | public synchronized Country getCountry(InetAddress ipAddress) { 462 | return getCountry(bytesToLong(ipAddress.getAddress())); 463 | } 464 | 465 | /** 466 | * Returns the country the IP address is in. 467 | * 468 | * @param addr 469 | * the IP address as Inet6Address. 470 | * @return the country the IP address is from. 471 | */ 472 | public synchronized Country getCountryV6(InetAddress addr) { 473 | if (file == null && (dboptions & GEOIP_MEMORY_CACHE) == 0) { 474 | throw new IllegalStateException("Database has been closed."); 475 | } 476 | int ret = seekCountryV6(addr) - COUNTRY_BEGIN; 477 | if (ret == 0) { 478 | return UNKNOWN_COUNTRY; 479 | } else { 480 | return new Country(countryCode[ret], countryName[ret]); 481 | } 482 | } 483 | 484 | /** 485 | * Returns the country the IP address is in. 486 | * 487 | * @param ipAddress 488 | * the IP address in long format. 489 | * @return the country the IP address is from. 490 | */ 491 | public synchronized Country getCountry(long ipAddress) { 492 | if (file == null && (dboptions & GEOIP_MEMORY_CACHE) == 0) { 493 | throw new IllegalStateException("Database has been closed."); 494 | } 495 | int ret = seekCountry(ipAddress) - COUNTRY_BEGIN; 496 | if (ret == 0) { 497 | return UNKNOWN_COUNTRY; 498 | } else { 499 | return new Country(countryCode[ret], countryName[ret]); 500 | } 501 | } 502 | 503 | public int getID(String ipAddress) { 504 | InetAddress addr; 505 | try { 506 | addr = InetAddress.getByName(ipAddress); 507 | } catch (UnknownHostException e) { 508 | return 0; 509 | } 510 | return getID(bytesToLong(addr.getAddress())); 511 | } 512 | 513 | public int getID(InetAddress ipAddress) { 514 | return getID(bytesToLong(ipAddress.getAddress())); 515 | } 516 | 517 | public synchronized int getID(long ipAddress) { 518 | if (file == null && (dboptions & GEOIP_MEMORY_CACHE) == 0) { 519 | throw new IllegalStateException("Database has been closed."); 520 | } 521 | return seekCountry(ipAddress) - databaseSegments[0]; 522 | } 523 | 524 | public int last_netmask() { 525 | return last_netmask; 526 | } 527 | 528 | public void netmask(int nm) { 529 | last_netmask = nm; 530 | } 531 | 532 | /** 533 | * Returns information about the database. 534 | * 535 | * @return database info. 536 | */ 537 | public synchronized DatabaseInfo getDatabaseInfo() { 538 | if (databaseInfo != null) { 539 | return databaseInfo; 540 | } 541 | try { 542 | _check_mtime(); 543 | boolean hasStructureInfo = false; 544 | byte[] delim = new byte[3]; 545 | // Advance to part of file where database info is stored. 546 | file.seek(file.length() - 3); 547 | for (int i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) { 548 | int read = file.read(delim); 549 | if (read == 3 && (delim[0] & 0xFF) == 255 550 | && (delim[1] & 0xFF) == 255 && (delim[2] & 0xFF) == 255) { 551 | hasStructureInfo = true; 552 | break; 553 | } 554 | file.seek(file.getFilePointer() - 4); 555 | 556 | } 557 | if (hasStructureInfo) { 558 | file.seek(file.getFilePointer() - 6); 559 | } else { 560 | // No structure info, must be pre Sep 2002 database, go back to 561 | // end. 562 | file.seek(file.length() - 3); 563 | } 564 | // Find the database info string. 565 | for (int i = 0; i < DATABASE_INFO_MAX_SIZE; i++) { 566 | file.readFully(delim); 567 | if (delim[0] == 0 && delim[1] == 0 && delim[2] == 0) { 568 | byte[] dbInfo = new byte[i]; 569 | file.readFully(dbInfo); 570 | // Create the database info object using the string. 571 | databaseInfo = new DatabaseInfo(new String(dbInfo, charset)); 572 | return databaseInfo; 573 | } 574 | file.seek(file.getFilePointer() - 4); 575 | } 576 | } catch (IOException e) { 577 | throw new InvalidDatabaseException("Error reading database info", e); 578 | } 579 | return new DatabaseInfo(""); 580 | } 581 | 582 | synchronized void _check_mtime() { 583 | try { 584 | if ((dboptions & GEOIP_CHECK_CACHE) != 0) { 585 | long t = databaseFile.lastModified(); 586 | if (t != mtime) { 587 | /* GeoIP Database file updated */ 588 | /* refresh filehandle */ 589 | close(); 590 | file = new RandomAccessFile(databaseFile, "r"); 591 | databaseInfo = null; 592 | init(); 593 | } 594 | } 595 | } catch (IOException e) { 596 | throw new InvalidDatabaseException("Database not found", e); 597 | } 598 | } 599 | 600 | // for GeoIP City only 601 | public Location getLocationV6(String str) { 602 | InetAddress addr; 603 | try { 604 | addr = InetAddress.getByName(str); 605 | } catch (UnknownHostException e) { 606 | return null; 607 | } 608 | 609 | return getLocationV6(addr); 610 | } 611 | 612 | // for GeoIP City only 613 | public Location getLocation(InetAddress addr) { 614 | return getLocation(bytesToLong(addr.getAddress())); 615 | } 616 | 617 | // for GeoIP City only 618 | public Location getLocation(String str) { 619 | InetAddress addr; 620 | try { 621 | addr = InetAddress.getByName(str); 622 | } catch (UnknownHostException e) { 623 | return null; 624 | } 625 | 626 | return getLocation(addr); 627 | } 628 | 629 | public synchronized Region getRegion(String str) { 630 | InetAddress addr; 631 | try { 632 | addr = InetAddress.getByName(str); 633 | } catch (UnknownHostException e) { 634 | return null; 635 | } 636 | 637 | return getRegion(bytesToLong(addr.getAddress())); 638 | } 639 | 640 | public synchronized Region getRegion(InetAddress addr) { 641 | return getRegion(bytesToLong(addr.getAddress())); 642 | } 643 | 644 | public synchronized Region getRegion(long ipnum) { 645 | Region record = new Region(); 646 | int seekRegion; 647 | if (databaseType == DatabaseInfo.REGION_EDITION_REV0) { 648 | seekRegion = seekCountry(ipnum) - STATE_BEGIN_REV0; 649 | char[] ch = new char[2]; 650 | if (seekRegion >= 1000) { 651 | record.countryCode = "US"; 652 | record.countryName = "United States"; 653 | ch[0] = (char) (((seekRegion - 1000) / 26) + 65); 654 | ch[1] = (char) (((seekRegion - 1000) % 26) + 65); 655 | record.region = new String(ch); 656 | } else { 657 | record.countryCode = countryCode[seekRegion]; 658 | record.countryName = countryName[seekRegion]; 659 | record.region = ""; 660 | } 661 | } else if (databaseType == DatabaseInfo.REGION_EDITION_REV1) { 662 | seekRegion = seekCountry(ipnum) - STATE_BEGIN_REV1; 663 | char[] ch = new char[2]; 664 | if (seekRegion < US_OFFSET) { 665 | record.countryCode = ""; 666 | record.countryName = ""; 667 | record.region = ""; 668 | } else if (seekRegion < CANADA_OFFSET) { 669 | record.countryCode = "US"; 670 | record.countryName = "United States"; 671 | ch[0] = (char) (((seekRegion - US_OFFSET) / 26) + 65); 672 | ch[1] = (char) (((seekRegion - US_OFFSET) % 26) + 65); 673 | record.region = new String(ch); 674 | } else if (seekRegion < WORLD_OFFSET) { 675 | record.countryCode = "CA"; 676 | record.countryName = "Canada"; 677 | ch[0] = (char) (((seekRegion - CANADA_OFFSET) / 26) + 65); 678 | ch[1] = (char) (((seekRegion - CANADA_OFFSET) % 26) + 65); 679 | record.region = new String(ch); 680 | } else { 681 | record.countryCode = countryCode[(seekRegion - WORLD_OFFSET) 682 | / FIPS_RANGE]; 683 | record.countryName = countryName[(seekRegion - WORLD_OFFSET) 684 | / FIPS_RANGE]; 685 | record.region = ""; 686 | } 687 | } 688 | return record; 689 | } 690 | 691 | public synchronized Location getLocationV6(InetAddress addr) { 692 | int seekCountry; 693 | 694 | try { 695 | seekCountry = seekCountryV6(addr); 696 | return readCityRecord(seekCountry); 697 | } catch (IOException e) { 698 | throw new InvalidDatabaseException("Error while seting up segments", e); 699 | } 700 | } 701 | 702 | public synchronized Location getLocation(long ipnum) { 703 | int seekCountry; 704 | 705 | try { 706 | seekCountry = seekCountry(ipnum); 707 | return readCityRecord(seekCountry); 708 | } catch (IOException e) { 709 | throw new InvalidDatabaseException("Error while seting up segments", e); 710 | } 711 | } 712 | 713 | private Location readCityRecord(int seekCountry) throws IOException { 714 | if (seekCountry == databaseSegments[0]) { 715 | return null; 716 | } 717 | ByteBuffer buffer = readRecordBuf(seekCountry, FULL_RECORD_LENGTH); 718 | 719 | Location record = new Location(); 720 | int country = unsignedByteToInt(buffer.get()); 721 | 722 | // get country 723 | record.countryCode = countryCode[country]; 724 | record.countryName = countryName[country]; 725 | 726 | record.region = readString(buffer); 727 | record.city = readString(buffer); 728 | record.postalCode = readString(buffer); 729 | record.latitude = readAngle(buffer); 730 | record.longitude = readAngle(buffer); 731 | 732 | // get DMA code 733 | if (databaseType == DatabaseInfo.CITY_EDITION_REV1 && "US".equals(record.countryCode)) { 734 | int metroareaCombo = readMetroAreaCombo(buffer); 735 | record.metro_code = record.dma_code = metroareaCombo / 1000; 736 | record.area_code = metroareaCombo % 1000; 737 | } 738 | return record; 739 | } 740 | 741 | private ByteBuffer readRecordBuf(int seek, int maxLength) throws IOException { 742 | 743 | int recordPointer = seek + (2 * recordLength - 1) 744 | * databaseSegments[0]; 745 | 746 | ByteBuffer buffer; 747 | if ((dboptions & GEOIP_MEMORY_CACHE) == 1) { 748 | buffer = ByteBuffer.wrap(dbbuffer, recordPointer, Math 749 | .min(dbbuffer.length - recordPointer, maxLength)); 750 | } else { 751 | byte[] recordBuf = new byte[maxLength]; 752 | // read from disk 753 | file.seek(recordPointer); 754 | file.read(recordBuf); 755 | buffer = ByteBuffer.wrap(recordBuf); 756 | } 757 | return buffer; 758 | } 759 | 760 | 761 | private String readString(ByteBuffer buffer) throws CharacterCodingException { 762 | int start = buffer.position(); 763 | int oldLimit = buffer.limit(); 764 | 765 | while (buffer.hasRemaining() && buffer.get() != 0) {} 766 | 767 | int end = buffer.position() - 1; 768 | String str = null; 769 | if (end > start) { 770 | buffer.position(start); 771 | buffer.limit(end); 772 | str = charsetDecoder.decode(buffer).toString(); 773 | buffer.limit(oldLimit); 774 | } 775 | buffer.position(end + 1); 776 | return str; 777 | } 778 | 779 | private static float readAngle(ByteBuffer buffer) { 780 | if (buffer.remaining() < 3) { 781 | throw new InvalidDatabaseException("Unexpected end of data record when reading angle"); 782 | } 783 | double num = 0; 784 | for (int j = 0; j < 3; j++) { 785 | num += unsignedByteToInt(buffer.get()) << (j * 8); 786 | } 787 | return (float) num / 10000 - 180; 788 | } 789 | 790 | private static int readMetroAreaCombo(ByteBuffer buffer) { 791 | if (buffer.remaining() < 3) { 792 | throw new InvalidDatabaseException("Unexpected end of data record when reading metro area"); 793 | } 794 | int metroareaCombo = 0; 795 | for (int j = 0; j < 3; j++) { 796 | metroareaCombo += unsignedByteToInt(buffer.get()) << (j * 8); 797 | } 798 | return metroareaCombo; 799 | } 800 | 801 | public String getOrg(InetAddress addr) { 802 | return getOrg(bytesToLong(addr.getAddress())); 803 | } 804 | 805 | public String getOrg(String str) { 806 | InetAddress addr; 807 | try { 808 | addr = InetAddress.getByName(str); 809 | } catch (UnknownHostException e) { 810 | return null; 811 | } 812 | return getOrg(addr); 813 | } 814 | 815 | // GeoIP Organization and ISP Edition methods 816 | public synchronized String getOrg(long ipnum) { 817 | try { 818 | int seekOrg = seekCountry(ipnum); 819 | return readOrgRecord(seekOrg); 820 | 821 | } catch (IOException e) { 822 | throw new InvalidDatabaseException("Error while reading org", e); 823 | } 824 | } 825 | 826 | public String getOrgV6(String str) { 827 | InetAddress addr; 828 | try { 829 | addr = InetAddress.getByName(str); 830 | } catch (UnknownHostException e) { 831 | return null; 832 | } 833 | return getOrgV6(addr); 834 | } 835 | 836 | // GeoIP Organization and ISP Edition methods 837 | public synchronized String getOrgV6(InetAddress addr) { 838 | try { 839 | int seekOrg = seekCountryV6(addr); 840 | return readOrgRecord(seekOrg); 841 | } catch (IOException e) { 842 | throw new InvalidDatabaseException("Error while reading org", e); 843 | } 844 | } 845 | 846 | private String readOrgRecord(int seekOrg) throws IOException { 847 | if (seekOrg == databaseSegments[0]) { 848 | return null; 849 | } 850 | ByteBuffer buf = readRecordBuf(seekOrg, MAX_ORG_RECORD_LENGTH); 851 | return readString(buf); 852 | } 853 | 854 | /** 855 | * Finds the country index value given an IPv6 address. 856 | * 857 | * @param addr 858 | * the ip address to find in long format. 859 | * @return the country index. 860 | */ 861 | private synchronized int seekCountryV6(InetAddress addr) { 862 | byte[] v6vec = addr.getAddress(); 863 | 864 | if (v6vec.length == 4) { 865 | // sometimes java returns an ipv4 address for IPv6 input 866 | // we have to work around that feature 867 | // It happens for ::ffff:24.24.24.24 868 | byte[] t = new byte[16]; 869 | System.arraycopy(v6vec, 0, t, 12, 4); 870 | v6vec = t; 871 | } 872 | 873 | byte[] buf = new byte[2 * MAX_RECORD_LENGTH]; 874 | int[] x = new int[2]; 875 | int offset = 0; 876 | _check_mtime(); 877 | for (int depth = 127; depth >= 0; depth--) { 878 | readNode(buf, x, offset); 879 | 880 | int bnum = 127 - depth; 881 | int idx = bnum >> 3; 882 | int bMask = 1 << (bnum & 7 ^ 7); 883 | if ((v6vec[idx] & bMask) > 0) { 884 | if (x[1] >= databaseSegments[0]) { 885 | last_netmask = 128 - depth; 886 | return x[1]; 887 | } 888 | offset = x[1]; 889 | } else { 890 | if (x[0] >= databaseSegments[0]) { 891 | last_netmask = 128 - depth; 892 | return x[0]; 893 | } 894 | offset = x[0]; 895 | } 896 | } 897 | 898 | throw new InvalidDatabaseException("Error seeking country while searching for " 899 | + addr.getHostAddress()); 900 | } 901 | 902 | /** 903 | * Finds the country index value given an IP address. 904 | * 905 | * @param ipAddress 906 | * the ip address to find in long format. 907 | * @return the country index. 908 | */ 909 | private synchronized int seekCountry(long ipAddress) { 910 | byte[] buf = new byte[2 * MAX_RECORD_LENGTH]; 911 | int[] x = new int[2]; 912 | int offset = 0; 913 | _check_mtime(); 914 | for (int depth = 31; depth >= 0; depth--) { 915 | readNode(buf, x, offset); 916 | 917 | if ((ipAddress & (1 << depth)) > 0) { 918 | if (x[1] >= databaseSegments[0]) { 919 | last_netmask = 32 - depth; 920 | return x[1]; 921 | } 922 | offset = x[1]; 923 | } else { 924 | if (x[0] >= databaseSegments[0]) { 925 | last_netmask = 32 - depth; 926 | return x[0]; 927 | } 928 | offset = x[0]; 929 | } 930 | } 931 | throw new InvalidDatabaseException("Error seeking country while searching for " 932 | + ipAddress); 933 | } 934 | 935 | private void readNode(byte[] buf, int[] x, int offset) { 936 | if ((dboptions & GEOIP_MEMORY_CACHE) == 1) { 937 | // read from memory 938 | System.arraycopy(dbbuffer, 2 * recordLength * offset, buf, 0, 2 * recordLength); 939 | } else if ((dboptions & GEOIP_INDEX_CACHE) != 0) { 940 | // read from index cache 941 | System.arraycopy(index_cache, 2 * recordLength * offset, buf, 0, 2 * recordLength); 942 | } else { 943 | // read from disk 944 | try { 945 | file.seek(2 * recordLength * offset); 946 | file.read(buf); 947 | } catch (IOException e) { 948 | throw new InvalidDatabaseException("Error seeking in database", e); 949 | } 950 | } 951 | for (int i = 0; i < 2; i++) { 952 | x[i] = 0; 953 | for (int j = 0; j < recordLength; j++) { 954 | int y = buf[i * recordLength + j]; 955 | if (y < 0) { 956 | y += 256; 957 | } 958 | x[i] += (y << (j * 8)); 959 | } 960 | } 961 | } 962 | 963 | /** 964 | * Returns the long version of an IP address given an InetAddress object. 965 | * 966 | * @param address 967 | * the InetAddress. 968 | * @return the long form of the IP address. 969 | */ 970 | private static long bytesToLong(byte[] address) { 971 | long ipnum = 0; 972 | for (int i = 0; i < 4; ++i) { 973 | long y = address[i]; 974 | if (y < 0) { 975 | y += 256; 976 | } 977 | ipnum += y << ((3 - i) * 8); 978 | } 979 | return ipnum; 980 | } 981 | 982 | private static int unsignedByteToInt(byte b) { 983 | return (int) b & 0xFF; 984 | } 985 | } 986 | -------------------------------------------------------------------------------- /src/main/java/com/maxmind/geoip/Region.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | public class Region { 4 | public String countryCode; 5 | public String countryName; 6 | public String region; 7 | } -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/ASNumLookupTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* ASNumLookupTest.java */ 4 | 5 | import com.maxmind.geoip.LookupService; 6 | 7 | 8 | import static org.junit.Assert.assertEquals; 9 | import org.junit.Test; 10 | 11 | import java.io.IOException; 12 | 13 | 14 | 15 | public class ASNumLookupTest { 16 | 17 | @Test 18 | public void testASNumLookup() throws IOException 19 | { 20 | LookupService asnl = new LookupService("src/test/resources/GeoIP/GeoIPASNum.dat"); 21 | String ASNum = asnl.getOrg("64.17.254.216"); 22 | asnl.close(); 23 | assertEquals(ASNum, "AS33224"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/CityLookupIdxTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* CityLookupTest.java */ 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | import java.io.IOException; 8 | 9 | import org.junit.Test; 10 | 11 | public class CityLookupIdxTest { 12 | private static final double DELTA = 1e-5; 13 | 14 | @Test 15 | public void testCityLookupIdx() throws IOException { 16 | 17 | LookupService cl = new LookupService( 18 | "src/test/resources/GeoIP/GeoIPCity.dat", 19 | LookupService.GEOIP_INDEX_CACHE); 20 | 21 | Location l1 = cl.getLocation("222.230.137.0"); 22 | 23 | assertEquals("JP", l1.countryCode); 24 | assertEquals("Japan", l1.countryName); 25 | assertEquals("40", l1.region); 26 | assertEquals("Tokyo", l1.city); 27 | assertEquals(35.6850, l1.latitude, DELTA); 28 | assertEquals(139.7510, l1.longitude, DELTA); 29 | assertEquals(0, l1.metro_code); 30 | assertEquals(0, l1.area_code); 31 | cl.close(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/CityLookupTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* CityLookupTest.java */ 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | import java.io.IOException; 8 | 9 | import org.junit.Test; 10 | 11 | public class CityLookupTest { 12 | private static final double DELTA = 1e-5; 13 | 14 | @Test 15 | public void testCityLookup() throws IOException { 16 | 17 | LookupService cl = new LookupService( 18 | "src/test/resources/GeoIP/GeoIPCity.dat", 19 | LookupService.GEOIP_MEMORY_CACHE); 20 | 21 | Location l1 = cl.getLocation("64.17.254.216"); 22 | Location l2 = cl.getLocation("66.92.181.240"); 23 | 24 | assertEquals("US", l2.countryCode); 25 | assertEquals("United States", l2.countryName); 26 | assertEquals("CA", l2.region); 27 | assertEquals("California", 28 | regionName.regionNameByCode(l2.countryCode, l2.region)); 29 | assertEquals("Fremont", l2.city); 30 | assertEquals("94538", l2.postalCode); 31 | assertEquals(37.507904, l2.latitude, DELTA); 32 | assertEquals(-121.96, l2.longitude, DELTA); 33 | assertEquals(512.893498, l2.distance(l1), DELTA); 34 | assertEquals(l2.distance(l1), l1.distance(l2), DELTA); 35 | assertEquals(807, l2.metro_code); 36 | assertEquals(510, l2.area_code); 37 | assertEquals("America/Los_Angeles", 38 | timeZone.timeZoneByCountryAndRegion(l2.countryCode, l2.region)); 39 | 40 | cl.close(); 41 | 42 | } 43 | 44 | @Test(expected=InvalidDatabaseException.class) 45 | public void testCityLookupInInvalidDatabase() throws IOException { 46 | 47 | LookupService cl = new LookupService( 48 | "src/test/resources/GeoIP/GeoIPCity-Corrupt.dat", 49 | LookupService.GEOIP_MEMORY_CACHE); 50 | Location l2 = cl.getLocation("66.92.181.240"); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/CityLookupV6Test.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* CityLookupV6Test.java */ 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | import java.io.IOException; 8 | 9 | import org.junit.Test; 10 | 11 | public class CityLookupV6Test { 12 | private static final double DELTA = 1e-5; 13 | 14 | @Test 15 | public void testCityLookupV6() throws IOException { 16 | 17 | LookupService cl = new LookupService( 18 | "src/test/resources/GeoIP/GeoLiteCityv6.dat", 19 | LookupService.GEOIP_MEMORY_CACHE); 20 | Location l1 = cl.getLocationV6("2a02:ff40::"); 21 | Location l2 = cl.getLocationV6("2001:208::"); 22 | 23 | assertEquals("SG", l2.countryCode); 24 | assertEquals("Singapore", l2.countryName); 25 | assertEquals(1.3666992, l2.latitude, DELTA); 26 | assertEquals(103.79999, l2.longitude, DELTA); 27 | assertEquals(11074.876894, l2.distance(l1), DELTA); 28 | assertEquals(11074.876894, l1.distance(l2), DELTA); 29 | assertEquals(0, l2.metro_code); 30 | assertEquals("Asia/Singapore", 31 | timeZone.timeZoneByCountryAndRegion(l2.countryCode, l2.region)); 32 | 33 | cl.close(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/CountryLookupTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* CountryLookupTest.java */ 4 | 5 | /* Only works with GeoIP Country Edition */ 6 | /* For Geoip City Edition, use CityLookupTest.java */ 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | import java.io.IOException; 11 | 12 | import org.junit.Test; 13 | 14 | public class CountryLookupTest { 15 | @Test 16 | public void testCountryLookup() throws IOException { 17 | 18 | String dbfile = "src/test/resources/GeoIP/GeoIP.dat"; 19 | LookupService cl = new LookupService(dbfile, 20 | LookupService.GEOIP_MEMORY_CACHE); 21 | 22 | assertEquals("US", cl.getCountry("64.17.254.216").getCode()); 23 | assertEquals("United States", cl.getCountry("64.17.254.216").getName()); 24 | assertEquals("Italy", cl.getCountry("78.26.70.208").getName()); 25 | assertEquals("France", cl.getCountry("83.206.36.224").getName()); 26 | assertEquals("Germany", cl.getCountry("85.88.2.224").getName()); 27 | 28 | cl.close(); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/CountryLookupV6Test.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.IOException; 6 | 7 | import org.junit.Test; 8 | 9 | public class CountryLookupV6Test { 10 | @Test 11 | public void testCountryLookup() throws IOException { 12 | 13 | String dbfile = "src/test/resources/GeoIP/GeoIPv6.dat"; 14 | LookupService cl = new LookupService(dbfile, 15 | LookupService.GEOIP_MEMORY_CACHE); 16 | 17 | assertEquals("US", cl.getCountryV6("64.17.254.216").getCode()); 18 | assertEquals("United States", cl.getCountryV6("64.17.254.216") 19 | .getName()); 20 | assertEquals("US", cl.getCountryV6("::64.17.254.216").getCode()); 21 | assertEquals("US", cl.getCountryV6("::ffff:64.17.254.216").getCode()); 22 | 23 | assertEquals("JP", cl.getCountry("2001:200::").getCode()); 24 | assertEquals("Japan", cl.getCountry("2001:200::").getName()); 25 | cl.close(); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/DomainLookupTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* DomainLookupTest.java */ 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | import java.io.IOException; 8 | 9 | import org.junit.Test; 10 | 11 | public class DomainLookupTest { 12 | @Test 13 | public void testDomainLookup() throws IOException { 14 | LookupService gid = new LookupService( 15 | "src/test/resources/GeoIP/GeoIPDomain.dat"); 16 | assertEquals("shoesfin.NET", gid.getOrg("67.43.156.0")); 17 | gid.close(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/NetSpeedCellLookupTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* OrgLookupTest.java */ 4 | 5 | // Need a binary sample dataset 6 | 7 | import static org.junit.Assert.assertEquals; 8 | 9 | import java.io.IOException; 10 | 11 | import org.junit.Test; 12 | 13 | public class NetSpeedCellLookupTest { 14 | @Test 15 | public void testNetSpeedCellLookup() throws IOException { 16 | LookupService ns = new LookupService( 17 | "src/test/resources/GeoIP/GeoIPNetSpeedCell.dat"); 18 | assertEquals("Cable/DSL", ns.getOrg("89.66.148.0")); 19 | ns.close(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/maxmind/geoip/OrgLookupTest.java: -------------------------------------------------------------------------------- 1 | package com.maxmind.geoip; 2 | 3 | /* OrgLookupTest.java */ 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | import java.io.IOException; 8 | 9 | import org.junit.Test; 10 | 11 | public class OrgLookupTest { 12 | @Test 13 | public void testOrgLookup() throws IOException { 14 | LookupService orgl = new LookupService( 15 | "src/test/resources/GeoIP/GeoIPOrg.dat"); 16 | 17 | assertEquals("DSLAM WAN Allocation", orgl.getOrg("70.46.123.145")); 18 | orgl.close(); 19 | } 20 | 21 | @Test 22 | public void testIspLookup() throws IOException { 23 | LookupService ispl = new LookupService( 24 | "src/test/resources/GeoIP/GeoIPISP.dat"); 25 | 26 | assertEquals("FDN Communications", ispl.getOrg("70.46.123.145")); 27 | ispl.close(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-113.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIP-113.csv -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-124.csv: -------------------------------------------------------------------------------- 1 | 12.87.118.0,12.87.119.255,"AT&T Services" 2 | 64.17.254.216,64.17.254.223,"Towerstream I" 3 | 65.23.121.221,65.23.121.221,"Nuvox Communications" 4 | 65.116.3.80,65.116.3.82,"Century Link" 5 | 66.92.181.240,66.92.181.255,Speakeasy 6 | 67.43.156.0,67.43.156.63,"Loud Packet" 7 | 67.43.156.64,67.43.156.127,"Loud Packet" 8 | 67.43.156.128,67.43.156.191,"Loud Packet" 9 | 67.43.156.192,67.43.156.255,"Loud Packet" 10 | 69.218.251.16,69.218.251.31,"AT&T Internet Services" 11 | 70.46.123.145,70.46.123.145,"FDN Communications" 12 | 71.138.104.240,71.138.104.247,"AT&T Internet Services" 13 | 74.0.137.194,74.0.137.194,"Covad Communications" 14 | 75.77.211.208,75.77.211.211,"Nuvox Communications" 15 | 78.26.70.208,78.26.70.215,"ASDASD srl a socio unico" 16 | 81.2.69.160,81.2.69.167,"Andrews & Arnold Ltd" 17 | 82.99.17.96,82.99.17.127,"IP-Only Telecommunication Networks AB" 18 | 83.206.36.224,83.206.36.231,"France Telecom" 19 | 85.88.2.224,85.88.2.255,"Surfplanet GmbH" 20 | 89.92.212.0,89.92.212.31,"Bouygues Telecom" 21 | 89.92.212.32,89.92.212.79,"Bouygues Telecom" 22 | 89.92.212.80,89.92.212.93,"Bouygues Telecom" 23 | 89.92.212.94,89.92.212.94,"Bouygues Telecom" 24 | 89.92.212.95,89.92.212.95,"Bouygues Telecom" 25 | 89.92.212.96,89.92.212.143,"Bouygues Telecom" 26 | 89.92.212.144,89.92.212.223,"Bouygues Telecom" 27 | 89.92.212.224,89.92.212.247,"Bouygues Telecom" 28 | 89.92.212.248,89.92.212.251,"Bouygues Telecom" 29 | 89.92.212.252,89.92.212.255,"Bouygues Telecom" 30 | 89.92.213.0,89.92.213.15,"Bouygues Telecom" 31 | 89.92.213.16,89.92.213.31,"Bouygues Telecom" 32 | 89.92.213.32,89.92.213.43,"Bouygues Telecom" 33 | 89.92.213.44,89.92.213.47,"Bouygues Telecom" 34 | 89.92.213.48,89.92.213.63,"Bouygues Telecom" 35 | 89.92.213.64,89.92.213.79,"Bouygues Telecom" 36 | 89.92.213.80,89.92.213.87,"Bouygues Telecom" 37 | 89.92.213.88,89.92.213.95,"Bouygues Telecom" 38 | 89.92.213.96,89.92.213.103,"Bouygues Telecom" 39 | 89.92.213.104,89.92.213.107,"Bouygues Telecom" 40 | 89.92.213.108,89.92.213.109,"Bouygues Telecom" 41 | 89.92.213.110,89.92.213.111,"Bouygues Telecom" 42 | 89.92.213.112,89.92.213.165,"Bouygues Telecom" 43 | 89.92.213.166,89.92.213.166,"Bouygues Telecom" 44 | 89.92.213.167,89.92.213.167,"Bouygues Telecom" 45 | 89.92.213.168,89.92.213.175,"Bouygues Telecom" 46 | 89.92.213.176,89.92.213.191,"Bouygues Telecom" 47 | 89.92.213.192,89.92.213.199,"Bouygues Telecom" 48 | 89.92.213.200,89.92.213.223,"Bouygues Telecom" 49 | 89.92.213.224,89.92.213.255,"Bouygues Telecom" 50 | 89.160.20.112,89.160.20.119,"Bredband2 AB" 51 | 142.217.214.0,142.217.214.255,Telebec 52 | 208.110.217.107,208.110.217.113,"Comcast - Houston" 53 | 216.83.171.192,216.83.171.223,"Sungard Network Solutions" 54 | 216.160.83.56,216.160.83.63,"Century Link" 55 | 222.230.136.0,222.230.136.255,"VECTANT Ltd." 56 | 222.230.137.0,222.230.137.255,"VECTANT Ltd." 57 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-134.csv: -------------------------------------------------------------------------------- 1 | 2 | 3 | "1359103374","1359103439","13547" 4 | "3634385720","3634385727","121700" 5 | "1503663216","1503663359","50428" 6 | "1126931456","1126931711","242" 7 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-139.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIP-139.csv -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-174.csv: -------------------------------------------------------------------------------- 1 | 65.23.96.0,65.23.127.255,nuvox.net 2 | 65.115.240.0,65.116.4.255,qwest.net 3 | 66.92.78.0,66.93.249.255,speakeasy.net 4 | 67.43.156.0,67.43.156.255,shoesfin.NET 5 | 67.43.156.0,67.43.156.255,shoesfin.NET 6 | 67.43.156.0,67.43.156.255,shoesfin.NET 7 | 67.43.156.0,67.43.156.255,shoesfin.NET 8 | 69.218.198.0,69.219.84.255,ameritech.net 9 | 70.46.0.0,70.46.132.255,nuvox.net 10 | 71.136.2.0,71.138.209.255,pacbell.net 11 | 74.0.88.0,74.2.174.255,covad.net 12 | 75.77.84.0,75.77.255.255,nuvox.net 13 | 78.26.67.0,78.26.110.255,popwifi.it 14 | 81.2.64.0,81.2.95.255,in-addr.arpa 15 | 83.206.0.0,83.206.255.255,oleane.fr 16 | 89.92.0.0,89.95.241.255,bbox.fr 17 | 89.92.0.0,89.95.241.255,bbox.fr 18 | 89.92.0.0,89.95.241.255,bbox.fr 19 | 89.92.0.0,89.95.241.255,bbox.fr 20 | 89.92.0.0,89.95.241.255,bbox.fr 21 | 89.92.0.0,89.95.241.255,bbox.fr 22 | 89.92.0.0,89.95.241.255,bbox.fr 23 | 89.92.0.0,89.95.241.255,bbox.fr 24 | 89.92.0.0,89.95.241.255,bbox.fr 25 | 89.92.0.0,89.95.241.255,bbox.fr 26 | 89.92.0.0,89.95.241.255,bbox.fr 27 | 89.92.0.0,89.95.241.255,bbox.fr 28 | 89.92.0.0,89.95.241.255,bbox.fr 29 | 89.92.0.0,89.95.241.255,bbox.fr 30 | 89.92.0.0,89.95.241.255,bbox.fr 31 | 89.92.0.0,89.95.241.255,bbox.fr 32 | 89.92.0.0,89.95.241.255,bbox.fr 33 | 89.92.0.0,89.95.241.255,bbox.fr 34 | 89.92.0.0,89.95.241.255,bbox.fr 35 | 89.92.0.0,89.95.241.255,bbox.fr 36 | 89.92.0.0,89.95.241.255,bbox.fr 37 | 89.92.0.0,89.95.241.255,bbox.fr 38 | 89.92.0.0,89.95.241.255,bbox.fr 39 | 89.92.0.0,89.95.241.255,bbox.fr 40 | 89.92.0.0,89.95.241.255,bbox.fr 41 | 89.92.0.0,89.95.241.255,bbox.fr 42 | 89.92.0.0,89.95.241.255,bbox.fr 43 | 89.92.0.0,89.95.241.255,bbox.fr 44 | 89.92.0.0,89.95.241.255,bbox.fr 45 | 89.92.0.0,89.95.241.255,bbox.fr 46 | 89.160.0.0,89.160.30.255,bredband2.com 47 | 142.217.194.0,142.217.214.255,telebecinternet.net 48 | 208.110.201.0,208.110.223.255,comcastbusiness.net 49 | 222.230.136.0,222.230.139.255,gol.ne.jp 50 | 222.230.136.0,222.230.139.255,gol.ne.jp 51 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-178.csv: -------------------------------------------------------------------------------- 1 | 12.83.207.0,12.87.255.255,Cable/DSL 2 | 64.17.246.0,64.18.63.255,Corporate 3 | 65.23.121.131,65.23.123.103,Corporate 4 | 65.116.2.224,65.116.6.255,Corporate 5 | 66.92.152.0,66.92.236.255,Cable/DSL 6 | 67.43.144.0,67.43.191.255,Corporate 7 | 67.43.144.0,67.43.191.255,Corporate 8 | 67.43.144.0,67.43.191.255,Corporate 9 | 67.43.144.0,67.43.191.255,Corporate 10 | 69.218.246.0,69.219.3.255,Cable/DSL 11 | 70.46.123.141,70.46.123.149,Cable/DSL 12 | 71.138.100.0,71.138.112.15,Cable/DSL 13 | 73.253.230.0,74.3.127.255,Cable/DSL 14 | 75.77.211.208,75.77.216.39,Corporate 15 | 81.2.68.144,81.2.69.179,Cable/DSL 16 | 83.206.29.224,83.206.84.31,Cable/DSL 17 | 85.88.0.0,85.88.5.31,Corporate 18 | 89.66.148.0,89.96.170.223,Cable/DSL 19 | 89.66.148.0,89.96.170.223,Cable/DSL 20 | 89.66.148.0,89.96.170.223,Cable/DSL 21 | 89.66.148.0,89.96.170.223,Cable/DSL 22 | 89.66.148.0,89.96.170.223,Cable/DSL 23 | 89.66.148.0,89.96.170.223,Cable/DSL 24 | 89.66.148.0,89.96.170.223,Cable/DSL 25 | 89.66.148.0,89.96.170.223,Cable/DSL 26 | 89.66.148.0,89.96.170.223,Cable/DSL 27 | 89.66.148.0,89.96.170.223,Cable/DSL 28 | 89.66.148.0,89.96.170.223,Cable/DSL 29 | 89.66.148.0,89.96.170.223,Cable/DSL 30 | 89.66.148.0,89.96.170.223,Cable/DSL 31 | 89.66.148.0,89.96.170.223,Cable/DSL 32 | 89.66.148.0,89.96.170.223,Cable/DSL 33 | 89.66.148.0,89.96.170.223,Cable/DSL 34 | 89.66.148.0,89.96.170.223,Cable/DSL 35 | 89.66.148.0,89.96.170.223,Cable/DSL 36 | 89.66.148.0,89.96.170.223,Cable/DSL 37 | 89.66.148.0,89.96.170.223,Cable/DSL 38 | 89.66.148.0,89.96.170.223,Cable/DSL 39 | 89.66.148.0,89.96.170.223,Cable/DSL 40 | 89.66.148.0,89.96.170.223,Cable/DSL 41 | 89.66.148.0,89.96.170.223,Cable/DSL 42 | 89.66.148.0,89.96.170.223,Cable/DSL 43 | 89.66.148.0,89.96.170.223,Cable/DSL 44 | 89.66.148.0,89.96.170.223,Cable/DSL 45 | 89.66.148.0,89.96.170.223,Cable/DSL 46 | 89.66.148.0,89.96.170.223,Cable/DSL 47 | 89.66.148.0,89.96.170.223,Cable/DSL 48 | 89.151.128.0,89.160.94.183,Cable/DSL 49 | 142.217.0.0,142.217.255.255,Cable/DSL 50 | 208.110.201.0,208.110.251.255,Corporate 51 | 216.83.169.80,216.83.174.103,Corporate 52 | 216.160.83.0,216.160.83.63,Corporate 53 | 222.228.245.0,222.231.19.255,Cable/DSL 54 | 222.228.245.0,222.231.19.255,Cable/DSL 55 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-ASNum.csv: -------------------------------------------------------------------------------- 1 | 12.81.92.0,12.96.16.255,AS7018 2 | 64.17.248.0,64.17.255.255,AS33224 3 | 65.23.96.0,65.23.127.255,AS11456 4 | 65.115.241.0,65.116.13.255,AS209 5 | 66.92.0.0,66.93.255.255,AS23504 6 | 67.43.149.0,67.43.159.255,AS35908 7 | 67.43.149.0,67.43.159.255,AS35908 8 | 67.43.149.0,67.43.159.255,AS35908 9 | 67.43.149.0,67.43.159.255,AS35908 10 | 69.218.35.0,69.219.83.255,AS7132 11 | 70.46.21.0,70.46.255.255,AS11456 12 | 71.134.78.0,71.140.197.255,AS7132 13 | 74.0.32.0,74.0.167.255,AS18566 14 | 75.77.40.0,75.77.255.255,AS11456 15 | 78.26.64.0,78.26.125.255,"AS28929 ASDASD srl" 16 | 82.99.0.0,82.99.63.255,"AS12552 IP-Only" 17 | 83.206.10.0,83.206.65.255,"AS3215 France Telecom - Orange" 18 | 85.88.0.0,85.88.31.255,"AS33984 Surfplanet GmbH" 19 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 20 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 21 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 22 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 23 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 24 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 25 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 26 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 27 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 28 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 29 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 30 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 31 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 32 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 33 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 34 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 35 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 36 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 37 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 38 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 39 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 40 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 41 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 42 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 43 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 44 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 45 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 46 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 47 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 48 | 89.80.0.0,89.95.255.255,"AS5410 Bouygues Telecom ISP" 49 | 89.160.0.0,89.160.127.255,"AS29518 Bredband2 AB" 50 | 142.217.208.0,142.217.238.255,AS35911 51 | 208.110.194.0,208.110.223.255,AS11025 52 | 216.83.161.0,216.83.191.255,"AS7381 SunGard Availability Services USA" 53 | 216.160.26.0,216.160.206.255,AS209 54 | 222.229.128.0,222.230.255.255,"AS2519 JPNIC" 55 | 222.229.128.0,222.230.255.255,"AS2519 JPNIC" 56 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP-UserType.csv: -------------------------------------------------------------------------------- 1 | 12.80.0.0,12.95.255.255,searchEngineSpider 2 | 64.17.254.208,64.17.254.223,government 3 | 65.23.121.192,65.23.121.223,searchEngineSpider 4 | 65.116.3.80,65.116.3.87,searchEngineSpider 5 | 66.92.180.0,66.92.183.255,government 6 | 67.43.156.0,67.43.159.255,searchEngineSpider 7 | 67.43.156.0,67.43.159.255,searchEngineSpider 8 | 67.43.156.0,67.43.159.255,searchEngineSpider 9 | 67.43.156.0,67.43.159.255,searchEngineSpider 10 | 69.218.251.0,69.218.251.127,government 11 | 70.46.123.128,70.46.123.191,searchEngineSpider 12 | 71.138.104.0,71.138.105.255,government 13 | 74.0.0.0,74.1.255.255,government 14 | 75.77.211.128,75.77.211.255,searchEngineSpider 15 | 78.26.70.0,78.26.71.255,government 16 | 81.2.69.160,81.2.69.175,government 17 | 82.99.16.0,82.99.23.255,searchEngineSpider 18 | 83.206.36.224,83.206.36.239,searchEngineSpider 19 | 85.88.2.192,85.88.2.255,cafe 20 | 89.92.0.0,89.95.255.255,government 21 | 89.92.0.0,89.95.255.255,government 22 | 89.92.0.0,89.95.255.255,government 23 | 89.92.0.0,89.95.255.255,government 24 | 89.92.0.0,89.95.255.255,government 25 | 89.92.0.0,89.95.255.255,government 26 | 89.92.0.0,89.95.255.255,government 27 | 89.92.0.0,89.95.255.255,government 28 | 89.92.0.0,89.95.255.255,government 29 | 89.92.0.0,89.95.255.255,government 30 | 89.92.0.0,89.95.255.255,government 31 | 89.92.0.0,89.95.255.255,government 32 | 89.92.0.0,89.95.255.255,government 33 | 89.92.0.0,89.95.255.255,government 34 | 89.92.0.0,89.95.255.255,government 35 | 89.92.0.0,89.95.255.255,government 36 | 89.92.0.0,89.95.255.255,government 37 | 89.92.0.0,89.95.255.255,government 38 | 89.92.0.0,89.95.255.255,government 39 | 89.92.0.0,89.95.255.255,government 40 | 89.92.0.0,89.95.255.255,government 41 | 89.92.0.0,89.95.255.255,government 42 | 89.92.0.0,89.95.255.255,government 43 | 89.92.0.0,89.95.255.255,government 44 | 89.92.0.0,89.95.255.255,government 45 | 89.92.0.0,89.95.255.255,government 46 | 89.92.0.0,89.95.255.255,government 47 | 89.92.0.0,89.95.255.255,government 48 | 89.92.0.0,89.95.255.255,government 49 | 89.92.0.0,89.95.255.255,government 50 | 89.160.20.112,89.160.20.127,government 51 | 142.216.0.0,142.217.255.255,government 52 | 208.110.217.0,208.110.217.255,searchEngineSpider 53 | 216.83.168.0,216.83.171.255,searchEngineSpider 54 | 216.160.83.32,216.160.83.63,government 55 | 222.230.128.0,222.230.159.255,government 56 | 222.230.128.0,222.230.159.255,government 57 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP.csv: -------------------------------------------------------------------------------- 1 | 12.87.118.0,12.87.119.255,US, 2 | 64.17.254.216,64.17.254.223,US, 3 | 65.23.121.221,65.23.121.221,US, 4 | 65.116.3.80,65.116.3.82,US, 5 | 66.92.181.240,66.92.181.255,US, 6 | 67.43.156.0,67.43.156.63,A1, 7 | 67.43.156.64,67.43.156.127,A1, 8 | 67.43.156.128,67.43.156.191,A1, 9 | 67.43.156.192,67.43.156.255,A1, 10 | 69.218.251.16,69.218.251.31,US, 11 | 70.46.123.145,70.46.123.145,US, 12 | 71.138.104.240,71.138.104.247,US, 13 | 74.0.137.194,74.0.137.194,US, 14 | 75.77.211.208,75.77.211.211,US, 15 | 78.26.70.208,78.26.70.215,IT, 16 | 81.2.69.160,81.2.69.167,GB, 17 | 82.99.17.96,82.99.17.127,NO, 18 | 83.206.36.224,83.206.36.231,FR, 19 | 85.88.2.224,85.88.2.255,DE, 20 | 89.92.212.0,89.92.212.31,FR, 21 | 89.92.212.32,89.92.212.79,FR, 22 | 89.92.212.80,89.92.212.93,FR, 23 | 89.92.212.94,89.92.212.94,FR, 24 | 89.92.212.95,89.92.212.95,FR, 25 | 89.92.212.96,89.92.212.143,FR, 26 | 89.92.212.144,89.92.212.223,FR, 27 | 89.92.212.224,89.92.212.247,FR, 28 | 89.92.212.248,89.92.212.251,FR, 29 | 89.92.212.252,89.92.212.255,FR, 30 | 89.92.213.0,89.92.213.15,FR, 31 | 89.92.213.16,89.92.213.31,FR, 32 | 89.92.213.32,89.92.213.43,FR, 33 | 89.92.213.44,89.92.213.47,FR, 34 | 89.92.213.48,89.92.213.63,FR, 35 | 89.92.213.64,89.92.213.79,FR, 36 | 89.92.213.80,89.92.213.87,FR, 37 | 89.92.213.88,89.92.213.95,FR, 38 | 89.92.213.96,89.92.213.103,FR, 39 | 89.92.213.104,89.92.213.107,FR, 40 | 89.92.213.108,89.92.213.109,FR, 41 | 89.92.213.110,89.92.213.111,FR, 42 | 89.92.213.112,89.92.213.165,FR, 43 | 89.92.213.166,89.92.213.166,FR, 44 | 89.92.213.167,89.92.213.167,FR, 45 | 89.92.213.168,89.92.213.175,FR, 46 | 89.92.213.176,89.92.213.191,FR, 47 | 89.92.213.192,89.92.213.199,FR, 48 | 89.92.213.200,89.92.213.223,FR, 49 | 89.92.213.224,89.92.213.255,FR, 50 | 89.160.20.112,89.160.20.119,SE, 51 | 142.217.214.0,142.217.214.255,CA, 52 | 208.110.217.107,208.110.217.113,US, 53 | 216.83.171.192,216.83.171.223,US, 54 | 216.160.83.56,216.160.83.63,US, 55 | 222.230.136.0,222.230.136.255,JP, 56 | 222.230.137.0,222.230.137.255,JP, 57 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIP.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIP.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPASNum.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPASNum.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPCity-Corrupt.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPCity-Corrupt.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPCity.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPCity.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPDistance.csv: -------------------------------------------------------------------------------- 1 | 12.87.118.0,12.87.118.255,57 2 | 12.87.119.0,12.87.119.255,173 3 | 64.17.254.216,64.17.254.223,10 4 | 65.23.121.0,65.23.121.255,534 5 | 65.116.3.80,65.116.3.81,351 6 | 65.116.3.82,65.116.3.82,351 7 | 66.92.181.240,66.92.181.255,139 8 | 67.43.144.0,67.43.159.255,534 9 | 67.43.144.0,67.43.159.255,534 10 | 67.43.144.0,67.43.159.255,534 11 | 67.43.144.0,67.43.159.255,534 12 | 70.46.123.128,70.46.123.159,321 13 | 71.138.104.224,71.138.104.255,8 14 | 74.0.137.194,74.0.137.194,10 15 | 75.77.211.192,75.77.211.255,120 16 | 78.26.70.192,78.26.70.255,2 17 | 81.2.69.160,81.2.69.191,96 18 | 82.99.17.0,82.99.17.255,1 19 | 83.206.36.224,83.206.36.231,30 20 | 89.92.212.0,89.92.212.15,1000 21 | 89.92.212.16,89.92.212.31,1 22 | 89.92.212.32,89.92.212.47,5 23 | 89.92.212.64,89.92.212.79,1 24 | 89.92.212.80,89.92.212.83,5 25 | 89.92.212.92,89.92.212.93,5 26 | 89.92.212.94,89.92.212.94,1 27 | 89.92.212.95,89.92.212.95,5 28 | 89.92.212.96,89.92.212.99,1 29 | 89.92.212.136,89.92.212.143,1 30 | 89.92.212.144,89.92.212.159,4 31 | 89.92.212.216,89.92.212.223,5 32 | 89.92.212.224,89.92.212.239,148 33 | 89.92.212.240,89.92.212.247,8 34 | 89.92.212.248,89.92.212.251,5 35 | 89.92.212.252,89.92.212.255,1 36 | 89.92.213.0,89.92.213.7,8 37 | 89.92.213.12,89.92.213.15,8 38 | 89.92.213.16,89.92.213.31,7 39 | 89.92.213.32,89.92.213.39,52 40 | 89.92.213.40,89.92.213.47,9 41 | 89.92.213.40,89.92.213.47,9 42 | 89.92.213.48,89.92.213.55,5 43 | 89.92.213.56,89.92.213.63,6 44 | 89.92.213.64,89.92.213.79,1 45 | 89.92.213.80,89.92.213.87,1 46 | 89.92.213.88,89.92.213.91,1 47 | 89.92.213.92,89.92.213.95,2 48 | 89.92.213.96,89.92.213.103,19 49 | 89.92.213.104,89.92.213.107,35 50 | 89.92.213.108,89.92.213.109,1 51 | 89.92.213.110,89.92.213.111,35 52 | 89.92.213.112,89.92.213.127,19 53 | 89.92.213.160,89.92.213.167,1 54 | 89.92.213.160,89.92.213.167,1 55 | 89.92.213.160,89.92.213.167,1 56 | 89.92.213.168,89.92.213.175,9 57 | 89.92.213.176,89.92.213.176,3 58 | 89.92.213.190,89.92.213.191,1 59 | 89.92.213.192,89.92.213.193,36 60 | 89.92.213.196,89.92.213.199,36 61 | 89.92.213.200,89.92.213.207,5 62 | 89.92.213.223,89.92.213.223,5 63 | 89.92.213.224,89.92.213.239,5 64 | 89.92.213.248,89.92.213.255,6 65 | 89.160.20.112,89.160.20.127,76 66 | 142.217.214.0,142.217.214.255,701 67 | 208.110.217.107,208.110.217.107,21 68 | 208.110.217.112,208.110.217.113,21 69 | 216.83.168.0,216.83.175.255,14 70 | 216.160.83.56,216.160.83.59,22 71 | 216.160.83.60,216.160.83.63,30 72 | 222.230.136.0,222.230.136.255,4 73 | 222.230.137.0,222.230.137.255,999 74 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPDistance.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPDistance.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPDomain.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPDomain.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPISP.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPISP.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPNetSpeedCell.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPNetSpeedCell.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPOrg.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPOrg.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPUserType.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPUserType.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPv6.csv: -------------------------------------------------------------------------------- 1 | ::12.87.118.0,::12.87.119.255,US 2 | ::64.17.254.216,::64.17.254.223,US 3 | 0000:0000:0000:0000:0000:ffff:0c57:7600,0000:0000:0000:0000:0000:ffff:0c57:76ff,US 4 | 0000:0000:0000:0000:0000:ffff:4011:fed8,0000:0000:0000:0000:0000:ffff:4011:fedf,US 5 | 2001:200::,2001:200:ffff:ffff:ffff:ffff:ffff:ffff,JP 6 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoIPv6.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoIPv6.dat -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoLiteCityv6-no-addr.csv: -------------------------------------------------------------------------------- 1 | 42540528726795050063891204319802818560,42540528806023212578155541913346768895,JP,,,36,138,,0,0 2 | 42540529360620350178005905068154421248,42540529439848512692270242661698371583,SG,,,1.3667,103.8,,0,0 3 | 42540530628270950406235306564857626624,42540530707499112920499644158401576959,JP,,,36,138,,0,0 4 | 42540531262096250520350007313209229312,42540531341324413034614344906753179647,KR,,,37,127.5,,0,0 5 | 42540532529746850748579408809912434688,42540532608975013262843746403456385023,KR,,,37,127.5,,0,0 6 | 42540533163572150862694109558264037376,42540533242800313376958447151807987711,TW,,,23.5,121,,0,0 7 | 42540533797397450976808810306615640064,42540533876625613491073147900159590399,JP,,,36,138,,0,0 8 | 42540535065048051205038211803318845440,42540535302732538747831224583950696447,CN,,,35,105,,0,0 9 | 42540535381960701262095562177494646784,42540535461188863776359899771038597119,CN,,,35,105,,0,0 10 | 42540535540417026290624237364582547456,42540535619645188804888574958126497791,CN,,,35,105,,0,0 11 | 42540535698873351319152912551670448128,42540535778101513833417250145214398463,JP,,,36,138,,0,0 12 | 42540536332698651433267613300022050816,42540536411926813947531950893566001151,JP,,,36,138,,0,0 13 | 42540536966523951547382314048373653504,42540537045752114061646651641917603839,JP,,,36,138,,0,0 14 | 42540537600349251661497014796725256192,42540537679577414175761352390269206527,KR,,,37,127.5,,0,0 15 | 42540538234174551775611715545076858880,42540538313402714289876053138620809215,JP,,,36,138,,0,0 16 | 42540538867999851889726416293428461568,42540538947228014403990753886972411903,KR,,,37,127.5,,0,0 17 | 42540539501825152003841117041780064256,42540539581053314518105454635324014591,TW,,,23.5,121,,0,0 18 | 42540540135650452117955817790131666944,42540540214878614632220155383675617279,KR,,,37,127.5,,0,0 19 | 42540540769475752232070518538483269632,42540540848703914746334856132027219967,JP,,,36,138,,0,0 20 | 42540541403301052346185219286834872320,42540541482529214860449556880378822655,JP,,,36,138,,0,0 21 | 42540542037126352460299920035186475008,42540542116354514974564257628730425343,JP,,,36,138,,0,0 22 | 42540542670951652574414620783538077696,42540542750179815088678958377082028031,KR,,,37,127.5,,0,0 23 | 42540543304776952688529321531889680384,42540543384005115202793659125433630719,KR,,,37,127.5,,0,0 24 | 42540543938602252802644022280241283072,42540544017830415316908359873785233407,JP,,,36,138,,0,0 25 | 42540544572427552916758723028592885760,42540544651655715431023060622136836095,JP,,,36,138,,0,0 26 | 42540545840078153144988124525296091136,42540545919306315659252462118840041471,KR,,,37,127.5,,0,0 27 | 42540546473903453259102825273647693824,42540546553131615773367162867191644159,HK,,,22.25,114.167,,0,0 28 | 42540547107728753373217526021999296512,42540547186956915887481863615543246847,JP,,,36,138,,0,0 29 | 42540547741554053487332226770350899200,42540547820782216001596564363894849535,JP,,,36,138,,0,0 30 | 42540548375379353601446927518702501888,42540548454607516115711265112246452223,JP,,,36,138,,0,0 31 | 55842163946073893125912320592261939200,55842164579899193240027021340613541887,NO,,,62,10,,0,0 32 | 55842169016676294038829926579074760704,55842169650501594152944627327426363391,IL,,,31.5,34.75,,0,0 33 | 55842174087278694951747532565887582208,55842174721103995065862233314239184895,FR,,,46,2,,0,0 34 | 55842179157881095864665138552700403712,55842179791706395978779839301052006399,CH,,,47,8,,0,0 35 | 55842184228483496777582744539513225216,55842184862308796891697445287864827903,SE,,,62,15,,0,0 36 | 55842189299085897690500350526326046720,55842189932911197804615051274677649407,BH,,,26,50.55,,0,0 37 | 55842194369688298603417956513138868224,55842195003513598717532657261490470911,RU,,,60,100,,0,0 38 | 55842199440290699516335562499951689728,55842200074115999630450263248303292415,PL,,,52,20,,0,0 39 | 55842204510893100429253168486764511232,55842205144718400543367869235116113919,NO,,,62,10,,0,0 40 | 55842209581495501342170774473577332736,55842210215320801456285475221928935423,DE,,,51,9,,0,0 41 | 55842214652097902255088380460390154240,55842215285923202369203081208741756927,IT,,,42.8333,12.8333,,0,0 42 | 55842219722700303168005986447202975744,55842220356525603282120687195554578431,FI,,,64,26,,0,0 43 | 55842224793302704080923592434015797248,55842225427128004195038293182367399935,BY,,,53,28,,0,0 44 | 55842229863905104993841198420828618752,55842230497730405107955899169180221439,CZ,,,49.75,15.5,,0,0 45 | 55842234934507505906758804407641440256,55842235568332806020873505155993042943,IR,,,32,53,,0,0 46 | 55842240005109906819676410394454261760,55842240638935206933791111142805864447,UA,,,49,32,,0,0 47 | 55842245075712307732594016381267083264,55842245709537607846708717129618685951,FR,,,46,2,,0,0 48 | 55842250146314708645511622368079904768,55842250780140008759626323116431507455,IR,,,32,53,,0,0 49 | 55842255216917109558429228354892726272,55842255850742409672543929103244328959,GB,,,54,-2,,0,0 50 | 55842260287519510471346834341705547776,55842260921344810585461535090057150463,HU,,,47,20,,0,0 51 | 55842265358121911384264440328518369280,55842265991947211498379141076869971967,SE,,,62,15,,0,0 52 | 55842270428724312297182046315331190784,55842271062549612411296747063682793471,DE,,,51,9,,0,0 53 | 55842275499326713210099652302144012288,55842275816239363267157002676319813631,FI,,,64,26,,0,0 54 | 55842278034627913666558455295550423040,55842278351540563723615805669726224383,DE,,,51,9,,0,0 55 | 55842280569929114123017258288956833792,55842281203754414237131959037308436479,EU,,,47,8,,0,0 56 | 55842285640531515035934864275769655296,55842286274356815150049565024121257983,GB,,,54,-2,,0,0 57 | 55842290711133915948852470262582476800,55842291344959216062967171010934079487,FR,,,46,2,,0,0 58 | 55842295781736316861770076249395298304,55842296415561616975884776997746900991,ES,,,40,-4,,0,0 59 | 55842300852338717774687682236208119808,55842301486164017888802382984559722495,DE,,,51,9,,0,0 60 | 55842305922941118687605288223020941312,55842306556766418801719988971372543999,FR,,,46,2,,0,0 61 | 55842310993543519600522894209833762816,55842311310456169657580244584009564159,GB,,,54,-2,,0,0 62 | 55842313528844720056981697203240173568,55842313845757370114039047577415974911,DE,,,51,9,,0,0 63 | 55842316064145920513440500196646584320,55842316697971220627555200944998187007,BG,,,43,25,,0,0 64 | 55842321134748321426358106183459405824,55842321768573621540472806931811008511,DE,,,51,9,,0,0 65 | 55842326205350722339275712170272227328,55842326839176022453390412918623830015,CH,,,47,8,,0,0 66 | 55842331275953123252193318157085048832,55842331909778423366308018905436651519,IR,,,32,53,,0,0 67 | 55842336346555524165110924143897870336,55842336980380824279225624892249473023,FR,,,46,2,,0,0 68 | 55842341417157925078028530130710691840,55842342050983225192143230879062294527,RO,,,46,25,,0,0 69 | 55842346487760325990946136117523513344,55842347121585626105060836865875116031,RU,,,60,100,,0,0 70 | 55842351558362726903863742104336334848,55842352192188027017978442852687937535,RU,,,60,100,,0,0 71 | 55842356628965127816781348091149156352,55842357262790427930896048839500759039,NO,,,62,10,,0,0 72 | 55842361699567528729698954077961977856,55842362333392828843813654826313580543,SE,,,62,15,,0,0 73 | 55842366770169929642616560064774799360,55842367403995229756731260813126402047,BE,,,50.8333,4,,0,0 74 | 55842371840772330555534166051587620864,55842372474597630669648866799939223551,TR,,,39,35,,0,0 75 | 55842376911374731468451772038400442368,55842377545200031582566472786752045055,TR,,,39,35,,0,0 76 | 55842381981977132381369378025213263872,55842382615802432495484078773564866559,DE,,,51,9,,0,0 77 | 55842387052579533294286984012026085376,55842387686404833408401684760377688063,GB,,,54,-2,,0,0 78 | 55842392123181934207204589998838906880,55842392757007234321319290747190509567,AT,,,47.3333,13.3333,,0,0 79 | 55842397193784335120122195985651728384,55842397827609635234236896734003331071,RU,,,60,100,,0,0 80 | 55842402264386736033039801972464549888,55842402898212036147154502720816152575,DE,,,51,9,,0,0 81 | 55842407334989136945957407959277371392,55842407968814437060072108707628974079,RO,,,46,25,,0,0 82 | 55842412405591537858875013946090192896,55842413039416837972989714694441795583,RU,,,60,100,,0,0 83 | 55842417476193938771792619932903014400,55842418110019238885907320681254617087,RU,,,60,100,,0,0 84 | 55842422546796339684710225919715835904,55842423180621639798824926668067438591,RU,,,60,100,,0,0 85 | 55842427617398740597627831906528657408,55842428251224040711742532654880260095,TR,,,39,35,,0,0 86 | 55842432688001141510545437893341478912,55842433321826441624660138641693081599,RU,,,60,100,,0,0 87 | 55842437758603542423463043880154300416,55842438392428842537577744628505903103,UA,,,49,32,,0,0 88 | 55842442829205943336380649866967121920,55842443463031243450495350615318724607,AL,,,41,20,,0,0 89 | 55842447899808344249298255853779943424,55842448533633644363412956602131546111,GB,,,54,-2,,0,0 90 | 55842452970410745162215861840592764928,55842453604236045276330562588944367615,SE,,,62,15,,0,0 91 | 55842458041013146075133467827405586432,55842458674838446189248168575757189119,RU,,,60,100,,0,0 92 | 55842463111615546988051073814218407936,55842463745440847102165774562570010623,RU,,,60,100,,0,0 93 | 55842468182217947900968679801031229440,55842468816043248015083380549382832127,IL,,,31.5,34.75,,0,0 94 | 55842473252820348813886285787844050944,55842473886645648928000986536195653631,RU,,,60,100,,0,0 95 | 55842478323422749726803891774656872448,55842478957248049840918592523008475135,LB,,,33.8333,35.8333,,0,0 96 | 55842483394025150639721497761469693952,55842484027850450753836198509821296639,IR,,,32,53,,0,0 97 | 55842488464627551552639103748282515456,55842489098452851666753804496634118143,TR,,,39,35,,0,0 98 | 55842493535229952465556709735095336960,55842494169055252579671410483446939647,GB,,,54,-2,,0,0 99 | 55842498605832353378474315721908158464,55842499239657653492589016470259761151,IR,,,32,53,,0,0 100 | 55842503676434754291391921708720979968,55842504310260054405506622457072582655,FR,,,46,2,,0,0 101 | 55842508747037155204309527695533801472,55842509380862455318424228443885404159,NL,,,52.5,5.75,,0,0 102 | 55842513817639556117227133682346622976,55842514451464856231341834430698225663,KW,,,29.3375,47.6581,,0,0 103 | 55842518888241957030144739669159444480,55842519522067257144259440417511047167,CH,,,47,8,,0,0 104 | 55842523958844357943062345655972265984,55842524592669658057177046404323868671,GB,,,54,-2,,0,0 105 | 55842529029446758855979951642785087488,55842529663272058970094652391136690175,PL,,,52,20,,0,0 106 | 55842534100049159768897557629597908992,55842534733874459883012258377949511679,GB,,,54,-2,,0,0 107 | 55842539170651560681815163616410730496,55842539804476860795929864364762333183,NL,,,52.5,5.75,,0,0 108 | 55842544241253961594732769603223552000,55842544558166611651790119977399353343,AT,,,47.3333,13.3333,,0,0 109 | 55842546776555162051191572596629962752,55842547093467812108248922970805764095,SA,,,25,45,,0,0 110 | 55842549311856362507650375590036373504,55842549945681662621765076338387976191,DE,,,51,9,,0,0 111 | 55842554382458763420567981576849195008,55842555016284063534682682325200797695,DE,,,51,9,,0,0 112 | 55842559453061164333485587563662016512,55842560086886464447600288312013619199,IT,,,42.8333,12.8333,,0,0 113 | 55842564523663565246403193550474838016,55842565157488865360517894298826440703,BY,,,53,28,,0,0 114 | 55842569594265966159320799537287659520,55842570228091266273435500285639262207,NO,,,62,10,,0,0 115 | 55842574664868367072238405524100481024,55842575298693667186353106272452083711,IT,,,42.8333,12.8333,,0,0 116 | 55842579735470767985156011510913302528,55842580369296068099270712259264905215,FR,,,46,2,,0,0 117 | 55842584806073168898073617497726124032,55842585439898469012188318246077726719,SE,,,62,15,,0,0 118 | 55842589876675569810991223484538945536,55842590510500869925105924232890548223,DE,,,51,9,,0,0 119 | 55842594947277970723908829471351767040,55842595581103270838023530219703369727,RU,,,60,100,,0,0 120 | 55842600017880371636826435458164588544,55842600651705671750941136206516191231,NL,,,52.5,5.75,,0,0 121 | 55842605088482772549744041444977410048,55842605722308072663858742193329012735,FR,,,46,2,,0,0 122 | 55842610159085173462661647431790231552,55842610792910473576776348180141834239,RS,,,44,21,,0,0 123 | 55842615229687574375579253418603053056,55842615863512874489693954166954655743,NO,,,62,10,,0,0 124 | 55842620300289975288496859405415874560,55842620934115275402611560153767477247,RU,,,60,100,,0,0 125 | 55842625370892376201414465392228696064,55842625687805026258471815766404497407,FR,,,46,2,,0,0 126 | 55842627906193576657873268385635106816,55842628223106226714930618759810908159,RU,,,60,100,,0,0 127 | 55842630441494777114332071379041517568,55842631075320077228446772127393120255,FR,,,46,2,,0,0 128 | 55842635512097178027249677365854339072,55842636145922478141364378114205941759,JO,,,31,36,,0,0 129 | 55842640582699578940167283352667160576,55842641216524879054281984101018763263,RU,,,60,100,,0,0 130 | 55842645653301979853084889339479982080,55842646287127279967199590087831584767,LY,,,25,17,,0,0 131 | 55842650723904380766002495326292803584,55842651357729680880117196074644406271,DE,,,51,9,,0,0 132 | 55842655794506781678920101313105625088,55842656428332081793034802061457227775,TR,,,39,35,,0,0 133 | 55842660865109182591837707299918446592,55842661498934482705952408048270049279,PL,,,52,20,,0,0 134 | 55842665935711583504755313286731268096,55842666569536883618870014035082870783,DE,,,51,9,,0,0 135 | 55842671006313984417672919273544089600,55842671640139284531787620021895692287,RU,,,60,100,,0,0 136 | 55842676076916385330590525260356911104,55842676710741685444705226008708513791,RU,,,60,100,,0,0 137 | 55842686218121187156425737233982554112,55842686851946487270540437982334156799,IE,,,53,-8,,0,0 138 | 55842691288723588069343343220795375616,55842691922548888183458043969146978303,RO,,,46,25,,0,0 139 | 55842696359325988982260949207608197120,55842696993151289096375649955959799807,IL,,,31.5,34.75,,0,0 140 | 55842701429928389895178555194421018624,55842702063753690009293255942772621311,SE,,,62,15,,0,0 141 | 55842706500530790808096161181233840128,55842707134356090922210861929585442815,CH,,,47,8,,0,0 142 | 55842711571133191721013767168046661632,55842712204958491835128467916398264319,GB,,,54,-2,,0,0 143 | 55842716641735592633931373154859483136,55842717275560892748046073903211085823,PL,,,52,20,,0,0 144 | 55842721712337993546848979141672304640,55842722346163293660963679890023907327,PL,,,52,20,,0,0 145 | 55842726782940394459766585128485126144,55842727416765694573881285876836728831,RU,,,60,100,,0,0 146 | 55842731853542795372684191115297947648,55842732487368095486798891863649550335,GB,,,54,-2,,0,0 147 | 55842736924145196285601797102110769152,55842737557970496399716497850462371839,RU,,,60,100,,0,0 148 | 55842741994747597198519403088923590656,55842742628572897312634103837275193343,FR,,,46,2,,0,0 149 | 55842747065349998111437009075736412160,55842747699175298225551709824088014847,FR,,,46,2,,0,0 150 | 55842752135952399024354615062549233664,55842752769777699138469315810900836351,RU,,,60,100,,0,0 151 | 55842757206554799937272221049362055168,55842757840380100051386921797713657855,EU,,,47,8,,0,0 152 | 55842762277157200850189827036174876672,55842762910982500964304527784526479359,AZ,,,40.5,47.5,,0,0 153 | 55842767347759601763107433022987698176,55842767981584901877222133771339300863,NO,,,62,10,,0,0 154 | 55842772418362002676025039009800519680,55842773052187302790139739758152122367,TR,,,39,35,,0,0 155 | 55842777488964403588942644996613341184,55842778122789703703057345744964943871,DE,,,51,9,,0,0 156 | 55842782559566804501860250983426162688,55842783193392104615974951731777765375,SA,,,25,45,,0,0 157 | 55842787630169205414777856970238984192,55842788263994505528892557718590586879,UA,,,49,32,,0,0 158 | 55842792700771606327695462957051805696,55842793334596906441810163705403408383,RU,,,60,100,,0,0 159 | 55842797771374007240613068943864627200,55842798405199307354727769692216229887,NL,,,52.5,5.75,,0,0 160 | 55842802841976408153530674930677448704,55842803475801708267645375679029051391,SE,,,62,15,,0,0 161 | 55842807912578809066448280917490270208,55842808546404109180562981665841872895,RU,,,60,100,,0,0 162 | 55842812983181209979365886904303091712,55842813617006510093480587652654694399,RU,,,60,100,,0,0 163 | 55842818053783610892283492891115913216,55842818687608911006398193639467515903,TR,,,39,35,,0,0 164 | 55842823124386011805201098877928734720,55842823758211311919315799626280337407,RU,,,60,100,,0,0 165 | 55842828194988412718118704864741556224,55842828828813712832233405613093158911,CZ,,,49.75,15.5,,0,0 166 | 55842833265590813631036310851554377728,55842833899416113745151011599905980415,BH,,,26,50.55,,0,0 167 | 55842838336193214543953916838367199232,55842838653105864601011267212543000575,UA,,,49,32,,0,0 168 | 55842840871494415000412719831773609984,55842841188407065057470070205949411327,GB,,,54,-2,,0,0 169 | 55842843406795615456871522825180020736,55842844040620915570986223573531623423,JO,,,31,36,,0,0 170 | 55842848477398016369789128811992842240,55842849111223316483903829560344444927,GB,,,54,-2,,0,0 171 | 55842853548000417282706734798805663744,55842854181825717396821435547157266431,DE,,,51,9,,0,0 172 | 55842858618602818195624340785618485248,55842859252428118309739041533970087935,FR,,,46,2,,0,0 173 | 55842863689205219108541946772431306752,55842864323030519222656647520782909439,UA,,,49,32,,0,0 174 | 55842868759807620021459552759244128256,55842869393632920135574253507595730943,DE,,,51,9,,0,0 175 | 55842873830410020934377158746056949760,55842874464235321048491859494408552447,IR,,,32,53,,0,0 176 | 55842878901012421847294764732869771264,55842879534837721961409465481221373951,FR,,,46,2,,0,0 177 | 55842883971614822760212370719682592768,55842884605440122874327071468034195455,RU,,,60,100,,0,0 178 | 55842889042217223673129976706495414272,55842889676042523787244677454847016959,NO,,,62,10,,0,0 179 | 55842894112819624586047582693308235776,55842894746644924700162283441659838463,DE,,,51,9,,0,0 180 | 55842899183422025498965188680121057280,55842899817247325613079889428472659967,GB,,,54,-2,,0,0 181 | 55842904254024426411882794666933878784,55842904887849726525997495415285481471,PL,,,52,20,,0,0 182 | 55842909324626827324800400653746700288,55842909958452127438915101402098302975,AE,,,24,54,,0,0 183 | 55842914395229228237718006640559521792,55842915029054528351832707388911124479,GB,,,54,-2,,0,0 184 | 55842919465831629150635612627372343296,55842920099656929264750313375723945983,NO,,,62,10,,0,0 185 | 55842924536434030063553218614185164800,55842925170259330177667919362536767487,ES,,,40,-4,,0,0 186 | 55842929607036430976470824600997986304,55842930240861731090585525349349588991,RU,,,60,100,,0,0 187 | 55842934677638831889388430587810807808,55842934994551481946445780961986609151,GB,,,54,-2,,0,0 188 | 55842937212940032345847233581217218560,55842937529852682402904583955393019903,RU,,,60,100,,0,0 189 | 55842939748241232802306036574623629312,55842940382066532916420737322975231999,AM,,,40,45,,0,0 190 | 55842944818843633715223642561436450816,55842945452668933829338343309788053503,NL,,,52.5,5.75,,0,0 191 | 55842949889446034628141248548249272320,55842950523271334742255949296600875007,NL,,,52.5,5.75,,0,0 192 | 55842954960048435541058854535062093824,55842955593873735655173555283413696511,NL,,,52.5,5.75,,0,0 193 | 55842960030650836453976460521874915328,55842960664476136568091161270226518015,RU,,,60,100,,0,0 194 | 55842965101253237366894066508687736832,55842965735078537481008767257039339519,RU,,,60,100,,0,0 195 | 55842970171855638279811672495500558336,55842970805680938393926373243852161023,LB,,,33.8333,35.8333,,0,0 196 | 55842975242458039192729278482313379840,55842975876283339306843979230664982527,PL,,,52,20,,0,0 197 | 55842980313060440105646884469126201344,55842980946885740219761585217477804031,SE,,,62,15,,0,0 198 | 55842985383662841018564490455939022848,55842986017488141132679191204290625535,PL,,,52,20,,0,0 199 | 55842990454265241931482096442751844352,55842991088090542045596797191103447039,RU,,,60,100,,0,0 200 | 55842995524867642844399702429564665856,55842996158692942958514403177916268543,NL,,,52.5,5.75,,0,0 201 | 55843000595470043757317308416377487360,55843001229295343871432009164729090047,DE,,,51,9,,0,0 202 | 55843005666072444670234914403190308864,55843006299897744784349615151541911551,PL,,,52,20,,0,0 203 | 55843010736674845583152520390003130368,55843011370500145697267221138354733055,IR,,,32,53,,0,0 204 | 55843015807277246496070126376815951872,55843016441102546610184827125167554559,HU,,,47,20,,0,0 205 | 55843020877879647408987732363628773376,55843021511704947523102433111980376063,GB,,,54,-2,,0,0 206 | 55843025948482048321905338350441594880,55843026582307348436020039098793197567,GB,,,54,-2,,0,0 207 | 55843031019084449234822944337254416384,55843031652909749348937645085606019071,SA,,,25,45,,0,0 208 | 55843036089686850147740550324067237888,55843036723512150261855251072418840575,TR,,,39,35,,0,0 209 | 55843041160289251060658156310880059392,55843041794114551174772857059231662079,DE,,,51,9,,0,0 210 | 55843046230891651973575762297692880896,55843046864716952087690463046044483583,PL,,,52,20,,0,0 211 | 55843051301494052886493368284505702400,55843051935319353000608069032857305087,DE,,,51,9,,0,0 212 | 55843056372096453799410974271318523904,55843057005921753913525675019670126591,GB,,,54,-2,,0,0 213 | 55843061442698854712328580258131345408,55843062076524154826443281006482948095,IT,,,42.8333,12.8333,,0,0 214 | 55843066513301255625246186244944166912,55843067147126555739360886993295769599,PL,,,52,20,,0,0 215 | 55843071583903656538163792231756988416,55843072217728956652278492980108591103,SE,,,62,15,,0,0 216 | 55843076654506057451081398218569809920,55843077288331357565196098966921412607,DK,,,56,10,,0,0 217 | 55843081725108458363999004205382631424,55843082358933758478113704953734234111,NO,,,62,10,,0,0 218 | 55843086795710859276916610192195452928,55843087429536159391031310940547055615,GB,,,54,-2,,0,0 219 | 55843091866313260189834216179008274432,55843092500138560303948916927359877119,DE,,,51,9,,0,0 220 | 55843096936915661102751822165821095936,55843097570740961216866522914172698623,IT,,,42.8333,12.8333,,0,0 221 | 55843102007518062015669428152633917440,55843102641343362129784128900985520127,DK,,,56,10,,0,0 222 | 55843107078120462928587034139446738944,55843107711945763042701734887798341631,AT,,,47.3333,13.3333,,0,0 223 | 55843112148722863841504640126259560448,55843112782548163955619340874611163135,NL,,,52.5,5.75,,0,0 224 | 55843117219325264754422246113072381952,55843117853150564868536946861423984639,GB,,,54,-2,,0,0 225 | 55843122289927665667339852099885203456,55843122923752965781454552848236806143,IT,,,42.8333,12.8333,,0,0 226 | 55843127360530066580257458086698024960,55843127994355366694372158835049627647,GB,,,54,-2,,0,0 227 | 55843132431132467493175064073510846464,55843133064957767607289764821862449151,IT,,,42.8333,12.8333,,0,0 228 | 55843137501734868406092670060323667968,55843138135560168520207370808675270655,IM,,,54.23,-4.57,,0,0 229 | 55843142572337269319010276047136489472,55843143206162569433124976795488092159,DE,,,51,9,,0,0 230 | 55843147642939670231927882033949310976,55843148276764970346042582782300913663,GI,,,36.1833,-5.3667,,0,0 231 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoLiteCityv6.csv: -------------------------------------------------------------------------------- 1 | 2001:200::,2001:200:ffff:ffff:ffff:ffff:ffff:ffff,42540528726795050063891204319802818560,42540528806023212578155541913346768895,JP,,,36,138,,0,0 2 | 2001:208::,2001:208:ffff:ffff:ffff:ffff:ffff:ffff,42540529360620350178005905068154421248,42540529439848512692270242661698371583,SG,,,1.3667,103.8,,0,0 3 | 2001:218::,2001:218:ffff:ffff:ffff:ffff:ffff:ffff,42540530628270950406235306564857626624,42540530707499112920499644158401576959,JP,,,36,138,,0,0 4 | 2001:220::,2001:220:ffff:ffff:ffff:ffff:ffff:ffff,42540531262096250520350007313209229312,42540531341324413034614344906753179647,KR,,,37,127.5,,0,0 5 | 2001:230::,2001:230:ffff:ffff:ffff:ffff:ffff:ffff,42540532529746850748579408809912434688,42540532608975013262843746403456385023,KR,,,37,127.5,,0,0 6 | 2001:238::,2001:238:ffff:ffff:ffff:ffff:ffff:ffff,42540533163572150862694109558264037376,42540533242800313376958447151807987711,TW,,,23.5,121,,0,0 7 | 2001:240::,2001:240:ffff:ffff:ffff:ffff:ffff:ffff,42540533797397450976808810306615640064,42540533876625613491073147900159590399,JP,,,36,138,,0,0 8 | 2001:250::,2001:252:ffff:ffff:ffff:ffff:ffff:ffff,42540535065048051205038211803318845440,42540535302732538747831224583950696447,CN,,,35,105,,0,0 9 | 2001:254::,2001:254:ffff:ffff:ffff:ffff:ffff:ffff,42540535381960701262095562177494646784,42540535461188863776359899771038597119,CN,,,35,105,,0,0 10 | 2001:256::,2001:256:ffff:ffff:ffff:ffff:ffff:ffff,42540535540417026290624237364582547456,42540535619645188804888574958126497791,CN,,,35,105,,0,0 11 | 2001:258::,2001:258:ffff:ffff:ffff:ffff:ffff:ffff,42540535698873351319152912551670448128,42540535778101513833417250145214398463,JP,,,36,138,,0,0 12 | 2001:260::,2001:260:ffff:ffff:ffff:ffff:ffff:ffff,42540536332698651433267613300022050816,42540536411926813947531950893566001151,JP,,,36,138,,0,0 13 | 2001:268::,2001:268:ffff:ffff:ffff:ffff:ffff:ffff,42540536966523951547382314048373653504,42540537045752114061646651641917603839,JP,,,36,138,,0,0 14 | 2001:270::,2001:270:ffff:ffff:ffff:ffff:ffff:ffff,42540537600349251661497014796725256192,42540537679577414175761352390269206527,KR,,,37,127.5,,0,0 15 | 2001:278::,2001:278:ffff:ffff:ffff:ffff:ffff:ffff,42540538234174551775611715545076858880,42540538313402714289876053138620809215,JP,,,36,138,,0,0 16 | 2001:280::,2001:280:ffff:ffff:ffff:ffff:ffff:ffff,42540538867999851889726416293428461568,42540538947228014403990753886972411903,KR,,,37,127.5,,0,0 17 | 2001:288::,2001:288:ffff:ffff:ffff:ffff:ffff:ffff,42540539501825152003841117041780064256,42540539581053314518105454635324014591,TW,,,23.5,121,,0,0 18 | 2001:290::,2001:290:ffff:ffff:ffff:ffff:ffff:ffff,42540540135650452117955817790131666944,42540540214878614632220155383675617279,KR,,,37,127.5,,0,0 19 | 2001:298::,2001:298:ffff:ffff:ffff:ffff:ffff:ffff,42540540769475752232070518538483269632,42540540848703914746334856132027219967,JP,,,36,138,,0,0 20 | 2001:2a0::,2001:2a0:ffff:ffff:ffff:ffff:ffff:ffff,42540541403301052346185219286834872320,42540541482529214860449556880378822655,JP,,,36,138,,0,0 21 | 2001:2a8::,2001:2a8:ffff:ffff:ffff:ffff:ffff:ffff,42540542037126352460299920035186475008,42540542116354514974564257628730425343,JP,,,36,138,,0,0 22 | 2001:2b0::,2001:2b0:ffff:ffff:ffff:ffff:ffff:ffff,42540542670951652574414620783538077696,42540542750179815088678958377082028031,KR,,,37,127.5,,0,0 23 | 2001:2b8::,2001:2b8:ffff:ffff:ffff:ffff:ffff:ffff,42540543304776952688529321531889680384,42540543384005115202793659125433630719,KR,,,37,127.5,,0,0 24 | 2001:2c0::,2001:2c0:ffff:ffff:ffff:ffff:ffff:ffff,42540543938602252802644022280241283072,42540544017830415316908359873785233407,JP,,,36,138,,0,0 25 | 2001:2c8::,2001:2c8:ffff:ffff:ffff:ffff:ffff:ffff,42540544572427552916758723028592885760,42540544651655715431023060622136836095,JP,,,36,138,,0,0 26 | 2001:2d8::,2001:2d8:ffff:ffff:ffff:ffff:ffff:ffff,42540545840078153144988124525296091136,42540545919306315659252462118840041471,KR,,,37,127.5,,0,0 27 | 2001:2e0::,2001:2e0:ffff:ffff:ffff:ffff:ffff:ffff,42540546473903453259102825273647693824,42540546553131615773367162867191644159,HK,,,22.25,114.167,,0,0 28 | 2001:2e8::,2001:2e8:ffff:ffff:ffff:ffff:ffff:ffff,42540547107728753373217526021999296512,42540547186956915887481863615543246847,JP,,,36,138,,0,0 29 | 2001:2f0::,2001:2f0:ffff:ffff:ffff:ffff:ffff:ffff,42540547741554053487332226770350899200,42540547820782216001596564363894849535,JP,,,36,138,,0,0 30 | 2001:2f8::,2001:2f8:ffff:ffff:ffff:ffff:ffff:ffff,42540548375379353601446927518702501888,42540548454607516115711265112246452223,JP,,,36,138,,0,0 31 | 2a02:cf40::,2a02:cf47:ffff:ffff:ffff:ffff:ffff:ffff,55842163946073893125912320592261939200,55842164579899193240027021340613541887,NO,,,62,10,,0,0 32 | 2a02:cf80::,2a02:cf87:ffff:ffff:ffff:ffff:ffff:ffff,55842169016676294038829926579074760704,55842169650501594152944627327426363391,IL,,,31.5,34.75,,0,0 33 | 2a02:cfc0::,2a02:cfc7:ffff:ffff:ffff:ffff:ffff:ffff,55842174087278694951747532565887582208,55842174721103995065862233314239184895,FR,,,46,2,,0,0 34 | 2a02:d000::,2a02:d007:ffff:ffff:ffff:ffff:ffff:ffff,55842179157881095864665138552700403712,55842179791706395978779839301052006399,CH,,,47,8,,0,0 35 | 2a02:d040::,2a02:d047:ffff:ffff:ffff:ffff:ffff:ffff,55842184228483496777582744539513225216,55842184862308796891697445287864827903,SE,,,62,15,,0,0 36 | 2a02:d080::,2a02:d087:ffff:ffff:ffff:ffff:ffff:ffff,55842189299085897690500350526326046720,55842189932911197804615051274677649407,BH,,,26,50.55,,0,0 37 | 2a02:d0c0::,2a02:d0c7:ffff:ffff:ffff:ffff:ffff:ffff,55842194369688298603417956513138868224,55842195003513598717532657261490470911,RU,,,60,100,,0,0 38 | 2a02:d100::,2a02:d107:ffff:ffff:ffff:ffff:ffff:ffff,55842199440290699516335562499951689728,55842200074115999630450263248303292415,PL,,,52,20,,0,0 39 | 2a02:d140::,2a02:d147:ffff:ffff:ffff:ffff:ffff:ffff,55842204510893100429253168486764511232,55842205144718400543367869235116113919,NO,,,62,10,,0,0 40 | 2a02:d180::,2a02:d187:ffff:ffff:ffff:ffff:ffff:ffff,55842209581495501342170774473577332736,55842210215320801456285475221928935423,DE,,,51,9,,0,0 41 | 2a02:d1c0::,2a02:d1c7:ffff:ffff:ffff:ffff:ffff:ffff,55842214652097902255088380460390154240,55842215285923202369203081208741756927,IT,,,42.8333,12.8333,,0,0 42 | 2a02:d200::,2a02:d207:ffff:ffff:ffff:ffff:ffff:ffff,55842219722700303168005986447202975744,55842220356525603282120687195554578431,FI,,,64,26,,0,0 43 | 2a02:d240::,2a02:d247:ffff:ffff:ffff:ffff:ffff:ffff,55842224793302704080923592434015797248,55842225427128004195038293182367399935,BY,,,53,28,,0,0 44 | 2a02:d280::,2a02:d287:ffff:ffff:ffff:ffff:ffff:ffff,55842229863905104993841198420828618752,55842230497730405107955899169180221439,CZ,,,49.75,15.5,,0,0 45 | 2a02:d2c0::,2a02:d2c7:ffff:ffff:ffff:ffff:ffff:ffff,55842234934507505906758804407641440256,55842235568332806020873505155993042943,IR,,,32,53,,0,0 46 | 2a02:d300::,2a02:d307:ffff:ffff:ffff:ffff:ffff:ffff,55842240005109906819676410394454261760,55842240638935206933791111142805864447,UA,,,49,32,,0,0 47 | 2a02:d340::,2a02:d347:ffff:ffff:ffff:ffff:ffff:ffff,55842245075712307732594016381267083264,55842245709537607846708717129618685951,FR,,,46,2,,0,0 48 | 2a02:d380::,2a02:d387:ffff:ffff:ffff:ffff:ffff:ffff,55842250146314708645511622368079904768,55842250780140008759626323116431507455,IR,,,32,53,,0,0 49 | 2a02:d3c0::,2a02:d3c7:ffff:ffff:ffff:ffff:ffff:ffff,55842255216917109558429228354892726272,55842255850742409672543929103244328959,GB,,,54,-2,,0,0 50 | 2a02:d400::,2a02:d407:ffff:ffff:ffff:ffff:ffff:ffff,55842260287519510471346834341705547776,55842260921344810585461535090057150463,HU,,,47,20,,0,0 51 | 2a02:d440::,2a02:d447:ffff:ffff:ffff:ffff:ffff:ffff,55842265358121911384264440328518369280,55842265991947211498379141076869971967,SE,,,62,15,,0,0 52 | 2a02:d480::,2a02:d487:ffff:ffff:ffff:ffff:ffff:ffff,55842270428724312297182046315331190784,55842271062549612411296747063682793471,DE,,,51,9,,0,0 53 | 2a02:d4c0::,2a02:d4c3:ffff:ffff:ffff:ffff:ffff:ffff,55842275499326713210099652302144012288,55842275816239363267157002676319813631,FI,,,64,26,,0,0 54 | 2a02:d4e0::,2a02:d4e3:ffff:ffff:ffff:ffff:ffff:ffff,55842278034627913666558455295550423040,55842278351540563723615805669726224383,DE,,,51,9,,0,0 55 | 2a02:d500::,2a02:d507:ffff:ffff:ffff:ffff:ffff:ffff,55842280569929114123017258288956833792,55842281203754414237131959037308436479,EU,,,47,8,,0,0 56 | 2a02:d540::,2a02:d547:ffff:ffff:ffff:ffff:ffff:ffff,55842285640531515035934864275769655296,55842286274356815150049565024121257983,GB,,,54,-2,,0,0 57 | 2a02:d580::,2a02:d587:ffff:ffff:ffff:ffff:ffff:ffff,55842290711133915948852470262582476800,55842291344959216062967171010934079487,FR,,,46,2,,0,0 58 | 2a02:d5c0::,2a02:d5c7:ffff:ffff:ffff:ffff:ffff:ffff,55842295781736316861770076249395298304,55842296415561616975884776997746900991,ES,,,40,-4,,0,0 59 | 2a02:d600::,2a02:d607:ffff:ffff:ffff:ffff:ffff:ffff,55842300852338717774687682236208119808,55842301486164017888802382984559722495,DE,,,51,9,,0,0 60 | 2a02:d640::,2a02:d647:ffff:ffff:ffff:ffff:ffff:ffff,55842305922941118687605288223020941312,55842306556766418801719988971372543999,FR,,,46,2,,0,0 61 | 2a02:d680::,2a02:d683:ffff:ffff:ffff:ffff:ffff:ffff,55842310993543519600522894209833762816,55842311310456169657580244584009564159,GB,,,54,-2,,0,0 62 | 2a02:d6a0::,2a02:d6a3:ffff:ffff:ffff:ffff:ffff:ffff,55842313528844720056981697203240173568,55842313845757370114039047577415974911,DE,,,51,9,,0,0 63 | 2a02:d6c0::,2a02:d6c7:ffff:ffff:ffff:ffff:ffff:ffff,55842316064145920513440500196646584320,55842316697971220627555200944998187007,BG,,,43,25,,0,0 64 | 2a02:d700::,2a02:d707:ffff:ffff:ffff:ffff:ffff:ffff,55842321134748321426358106183459405824,55842321768573621540472806931811008511,DE,,,51,9,,0,0 65 | 2a02:d740::,2a02:d747:ffff:ffff:ffff:ffff:ffff:ffff,55842326205350722339275712170272227328,55842326839176022453390412918623830015,CH,,,47,8,,0,0 66 | 2a02:d780::,2a02:d787:ffff:ffff:ffff:ffff:ffff:ffff,55842331275953123252193318157085048832,55842331909778423366308018905436651519,IR,,,32,53,,0,0 67 | 2a02:d7c0::,2a02:d7c7:ffff:ffff:ffff:ffff:ffff:ffff,55842336346555524165110924143897870336,55842336980380824279225624892249473023,FR,,,46,2,,0,0 68 | 2a02:d800::,2a02:d807:ffff:ffff:ffff:ffff:ffff:ffff,55842341417157925078028530130710691840,55842342050983225192143230879062294527,RO,,,46,25,,0,0 69 | 2a02:d840::,2a02:d847:ffff:ffff:ffff:ffff:ffff:ffff,55842346487760325990946136117523513344,55842347121585626105060836865875116031,RU,,,60,100,,0,0 70 | 2a02:d880::,2a02:d887:ffff:ffff:ffff:ffff:ffff:ffff,55842351558362726903863742104336334848,55842352192188027017978442852687937535,RU,,,60,100,,0,0 71 | 2a02:d8c0::,2a02:d8c7:ffff:ffff:ffff:ffff:ffff:ffff,55842356628965127816781348091149156352,55842357262790427930896048839500759039,NO,,,62,10,,0,0 72 | 2a02:d900::,2a02:d907:ffff:ffff:ffff:ffff:ffff:ffff,55842361699567528729698954077961977856,55842362333392828843813654826313580543,SE,,,62,15,,0,0 73 | 2a02:d940::,2a02:d947:ffff:ffff:ffff:ffff:ffff:ffff,55842366770169929642616560064774799360,55842367403995229756731260813126402047,BE,,,50.8333,4,,0,0 74 | 2a02:d980::,2a02:d987:ffff:ffff:ffff:ffff:ffff:ffff,55842371840772330555534166051587620864,55842372474597630669648866799939223551,TR,,,39,35,,0,0 75 | 2a02:d9c0::,2a02:d9c7:ffff:ffff:ffff:ffff:ffff:ffff,55842376911374731468451772038400442368,55842377545200031582566472786752045055,TR,,,39,35,,0,0 76 | 2a02:da00::,2a02:da07:ffff:ffff:ffff:ffff:ffff:ffff,55842381981977132381369378025213263872,55842382615802432495484078773564866559,DE,,,51,9,,0,0 77 | 2a02:da40::,2a02:da47:ffff:ffff:ffff:ffff:ffff:ffff,55842387052579533294286984012026085376,55842387686404833408401684760377688063,GB,,,54,-2,,0,0 78 | 2a02:da80::,2a02:da87:ffff:ffff:ffff:ffff:ffff:ffff,55842392123181934207204589998838906880,55842392757007234321319290747190509567,AT,,,47.3333,13.3333,,0,0 79 | 2a02:dac0::,2a02:dac7:ffff:ffff:ffff:ffff:ffff:ffff,55842397193784335120122195985651728384,55842397827609635234236896734003331071,RU,,,60,100,,0,0 80 | 2a02:db00::,2a02:db07:ffff:ffff:ffff:ffff:ffff:ffff,55842402264386736033039801972464549888,55842402898212036147154502720816152575,DE,,,51,9,,0,0 81 | 2a02:db40::,2a02:db47:ffff:ffff:ffff:ffff:ffff:ffff,55842407334989136945957407959277371392,55842407968814437060072108707628974079,RO,,,46,25,,0,0 82 | 2a02:db80::,2a02:db87:ffff:ffff:ffff:ffff:ffff:ffff,55842412405591537858875013946090192896,55842413039416837972989714694441795583,RU,,,60,100,,0,0 83 | 2a02:dbc0::,2a02:dbc7:ffff:ffff:ffff:ffff:ffff:ffff,55842417476193938771792619932903014400,55842418110019238885907320681254617087,RU,,,60,100,,0,0 84 | 2a02:dc00::,2a02:dc07:ffff:ffff:ffff:ffff:ffff:ffff,55842422546796339684710225919715835904,55842423180621639798824926668067438591,RU,,,60,100,,0,0 85 | 2a02:dc40::,2a02:dc47:ffff:ffff:ffff:ffff:ffff:ffff,55842427617398740597627831906528657408,55842428251224040711742532654880260095,TR,,,39,35,,0,0 86 | 2a02:dc80::,2a02:dc87:ffff:ffff:ffff:ffff:ffff:ffff,55842432688001141510545437893341478912,55842433321826441624660138641693081599,RU,,,60,100,,0,0 87 | 2a02:dcc0::,2a02:dcc7:ffff:ffff:ffff:ffff:ffff:ffff,55842437758603542423463043880154300416,55842438392428842537577744628505903103,UA,,,49,32,,0,0 88 | 2a02:dd00::,2a02:dd07:ffff:ffff:ffff:ffff:ffff:ffff,55842442829205943336380649866967121920,55842443463031243450495350615318724607,AL,,,41,20,,0,0 89 | 2a02:dd40::,2a02:dd47:ffff:ffff:ffff:ffff:ffff:ffff,55842447899808344249298255853779943424,55842448533633644363412956602131546111,GB,,,54,-2,,0,0 90 | 2a02:dd80::,2a02:dd87:ffff:ffff:ffff:ffff:ffff:ffff,55842452970410745162215861840592764928,55842453604236045276330562588944367615,SE,,,62,15,,0,0 91 | 2a02:ddc0::,2a02:ddc7:ffff:ffff:ffff:ffff:ffff:ffff,55842458041013146075133467827405586432,55842458674838446189248168575757189119,RU,,,60,100,,0,0 92 | 2a02:de00::,2a02:de07:ffff:ffff:ffff:ffff:ffff:ffff,55842463111615546988051073814218407936,55842463745440847102165774562570010623,RU,,,60,100,,0,0 93 | 2a02:de40::,2a02:de47:ffff:ffff:ffff:ffff:ffff:ffff,55842468182217947900968679801031229440,55842468816043248015083380549382832127,IL,,,31.5,34.75,,0,0 94 | 2a02:de80::,2a02:de87:ffff:ffff:ffff:ffff:ffff:ffff,55842473252820348813886285787844050944,55842473886645648928000986536195653631,RU,,,60,100,,0,0 95 | 2a02:dec0::,2a02:dec7:ffff:ffff:ffff:ffff:ffff:ffff,55842478323422749726803891774656872448,55842478957248049840918592523008475135,LB,,,33.8333,35.8333,,0,0 96 | 2a02:df00::,2a02:df07:ffff:ffff:ffff:ffff:ffff:ffff,55842483394025150639721497761469693952,55842484027850450753836198509821296639,IR,,,32,53,,0,0 97 | 2a02:df40::,2a02:df47:ffff:ffff:ffff:ffff:ffff:ffff,55842488464627551552639103748282515456,55842489098452851666753804496634118143,TR,,,39,35,,0,0 98 | 2a02:df80::,2a02:df87:ffff:ffff:ffff:ffff:ffff:ffff,55842493535229952465556709735095336960,55842494169055252579671410483446939647,GB,,,54,-2,,0,0 99 | 2a02:dfc0::,2a02:dfc7:ffff:ffff:ffff:ffff:ffff:ffff,55842498605832353378474315721908158464,55842499239657653492589016470259761151,IR,,,32,53,,0,0 100 | 2a02:e000::,2a02:e007:ffff:ffff:ffff:ffff:ffff:ffff,55842503676434754291391921708720979968,55842504310260054405506622457072582655,FR,,,46,2,,0,0 101 | 2a02:e040::,2a02:e047:ffff:ffff:ffff:ffff:ffff:ffff,55842508747037155204309527695533801472,55842509380862455318424228443885404159,NL,,,52.5,5.75,,0,0 102 | 2a02:e080::,2a02:e087:ffff:ffff:ffff:ffff:ffff:ffff,55842513817639556117227133682346622976,55842514451464856231341834430698225663,KW,,,29.3375,47.6581,,0,0 103 | 2a02:e0c0::,2a02:e0c7:ffff:ffff:ffff:ffff:ffff:ffff,55842518888241957030144739669159444480,55842519522067257144259440417511047167,CH,,,47,8,,0,0 104 | 2a02:e100::,2a02:e107:ffff:ffff:ffff:ffff:ffff:ffff,55842523958844357943062345655972265984,55842524592669658057177046404323868671,GB,,,54,-2,,0,0 105 | 2a02:e140::,2a02:e147:ffff:ffff:ffff:ffff:ffff:ffff,55842529029446758855979951642785087488,55842529663272058970094652391136690175,PL,,,52,20,,0,0 106 | 2a02:e180::,2a02:e187:ffff:ffff:ffff:ffff:ffff:ffff,55842534100049159768897557629597908992,55842534733874459883012258377949511679,GB,,,54,-2,,0,0 107 | 2a02:e1c0::,2a02:e1c7:ffff:ffff:ffff:ffff:ffff:ffff,55842539170651560681815163616410730496,55842539804476860795929864364762333183,NL,,,52.5,5.75,,0,0 108 | 2a02:e200::,2a02:e203:ffff:ffff:ffff:ffff:ffff:ffff,55842544241253961594732769603223552000,55842544558166611651790119977399353343,AT,,,47.3333,13.3333,,0,0 109 | 2a02:e220::,2a02:e223:ffff:ffff:ffff:ffff:ffff:ffff,55842546776555162051191572596629962752,55842547093467812108248922970805764095,SA,,,25,45,,0,0 110 | 2a02:e240::,2a02:e247:ffff:ffff:ffff:ffff:ffff:ffff,55842549311856362507650375590036373504,55842549945681662621765076338387976191,DE,,,51,9,,0,0 111 | 2a02:e280::,2a02:e287:ffff:ffff:ffff:ffff:ffff:ffff,55842554382458763420567981576849195008,55842555016284063534682682325200797695,DE,,,51,9,,0,0 112 | 2a02:e2c0::,2a02:e2c7:ffff:ffff:ffff:ffff:ffff:ffff,55842559453061164333485587563662016512,55842560086886464447600288312013619199,IT,,,42.8333,12.8333,,0,0 113 | 2a02:e300::,2a02:e307:ffff:ffff:ffff:ffff:ffff:ffff,55842564523663565246403193550474838016,55842565157488865360517894298826440703,BY,,,53,28,,0,0 114 | 2a02:e340::,2a02:e347:ffff:ffff:ffff:ffff:ffff:ffff,55842569594265966159320799537287659520,55842570228091266273435500285639262207,NO,,,62,10,,0,0 115 | 2a02:e380::,2a02:e387:ffff:ffff:ffff:ffff:ffff:ffff,55842574664868367072238405524100481024,55842575298693667186353106272452083711,IT,,,42.8333,12.8333,,0,0 116 | 2a02:e3c0::,2a02:e3c7:ffff:ffff:ffff:ffff:ffff:ffff,55842579735470767985156011510913302528,55842580369296068099270712259264905215,FR,,,46,2,,0,0 117 | 2a02:e400::,2a02:e407:ffff:ffff:ffff:ffff:ffff:ffff,55842584806073168898073617497726124032,55842585439898469012188318246077726719,SE,,,62,15,,0,0 118 | 2a02:e440::,2a02:e447:ffff:ffff:ffff:ffff:ffff:ffff,55842589876675569810991223484538945536,55842590510500869925105924232890548223,DE,,,51,9,,0,0 119 | 2a02:e480::,2a02:e487:ffff:ffff:ffff:ffff:ffff:ffff,55842594947277970723908829471351767040,55842595581103270838023530219703369727,RU,,,60,100,,0,0 120 | 2a02:e4c0::,2a02:e4c7:ffff:ffff:ffff:ffff:ffff:ffff,55842600017880371636826435458164588544,55842600651705671750941136206516191231,NL,,,52.5,5.75,,0,0 121 | 2a02:e500::,2a02:e507:ffff:ffff:ffff:ffff:ffff:ffff,55842605088482772549744041444977410048,55842605722308072663858742193329012735,FR,,,46,2,,0,0 122 | 2a02:e540::,2a02:e547:ffff:ffff:ffff:ffff:ffff:ffff,55842610159085173462661647431790231552,55842610792910473576776348180141834239,RS,,,44,21,,0,0 123 | 2a02:e580::,2a02:e587:ffff:ffff:ffff:ffff:ffff:ffff,55842615229687574375579253418603053056,55842615863512874489693954166954655743,NO,,,62,10,,0,0 124 | 2a02:e5c0::,2a02:e5c7:ffff:ffff:ffff:ffff:ffff:ffff,55842620300289975288496859405415874560,55842620934115275402611560153767477247,RU,,,60,100,,0,0 125 | 2a02:e600::,2a02:e603:ffff:ffff:ffff:ffff:ffff:ffff,55842625370892376201414465392228696064,55842625687805026258471815766404497407,FR,,,46,2,,0,0 126 | 2a02:e620::,2a02:e623:ffff:ffff:ffff:ffff:ffff:ffff,55842627906193576657873268385635106816,55842628223106226714930618759810908159,RU,,,60,100,,0,0 127 | 2a02:e640::,2a02:e647:ffff:ffff:ffff:ffff:ffff:ffff,55842630441494777114332071379041517568,55842631075320077228446772127393120255,FR,,,46,2,,0,0 128 | 2a02:e680::,2a02:e687:ffff:ffff:ffff:ffff:ffff:ffff,55842635512097178027249677365854339072,55842636145922478141364378114205941759,JO,,,31,36,,0,0 129 | 2a02:e6c0::,2a02:e6c7:ffff:ffff:ffff:ffff:ffff:ffff,55842640582699578940167283352667160576,55842641216524879054281984101018763263,RU,,,60,100,,0,0 130 | 2a02:e700::,2a02:e707:ffff:ffff:ffff:ffff:ffff:ffff,55842645653301979853084889339479982080,55842646287127279967199590087831584767,LY,,,25,17,,0,0 131 | 2a02:e740::,2a02:e747:ffff:ffff:ffff:ffff:ffff:ffff,55842650723904380766002495326292803584,55842651357729680880117196074644406271,DE,,,51,9,,0,0 132 | 2a02:e780::,2a02:e787:ffff:ffff:ffff:ffff:ffff:ffff,55842655794506781678920101313105625088,55842656428332081793034802061457227775,TR,,,39,35,,0,0 133 | 2a02:e7c0::,2a02:e7c7:ffff:ffff:ffff:ffff:ffff:ffff,55842660865109182591837707299918446592,55842661498934482705952408048270049279,PL,,,52,20,,0,0 134 | 2a02:e800::,2a02:e807:ffff:ffff:ffff:ffff:ffff:ffff,55842665935711583504755313286731268096,55842666569536883618870014035082870783,DE,,,51,9,,0,0 135 | 2a02:e840::,2a02:e847:ffff:ffff:ffff:ffff:ffff:ffff,55842671006313984417672919273544089600,55842671640139284531787620021895692287,RU,,,60,100,,0,0 136 | 2a02:e880::,2a02:e887:ffff:ffff:ffff:ffff:ffff:ffff,55842676076916385330590525260356911104,55842676710741685444705226008708513791,RU,,,60,100,,0,0 137 | 2a02:e900::,2a02:e907:ffff:ffff:ffff:ffff:ffff:ffff,55842686218121187156425737233982554112,55842686851946487270540437982334156799,IE,,,53,-8,,0,0 138 | 2a02:e940::,2a02:e947:ffff:ffff:ffff:ffff:ffff:ffff,55842691288723588069343343220795375616,55842691922548888183458043969146978303,RO,,,46,25,,0,0 139 | 2a02:e980::,2a02:e987:ffff:ffff:ffff:ffff:ffff:ffff,55842696359325988982260949207608197120,55842696993151289096375649955959799807,IL,,,31.5,34.75,,0,0 140 | 2a02:e9c0::,2a02:e9c7:ffff:ffff:ffff:ffff:ffff:ffff,55842701429928389895178555194421018624,55842702063753690009293255942772621311,SE,,,62,15,,0,0 141 | 2a02:ea00::,2a02:ea07:ffff:ffff:ffff:ffff:ffff:ffff,55842706500530790808096161181233840128,55842707134356090922210861929585442815,CH,,,47,8,,0,0 142 | 2a02:ea40::,2a02:ea47:ffff:ffff:ffff:ffff:ffff:ffff,55842711571133191721013767168046661632,55842712204958491835128467916398264319,GB,,,54,-2,,0,0 143 | 2a02:ea80::,2a02:ea87:ffff:ffff:ffff:ffff:ffff:ffff,55842716641735592633931373154859483136,55842717275560892748046073903211085823,PL,,,52,20,,0,0 144 | 2a02:eac0::,2a02:eac7:ffff:ffff:ffff:ffff:ffff:ffff,55842721712337993546848979141672304640,55842722346163293660963679890023907327,PL,,,52,20,,0,0 145 | 2a02:eb00::,2a02:eb07:ffff:ffff:ffff:ffff:ffff:ffff,55842726782940394459766585128485126144,55842727416765694573881285876836728831,RU,,,60,100,,0,0 146 | 2a02:eb40::,2a02:eb47:ffff:ffff:ffff:ffff:ffff:ffff,55842731853542795372684191115297947648,55842732487368095486798891863649550335,GB,,,54,-2,,0,0 147 | 2a02:eb80::,2a02:eb87:ffff:ffff:ffff:ffff:ffff:ffff,55842736924145196285601797102110769152,55842737557970496399716497850462371839,RU,,,60,100,,0,0 148 | 2a02:ebc0::,2a02:ebc7:ffff:ffff:ffff:ffff:ffff:ffff,55842741994747597198519403088923590656,55842742628572897312634103837275193343,FR,,,46,2,,0,0 149 | 2a02:ec00::,2a02:ec07:ffff:ffff:ffff:ffff:ffff:ffff,55842747065349998111437009075736412160,55842747699175298225551709824088014847,FR,,,46,2,,0,0 150 | 2a02:ec40::,2a02:ec47:ffff:ffff:ffff:ffff:ffff:ffff,55842752135952399024354615062549233664,55842752769777699138469315810900836351,RU,,,60,100,,0,0 151 | 2a02:ec80::,2a02:ec87:ffff:ffff:ffff:ffff:ffff:ffff,55842757206554799937272221049362055168,55842757840380100051386921797713657855,EU,,,47,8,,0,0 152 | 2a02:ecc0::,2a02:ecc7:ffff:ffff:ffff:ffff:ffff:ffff,55842762277157200850189827036174876672,55842762910982500964304527784526479359,AZ,,,40.5,47.5,,0,0 153 | 2a02:ed00::,2a02:ed07:ffff:ffff:ffff:ffff:ffff:ffff,55842767347759601763107433022987698176,55842767981584901877222133771339300863,NO,,,62,10,,0,0 154 | 2a02:ed40::,2a02:ed47:ffff:ffff:ffff:ffff:ffff:ffff,55842772418362002676025039009800519680,55842773052187302790139739758152122367,TR,,,39,35,,0,0 155 | 2a02:ed80::,2a02:ed87:ffff:ffff:ffff:ffff:ffff:ffff,55842777488964403588942644996613341184,55842778122789703703057345744964943871,DE,,,51,9,,0,0 156 | 2a02:edc0::,2a02:edc7:ffff:ffff:ffff:ffff:ffff:ffff,55842782559566804501860250983426162688,55842783193392104615974951731777765375,SA,,,25,45,,0,0 157 | 2a02:ee00::,2a02:ee07:ffff:ffff:ffff:ffff:ffff:ffff,55842787630169205414777856970238984192,55842788263994505528892557718590586879,UA,,,49,32,,0,0 158 | 2a02:ee40::,2a02:ee47:ffff:ffff:ffff:ffff:ffff:ffff,55842792700771606327695462957051805696,55842793334596906441810163705403408383,RU,,,60,100,,0,0 159 | 2a02:ee80::,2a02:ee87:ffff:ffff:ffff:ffff:ffff:ffff,55842797771374007240613068943864627200,55842798405199307354727769692216229887,NL,,,52.5,5.75,,0,0 160 | 2a02:eec0::,2a02:eec7:ffff:ffff:ffff:ffff:ffff:ffff,55842802841976408153530674930677448704,55842803475801708267645375679029051391,SE,,,62,15,,0,0 161 | 2a02:ef00::,2a02:ef07:ffff:ffff:ffff:ffff:ffff:ffff,55842807912578809066448280917490270208,55842808546404109180562981665841872895,RU,,,60,100,,0,0 162 | 2a02:ef40::,2a02:ef47:ffff:ffff:ffff:ffff:ffff:ffff,55842812983181209979365886904303091712,55842813617006510093480587652654694399,RU,,,60,100,,0,0 163 | 2a02:ef80::,2a02:ef87:ffff:ffff:ffff:ffff:ffff:ffff,55842818053783610892283492891115913216,55842818687608911006398193639467515903,TR,,,39,35,,0,0 164 | 2a02:efc0::,2a02:efc7:ffff:ffff:ffff:ffff:ffff:ffff,55842823124386011805201098877928734720,55842823758211311919315799626280337407,RU,,,60,100,,0,0 165 | 2a02:f000::,2a02:f007:ffff:ffff:ffff:ffff:ffff:ffff,55842828194988412718118704864741556224,55842828828813712832233405613093158911,CZ,,,49.75,15.5,,0,0 166 | 2a02:f040::,2a02:f047:ffff:ffff:ffff:ffff:ffff:ffff,55842833265590813631036310851554377728,55842833899416113745151011599905980415,BH,,,26,50.55,,0,0 167 | 2a02:f080::,2a02:f083:ffff:ffff:ffff:ffff:ffff:ffff,55842838336193214543953916838367199232,55842838653105864601011267212543000575,UA,,,49,32,,0,0 168 | 2a02:f0a0::,2a02:f0a3:ffff:ffff:ffff:ffff:ffff:ffff,55842840871494415000412719831773609984,55842841188407065057470070205949411327,GB,,,54,-2,,0,0 169 | 2a02:f0c0::,2a02:f0c7:ffff:ffff:ffff:ffff:ffff:ffff,55842843406795615456871522825180020736,55842844040620915570986223573531623423,JO,,,31,36,,0,0 170 | 2a02:f100::,2a02:f107:ffff:ffff:ffff:ffff:ffff:ffff,55842848477398016369789128811992842240,55842849111223316483903829560344444927,GB,,,54,-2,,0,0 171 | 2a02:f140::,2a02:f147:ffff:ffff:ffff:ffff:ffff:ffff,55842853548000417282706734798805663744,55842854181825717396821435547157266431,DE,,,51,9,,0,0 172 | 2a02:f180::,2a02:f187:ffff:ffff:ffff:ffff:ffff:ffff,55842858618602818195624340785618485248,55842859252428118309739041533970087935,FR,,,46,2,,0,0 173 | 2a02:f1c0::,2a02:f1c7:ffff:ffff:ffff:ffff:ffff:ffff,55842863689205219108541946772431306752,55842864323030519222656647520782909439,UA,,,49,32,,0,0 174 | 2a02:f200::,2a02:f207:ffff:ffff:ffff:ffff:ffff:ffff,55842868759807620021459552759244128256,55842869393632920135574253507595730943,DE,,,51,9,,0,0 175 | 2a02:f240::,2a02:f247:ffff:ffff:ffff:ffff:ffff:ffff,55842873830410020934377158746056949760,55842874464235321048491859494408552447,IR,,,32,53,,0,0 176 | 2a02:f280::,2a02:f287:ffff:ffff:ffff:ffff:ffff:ffff,55842878901012421847294764732869771264,55842879534837721961409465481221373951,FR,,,46,2,,0,0 177 | 2a02:f2c0::,2a02:f2c7:ffff:ffff:ffff:ffff:ffff:ffff,55842883971614822760212370719682592768,55842884605440122874327071468034195455,RU,,,60,100,,0,0 178 | 2a02:f300::,2a02:f307:ffff:ffff:ffff:ffff:ffff:ffff,55842889042217223673129976706495414272,55842889676042523787244677454847016959,NO,,,62,10,,0,0 179 | 2a02:f340::,2a02:f347:ffff:ffff:ffff:ffff:ffff:ffff,55842894112819624586047582693308235776,55842894746644924700162283441659838463,DE,,,51,9,,0,0 180 | 2a02:f380::,2a02:f387:ffff:ffff:ffff:ffff:ffff:ffff,55842899183422025498965188680121057280,55842899817247325613079889428472659967,GB,,,54,-2,,0,0 181 | 2a02:f3c0::,2a02:f3c7:ffff:ffff:ffff:ffff:ffff:ffff,55842904254024426411882794666933878784,55842904887849726525997495415285481471,PL,,,52,20,,0,0 182 | 2a02:f400::,2a02:f407:ffff:ffff:ffff:ffff:ffff:ffff,55842909324626827324800400653746700288,55842909958452127438915101402098302975,AE,,,24,54,,0,0 183 | 2a02:f440::,2a02:f447:ffff:ffff:ffff:ffff:ffff:ffff,55842914395229228237718006640559521792,55842915029054528351832707388911124479,GB,,,54,-2,,0,0 184 | 2a02:f480::,2a02:f487:ffff:ffff:ffff:ffff:ffff:ffff,55842919465831629150635612627372343296,55842920099656929264750313375723945983,NO,,,62,10,,0,0 185 | 2a02:f4c0::,2a02:f4c7:ffff:ffff:ffff:ffff:ffff:ffff,55842924536434030063553218614185164800,55842925170259330177667919362536767487,ES,,,40,-4,,0,0 186 | 2a02:f500::,2a02:f507:ffff:ffff:ffff:ffff:ffff:ffff,55842929607036430976470824600997986304,55842930240861731090585525349349588991,RU,,,60,100,,0,0 187 | 2a02:f540::,2a02:f543:ffff:ffff:ffff:ffff:ffff:ffff,55842934677638831889388430587810807808,55842934994551481946445780961986609151,GB,,,54,-2,,0,0 188 | 2a02:f560::,2a02:f563:ffff:ffff:ffff:ffff:ffff:ffff,55842937212940032345847233581217218560,55842937529852682402904583955393019903,RU,,,60,100,,0,0 189 | 2a02:f580::,2a02:f587:ffff:ffff:ffff:ffff:ffff:ffff,55842939748241232802306036574623629312,55842940382066532916420737322975231999,AM,,,40,45,,0,0 190 | 2a02:f5c0::,2a02:f5c7:ffff:ffff:ffff:ffff:ffff:ffff,55842944818843633715223642561436450816,55842945452668933829338343309788053503,NL,,,52.5,5.75,,0,0 191 | 2a02:f600::,2a02:f607:ffff:ffff:ffff:ffff:ffff:ffff,55842949889446034628141248548249272320,55842950523271334742255949296600875007,NL,,,52.5,5.75,,0,0 192 | 2a02:f640::,2a02:f647:ffff:ffff:ffff:ffff:ffff:ffff,55842954960048435541058854535062093824,55842955593873735655173555283413696511,NL,,,52.5,5.75,,0,0 193 | 2a02:f680::,2a02:f687:ffff:ffff:ffff:ffff:ffff:ffff,55842960030650836453976460521874915328,55842960664476136568091161270226518015,RU,,,60,100,,0,0 194 | 2a02:f6c0::,2a02:f6c7:ffff:ffff:ffff:ffff:ffff:ffff,55842965101253237366894066508687736832,55842965735078537481008767257039339519,RU,,,60,100,,0,0 195 | 2a02:f700::,2a02:f707:ffff:ffff:ffff:ffff:ffff:ffff,55842970171855638279811672495500558336,55842970805680938393926373243852161023,LB,,,33.8333,35.8333,,0,0 196 | 2a02:f740::,2a02:f747:ffff:ffff:ffff:ffff:ffff:ffff,55842975242458039192729278482313379840,55842975876283339306843979230664982527,PL,,,52,20,,0,0 197 | 2a02:f780::,2a02:f787:ffff:ffff:ffff:ffff:ffff:ffff,55842980313060440105646884469126201344,55842980946885740219761585217477804031,SE,,,62,15,,0,0 198 | 2a02:f7c0::,2a02:f7c7:ffff:ffff:ffff:ffff:ffff:ffff,55842985383662841018564490455939022848,55842986017488141132679191204290625535,PL,,,52,20,,0,0 199 | 2a02:f800::,2a02:f807:ffff:ffff:ffff:ffff:ffff:ffff,55842990454265241931482096442751844352,55842991088090542045596797191103447039,RU,,,60,100,,0,0 200 | 2a02:f840::,2a02:f847:ffff:ffff:ffff:ffff:ffff:ffff,55842995524867642844399702429564665856,55842996158692942958514403177916268543,NL,,,52.5,5.75,,0,0 201 | 2a02:f880::,2a02:f887:ffff:ffff:ffff:ffff:ffff:ffff,55843000595470043757317308416377487360,55843001229295343871432009164729090047,DE,,,51,9,,0,0 202 | 2a02:f8c0::,2a02:f8c7:ffff:ffff:ffff:ffff:ffff:ffff,55843005666072444670234914403190308864,55843006299897744784349615151541911551,PL,,,52,20,,0,0 203 | 2a02:f900::,2a02:f907:ffff:ffff:ffff:ffff:ffff:ffff,55843010736674845583152520390003130368,55843011370500145697267221138354733055,IR,,,32,53,,0,0 204 | 2a02:f940::,2a02:f947:ffff:ffff:ffff:ffff:ffff:ffff,55843015807277246496070126376815951872,55843016441102546610184827125167554559,HU,,,47,20,,0,0 205 | 2a02:f980::,2a02:f987:ffff:ffff:ffff:ffff:ffff:ffff,55843020877879647408987732363628773376,55843021511704947523102433111980376063,GB,,,54,-2,,0,0 206 | 2a02:f9c0::,2a02:f9c7:ffff:ffff:ffff:ffff:ffff:ffff,55843025948482048321905338350441594880,55843026582307348436020039098793197567,GB,,,54,-2,,0,0 207 | 2a02:fa00::,2a02:fa07:ffff:ffff:ffff:ffff:ffff:ffff,55843031019084449234822944337254416384,55843031652909749348937645085606019071,SA,,,25,45,,0,0 208 | 2a02:fa40::,2a02:fa47:ffff:ffff:ffff:ffff:ffff:ffff,55843036089686850147740550324067237888,55843036723512150261855251072418840575,TR,,,39,35,,0,0 209 | 2a02:fa80::,2a02:fa87:ffff:ffff:ffff:ffff:ffff:ffff,55843041160289251060658156310880059392,55843041794114551174772857059231662079,DE,,,51,9,,0,0 210 | 2a02:fac0::,2a02:fac7:ffff:ffff:ffff:ffff:ffff:ffff,55843046230891651973575762297692880896,55843046864716952087690463046044483583,PL,,,52,20,,0,0 211 | 2a02:fb00::,2a02:fb07:ffff:ffff:ffff:ffff:ffff:ffff,55843051301494052886493368284505702400,55843051935319353000608069032857305087,DE,,,51,9,,0,0 212 | 2a02:fb40::,2a02:fb47:ffff:ffff:ffff:ffff:ffff:ffff,55843056372096453799410974271318523904,55843057005921753913525675019670126591,GB,,,54,-2,,0,0 213 | 2a02:fb80::,2a02:fb87:ffff:ffff:ffff:ffff:ffff:ffff,55843061442698854712328580258131345408,55843062076524154826443281006482948095,IT,,,42.8333,12.8333,,0,0 214 | 2a02:fbc0::,2a02:fbc7:ffff:ffff:ffff:ffff:ffff:ffff,55843066513301255625246186244944166912,55843067147126555739360886993295769599,PL,,,52,20,,0,0 215 | 2a02:fc00::,2a02:fc07:ffff:ffff:ffff:ffff:ffff:ffff,55843071583903656538163792231756988416,55843072217728956652278492980108591103,SE,,,62,15,,0,0 216 | 2a02:fc40::,2a02:fc47:ffff:ffff:ffff:ffff:ffff:ffff,55843076654506057451081398218569809920,55843077288331357565196098966921412607,DK,,,56,10,,0,0 217 | 2a02:fc80::,2a02:fc87:ffff:ffff:ffff:ffff:ffff:ffff,55843081725108458363999004205382631424,55843082358933758478113704953734234111,NO,,,62,10,,0,0 218 | 2a02:fcc0::,2a02:fcc7:ffff:ffff:ffff:ffff:ffff:ffff,55843086795710859276916610192195452928,55843087429536159391031310940547055615,GB,,,54,-2,,0,0 219 | 2a02:fd00::,2a02:fd07:ffff:ffff:ffff:ffff:ffff:ffff,55843091866313260189834216179008274432,55843092500138560303948916927359877119,DE,,,51,9,,0,0 220 | 2a02:fd40::,2a02:fd47:ffff:ffff:ffff:ffff:ffff:ffff,55843096936915661102751822165821095936,55843097570740961216866522914172698623,IT,,,42.8333,12.8333,,0,0 221 | 2a02:fd80::,2a02:fd87:ffff:ffff:ffff:ffff:ffff:ffff,55843102007518062015669428152633917440,55843102641343362129784128900985520127,DK,,,56,10,,0,0 222 | 2a02:fdc0::,2a02:fdc7:ffff:ffff:ffff:ffff:ffff:ffff,55843107078120462928587034139446738944,55843107711945763042701734887798341631,AT,,,47.3333,13.3333,,0,0 223 | 2a02:fe00::,2a02:fe07:ffff:ffff:ffff:ffff:ffff:ffff,55843112148722863841504640126259560448,55843112782548163955619340874611163135,NL,,,52.5,5.75,,0,0 224 | 2a02:fe40::,2a02:fe47:ffff:ffff:ffff:ffff:ffff:ffff,55843117219325264754422246113072381952,55843117853150564868536946861423984639,GB,,,54,-2,,0,0 225 | 2a02:fe80::,2a02:fe87:ffff:ffff:ffff:ffff:ffff:ffff,55843122289927665667339852099885203456,55843122923752965781454552848236806143,IT,,,42.8333,12.8333,,0,0 226 | 2a02:fec0::,2a02:fec7:ffff:ffff:ffff:ffff:ffff:ffff,55843127360530066580257458086698024960,55843127994355366694372158835049627647,GB,,,54,-2,,0,0 227 | 2a02:ff00::,2a02:ff07:ffff:ffff:ffff:ffff:ffff:ffff,55843132431132467493175064073510846464,55843133064957767607289764821862449151,IT,,,42.8333,12.8333,,0,0 228 | 2a02:ff40::,2a02:ff47:ffff:ffff:ffff:ffff:ffff:ffff,55843137501734868406092670060323667968,55843138135560168520207370808675270655,IM,,,54.23,-4.57,,0,0 229 | 2a02:ff80::,2a02:ff87:ffff:ffff:ffff:ffff:ffff:ffff,55843142572337269319010276047136489472,55843143206162569433124976795488092159,DE,,,51,9,,0,0 230 | 2a02:ffc0::,2a02:ffc7:ffff:ffff:ffff:ffff:ffff:ffff,55843147642939670231927882033949310976,55843148276764970346042582782300913663,GI,,,36.1833,-5.3667,,0,0 231 | -------------------------------------------------------------------------------- /src/test/resources/GeoIP/GeoLiteCityv6.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxmind/geoip-api-java/0ed8a38981512667533d47204486aae0278a1bc8/src/test/resources/GeoIP/GeoLiteCityv6.dat --------------------------------------------------------------------------------