New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

maxmind

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maxmind - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

33

lib/lookup_service.js

@@ -582,2 +582,33 @@

// GeoIP Organization and ISP Edition methods
module.exports.getOrganization = function(ipnum) {
if (typeof ipnum === "string")
ipnum = this.ip2Long(ipnum);
var seekCountry,
recordPointer,
recordBuf,
position = 0;
seekCountry = this.seekCountry(ipnum);
if (seekCountry == databaseSegment)
return null;
recordPointer = seekCountry + (2 * recordLength - 1) * databaseSegment;
if ((dboptions & GEOIP_MEMORY_CACHE) != 0) {
recordBuf = new DynBuffer(dbbuffer, recordPointer, Math.min(dbbuffer.length - recordPointer, MAX_ORG_RECORD_LENGTH));
} else {
//read from disk
recordBuf = new DynBuffer(new Buffer(MAX_ORG_RECORD_LENGTH), 0, MAX_ORG_RECORD_LENGTH);
file.seek(recordPointer);
file.readFully(recordBuf.source);
}
while (recordBuf.at(++position) != 0x00);
return recordBuf.toString('utf8', 0, position);
};
module.exports.uninit = function() {

@@ -595,2 +626,2 @@ this.databaseInfo = null;

return true;
};
};

9

package.json
{
"name": "maxmind",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://github.com/runk/node-maxmind",
"description": "IP lookup using Maxmind databases",
"keywords": ["maxmind", "geo", "geobase", "geo lookup", "ip base", "geocode", "timezone"],
"keywords": ["maxmind", "geo", "geobase", "geo lookup", "ip base", "geocode", "timezone", "asn"],
"author": "Shirokov Dmitry <deadrunk@gmail.com>",
"dependencies": {
"dependencies": {},
"devDependencies": {
"mocha": ">= 1.10.0"
},

@@ -11,0 +12,0 @@ "repository": {

@@ -23,2 +23,3 @@

- Timezone lookup by IP
- Autonomous System Numbers (ASN) lookup

@@ -45,2 +46,10 @@ ## Usage

Autonomous System Numbers (ASN) lookup
```js
var maxmind = require('maxmind');
maxmind.init('/path/to/GeoIPASNum.dat');
console.log(maxmind.getOrganization("66.6.44.4"));
```
## Caching

@@ -47,0 +56,0 @@

@@ -23,3 +23,3 @@

});
})
});
});
});

@@ -9,5 +9,6 @@

const GEO_CITY = __dirname + '/dbs/GeoLiteCity.dat';
const GEO_CITY = __dirname + '/dbs/GeoLiteCity.dat';
const GEO_CITY_FULL = __dirname + '/dbs/GeoIPCity_FULL.dat';
const GEO_COUNTRY = __dirname + '/dbs/GeoIP.dat';
const GEO_COUNTRY = __dirname + '/dbs/GeoIP.dat';
const GEO_ASN = __dirname + '/dbs/GeoIPASNum.dat';

@@ -149,2 +150,15 @@ describe('lib/lookup_service', function() {

});
describe('#getOrg', function() {
it('should init with country db', function() {
assert.equal(ls.init(GEO_ASN), true);
assert.equal(ls.inited, true);
});
it('should return ISP by ip', function() {
assert.equal(ls.getOrganization('109.60.171.33'), 'AS47241 CJSC "Ivtelecom"')
assert.equal(ls.getOrganization('64.4.4.4'), 'AS8075 Microsoft Corp')
assert.equal(ls.getOrganization('210.250.100.200'), 'AS2527 So-net Entertainment Corporation')
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc