Skip to content

Commit 1fba867

Browse files
committed
Merge branch 'master' of https://github.com/alanszlosek/nodeftpd
2 parents f231d88 + f9101ef commit 1fba867

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

ftpd.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ function createServer(host, sandbox, pasvstartport, numports) {
136136
}
137137
};
138138

139-
socket.addListener("connect", function () {
140-
logIf(1, "Connection", socket);
141-
//socket.send("220 NodeFTPd Server version 0.0.10\r\n");
142-
//socket.write("220 written by Andrew Johnston (apjohnsto@gmail.com)\r\n");
143-
//socket.write("220 Please visit http://github.com/billywhizz/NodeFTPd\r\n");
144-
socket.write("220 FTP server (nodeftpd) ready\r\n");
145-
});
146-
147139
socket.addListener("data", function (data) {
148140
data = (data+'').trim();
149141
logIf(2, "FTP command: " + data, socket);
@@ -366,18 +358,6 @@ function createServer(host, sandbox, pasvstartport, numports) {
366358
// should watch out for malicious users uploading large amounts of data outside protocol
367359
logIf(4, 'Data event: received ' + (Buffer.isBuffer(data) ? 'buffer' : 'string'), socket);
368360
});
369-
psocket.on("connect", function() {
370-
logIf(1, "Passive data event: connect", socket);
371-
// Once we have a completed data connection, make note of it
372-
socket.dataSocket = psocket;
373-
374-
// 150 should be sent before we send data on the data connection
375-
//socket.write("150 Connection Accepted\r\n");
376-
if (socket.readable) socket.resume();
377-
378-
// Emit this so the pending callback gets picked up in whenDataWritable()
379-
socket.dataListener.emit("data-ready", psocket);
380-
});
381361
psocket.on("end", function () {
382362
logIf(3, "Passive data event: end", socket);
383363
// remove pointer
@@ -397,6 +377,17 @@ function createServer(host, sandbox, pasvstartport, numports) {
397377
);
398378
if (socket.readable) socket.resume();
399379
});
380+
381+
// Once we have a completed data connection, make note of it
382+
socket.dataSocket = psocket;
383+
384+
// 150 should be sent before we send data on the data connection
385+
//socket.write("150 Connection Accepted\r\n");
386+
if (socket.readable) socket.resume();
387+
388+
// Emit this so the pending callback gets picked up in whenDataWritable()
389+
socket.dataListener.emit("data-ready", psocket);
390+
400391
});
401392
// Once we're successfully listening, tell the client
402393
pasv.addListener("listening", function() {
@@ -686,6 +677,13 @@ function createServer(host, sandbox, pasvstartport, numports) {
686677
socket.addListener("error", function (err) {
687678
logIf(0, "Client connection error: " + err, socket);
688679
});
680+
681+
// Tell client we're ready
682+
logIf(1, "Connection", socket);
683+
//socket.send("220 NodeFTPd Server version 0.0.10\r\n");
684+
//socket.write("220 written by Andrew Johnston (apjohnsto@gmail.com)\r\n");
685+
//socket.write("220 Please visit http://github.com/billywhizz/NodeFTPd\r\n");
686+
socket.write("220 FTP server (nodeftpd) ready\r\n");
689687
});
690688

691689
server.addListener("close", function() {

0 commit comments

Comments
 (0)