mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-27 07:59:41 +08:00
adding state to socket functions
This commit is contained in:
1 parent
d83c1f47f8
commit
8198db8617
18 files changed
+462
-360
No files matched your search
@@ -29,7 +29,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
||||
return 702;
|
||||
}
|
||||
sprintf(buf, "USER %.128s\r\n", param->extusername?param->extusername:(unsigned char *)"anonymous");
|
||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
if((int)socksend(param, param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
return 703;
|
||||
}
|
||||
param->statscli64 += (int)strlen(buf);
|
||||
@@ -46,7 +46,7 @@ int ftplogin(struct clientparam *param, char *nbuf, int *innbuf) {
|
||||
param->extpassword:(unsigned char *)"")
|
||||
:(unsigned char *)"3proxy@");
|
||||
res = (int)strlen(buf);
|
||||
if((int)socksend(param->remsock, (unsigned char *)buf, res, conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
if((int)socksend(param, param->remsock, (unsigned char *)buf, res, conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
return 705;
|
||||
}
|
||||
param->statscli64 += res;
|
||||
@@ -77,7 +77,7 @@ int ftpcd(struct clientparam *param, unsigned char* path, char *nbuf, int *innbu
|
||||
int inbuf = 0;
|
||||
|
||||
sprintf(buf, "CWD %.512s\r\n", path);
|
||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
if((int)socksend(param, param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
return 711;
|
||||
}
|
||||
param->statscli64 += (int)strlen(buf);
|
||||
@@ -110,7 +110,7 @@ int ftpres(struct clientparam *param, unsigned char * buf, int l){
|
||||
int ftpsyst(struct clientparam *param, unsigned char *buf, unsigned len){
|
||||
int i;
|
||||
|
||||
if(socksend(param->remsock, (unsigned char *)"SYST\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||
if(socksend(param, param->remsock, (unsigned char *)"SYST\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||
return 721;
|
||||
}
|
||||
param->statscli64 += 6;
|
||||
@@ -129,7 +129,7 @@ int ftppwd(struct clientparam *param, unsigned char *buf, unsigned len){
|
||||
int i;
|
||||
char *b, *e;
|
||||
|
||||
if(socksend(param->remsock, (unsigned char *)"PWD\r\n", 5, conf.timeouts[STRING_S]) != 5){
|
||||
if(socksend(param, param->remsock, (unsigned char *)"PWD\r\n", 5, conf.timeouts[STRING_S]) != 5){
|
||||
return 731;
|
||||
}
|
||||
param->statscli64 += 5;
|
||||
@@ -154,7 +154,7 @@ int ftptype(struct clientparam *param, unsigned char* f_type){
|
||||
int i;
|
||||
|
||||
sprintf(buf, "TYPE %.512s\r\n", f_type);
|
||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
if((int)socksend(param, param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
return 741;
|
||||
}
|
||||
param->statscli64 += (int)strlen(buf);
|
||||
@@ -176,7 +176,7 @@ SOCKET ftpdata(struct clientparam *param){
|
||||
unsigned short b5, b6;
|
||||
SASIZETYPE sasize;
|
||||
|
||||
if(socksend(param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||
if(socksend(param, param->remsock, (unsigned char *)"PASV\r\n", 6, conf.timeouts[STRING_S]) != 6){
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
param->statscli64 += 6;
|
||||
@@ -189,9 +189,9 @@ SOCKET ftpdata(struct clientparam *param){
|
||||
if(!(sb = strchr(buf+4, '(')) || !(se= strchr(sb, ')'))) return INVALID_SOCKET;
|
||||
if(sscanf(sb+1, "%lu,%lu,%lu,%lu,%hu,%hu", &b1, &b2, &b3, &b4, &b5, &b6)!=6) return INVALID_SOCKET;
|
||||
sasize = sizeof(param->sinsl);
|
||||
if(so._getsockname(param->remsock, (struct sockaddr *)¶m->sinsl, &sasize)){return INVALID_SOCKET;}
|
||||
if(so._getsockname(param->sostate, param->remsock, (struct sockaddr *)¶m->sinsl, &sasize)){return INVALID_SOCKET;}
|
||||
sasize = sizeof(param->sinsr);
|
||||
if(so._getpeername(param->remsock, (struct sockaddr *)¶m->sinsr, &sasize)){return INVALID_SOCKET;}
|
||||
if(so._getpeername(param->sostate, param->remsock, (struct sockaddr *)¶m->sinsr, &sasize)){return INVALID_SOCKET;}
|
||||
rem = param->remsock;
|
||||
param->remsock = INVALID_SOCKET;
|
||||
param->req = param->sinsr;
|
||||
@@ -201,7 +201,7 @@ SOCKET ftpdata(struct clientparam *param){
|
||||
param->operation = FTP_DATA;
|
||||
if((param->res = (*param->srv->authfunc)(param))) {
|
||||
if(param->remsock != INVALID_SOCKET) {
|
||||
so._closesocket(param->remsock);
|
||||
so._closesocket(param->sostate, param->remsock);
|
||||
param->remsock = INVALID_SOCKET;
|
||||
}
|
||||
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||
@@ -227,8 +227,8 @@ SOCKET ftpcommand(struct clientparam *param, unsigned char * command, unsigned c
|
||||
sprintf(buf, "%.15s%s%.512s\r\n", command, arg?
|
||||
(unsigned char *)" ":(unsigned char *)"",
|
||||
arg?arg:(unsigned char *)"");
|
||||
if((int)socksend(param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
so._closesocket(s);
|
||||
if((int)socksend(param, param->remsock, (unsigned char *)buf, (int)strlen(buf), conf.timeouts[STRING_S]) != (int)strlen(buf)){
|
||||
so._closesocket(param->sostate, s);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
param->statscli64 += (int)strlen(buf);
|
||||
@@ -236,11 +236,11 @@ SOCKET ftpcommand(struct clientparam *param, unsigned char * command, unsigned c
|
||||
while((i = sockgetlinebuf(param, SERVER, (unsigned char *)buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L])) > 0 && (i < 3 || !isnumber(*buf) || buf[3] == '-')){
|
||||
}
|
||||
if(i < 3) {
|
||||
so._closesocket(s);
|
||||
so._closesocket(param->sostate, s);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
if(buf[0] != '1') {
|
||||
so._closesocket(s);
|
||||
so._closesocket(param->sostate, s);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
return s;
|
||||
|
||||
Reference in new issue
Block a user