Roxen.git
/
server
/
plugins
/
protocols
/
ftp.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/plugins/protocols/ftp.pike:1:
// This is a roxen protocol module. // Copyright © 1997 - 2001, Roxen IS. /* * FTP protocol mk 2 *
-
* $Id: ftp.pike,v 2.
80
2002/
04
/
11
12
:
24
:
48
anders
Exp $
+
* $Id: ftp.pike,v 2.
81
2002/
07/
04
11:
42
:
19
per
Exp $
* * Henrik Grubbström <grubba@roxen.com> */ /* * TODO: * * How much is supposed to be logged? */
Roxen.git/server/plugins/protocols/ftp.pike:199:
#endif /* FTP2_DEBUG */ } } o["misc"] = m_rid["misc"] + ([ ]); } else { // Defaults... client = ({ "ftp" }); prot = "FTP"; clientprot = "FTP"; real_variables = ([]);
+
variables = FakedVariables( real_variables );
misc = ([]); cookies = ([]); throttle = ([]); client_var = ([]); request_headers = ([]); prestate = (<>); config = (<>); supports = (< "ftp", "images", "tables", >); pragma = (<>);
Roxen.git/server/plugins/protocols/ftp.pike:1732:
DWRITE("FTP: Illegal internet address in connect in async comm.\n"); destruct(f); fun(0, 0, @args); return; } } /* * Data connection handling */
-
static private void send_done_callback(
array(
object
)
args
)
+
static private void send_done_callback(
object
fd, object session,
+
int amount
)
{ DWRITE("FTP: send_done_callback()\n");
-
object fd = args[0];
-
object session = args[1];
-
+
if(fd) { if (fd->set_blocking) { fd->set_blocking(); // Force close() to flush any buffers. } BACKEND_CLOSE(fd); } curr_pipe = 0; if (session && session->file) {
-
+
session->file->len = amount;
session->conf->log(session->file, session); session->file = 0; } send(226, ({ "Transfer complete." })); } static private mapping|array|object stat_file(string fname, object|void session) {
Roxen.git/server/plugins/protocols/ftp.pike:1948:
break; default: // "I" and "L" // Binary -- no conversion needed. if (objectp(file->file) && file->file->set_nonblocking) { file->file = BinaryWrapper(file->file, 0, this_object()); } break; }
-
#ifndef
DISABLE_FTP_THROTTLING
-
mapping throttle
=session->
throttle||([])
;
+
object
throttler
=session->
throttler
;
object pipe;
-
if ( conf &&
-
((throttle->doit && conf->query("req_throttle")) ||
-
conf->throttler
-
) ) {
-
// report_debug("ftp: using slowpipe\n");
-
pipe=
((program)"slowpipe")();
-
} else {
-
// report
_
debug
(
"ftp:
using
fastpipe\n"
);
-
pipe=((program)"fastpipe")(); //will use Stdio.sendfile
if
possible
-
throttle->doit=0;
-
}
-
if
(
throttle->doit)
{
-
throttle->rate=max(throttle->rate,
-
conf
->query("req_throttle_min"));
-
pipe->throttle(throttle->rate,
-
(int
)
(throttle->rate*
-
conf->
query("req
_
throttle_depth_mult")),
-
0);
-
}
-
if
(
conf
&& conf->throttler) { //we are sure to be using slowpipe
-
pipe->assign
_
throttler
(
conf->throttler
)
;
-
}
-
#else
-
object
pipe
=((program
)
"fastpipe")()
;
-
#endif
+
pipe
=
roxen.get
_
shuffler
(
fd
);
+
if( conf )
+
conf->
connection
_
add
(
this
_
object
()
,
pipe
);
-
pipe->set_done_callback(send_done_callback
,
(
{
fd, session
}
) );
+
if( throttler || conf->throttler )
+
pipe->set_
throttler( throttler || conf->throttler );
+
+
pipe->set_
done_callback(
+
lambda( Shuffler.Shuffle r, int reason ) {
+
send_done_callback( fd, session
,
r->sent_data(
) );
+
} );
master_session->file = session->file = file; if(stringp(file->data)) {
-
pipe->
write
(file->data);
+
pipe->
add_source
(file->data
,0,strlen(file->data
)
)
;
} if(file->file) {
-
+
int off;
file->file->set_blocking();
-
pipe->
input
(file->file, file->len);
+
catch( off = file->tell() );
+
pipe->
add_source
(
file->file,
max(off,0), (
file->len
||-1
)
)
;
}
-
+
pipe->start();
curr_pipe = pipe;
-
pipe->output(fd);
+
} static private void connected_to_receive(object fd, string data, string args) { DWRITE("FTP: connected_to_receive(X, %O, %O)\n", data, args); touch_me(); if (fd) { send(150, ({ sprintf("Opening %s mode data connection for %s.",
Roxen.git/server/plugins/protocols/ftp.pike:2019:
break; case "E": fd = FromEBCDICWrapper(fd, data, this_object()); return; default: // "I" and "L" // Binary, no need to do anything. fd = BinaryWrapper(fd, data, this_object()); break; }
-
RequestID
session = RequestID2(master_session);
+
object
session = RequestID2(master_session);
session->method = "PUT"; session->my_fd = PutFileWrapper(fd, session, this_object()); session->misc->len = 0x7fffffff; if (open_file(args, session, "STOR")) { if (!(session->file->pipe)) { if (fd) { BACKEND_CLOSE(fd); } switch(session->file->error) {
Roxen.git/server/plugins/protocols/ftp.pike:3117:
return; } restart_point = (int)args; send(350, ({ "'REST' ok" })); } void ftp_ABOR(string args) { if (curr_pipe) { catch {
-
destruct(
curr_pipe);
+
curr_pipe
->stop(
);
}; curr_pipe = 0; send(426, ({ "Data transmission terminated." })); } send(226, ({ "'ABOR' Completed." })); } void ftp_PWD(string args) { send(257, ({ sprintf("\"%s\" is current directory.", cwd) }));