Skip to content

[technical-test] Gathering info for a given IP or domain name

License

Notifications You must be signed in to change notification settings

jgburet/whosthat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Who's that?

Gather info for a given IP or domain name.

TL;DR

docker-compose up
curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{ "query": "{ newDnLookup(dn: "github.com", methods: [echo]) }" }' \
  http://0.0.0.0:4000

... or http://0.0.0.0:4000

Usage

Using docker

Requirements

  • docker 17.12.0+
  • docker-compose
docker-compose up

Adjust the scale:

docker-compose up --scale worker-gather-information=4 -d

Not using docker

Requirements

  • Node 10.14.1
  • yarn 1.12
  • redis 5.0.2
cd services/service-gateway && yarn start
cd services/worker-gather-information && yarn start

How it works

The service-gateway creates tasks into a redis server. Each lookup method has its own queue.
The instances of worker-gather-information consumes those tasks, according to their configuration. Meaning, we can spawn new instances that will only deal with certain queues.

Defining new methods is quite simple:

  • create a new class and its handler in worker-gather-information/src/consumers/
  • whitelist the method in service-gateway/src/lookup-methods.ts

Project structure

This is a monorepo. Each directory under services/ is an independent part of the application we are building.

TODO

  • For now, the lookup methods available are hard coded, and their respective Task classes (cf service-gateway) are generated from that. It would be cool 😎 to manage them dynamically, like, updating them according to a list broadcast-ed by the workers alive.
  • Have some fun:
    • look for dbs/websites/whatever-scrapper;
    • create some kind of subscription service to get ping-ed with reports;
  • Tests. Sorry, too much back and forth for now, did not have time to do that 😢
    To do it correctly, I think we should mock the redis connection or the Queue class from package bee-queue.

Functionalities & examples

# available methods:
echo
geoIp
rdap
whois
curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{ "query": "{ newDnLookup(dn: "github.com", methods: [echo, geoIp]) }" }' \
  http://0.0.0.0:4000
curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{ "query": "{ newIpLookup(ip: "192.30.255.112", methods: [geoIp]) }" }' \
  http://0.0.0.0:4000

About

[technical-test] Gathering info for a given IP or domain name

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published