turbobytes / geoipdb

GeoIP related related helper functions for TurboBytes stack
MIT License
0 stars 2 forks source link

Replace www.turbobytes.com IP by a known static address in tests #4

Closed coolparadox closed 7 years ago

coolparadox commented 7 years ago

(Copy of original comment by @sajal )

re: https://github.com/turbobytes/geoipdb/blob/bbf39598be903a3d6553f6ed22846ae1fd950739/geoipdb_test.go

I suggest using a well known IP address (like 8.8.8.8) . It is is highly unlikely that it will move across ASNs in the foreseeable future. Using www.turbobytes.com is not that ideal because if/when we move hosting provider it will break the test. Also we plan to host the site on CDN, once we do that the IP from LookupIP will be very inconsistent.

coolparadox commented 7 years ago

Curiously IP 8.8.8.8 is reported to be part of distinct ASNs according to who is queried:

 $ go test -v
=== RUN   TestInitIp
--- PASS: TestInitIp (0.00s)
    geoipdb_test.go:44: using ip '8.8.8.8' for tests
=== RUN   TestCreateHandler
--- PASS: TestCreateHandler (0.01s)
=== RUN   TestLibGeoipLookup
--- PASS: TestLibGeoipLookup (0.00s)
    geoipdb_test.go:63: libgeoip results for 8.8.8.8: AS15169 Google Inc.
=== RUN   TestIpInfoLookup
--- PASS: TestIpInfoLookup (0.39s)
    geoipdb_test.go:73: ipinfo.io results for 8.8.8.8: AS3356 Level 3 Communications, Inc.
=== RUN   TestCymruDnsLookup
--- PASS: TestCymruDnsLookup (0.18s)
    geoipdb_test.go:82: CymruDnsLookup results for AS15169: GOOGLE - Google Inc., US
    geoipdb_test.go:89: CymruDnsLookup results for AS3356: LEVEL3 - Level 3 Communications, Inc., US
=== RUN   TestLookupAsn
--- PASS: TestLookupAsn (0.00s)
    geoipdb_test.go:98: LookupAsn results: AS15169 Google Inc.
PASS
ok      github.com/turbobytes/geoipdb   0.583s

Interesting; I'll investigate it a bit

sajal commented 7 years ago

The issue is with ipinfo.org database: ipinfo.io/8.8.8.8

AS3356 owns the parent subnet 8.0.0.0/8, but AS15169 announces 8.8.8.0/24 so correct answer should have been AS15169 http://bgp.he.net/ip/8.8.8.8

coolparadox commented 7 years ago

Good thing libgeoip is preferred over ipinfo in LookupAsn implementation.