@icetee/ftp
Advanced tools
Comparing version 0.3.11 to 0.3.13
@@ -15,2 +15,3 @@ var fs = require('fs'), | ||
RE_PASV = /([\d]+),([\d]+),([\d]+),([\d]+),([-\d]+),([-\d]+)/, | ||
RE_EPSV = /([\d]+)/, | ||
RE_EOL = /\r?\n/g, | ||
@@ -80,3 +81,4 @@ RE_WD = /"(.+)"(?: |$)/, | ||
pasvTimeout: undefined, | ||
aliveTimeout: undefined | ||
aliveTimeout: undefined, | ||
forcePasv: undefined, | ||
}; | ||
@@ -103,2 +105,3 @@ this.connected = false; | ||
this.options.aliveTimeout = options.keepalive || 10000; | ||
this.options.forcePasv = options.forcePasv || false; | ||
@@ -243,3 +246,5 @@ if (typeof options.debug === 'function') | ||
self._feat = Parser.parseFeat(text); | ||
self._utf8 = self._feat.indexOf('UTF8')>=0 // RFC #2640 | ||
self._utf8 = self._feat.indexOf('UTF8') > -1; // RFC #2640 | ||
self._epsv = self._feat.indexOf('EPSV') > -1; | ||
self._eprt = self._feat.indexOf('EPRT') > -1; | ||
} | ||
@@ -877,8 +882,23 @@ if (self._utf8) { | ||
// FTP Extensions for IPv6 and NATs | ||
// https://tools.ietf.org/html/rfc2428 | ||
// Must run EPSV before running [ IPv6 passive mod ] | ||
FTP.prototype._eprt = function(response, cb) { | ||
var tcpPrt = RE_EPSV.exec(response)[0], | ||
netPrt = (this._socket.remoteFamily === 'IPv4') ? 1 : 2, | ||
eprtParam = [netPrt, this._socket.remoteAddress, tcpPrt].join('|'); | ||
self._send('EPRT |' + eprtParam + '|', function(eprtErr, eprtText) { | ||
if (eprtErr) return cb(eprtErr); | ||
console.log(eprtText); | ||
}); | ||
}; | ||
// Private/Internal methods | ||
FTP.prototype._pasv = function(cb) { | ||
var self = this, first = true, ip, port; | ||
this._send('PASV', function reentry(err, text) { | ||
var pasvCmd = (self._epsv && !this.options.forcePasv) ? 'EPSV' : 'PASV'; | ||
this._send(pasvCmd, function(err, text) { | ||
if (err) | ||
@@ -890,16 +910,24 @@ return cb(err); | ||
if (first) { | ||
var m = RE_PASV.exec(text); | ||
if (!m) | ||
return cb(new Error('Unable to parse PASV server response')); | ||
ip = m[1]; | ||
ip += '.'; | ||
ip += m[2]; | ||
ip += '.'; | ||
ip += m[3]; | ||
ip += '.'; | ||
ip += m[4]; | ||
port = (parseInt(m[5], 10) * 256) + parseInt(m[6], 10); | ||
if (pasvCmd === 'EPSV') { | ||
var tcpPrt = RE_EPSV.exec(text)[0]; | ||
first = false; | ||
ip = self._socket.remoteAddress; | ||
port = tcpPrt; | ||
} else { | ||
var m = RE_PASV.exec(text); | ||
if (!m) return cb(new Error('Unable to parse PASV server response')); | ||
ip = m[1]; | ||
ip += '.'; | ||
ip += m[2]; | ||
ip += '.'; | ||
ip += m[3]; | ||
ip += '.'; | ||
ip += m[4]; | ||
port = (parseInt(m[5], 10) * 256) + parseInt(m[6], 10); | ||
} | ||
first = false; | ||
} | ||
self._pasvConnect(ip, port, function(err, sock) { | ||
@@ -906,0 +934,0 @@ if (err) { |
{ | ||
"name": "@icetee/ftp", | ||
"version": "0.3.11", | ||
"author": "Tamás András Horváth <htomy92@gmail.com>", | ||
"contributors": [ | ||
"Brian White <mscdex@mscdex.net>" | ||
], | ||
"description": "An FTP client module for node.js", | ||
"main": "./lib/connection", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"dependencies": { | ||
"xregexp": "2.0.0", | ||
"readable-stream": "1.1.x" | ||
}, | ||
"scripts": { | ||
"test": "node test/test.js" | ||
}, | ||
"keywords": [ | ||
"ftp", "client", "transfer" | ||
], | ||
"licenses": [{ | ||
"type": "MIT", | ||
"url": "http://github.com/icetee/node-ftp/raw/master/LICENSE" | ||
}], | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/icetee/node-ftp.git" | ||
"name": "@icetee/ftp", | ||
"version": "0.3.13", | ||
"author": "Tamás András Horváth <htomy92@gmail.com>", | ||
"contributors": [ | ||
"Brian White <mscdex@mscdex.net>" | ||
], | ||
"description": "An FTP client module for node.js", | ||
"main": "./lib/connection", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"dependencies": { | ||
"xregexp": "2.0.0", | ||
"readable-stream": "1.1.x" | ||
}, | ||
"scripts": { | ||
"test": "node test/test.js" | ||
}, | ||
"keywords": [ | ||
"ftp", | ||
"client", | ||
"transfer" | ||
], | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/icetee/node-ftp/raw/master/LICENSE" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/icetee/node-ftp.git" | ||
} | ||
} |
@@ -22,3 +22,3 @@ var Parser = require('../lib/parser'), | ||
size: 4096, | ||
date: new Date('2012-12-21T00:00Z') | ||
date: new Date('2012-12-21T00:00:00.000Z') | ||
}, | ||
@@ -38,3 +38,3 @@ what: 'Normal directory' | ||
size: 0, | ||
date: new Date('2012-08-31T00:00Z') | ||
date: new Date('2012-08-31T00:00:00.000Z') | ||
}, | ||
@@ -54,3 +54,3 @@ what: 'Normal directory #2' | ||
size: 7045120, | ||
date: new Date('2012-09-02T00:00Z') | ||
date: new Date('2012-09-02T00:00:00.000Z') | ||
}, | ||
@@ -70,3 +70,3 @@ what: 'Normal file' | ||
size: 7045120, | ||
date: new Date('2012-09-02T00:00Z') | ||
date: new Date('2012-09-02T00:00:00.000Z') | ||
}, | ||
@@ -86,3 +86,3 @@ what: 'File with ACL set' | ||
size: 4096, | ||
date: new Date('2012-05-19T00:00Z') | ||
date: new Date('2012-05-19T00:00:00.000Z') | ||
}, | ||
@@ -102,3 +102,3 @@ what: 'Directory with sticky bit and executable for others' | ||
size: 4096, | ||
date: new Date('2012-05-19T00:00Z') | ||
date: new Date('2012-05-19T00:00:00.000Z') | ||
}, | ||
@@ -118,3 +118,3 @@ what: 'Directory with sticky bit and executable for others #2' | ||
size: 4096, | ||
date: new Date('2012-05-19T00:00Z') | ||
date: new Date('2012-05-19T00:00:00.000Z') | ||
}, | ||
@@ -134,3 +134,3 @@ what: 'Directory with sticky bit and not executable for others' | ||
size: 4096, | ||
date: new Date('2012-05-19T00:00Z') | ||
date: new Date('2012-05-19T00:00:00.000Z') | ||
}, | ||
@@ -137,0 +137,0 @@ what: 'Directory with sticky bit and not executable for others #2' |
58209
10
1389