IP address for testing MaxMind GeoIP DB

谁说我不能喝 提交于 2020-01-03 14:27:08

问题


I'm experimenting with the MaxMind GeoIP (lite) DB.

Part of this is trying to see if I can make solid unittests.

For unittests I'd need to have some IP addresses I can rely on sending the same information always.

Most IP addresses will move around, and I'm assuming they're even more fluid in a GeoIP database, but are there some IP addresses I can reasonably rely on (for whatever reason)?


回答1:


Martijn,

You can use the Pingdom probe servers IP address as reference. It is physical server running 24x7 and it is rarely reallocated to other locations unless required by data center.

https://www.pingdom.com/rss/probe_servers.xml




回答2:


You could also use a test database from the API unit tests. These are small enough to just include in your repo.




回答3:


Approach 1: If the point is to test how your code behaves when Maxmind reports that an IP address is in a particular country or whatever, stub the Maxmind library method to return the answer you need for each test. I have used Maxmind and this approach was all I ever needed.

Approach 2: Pick a hostname which you expect to be in the country you need (say whitehouse.gov), look up its IP address each time you run the test, and use that.



来源:https://stackoverflow.com/questions/23610142/ip-address-for-testing-maxmind-geoip-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!