forked from rinie/nodeftpd
-
Notifications
You must be signed in to change notification settings - Fork 39
/
ftptest.js
executable file
·68 lines (64 loc) · 1.64 KB
/
ftptest.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
62
63
64
65
66
67
68
var sys = require("sys");
var net = require("net");
var ftpd = require("./ftpd");
var spf = require("./sprintf");
ftpd.createServer("localhost").listen(21);
var responses = {"RSS":0,"VSZ":0,"CON":0,"ERR":0,"EOF":0,"CLO":0,"TIM":0,"220": 0,"331":0};
/*
setInterval(function() {
if(responses["CON"] < 50000) {
var client = net.createConnection(7002, "localhost");
client.setTimeout(0);
client.setEncoding("ascii"); // force data String not Buffer
client.addListener("data", function (data) {
status = data.substr(0,3);
switch(status)
{
case "220":
this.write("USER root\r\n");
break;
case "331":
this.write("PASS root\r\n");
break;
case "230":
this.write("PWD\r\n");
break;
default:
//isend++;
//this.send("PWD\r\n");
break;
}
if(!responses[status]) responses[status] = 0;
responses[status]++;
});
client.addListener("connect", function () {
responses["CON"]++;
});
client.addListener("end", function () {
responses["EOF"]++;
responses["CON"]--;
});
client.addListener("close", function () {
responses["CLO"]++;
});
client.addListener("timeout", function () {
responses["TIM"]++;
});
client.addListener("drain", function () {
//sys.puts("drain");
});
client.addListener("error", function () {
responses["ERR"]++;
});
}
}, 25);
setInterval(function() {
var mem = process.memoryUsage();
responses["RSS"] = parseInt(mem.rss/(1024*1024));
responses["VSZ"] = parseInt(mem.vsize/(1024*1024));
sys.puts(JSON.stringify(responses));
}, 10000);
*/
process.on('uncaughtException', function (err) {
console.log('Uncaught exception: ' + err);
});