mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 02:25:40 +08:00
eliminate redundant code in previous fix
This commit is contained in:
parent
dc7e098e6b
commit
00513a7d28
29
src/socks.c
29
src/socks.c
@ -15,6 +15,17 @@ unsigned char * commands[] = {(unsigned char *)"UNKNOWN", (unsigned char *)"CONN
|
||||
#define BUFSIZE 1024
|
||||
#define LARGEBUFSIZE 67000
|
||||
|
||||
static void printcommand(unsigned char * buf, int command, struct clientparam *param){
|
||||
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)));
|
||||
|
||||
}
|
||||
|
||||
void * sockschild(struct clientparam* param) {
|
||||
int res;
|
||||
unsigned i=0;
|
||||
@ -207,13 +218,8 @@ void * sockschild(struct clientparam* param) {
|
||||
#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)));
|
||||
|
||||
printcommand(buf, command, param);
|
||||
reqsize = strlen((char *)buf);
|
||||
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
||||
if(action == HANDLED){
|
||||
@ -488,13 +494,8 @@ fflush(stderr);
|
||||
|
||||
if(command > 3) command = 0;
|
||||
if(buf){
|
||||
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)));
|
||||
printcommand(buf, command, param);
|
||||
|
||||
dolog(param, buf);
|
||||
myfree(buf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user