runk / node-maxmind

Maxmind GEO Lookup
MIT License
606 stars 62 forks source link

When using ISP, ASN and/or NetSpeed together data is missing #18

Closed cmelendez closed 10 years ago

cmelendez commented 10 years ago

Hello,

It's actually not possible to use more than one db that needs the getOrganization() method because the last one to be loaded "eats" data from the others.

Example:

maxmind = require('maxmind')
maxmind.init(['IP.dat', 'NetSpeed.dat', 'ASN.dat', 'ISP.dat'])
maxmind.getCountry(IP_ADDRESS) -> returns correct object
maxmind.getOrganization(IP_ADDRESS) -> returns ISP name when should be able to retrieve netspeed info, ASN and ISP name

Even when you create new instances of the module you get the exact same behavior

Example:

maxmind = require('maxmind')
maxmind_netspeed = require('maxmind')
maxmind_asn = require('maxmind')
maxmind_isp = require('maxmind')
maxmind.init(['IP.dat'])
maxmind_netspeed.init(['NetSpeed.dat'])
maxmind_asn.init(['ASN.dat'])
maxmind_isp.init(['ISP.dat'])

maxmind.getCountry(IP_ADDRESS) -> returns correct object
maxmind_netspeed.getOrganization(IP_ADDRESS) -> returns ISP name when should be able to retrieve netspeed info
maxmind_asn.getOrganization(IP_ADDRESS) -> returns ISP name when should be able to retrieve ASN info
maxmind_isp.getOrganization(IP_ADDRESS) -> returns ISP name

Tried enabling/disabling cache but got the same results.

Cheers.

runk commented 10 years ago

Thanks for feedback.

Just added a getNetSpeed method for NetSpeed database.

It's interesting that getOrganization method can be used for a range of different databases. What do you reckon would be the best approach here? Split it to separate methods for net speed (done), asn, isp, registrar etc or return an array with information from corresponding databases?

I like specialised methods better.

cmelendez commented 10 years ago

Wonderful, thank you @runk !

IMHO separated methods for each type looks cleaner and might be a better option for your existing user base if you consider backwards compatibility.

runk commented 10 years ago

Done, please check README file