Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connect(connection) {
const self = this;
self.emit('debug', 'ftp:connect');
self.client = new ftpClient.Client();
// force PASV mode
self.client.prepareTransfer = ftpClient.enterPassiveModeIPv4;
// logging
self.client.ftp.verbose = true;
self.client.ftp.log = (message) => {
if (message.startsWith('<') || message.startsWith('>')) {
self.emit('log', message.replace(/\'+/g, "").replace(/\\r|\\n/g, " "));
} else {
self.emit('debug', 'ftp:debug: ' + message);
}
};
// options
let options = {
host: connection.host,
port: (connection.port) ? connection.port : 21,
user: connection.user,