From 8aeb6976d2427caca02d5f9878689214a7697a9d Mon Sep 17 00:00:00 2001 From: Tyler Stewart Date: Mon, 26 Jun 2017 12:35:41 -0600 Subject: [PATCH] fix(auth): update checks, ensure `secure` is set using ftps --- src/commands/registration/auth.js | 3 ++- src/commands/registration/pbsz.js | 3 ++- src/commands/registration/prot.js | 3 ++- src/connection.js | 9 +++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/commands/registration/auth.js b/src/commands/registration/auth.js index 4ae6b683..6d3f22e9 100644 --- a/src/commands/registration/auth.js +++ b/src/commands/registration/auth.js @@ -20,7 +20,8 @@ module.exports = { }; function handleTLS() { - if (!this.server._tls) return this.reply(504); + if (!this.server._tls) return this.reply(502); + if (this.secure) return this.reply(202); return this.reply(234) .then(() => { diff --git a/src/commands/registration/pbsz.js b/src/commands/registration/pbsz.js index 6e026875..bf379108 100644 --- a/src/commands/registration/pbsz.js +++ b/src/commands/registration/pbsz.js @@ -8,6 +8,7 @@ module.exports = { syntax: '{{cmd}}', description: 'Protection Buffer Size', flags: { - no_auth: true + no_auth: true, + feat: 'PBSZ' } }; diff --git a/src/commands/registration/prot.js b/src/commands/registration/prot.js index 78a94e45..a70da188 100644 --- a/src/commands/registration/prot.js +++ b/src/commands/registration/prot.js @@ -17,6 +17,7 @@ module.exports = { syntax: '{{cmd}}', description: 'Data Channel Protection Level', flags: { - no_auth: true + no_auth: true, + feat: 'PROT' } }; diff --git a/src/connection.js b/src/connection.js index de6c8042..94be77e7 100644 --- a/src/connection.js +++ b/src/connection.js @@ -18,6 +18,8 @@ class FtpConnection { this.transferType = 'binary'; this.encoding = 'utf8'; this.bufferSize = false; + this.restByteCount = 0; + this._secure = false; this.connector = new BaseConnector(this); @@ -48,6 +50,13 @@ class FtpConnection { } } + get secure() { + return this.server.isTLS || this._secure; + } + set secure(sec) { + this._secure = sec; + } + close(code = 421, message = 'Closing connection') { return when .resolve(code)