修改 - 重新 clone ftpd 模块

This commit is contained in:
suwings 2018-04-16 11:08:31 +08:00
parent 8446292d61
commit 6f787f4692
4 changed files with 28 additions and 18 deletions

2
ftpd/ftpd.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,21 +1,25 @@
var ftpd = require('./ftpd.min');
var fs = require('fs');
var path = require('path');
//因为这库在旧版本节点上有问题,所以从 github 获取最新版本
//npm i https://github.com/sstur/nodeftpd.git --save
var ftpdzz = require('ftpd');
var keyFile;
var certFile;
var options = null;
var FTPserver = null;
var rootCwdListener = () => { return '/'; }; //默认
// console.log('*** To run as FTPS server, ***');
var rootCwdListener = () => {
return '/';
}; //默认
module.exports.initFTPdServerOptions = (_options) => {
options = _options;
}
module.exports.createFTPServer = (createOptions) => {
FTPserver = new ftpd.FtpServer(options.host, createOptions);
FTPserver = new ftpdzz.FtpServer(options.host, createOptions);
}
module.exports.initFTPServerListener = (config) => {
@ -24,13 +28,9 @@ module.exports.initFTPServerListener = (config) => {
config['errorFunc'] && config['errorFunc']();
});
// FTPserver.on('client:close',function(e){
// console.log('28 - ',e)
// })
FTPserver.on('client:connected', function (connection) {
var username = null;
// console.log('client connected: ' + connection.remoteAddress);
connection.on('command:user', function (user, success, failure) {
if (user.length >= 6) {
username = user;
@ -41,7 +41,10 @@ module.exports.initFTPServerListener = (config) => {
});
connection.on('command:pass', function (pswd, success, failure) {
if (!pswd || !username) { failure(); return; }
if (!pswd || !username) {
failure();
return;
}
//通过外接函数
let result = config['loginCheck'](connection, username, pswd);
if (result) {
@ -62,9 +65,4 @@ module.exports.runFTPServer = () => {
FTPserver.listen(options.port);
// MCSERVER.infoLog('FTP'.green, 'FTP Module', true);
MCSERVER.infoLog('FTP'.green, " FTP 模块监听: [ ftp://" + (MCSERVER.softConfig.FTP_ip || "127.0.0.1".yellow) + ":" + MCSERVER.softConfig.FTP_port + " ]");
}
}

13
package-lock.json generated
View File

@ -80,6 +80,11 @@
"resolved": "http://registry.npm.taobao.org/crc/download/crc-3.4.4.tgz",
"integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms="
},
"dateformat": {
"version": "1.0.7-1.2.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.7-1.2.3.tgz",
"integrity": "sha1-67Vhu3IU7leo3CaHrasdVV3pQZw="
},
"debug": {
"version": "2.6.9",
"resolved": "http://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz",
@ -179,6 +184,9 @@
"resolved": "http://registry.npm.taobao.org/fs-extra/download/fs-extra-5.0.0.tgz",
"integrity": "sha1-QU0BEM3QZwVzTQVWUsVBEmDDGr0="
},
"ftpd": {
"version": "git+https://github.com/sstur/nodeftpd.git#0d299f78af7f0006a9d5a084614bd8b56a369d1b"
},
"graceful-fs": {
"version": "4.1.11",
"resolved": "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.11.tgz",
@ -351,6 +359,11 @@
"resolved": "http://registry.npm.taobao.org/setprototypeof/download/setprototypeof-1.0.3.tgz",
"integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ="
},
"stat-mode": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-0.2.2.tgz",
"integrity": "sha1-5sgLYjEj19gM8TLOU480YokHJQI="
},
"statuses": {
"version": "1.4.0",
"resolved": "http://registry.npm.taobao.org/statuses/download/statuses-1.4.0.tgz",

View File

@ -26,6 +26,7 @@
"express-session": "^1.15.3",
"express-ws": "^3.0.0",
"fs-extra": "^5.0.0",
"ftpd": "git+https://github.com/sstur/nodeftpd.git",
"iconv-lite": "^0.4.21",
"multiparty": "^4.1.3",
"os-utils": "0.0.14",