Skip to content
Snippets Groups Projects
Commit 2ae4ad77 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add an 8th (!) argument to constructor to allow connect timeout override

... for Nelgin
parent 500a36f3
No related branches found
No related tags found
No related merge requests found
/* $Id: ftp.js,v 1.23 2020/05/21 01:56:45 rswindell Exp $ */ // FTP Client library
require('sockdefs.js', 'SOCK_STREAM'); require('sockdefs.js', 'SOCK_STREAM');
function FTP(host, user, pass, port, dport, bindhost, account) function FTP(host, user, pass, port, dport, bindhost, account, timeout)
{ {
var ret; var ret;
if (host === undefined) if (host === undefined)
throw new Error("No hostname specified"); throw new Error("No hostname specified");
this.revision = "JSFTP v" + "$Revision: 1.23 $".split(' ')[1]; this.revision = "JSFTP v1.4";
if (port === undefined) if (port === undefined)
port = 21; port = 21;
...@@ -29,7 +29,7 @@ function FTP(host, user, pass, port, dport, bindhost, account) ...@@ -29,7 +29,7 @@ function FTP(host, user, pass, port, dport, bindhost, account)
this.pass = pass; this.pass = pass;
this.dport = dport; this.dport = dport;
this.bindhost = bindhost; this.bindhost = bindhost;
this.timeout = 300; this.timeout = timeout || 300;
this.maxline = 500; this.maxline = 500;
this.account = account; this.account = account;
this.socket = new ConnectedSocket(host, port, {protocol:'FTP', timeout:this.timeout, binadaddrs:this.bindhost}); this.socket = new ConnectedSocket(host, port, {protocol:'FTP', timeout:this.timeout, binadaddrs:this.bindhost});
...@@ -308,7 +308,7 @@ FTP.prototype.do_sendfile = function(src, data_socket) ...@@ -308,7 +308,7 @@ FTP.prototype.do_sendfile = function(src, data_socket)
break; break;
} }
total += buf.length; total += buf.length;
} while((!f.eof) && data_socket.is_connected && this.socket.is_connected); } while((!f.eof) && data_socket.is_connected && this.socket.is_connected);
data_socket.close(); data_socket.close();
f.close(); f.close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment