Skip to content

Commit

Permalink
fix(auth): update checks, ensure secure is set using ftps
Browse files Browse the repository at this point in the history
  • Loading branch information
trs committed Jun 26, 2017
1 parent 84a68ae commit 8aeb697
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/commands/registration/auth.js
Expand Up @@ -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(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/registration/pbsz.js
Expand Up @@ -8,6 +8,7 @@ module.exports = {
syntax: '{{cmd}}',
description: 'Protection Buffer Size',
flags: {
no_auth: true
no_auth: true,
feat: 'PBSZ'
}
};
3 changes: 2 additions & 1 deletion src/commands/registration/prot.js
Expand Up @@ -17,6 +17,7 @@ module.exports = {
syntax: '{{cmd}}',
description: 'Data Channel Protection Level',
flags: {
no_auth: true
no_auth: true,
feat: 'PROT'
}
};
9 changes: 9 additions & 0 deletions src/connection.js
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8aeb697

Please sign in to comment.