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.
bash setup-config.sh
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'
First, export your license key, for staging/prod we have a comercial license. For dev, you can get a free key key optained through https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en
export MAXMIND_LICENSE='your secret license'
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
To turn on ACL and SSL set up, copy sec-test
to sec
:
cp -R sec-test sec
Set access rules in sec/acl.json
Access is logged to sec/acl.log.
To use SSL in example.js
, uncomment everything related to SSL: https://github.com/bitfinexcom/bfx-util-net-js/blob/8d07c144f3a4135db0d4c7bc51297ffc06e358f9/example.js#L16.L24
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)
})