EPSV support for ftppr

This commit is contained in:
z3APA3A 2017-06-27 23:28:17 +03:00
parent 177fbb1117
commit 481b9e389f

View File

@ -88,6 +88,7 @@ void * ftpprchild(struct clientparam* param) {
} }
else if (status >= 3 && ( else if (status >= 3 && (
(!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) || (!strncasecmp((char *)buf, "PASV", 4) && (pasv = 1)) ||
(!strncasecmp((char *)buf, "EPSV", 4) && (pasv = 2)) ||
(!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0)) (!strncasecmp((char *)buf, "PORT ", 5) && !(pasv = 0))
)){ )){
#ifndef WITHMAIN #ifndef WITHMAIN
@ -125,6 +126,7 @@ void * ftpprchild(struct clientparam* param) {
if(so._listen(clidatasock, 1)) {RETURN(823);} if(so._listen(clidatasock, 1)) {RETURN(823);}
sasize = sizeof(param->sincl); sasize = sizeof(param->sincl);
if(so._getsockname(clidatasock, (struct sockaddr *)&param->sincl, &sasize)){RETURN(824);} if(so._getsockname(clidatasock, (struct sockaddr *)&param->sincl, &sasize)){RETURN(824);}
if(pasv == 1){
if(*SAFAMILY(&param->sincl) == AF_INET) if(*SAFAMILY(&param->sincl) == AF_INET)
sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n", sprintf((char *)buf, "227 OK (%u,%u,%u,%u,%u,%u)\r\n",
(unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[0]), (unsigned)(((unsigned char *)(SAADDR(&param->sincl)))[0]),
@ -139,6 +141,12 @@ void * ftpprchild(struct clientparam* param) {
(unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1]) (unsigned)(((unsigned char *)(SAPORT(&param->sincl)))[1])
); );
} }
else {
sprintf((char *)buf, "227 OK (|||%u|)\r\n",
(unsigned)ntohs(*SAPORT(&param->sincl))
);
}
}
else { else {
unsigned long b1, b2, b3, b4; unsigned long b1, b2, b3, b4;
unsigned short b5, b6; unsigned short b5, b6;