npm install iparea
var ipArea = new (require('iparea'))();
1 timeout option, default 1000ms.
var ipArea = new (require('iparea'))({timeout: 1000});
```js
2 url option, using sina API proxy.<br/>
default: http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=
```js
var ipArea = new (require('iparea'))({url:'http://127.0.0.1:52000/iplookup/iplookup.php?format=json&ip=', timeout: 2000});
ipArea.getIPArea('127.0.0.1',function(err, data){
console.log(data);
});
inputs
0.0.0.0
127.0.0.1
192.168.1.1
183.129.210.50
66.104.77.20
results
未识别
本地
局域网
浙江
美国
ipArea.getIPInfo('127.0.0.1',function(err, data){
console.log(data);
});
inputs
0.0.0.0
127.0.0.1
192.168.1.1
183.129.210.50
66.104.77.20
results
-2
{ ret: -1, ip: '127.0.0.1' }
{ ret: -1, ip: '192.168.1.1' }
{ ret: 1,
start: -1,
end: -1,
country: '美国',
province: '',
city: '',
district: '',
isp: '',
type: '',
desc: ''
}
{ ret: 1,
start: -1,
end: -1,
country: '**',
province: '浙江',
city: '杭州',
district: '',
isp: '',
type: '',
desc: ''
}
Add method: getIPInfo.
Add url option, using sina API proxy.
Add timeout option; Change method-name: getIPAdrea to getIPArea.
Make all return data type to be string.
1 Add return error param; 2 improve http deal.