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 BUFSIZE 1024
|
||||||
#define LARGEBUFSIZE 67000
|
#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) {
|
void * sockschild(struct clientparam* param) {
|
||||||
int res;
|
int res;
|
||||||
unsigned i=0;
|
unsigned i=0;
|
||||||
@ -207,13 +218,8 @@ void * sockschild(struct clientparam* param) {
|
|||||||
#ifndef WITHMAIN
|
#ifndef WITHMAIN
|
||||||
if(param->nreqfilters && buf){
|
if(param->nreqfilters && buf){
|
||||||
int reqbufsize = BUFSIZE, reqsize, action;
|
int reqbufsize = BUFSIZE, reqsize, action;
|
||||||
sprintf((char *)buf, "%s ", commands[command]);
|
|
||||||
if(param->hostname){
|
printcommand(buf, command, param);
|
||||||
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);
|
reqsize = strlen((char *)buf);
|
||||||
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
@ -488,13 +494,8 @@ fflush(stderr);
|
|||||||
|
|
||||||
if(command > 3) command = 0;
|
if(command > 3) command = 0;
|
||||||
if(buf){
|
if(buf){
|
||||||
sprintf((char *)buf, "%s ", commands[command]);
|
printcommand(buf, command, param);
|
||||||
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)));
|
|
||||||
dolog(param, buf);
|
dolog(param, buf);
|
||||||
myfree(buf);
|
myfree(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user