From 5d299aac7d003952c2593815664d00d841e395d6 Mon Sep 17 00:00:00 2001 From: Brian Simonson Date: Tue, 22 May 2018 17:39:44 -0500 Subject: [PATCH 1/2] Add Implicit Connection with Secure Data --- lib/connection.js | 22 +++++++++++++++++----- package.json | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/connection.js b/lib/connection.js index 0f58d55..78f65db 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -144,7 +144,8 @@ FTP.prototype.connect = function(options) { } this._socket = socket; - if (this.options.secure === 'implicit') + if (this.options.secure === 'implicit' || + this.options.secure === 'implicit_secure') socket = tls.connect(secureOptions, onconnect); else { socket.once('connect', onconnect); @@ -210,7 +211,8 @@ FTP.prototype.connect = function(options) { // about authorized use, other limits, etc. self.emit('greeting', text); - if (self.options.secure && self.options.secure !== 'implicit') { + if (self.options.secure && self.options.secure !== 'implicit' && + self.options.secure !== 'implicit_secure') { cmd = 'AUTH TLS'; self._send(cmd, reentry, true); } else { @@ -248,8 +250,13 @@ FTP.prototype.connect = function(options) { cmd = 'OPTS'; self._send('OPTS UTF8 ON', reentry, true); } else { - cmd = 'TYPE'; - self._send('TYPE I', reentry, true); + if (self.options.secure === 'implicit_secure' && !self.nowSecure) { + cmd = 'PBSZ'; + self._send('PBSZ 0', reentry, true); + } else { + cmd = 'TYPE'; + self._send('TYPE I', reentry, true); + } } } else if (cmd === 'OPTS') { // ignore OPTS UTF8 result cmd = 'TYPE'; @@ -258,6 +265,10 @@ FTP.prototype.connect = function(options) { self.emit('ready'); else if (cmd === 'PBSZ') { cmd = 'PROT'; + if (self.options.secure === 'implicit_secure') { + cmd = 'FEAT'; + self.nowSecure = true; + } self._send('PROT P', reentry, true); } else if (cmd === 'PROT') { cmd = 'USER'; @@ -961,7 +972,8 @@ FTP.prototype._pasvConnect = function(ip, port, cb) { socket.once('connect', function() { self._debug&&self._debug('[connection] PASV socket connected'); - if (self.options.secure === true) { + if (self.options.secure === true || + self.options.secure === 'implicit_secure') { self.options.secureOptions.socket = socket; self.options.secureOptions.session = self._socket.getSession(); //socket.removeAllListeners('error'); diff --git a/package.json b/package.json index a23d95e..412db65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@icetee/ftp", - "version": "1.0.2", + "version": "1.0.3", "author": "Tamás András Horváth ", "contributors": [ "Brian White " From 1b2a247174fa95b0842778854e14b503643ac595 Mon Sep 17 00:00:00 2001 From: Brian Simonson Date: Wed, 23 May 2018 10:17:36 -0500 Subject: [PATCH 2/2] Revert Version Change --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 412db65..a23d95e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@icetee/ftp", - "version": "1.0.3", + "version": "1.0.2", "author": "Tamás András Horváth ", "contributors": [ "Brian White "