29 lines
869 B
JavaScript
29 lines
869 B
JavaScript
|
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')
|
||
|
});
|