nodejs client init
This commit is contained in:
parent
72ca42f54f
commit
0e498e27f8
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* ip2region client for nodejs
|
||||||
|
*
|
||||||
|
* project: https://github.com/lionsoul2016/ip2region
|
||||||
|
*
|
||||||
|
* @author dongyado<dongyado@gmail.com>
|
||||||
|
* */
|
||||||
|
|
||||||
|
var ip2r = {};
|
||||||
|
ip2r.db_file = null;
|
||||||
|
|
||||||
|
|
||||||
|
exports.setDbFile = function(path)
|
||||||
|
{
|
||||||
|
ip2r.db_file = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.getDbFile = function(path)
|
||||||
|
{
|
||||||
|
return ip2r.db_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.binarySearch = function(ip)
|
||||||
|
{
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.btreeSearch = function(ip)
|
||||||
|
{
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "ip2region",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "ip database ",
|
||||||
|
"main": "ip2region.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/lionsoul2016/ip2region"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"ip2region",
|
||||||
|
"ip",
|
||||||
|
"region"
|
||||||
|
],
|
||||||
|
"author": "dongyado",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/lionsoul2016/ip2region/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/lionsoul2016/ip2region"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* test program
|
||||||
|
* */
|
||||||
|
|
||||||
|
var ip2r = require('./ip2region');
|
||||||
|
|
||||||
|
ip2r.setDbFile('./ip2region.db');
|
||||||
|
|
||||||
|
console.log(ip2r.getDbFile());
|
||||||
|
console.log(ip2r.binarySearch("12321231"));
|
||||||
Loading…
Reference in New Issue