Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ The user is not able to escape this directory.
- Integer, specifies the lower-bound port (min port) for creating PASV connections
- `pasvPortRangeEnd`: _(default: random?)_
- Integer, specifies the upper-bound port (max port) for creating PASV connections
- `pasvHostAliases`: _(default: auto-detect)_
- Dictionary object string → string, mapping auto-detected IP addresses (key) to addresses that shall be announced (value).
The values must be IPv4 addresses (four decimal numbers separated by dots) that shall be sent as the server IP in the PASV reply.
This is required when you want to use PASV transfers with the FTP server behind a NAT, especially if the internal network uses IPv6.
- If you want to support PASV connections inside the FTP server's network, you'll need separate IPs for the internal connections and the NAT connections.
Internal clients that accidentially connect to the IP configured for NAT will receive announcements for the external IP, which may cause redundant NAT traffic or might just fail.
- If the auto-detected IP address doesn't have its own entry, the fallback entry with key `*` (U+002A asterisk) will be tried.
Thus, in simple scenarios where your NAT only has one external IP and you do not need PASV mode inside the network behind the NAT, you can always use the fallback key `*`.


## Filesystem Abstraction
Expand Down
3 changes: 3 additions & 0 deletions lib/FtpConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,13 @@ FtpConnection.prototype._writePASVReady = function(command) {

var a = self.pasv.address();
var host = self.server.host;
var ipMap;
var port = a.port;
if (command === 'PASV') {
var i1 = (port / 256) | 0;
var i2 = port % 256;
ipMap = self.server.options.pasvHostAliases;
if (ipMap) { host = (ipMap[host] || ipMap['*'] || host); }
self.respond('227 Entering Passive Mode (' + host.split('.').join(',') + ',' + i1 + ',' + i2 + ')');
} else { // EPASV
self.respond('229 Entering Extended Passive Mode (|||' + port + '|)');
Expand Down