mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 02:25:40 +08:00
Support request filters for SOCKS, support broken BIND request from some clients
This commit is contained in:
parent
8b57982a09
commit
dc7e098e6b
29
src/socks.c
29
src/socks.c
@ -132,7 +132,8 @@ void * sockschild(struct clientparam* param) {
|
||||
buf[i] = (unsigned char)res;
|
||||
}
|
||||
buf[i] = 0;
|
||||
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||
if(command != 1 && param->srv->family != 6 && (!strcmp((char *)buf, "0.0.0.0") || !strcmp((char *)buf, "0"))) param->req = param->srv->extsa;
|
||||
else if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||
param->sinsr = param->req;
|
||||
break;
|
||||
default:
|
||||
@ -203,7 +204,24 @@ void * sockschild(struct clientparam* param) {
|
||||
RETURN(res);
|
||||
}
|
||||
|
||||
|
||||
#ifndef WITHMAIN
|
||||
if(param->nreqfilters && buf){
|
||||
int reqbufsize = BUFSIZE, reqsize, action;
|
||||
sprintf((char *)buf, "%s ", commands[command]);
|
||||
if(param->hostname){
|
||||
sprintf((char *)buf + strlen((char *)buf), "%.265s", param->hostname);
|
||||
}
|
||||
else
|
||||
myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + strlen((char *)buf), 64);
|
||||
sprintf((char *)buf+strlen((char *)buf), ":%hu", ntohs(*SAPORT(¶m->req)));
|
||||
reqsize = strlen((char *)buf);
|
||||
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
||||
if(action == HANDLED){
|
||||
RETURN(0);
|
||||
}
|
||||
if(action != PASS) RETURN(517);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(command > 1) {
|
||||
if(so._bind(param->remsock,(struct sockaddr *)¶m->sinsl,SASIZE(¶m->sinsl))) {
|
||||
@ -233,6 +251,11 @@ fflush(stderr);
|
||||
}
|
||||
param->res = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CLEANRET:
|
||||
|
||||
if(param->clisock != INVALID_SOCKET){
|
||||
@ -274,6 +297,8 @@ fflush(stderr);
|
||||
socksend(param->clisock, buf, 8, conf.timeouts[STRING_S]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (param->npredatfilters){
|
||||
int action;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user