Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
0ba2942c
Commit
0ba2942c
authored
5 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Add account parameter... start going through the RFCs...
parent
f3e461bc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/ftp.js
+22
-18
22 additions, 18 deletions
exec/load/ftp.js
with
22 additions
and
18 deletions
exec/load/ftp.js
+
22
−
18
View file @
0ba2942c
...
...
@@ -2,7 +2,7 @@
require
(
'
sockdefs.js
'
,
'
SOCK_STREAM
'
);
function
FTP
(
host
,
user
,
pass
,
port
,
dport
,
bindhost
)
function
FTP
(
host
,
user
,
pass
,
port
,
dport
,
bindhost
,
account
)
{
var
ret
;
...
...
@@ -29,14 +29,18 @@ function FTP(host, user, pass, port, dport, bindhost)
this
.
bindhost
=
bindhost
;
this
.
timeout
=
300
;
this
.
maxline
=
500
;
this
.
account
=
account
;
this
.
socket
=
new
ConnectedSocket
(
host
,
port
,
{
protocol
:
'
FTP
'
,
timeout
:
this
.
timeout
,
binadaddrs
:
this
.
bindhost
});
if
(
parseInt
(
this
.
cmd
(
undefined
,
true
),
10
)
!==
220
)
{
this
.
socket
.
close
();
throw
(
"
Invalid response from server
"
);
}
ret
=
parseInt
(
this
.
cmd
(
"
USER
"
+
this
.
user
,
true
),
10
)
if
(
ret
===
331
)
ret
=
parseInt
(
this
.
cmd
(
"
PASS
"
+
this
.
pass
,
true
),
10
);
if
(
ret
===
332
)
{
if
(
this
.
account
===
undefined
)
throw
(
"
Account required
"
);
ret
=
parseInt
(
this
.
cmd
(
"
ACCOUNT
"
+
this
.
account
,
true
),
10
);
}
if
(
ret
!==
230
)
{
this
.
socket
.
close
();
throw
(
"
Login failed
"
);
...
...
@@ -45,15 +49,26 @@ function FTP(host, user, pass, port, dport, bindhost)
this
.
passive
=
true
;
}
FTP
.
prototype
.
cwd
=
function
(
path
)
{
var
rstr
;
var
ret
;
rstr
=
this
.
cmd
(
"
CWD
"
+
path
,
true
);
ret
=
parseInt
(
rstr
,
10
);
if
(
ret
!==
250
)
return
false
;
return
true
;
}
FTP
.
prototype
.
logout
=
function
()
{
var
ret
;
ret
=
parseInt
(
this
.
cmd
(
"
QUIT
"
,
true
),
10
)
// TODO: Hrm....
this
.
socket
.
close
();
if
(
ret
!==
221
)
return
false
;
this
.
socket
.
close
();
return
true
;
}
...
...
@@ -69,18 +84,6 @@ FTP.prototype.pwd = function()
return
null
;
}
FTP
.
prototype
.
cwd
=
function
(
path
)
{
var
rstr
;
var
ret
;
rstr
=
this
.
cmd
(
"
CWD
"
+
path
,
true
);
ret
=
parseInt
(
rstr
,
10
);
if
(
ret
!==
250
)
return
false
;
return
true
;
}
FTP
.
prototype
.
dir
=
function
(
path
)
{
return
this
.
do_get
(
path
,
undefined
,
true
);
...
...
@@ -160,7 +163,7 @@ FTP.prototype.cmd = function(cmd, needresp)
if
(
cmd
!==
undefined
)
{
cmdline
=
cmd
+
'
\r\n
'
;
log
(
LOG_DEBUG
,
"
CMD: '
"
+
cmd
+
"
'
"
);
log
(
LOG_DEBUG
,
"
CMD: '
"
+
cmd
.
replace
(
/
\x
ff/g
,
"
\
xff
\
xff
"
)
+
"
'
"
);
if
(
this
.
socket
.
send
(
cmdline
)
!=
cmdline
.
length
)
throw
(
"
Error sending command
"
);
}
...
...
@@ -171,6 +174,7 @@ FTP.prototype.cmd = function(cmd, needresp)
do
{
rd
=
this
.
socket
.
recvline
(
this
.
maxline
,
this
.
timeout
-
(
time
()
-
start
));
if
(
rd
!==
null
)
{
rd
=
rd
.
replace
(
/
\x
ff
\x
ff/g
,
"
\
xff
"
);
log
(
LOG_DEBUG
,
"
RSP: '
"
+
rd
+
"
'
"
);
if
(
rd
.
length
===
0
)
continue
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment