mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
somewhat more functioning FTP
This commit is contained in:
parent
3cd77a19ca
commit
bd3dca96f6
@ -18,9 +18,8 @@ else {
|
|||||||
$protocol="HTTP";
|
$protocol="HTTP";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
socket(Server, PF_INET, SOCK_STREAM, $proto)|| die "socket: $!";
|
socket(Server, PF_INET, SOCK_STREAM, $proto)|| die "socket: $!";
|
||||||
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
|
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
|
||||||
pack("l", 1)) || die "setsockopt: $!";
|
pack("l", 1)) || die "setsockopt: $!";
|
||||||
bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
|
bind(Server, sockaddr_in($port, INADDR_ANY))|| die "bind: $!";
|
||||||
listen(Server,SOMAXCONN) || die "listen: $!";
|
listen(Server,SOMAXCONN) || die "listen: $!";
|
||||||
@ -40,14 +39,19 @@ sub REAPER {
|
|||||||
logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
|
logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
$commandok{ USER => 'fresh'}; # USER is ok in fresh state
|
# USER is ok in fresh state
|
||||||
|
%commandok = ( "USER" => "fresh",
|
||||||
|
"PASS" => "passwd",
|
||||||
|
"PASV" => "loggedin",
|
||||||
|
);
|
||||||
|
|
||||||
print "TEST: ".$commandok{"USER"}."\n";
|
%statechange = ( 'USER' => 'passwd', # USER goes to passwd state
|
||||||
|
'PASS' => 'loggedin', # PASS goes to loggedin state
|
||||||
|
);
|
||||||
|
|
||||||
|
%displaytext = ('USER' => '331 We are happy you popped in!', # output FTP line
|
||||||
$statechange{ 'USER' => 'passwd'}; # USER goes to passwd state
|
'PASS' => '230 Welcome you silly person',
|
||||||
|
);
|
||||||
$displaytext{'USER' => '331 We are happy you arrived!'}; # output FTP line
|
|
||||||
|
|
||||||
$SIG{CHLD} = \&REAPER;
|
$SIG{CHLD} = \&REAPER;
|
||||||
|
|
||||||
@ -117,10 +121,12 @@ for ( $waitedpid = 0;
|
|||||||
}
|
}
|
||||||
|
|
||||||
$state=$statechange{$FTPCMD};
|
$state=$statechange{$FTPCMD};
|
||||||
if($command{$1} eq "") {
|
if($state eq "") {
|
||||||
print "314 Wwwwweeeeird internal error\r\n";
|
print "314 Wwwwweeeeird internal error state: $state\r\n";
|
||||||
exit
|
exit;
|
||||||
}
|
}
|
||||||
|
print STDERR "gone to state $state\n";
|
||||||
|
|
||||||
$text = $displaytext{$FTPCMD};
|
$text = $displaytext{$FTPCMD};
|
||||||
print "$text\r\n";
|
print "$text\r\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user