Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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');
Expand Down