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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ Creates a new Ftp instance.

Host name for the current FTP server.

#### Ftp.hostPasv

Manual set host for passive mode. (When server return wrong host on passive mode. See issue https://github.com/sergi/jsftp/issues/158)

#### Ftp.port

Port number for the current FTP server (defaults to 21).
Expand Down
5 changes: 5 additions & 0 deletions lib/jsftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function runCmd(name, ...params) {

function Ftp(cfg) {
this.host = cfg.host || FTP_HOST;
this.hostPasv = cfg.hostPasv;
this.port = cfg.port || FTP_PORT;
this.user = cfg.user || "anonymous";
this.pass = cfg.pass || "@anonymous";
Expand Down Expand Up @@ -241,6 +242,10 @@ Ftp.prototype.getPasvPort = function(text) {
host = this.host;
}

if (this.hostPasv) {
host = this.hostPasv;
}

return {
host,
port: (parseInt(match[2], 10) & 255) * 256 + (parseInt(match[3], 10) & 255)
Expand Down