mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
ntoa changed to ntop
This commit is contained in:
parent
7897b009a1
commit
ccf606fd9e
@ -727,7 +727,7 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
}
|
||||
|
||||
static int h_internal(int argc, unsigned char ** argv){
|
||||
getip46(46, argv[1], &conf.intsa);
|
||||
getip46(46, argv[1], (struct sockaddr *)&conf.intsa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, unsigned l
|
||||
len = 8 + sprintf((char *)buf + 8, "%.256s", param->hostname);
|
||||
}
|
||||
else {
|
||||
len = 8 + myinet_ntoa(ina, (char *)buf+8);
|
||||
len = 8 + myinet_ntop(AF_INET, &ina, (char *)buf+8, 256);
|
||||
}
|
||||
len += sprintf((char *)buf + len,
|
||||
":%hu HTTP/1.0\r\nProxy-Connection: keep-alive\r\n", ntohs(port));
|
||||
|
25
src/common.c
25
src/common.c
@ -22,13 +22,22 @@ int randomizer = 1;
|
||||
|
||||
unsigned char **stringtable = NULL;
|
||||
|
||||
int myinet_ntoa(struct in_addr in, char * buf){
|
||||
unsigned u = ntohl(in.s_addr);
|
||||
return sprintf(buf, "%u.%u.%u.%u",
|
||||
int myinet_ntop(int af, const void *src, char *dst, socklen_t size){
|
||||
#ifndef NOIPV6
|
||||
if(af != AF_INET6){
|
||||
#endif
|
||||
unsigned u = ntohl(((struct in_addr *)src)->s_addr);
|
||||
return sprintf(dst, "%u.%u.%u.%u",
|
||||
((u&0xFF000000)>>24),
|
||||
((u&0x00FF0000)>>16),
|
||||
((u&0x0000FF00)>>8),
|
||||
((u&0x000000FF)));
|
||||
#ifndef NOIPV6
|
||||
}
|
||||
*dst = 0;
|
||||
inet_ntop(af, src, dst, size);
|
||||
return strlen(dst);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *rotations[] = {
|
||||
@ -421,7 +430,7 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else i += myinet_ntoa(param->sins.sin_addr, (char *)buf + i);
|
||||
else i += myinet_ntop(*SAFAMILY(¶m->sins), SAADDR(¶m->sins), (char *)buf + i, 64);
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
@ -451,16 +460,16 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
|
||||
break;
|
||||
case 'e':
|
||||
tmpia.s_addr = param->extip;
|
||||
i += myinet_ntoa(tmpia, (char *)buf + i);
|
||||
i += myinet_ntop(AF_INET, &tmpia, (char *)buf + i, 64);
|
||||
break;
|
||||
case 'C':
|
||||
i += myinet_ntoa(param->sinc.sin_addr, (char *)buf + i);
|
||||
i += myinet_ntop(*SAFAMILY(¶m->sinc), SAADDR(¶m->sinc), (char *)buf + i, 64);
|
||||
break;
|
||||
case 'R':
|
||||
i += myinet_ntoa(param->sins.sin_addr, (char *)buf + i);
|
||||
i += myinet_ntop(*SAFAMILY(¶m->sins), SAADDR(¶m->sins), (char *)buf + i, 64);
|
||||
break;
|
||||
case 'Q':
|
||||
i += myinet_ntoa(param->req.sin_addr, (char *)buf + i);
|
||||
i += myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + i, 64);
|
||||
break;
|
||||
case 'p':
|
||||
sprintf((char *)buf+i, "%hu", ntohs(*SAPORT(¶m->srv->intsa)));
|
||||
|
@ -77,7 +77,7 @@ static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
||||
if(node->value)return pr_ip(node, &((struct sockaddr_in *)node->value)->sin_addr.s_addr)
|
||||
#else
|
||||
char buf[64];
|
||||
buf[0] = '['
|
||||
buf[0] = '[';
|
||||
buf[1] = 0;
|
||||
inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
|
||||
sprintf(buf + strlen(buf), "]:hu", (unsigned short)*SAPORT(node->value));
|
||||
|
@ -118,7 +118,7 @@ static void addbuffer(int increment, struct clientparam * param, unsigned char *
|
||||
|
||||
static int searchcookie(struct clientparam *param, struct flap_header * flap, int len, int * dif, struct tlv_header *tlv, int extra){
|
||||
struct icq_cookie *ic;
|
||||
char smallbuf[32];
|
||||
char smallbuf[64];
|
||||
struct tlv_header *bostlv = NULL;
|
||||
struct sockaddr_in sa;
|
||||
SASIZETYPE size = sizeof(sa);
|
||||
@ -165,7 +165,7 @@ static int searchcookie(struct clientparam *param, struct flap_header * flap, in
|
||||
pthread_mutex_unlock(&icq_cookie_mutex);
|
||||
if(bostlv){
|
||||
if(so._getsockname(param->clisock, (struct sockaddr *)&sa, &size)==-1) return 1;
|
||||
len = myinet_ntoa(sa.sin_addr, smallbuf);
|
||||
len = myinet_ntop(*SAFAMILY(&sa),SAADDR(&sa), smallbuf, 64);
|
||||
if(strchr(ic->connectstring, ':'))sprintf(smallbuf+len, ":%hu", ntohs(sa.sin_port));
|
||||
len = (int)strlen(smallbuf);
|
||||
*dif = len - (int)ntohs(bostlv->size);
|
||||
|
@ -70,7 +70,7 @@ static FILTER_ACTION msn_srv(void *fc, struct clientparam * param, unsigned char
|
||||
len = (int)strlen(tmpbuf);
|
||||
tmpbuf[len++] = ' ';
|
||||
|
||||
len+=myinet_ntoa(sa.sin_addr, tmpbuf+len);
|
||||
len+=myinet_ntop(*SAFAMILY(&sa), SAADDR(&sa), tmpbuf+len, 64);
|
||||
sprintf(tmpbuf+len, ":%hu %s", ntohs(sa.sin_port), sp3 + 1);
|
||||
len = (int)strlen(tmpbuf);
|
||||
memcpy(*buf_p + offset, tmpbuf, len);
|
||||
|
@ -33,7 +33,7 @@ struct symbol symbols[] = {
|
||||
{symbols+5, "sockgetcharcli", (void *) sockgetcharcli},
|
||||
{symbols+6, "sockgetcharsrv", (void *) sockgetcharsrv},
|
||||
{symbols+7, "sockgetlinebuf", (void *) sockgetlinebuf},
|
||||
{symbols+8, "myinet_ntoa", (void *) myinet_ntoa},
|
||||
{symbols+8, "myinet_ntop", (void *) myinet_ntop},
|
||||
{symbols+9, "dobuf", (void *) dobuf},
|
||||
{symbols+10, "scanaddr", (void *) scanaddr},
|
||||
{symbols+11, "getip", (void *) getip},
|
||||
@ -103,7 +103,7 @@ struct pluginlink pluginlink = {
|
||||
sockgetcharcli,
|
||||
sockgetcharsrv,
|
||||
sockgetlinebuf,
|
||||
myinet_ntoa,
|
||||
myinet_ntop,
|
||||
dobuf,
|
||||
dobuf2,
|
||||
scanaddr,
|
||||
|
@ -831,13 +831,13 @@ for(;;){
|
||||
sprintf((char*)buf+strlen((char *)buf), "Via: 1.1 ");
|
||||
gethostname((char *)(buf+strlen((char *)buf)), 256);
|
||||
sprintf((char*)buf+strlen((char *)buf), ":%d (%s %s)\r\nX-Forwarded-For: ", (int)ntohs(*SAPORT(¶m->srv->intsa)), conf.stringtable?conf.stringtable[2]:(unsigned char *)"", conf.stringtable?conf.stringtable[3]:(unsigned char *)"");
|
||||
if(!anonymous)myinet_ntoa(param->sinc.sin_addr, (char *)buf + strlen((char *)buf));
|
||||
if(!anonymous)myinet_ntop(*SAFAMILY(¶m->sinc), SAADDR(¶m->sinc), (char *)buf + strlen((char *)buf), 64);
|
||||
else {
|
||||
unsigned long tmp;
|
||||
|
||||
tmp = param->sinc.sin_addr.s_addr;
|
||||
param->sinc.sin_addr.s_addr = ((unsigned long)myrand(param, sizeof(struct clientparam))<<16)^(unsigned long)rand();
|
||||
myinet_ntoa(param->sinc.sin_addr, (char *)buf + strlen((char *)buf));
|
||||
myinet_ntop(*SAFAMILY(¶m->sinc), SAADDR(¶m->sinc), (char *)buf + strlen((char *)buf), 64);
|
||||
param->sinc.sin_addr.s_addr = tmp;
|
||||
}
|
||||
sprintf((char*)buf+strlen((char *)buf), "\r\n");
|
||||
|
@ -184,7 +184,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
|
||||
|
||||
|
||||
int scanaddr(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
||||
int myinet_ntoa(struct in_addr in, char * buf);
|
||||
int myinet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
extern unsigned long nservers[MAXNSERVERS];
|
||||
extern unsigned long authnserver;
|
||||
unsigned long getip(unsigned char *name);
|
||||
|
@ -96,7 +96,7 @@ void * sockschild(struct clientparam* param) {
|
||||
if(command==1 && !param->req.sin_addr.s_addr) {
|
||||
RETURN(422);
|
||||
}
|
||||
myinet_ntoa(param->sins.sin_addr, (char *)buf);
|
||||
myinet_ntop(*SAFAMILY(¶m->sins), SAADDR(¶m->sins), (char *)buf + strlen((char *)buf), 64);
|
||||
break;
|
||||
case 3:
|
||||
if ((size = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);} /* nmethods */
|
||||
@ -400,7 +400,8 @@ fflush(stderr);
|
||||
if(param->hostname){
|
||||
sprintf((char *)buf + strlen((char *)buf), "%.265s", param->hostname);
|
||||
}
|
||||
else myinet_ntoa(param->req.sin_addr, (char *)buf+strlen((char *)buf));
|
||||
else
|
||||
myinet_ntop(*SAFAMILY(¶m->req), SAADDR(¶m->req), (char *)buf + strlen((char *)buf), 64);
|
||||
sprintf((char *)buf+strlen((char *)buf), ":%hu", ntohs(param->req.sin_port));
|
||||
(*param->srv->logfunc)(param, buf);
|
||||
myfree(buf);
|
||||
|
@ -625,7 +625,7 @@ struct pluginlink {
|
||||
int (*sockgetcharcli)(struct clientparam * param, int timeosec, int timeousec);
|
||||
int (*sockgetcharsrv)(struct clientparam * param, int timeosec, int timeousec);
|
||||
int (*sockgetlinebuf)(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to);
|
||||
int (*myinet_ntoa)(struct in_addr in, char * buf);
|
||||
int (*myinet_ntop)(int af, const void *src, char *dst, socklen_t size);
|
||||
int (*dobuf)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec);
|
||||
int (*dobuf2)(struct clientparam * param, unsigned char * buf, const unsigned char *s, const unsigned char * doublec, struct tm* tm, char * format);
|
||||
int (*scanaddr)(const unsigned char *s, unsigned long * ip, unsigned long * mask);
|
||||
|
Loading…
Reference in New Issue
Block a user