wiz/index.js

29 lines
869 B
JavaScript
Raw Permalink Normal View History

2019-02-12 16:25:14 +01:00
global.dir = __dirname;
const ftp = require('./controller/ftp');
//const storage = require('./controller/storage');
var f = new ftp.MyFileSystem();
const FtpSrv = require('ftp-srv');
const ftpServer = new FtpSrv({url:"ftp://127.0.0.1:2221" });
ftpServer.on('login', ({connection,username,password},resolve, reject) => {
if ((username === 'test' || username === 'testdb') && password === 'test' || username === 'anonymous') {
if (username === 'testdb') {
var root = '/code/data';
var cwd = '/';
return resolve({root: root, cwd: cwd, fs: new ftp.MyFileSystem(connection, {root: root, cwd: cwd}) });
} else {
return resolve({ root: '/code/data', cwd: '/' });
}
} else {
reject('Bad username or password');
}
});
ftpServer.listen()
.then(() => {
console.log('HELP')
});