The project inherits code from a base repository.
The base / root project is: https://github.com/bitfinexcom/bfx-util-js
git remote add upstream https://github.com/bitfinexcom/bfx-util-js
Changes should go through the base project and merged from upstream, if applicable.
cp config/common.json.example config/common.json
cp config/facs/grc.config.json.example config/facs/grc.config.json
cp config/net.util.json.example config/net.util.json
Run two Grapes:
grape --dp 20001 --aph 30001 --bn '127.0.0.1:20002'
grape --dp 20002 --aph 40001 --bn '127.0.0.1:20001'
npm run update-geo-data
npm run update-asn-data
Update geo-data at midnight every three days with cron. Update geo-data at 23:00 every three days with cron.
Let's assume the path to the deployed service is /opt/var/bfx-util-net
.
0 0 */3 * * cd /opt/var/bfx-util-net && /usr/bin/npm run update-geo-data
0 23 */3 * * cd /opt/var/bfx-util-net && /usr/bin/npm run update-asn-data
The IP databases are watching the database files for changes and will load the updated data into the RAM as soon as the data changes.
node worker.js --env=development --wtype=wrk-util-net-api --apiPort 8721
args
: <Array>0
: <String> IP to lookup
Response:
- <Array>
- 0 <String> Ip that was looked up
- 1 <Object> Result: geo, dns
Example Response:
[
"8.8.8.8",
{
"geo": {
"range": [
134744064,
134744319
],
"country": "US",
"region": "CA",
"city": "Mountain View",
"ll": [
37.386,
-122.0838
],
"metro": 807,
"zip": 94035
},
"dns": [
"google-public-dns-a.google.com"
],
"asn": {
"autonomous_system_number": 15169,
"autonomous_system_organization": "Google Inc."
}
}
]
args
: <Array>0
: <String> IP to lookup
Response:
- <Array>
- 0 <String> Ip that was looked up
- 1 <Object> ASN information
Example Response:
[ '8.8.8.8',
{ autonomous_system_number: 15169,
autonomous_system_organization: 'Google Inc.' } ]
args
: <Array>0
: <String> IP to lookup
Response:
- <Array>
- 0 <String> Ip that was looked up
- 1 <Array> hostnames
Example Response:
[ '8.8.8.8', [ 'google-public-dns-a.google.com' ] ]
args
: <Array>0
: <String> IP to lookup
Response:
- <Array>
- 0 <String> Ip that was looked up
- 1 <Object> Result: range, country, region, city, ll, metro, zip
Example Response:
[ '53.1.34.21',
{ range: [ 889192448, 897238054 ],
country: 'DE',
region: '',
city: '',
ll: [ 51.2993, 9.491 ],
metro: 0,
zip: 0 } ]
args
: <Array>0
: <Array> IPs to lookup
Response:
- <Array>
- 0 <String> Ip that was looked up
- 1 <Array> Result array
Example Response:
[ '53.1.34.21',
{ range: [ 889192448, 897238054 ],
country: 'DE',
region: '',
city: '',
ll: [ 51.2993, 9.491 ],
metro: 0,
zip: 0 } ]
const query = {
action: 'geoIp',
'args': [ '53.1.34.21' ]
}
peer.request('rest:net:util', query, { timeout: 10000 }, (err, data) => {
if (err) {
console.error(err)
process.exit(1)
}
console.log(data)
})