turbobytes / geoipdb

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

Implement LookupAsn #1

Closed coolparadox closed 7 years ago

coolparadox commented 7 years ago

The first task for warming up this project is to implement function LookupAsn to be used as a direct replacement of getasn in cnc.go.

Suggested interface:

func LookupAsn(ip string) (asn, asnname string, error)

For now it's not required that it handles lookups differently than getasn does; we'll add specific issues for improvement later.

coolparadox commented 7 years ago

Peeking around getasn I see it requires previously (geoip) and by demand (cymru's dns) initialized handlers. Ipinfo by itself is an external service.

I plan transporting code and create simple test cases related to these specific lookups into the library.

Moreover, the way I see our geoipdb library will require initialization of a handler by clients prior to usage. Features like LookupAsn would then be accessible handler's methods.

sajal commented 7 years ago

Agree. I am in favour of clients explicitly initializing geoip. How about doing the geoip initialization during New() ? Also I think the convention is for New to be called NewHandler . Especially if we plan to have other type of exported top level things.

coolparadox commented 7 years ago

Agreed.

sajal commented 7 years ago

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

Created #4 with this request.