GithubHelp home page GithubHelp logo

bfx-util-net-js's Introduction

Build Status

bfx-util-net

Setup

The project inherits code from a base repository.

The base / root project is: https://github.com/bitfinexcom/bfx-util-js

Setup

Set upstream

git remote add upstream https://github.com/bitfinexcom/bfx-util-js

Changes should go through the base project and merged from upstream, if applicable.

Configuration

bash setup-config.sh

Grapes

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'

Update Geo/ASN data

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

Periodic Updates for Geo/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.

Boot worker

node worker.js --env=development --wtype=wrk-util-net-api --apiPort 8721

SSL / ACL

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

Grenache API

action: 'getIpInfo'

  • 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."
    }
  }
]

action: 'getIpAsn'

  • 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.' } ]

action: 'getReverseDns'

  • 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' ] ]

action: 'getIpGeo'

  • 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 } ]

action: 'getIpGeoBatch'

  • 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 } ]

Example

  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)
  })

bfx-util-net-js's People

Contributors

davide-scola avatar face avatar prdn avatar quadramadery avatar robertkowalski avatar vigan-abd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.