mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
Do not resolve hostname to IP on ACL destination
This commit is contained in:
parent
35153001ed
commit
8c511a19e9
68
src/common.c
68
src/common.c
@ -861,11 +861,42 @@ unsigned long getip(unsigned char *name){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int afdetect(unsigned char *name){
|
||||||
|
int ndots=0, ncols=0, nhex=0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0; name[i]; i++){
|
||||||
|
if(name[i] == '.'){
|
||||||
|
if(++ndots > 3) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name[i] == ':'){
|
||||||
|
if(++ncols > 7) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(name[i] == '%' || (name[i] >= 'a' && name[i] <= 'f') || (name[i] >= 'A' && name[i] <= 'F')){
|
||||||
|
nhex++;
|
||||||
|
}
|
||||||
|
else if(name[i] <'0' || name[i] >'9') {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(ndots == 3 && ncols == 0 && nhex == 0){
|
||||||
|
return AF_INET;
|
||||||
|
}
|
||||||
|
if(ncols >= 2) {
|
||||||
|
return AF_INET6;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
int ndots=0, ncols=0, nhex=0;
|
int detect;
|
||||||
struct addrinfo *ai, hint;
|
struct addrinfo *ai, hint;
|
||||||
int i;
|
|
||||||
RESOLVFUNC tmpresolv;
|
RESOLVFUNC tmpresolv;
|
||||||
|
|
||||||
if(!sa) return 0;
|
if(!sa) return 0;
|
||||||
@ -877,34 +908,15 @@ unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa){
|
|||||||
#endif
|
#endif
|
||||||
#ifndef NOIPV6
|
#ifndef NOIPV6
|
||||||
}
|
}
|
||||||
for(i=0; name[i]; i++){
|
|
||||||
if(name[i] == '.'){
|
detect = afdetect(name);
|
||||||
if(++ndots > 3) {
|
if(detect != -1){
|
||||||
break;
|
if(family == 4 && detect != 4) return 0;
|
||||||
}
|
*SAFAMILY(sa) = (family == 6)? AF_INET6 : detect;
|
||||||
}
|
|
||||||
else if(name[i] == ':'){
|
|
||||||
if(++ncols > 7) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(name[i] == '%' || (name[i] >= 'a' && name[i] <= 'f') || (name[i] >= 'A' && name[i] <= 'F')){
|
|
||||||
nhex++;
|
|
||||||
}
|
|
||||||
else if(name[i] <'0' || name[i] >'9') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!name[i]){
|
|
||||||
if(ndots == 3 && ncols == 0 && nhex == 0){
|
|
||||||
*SAFAMILY(sa)=(family == 6)?AF_INET6 : AF_INET;
|
|
||||||
return inet_pton(*SAFAMILY(sa), (char *)name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
return inet_pton(*SAFAMILY(sa), (char *)name, SAADDR(sa))? *SAFAMILY(sa) : 0;
|
||||||
}
|
}
|
||||||
if(ncols >= 2) {
|
|
||||||
*SAFAMILY(sa)=AF_INET6;
|
|
||||||
return inet_pton(AF_INET6, (char *)name, SAADDR(sa))?(family==4? 0:AF_INET6) : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if((tmpresolv = resolvfunc)){
|
if((tmpresolv = resolvfunc)){
|
||||||
int f = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
int f = (family == 6 || family == 64)?AF_INET6:AF_INET;
|
||||||
*SAFAMILY(sa) = f;
|
*SAFAMILY(sa) = f;
|
||||||
|
@ -196,6 +196,7 @@ extern struct nserver nservers[MAXNSERVERS];
|
|||||||
extern struct nserver authnserver;
|
extern struct nserver authnserver;
|
||||||
unsigned long getip(unsigned char *name);
|
unsigned long getip(unsigned char *name);
|
||||||
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
unsigned long getip46(int family, unsigned char *name, struct sockaddr *sa);
|
||||||
|
int afdetect(unsigned char *name);
|
||||||
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
unsigned long myresolver(int, unsigned char *, unsigned char *);
|
||||||
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
unsigned long fakeresolver (int, unsigned char *, unsigned char*);
|
||||||
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
int inithashtable(struct hashtable *hashtable, unsigned nhashsize);
|
||||||
|
Loading…
Reference in New Issue
Block a user