-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
60 lines (47 loc) · 1.69 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//Dependencies
const Request = require("request")
const Chalk = require("chalk")
//Variables
const Settings = require("./settings.json")
const Self_Args = process.argv.slice(2)
var PortLol_Data = {}
PortLol_Data.maximum = 0
//Functions
function Initiate_A_Request(name, port){
Request(`${Self_Args[0]}:${port}`, function(err, res, body){
if(err){
console.log(`${Chalk.grey("[") + Chalk.redBright("DEAD") + Chalk.grey("]")}${Chalk.grey("[") + Chalk.magentaBright(name) + Chalk.grey("]")} ${Self_Args[0]}:${port}`)
PortLol_Data.maximum += 1
if(PortLol_Data.maximum == Settings.ports.length-1){
console.log("Done!")
process.exit()
}
return
}
console.log(`${Chalk.grey("[") + Chalk.greenBright("ALIVE") + Chalk.grey("]")}${Chalk.grey("[") + Chalk.magentaBright(name) + Chalk.grey("]")} ${Self_Args[0]}:${port}`)
PortLol_Data.maximum += 1
if(PortLol_Data.maximum == Settings.ports.length-1){
console.log("Done!")
process.exit()
}
})
}
//Main
if(Self_Args.length == 0){
console.log(`node index.js <url>
Example: node index.js http://192.168.0.1`)
process.exit()
}
if(Self_Args[0].indexOf("http") == -1){
console.log(`${Chalk.grey("[") + Chalk.redBright("ERROR") + Chalk.grey("]")} Invalid url.`)
process.exit()
}
Request(Self_Args[0], function(err, res, body){
if(err){
console.log(`${Chalk.grey("[") + Chalk.redBright("ERROR") + Chalk.grey("]")} Invalid url.`)
process.exit()
}
for( i = 0; i <= Settings.ports.length-1; i++ ){
Initiate_A_Request(Settings.ports[i].name, Settings.ports[i].port)
}
})