forked from wigy-opensource-developer/hydra-crawler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor around promises so it can be used in other apps
- Loading branch information
Showing
5 changed files
with
252 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# Crawler | ||
|
||
Network scanning tool for Ark (v2) | ||
Network scanning tool for ARK. | ||
|
||
This currently works for ARK v1 and will be updated to work with V2's API structure shortly. | ||
|
||
## Installation | ||
|
||
`npm install` | ||
|
||
## Usage | ||
|
||
`node app.js http://<ip>:<port>` | ||
`npm start http://<ip>:<port>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
const Crawler = require('./src/crawler') | ||
const { URL } = require('url') | ||
const { forEach, keys } = require('lodash') | ||
|
||
const crawler = new Crawler() | ||
const args = process.argv.slice(2) | ||
|
||
const report = (crawler) => { | ||
let blockStats = {} | ||
|
||
forEach(crawler.heights, (item) => { | ||
if (blockStats[item.height]) { | ||
blockStats[item.height].count += 1 | ||
blockStats[item.height].ids[item.id] += 1 | ||
} else { | ||
blockStats[item.height] = {} | ||
blockStats[item.height].count = 1 | ||
blockStats[item.height].ids = {} | ||
blockStats[item.height].ids[item.id] = 1 | ||
} | ||
}) | ||
|
||
console.log(`===========================================`) | ||
console.log(`Total nodes visited: ${keys(crawler.nodes).length}`) | ||
console.log(`Total nodes online: ${crawler.heights.length}`) | ||
console.log(`------------------------------------------`) | ||
console.log(`Block stats:`) | ||
console.log(blockStats) | ||
console.log(`------------------------------------------`) | ||
console.log(`Finished scanning in ${new Date() - crawler.startTime}ms`) | ||
process.exit(0) | ||
} | ||
|
||
let node = {ip: '167.99.243.111', port: 4003} | ||
|
||
if (args.length === 1) { | ||
const url = new URL(args[0]) | ||
node.ip = url.hostname | ||
node.port = url.port | ||
} | ||
crawler.run(node) | ||
|
||
crawler.run(node).then(report) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
{ | ||
"name": "crawler", | ||
"version": "0.0.1", | ||
"description": "loops through the ARK network to get the height of connected peers", | ||
"main": "app.js", | ||
"scripts": { | ||
"start": "node app.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/roks0n/crawler.git" | ||
}, | ||
"engines": { | ||
"node": "^8.11.2" | ||
}, | ||
"keywords": [], | ||
"author": "A(rk)-Team", | ||
"license": "Apache-2.0", | ||
"homepage": "https://github.com/roks0n/crawler#readme", | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"axios": "^0.18.0", | ||
"delay": "^4.0.1", | ||
"lodash": "^4.17.11" | ||
} | ||
} |
Oops, something went wrong.