mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
more changes for IPv6 client support
This commit is contained in:
1 parent
10bc0db2a8
commit
db5c4b1255
8 files changed
+90
-100
No files matched your search
+18
-17
@@ -205,16 +205,12 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
int done = 0;
|
||||
struct chain * cur;
|
||||
struct chain * redir = NULL;
|
||||
unsigned long targetip;
|
||||
unsigned short targetport;
|
||||
int r2;
|
||||
|
||||
if(param->remsock != INVALID_SOCKET) {
|
||||
return 0;
|
||||
}
|
||||
targetip = param->req.sin_addr.s_addr;
|
||||
targetport = param->req.sin_port;
|
||||
if(!targetip || !targetport) return 100;
|
||||
if(!memcmp(SAADDR(¶m->req),"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",SAADDRLEN(¶m->req)) || !*SAPORT(¶m->req)) return 100;
|
||||
|
||||
r2 = (myrand(param, sizeof(struct clientparam))%1000);
|
||||
|
||||
@@ -270,11 +266,16 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if(!cur->redirip && cur->redirport) param->extport = cur->redirport;
|
||||
else if(!cur->redirport && cur->redirip) param->extip = cur->redirip;
|
||||
else {
|
||||
param->sins.sin_port = cur->redirport;
|
||||
param->sins.sin_addr.s_addr = cur->redirip;
|
||||
else if(!cur->redirport && cur->redirip) {
|
||||
unsigned short port = *SAPORT(¶m->sinsl);
|
||||
*SAFAMILY(¶m->sinsl) = AF_INET;
|
||||
*(unsigned long *)SAADDR(¶m->sinsl) = cur->redirip;
|
||||
*SAPORT(¶m->sinsl) = port;
|
||||
}
|
||||
else if(!cur->redirip && cur->redirport) *SAPORT(¶m->sinsl) = cur->redirport;
|
||||
else if(*SAFAMILY(¶m->req) == AF_INET){
|
||||
*(unsigned long *)SAADDR(¶m->sinsr) = cur->redirip;
|
||||
*SAPORT(¶m->sinsr) = cur->redirport;
|
||||
}
|
||||
|
||||
if((res = alwaysauth(param))){
|
||||
@@ -282,7 +283,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = redir?clientnegotiate(redir, param, cur->redirip, cur->redirport):0;
|
||||
res = (redir && *SAFAMILY(¶m->req) == AF_INET)?clientnegotiate(redir, param, cur->redirip, cur->redirport):0;
|
||||
if(res) return res;
|
||||
}
|
||||
redir = cur;
|
||||
@@ -305,7 +306,7 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
}
|
||||
|
||||
if(!connected) return 9;
|
||||
return redir?clientnegotiate(redir, param, targetip, targetport):0;
|
||||
return (redir && *SAFAMILY(¶m->req) == AF_INET)?clientnegotiate(redir, param, *(unsigned long *)SAADDR(¶m->req), *SAPORT(¶m->req)):0;
|
||||
}
|
||||
|
||||
int IPInentry(struct sockaddr *sa, struct iplist *ipentry){
|
||||
@@ -339,7 +340,7 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
||||
}
|
||||
if(!ipentry) return 0;
|
||||
}
|
||||
if((acentry->dst && param->req.sin_addr.s_addr) || (acentry->dstnames && param->hostname)) {
|
||||
if((acentry->dst && memcmp(SAADDR(¶m->req), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", SAADDRLEN(¶m->req))) || (acentry->dstnames && param->hostname)) {
|
||||
for(ipentry = acentry->dst; ipentry; ipentry = ipentry->next)
|
||||
if(IPInentry((struct sockaddr *)¶m->req, ipentry)) {
|
||||
break;
|
||||
@@ -374,10 +375,10 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
|
||||
}
|
||||
if(!ipentry && !hstentry) return 0;
|
||||
}
|
||||
if(acentry->ports && param->req.sin_port) {
|
||||
if(acentry->ports && *SAPORT(¶m->req)) {
|
||||
for (portentry = acentry->ports; portentry; portentry = portentry->next)
|
||||
if(ntohs(param->req.sin_port) >= portentry->startport &&
|
||||
ntohs(param->req.sin_port) <= portentry->endport) {
|
||||
if(ntohs(*SAPORT(¶m->req)) >= portentry->startport &&
|
||||
ntohs(*SAPORT(¶m->req)) <= portentry->endport) {
|
||||
break;
|
||||
}
|
||||
if(!portentry) return 0;
|
||||
@@ -970,7 +971,7 @@ unsigned long udpresolve(unsigned char * name, unsigned *retttl, struct clientpa
|
||||
struct sockaddr_in sin, *sinsp;
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sinsp = (param && !makeauth)? ¶m->sins : &sin;
|
||||
sinsp = (param && !makeauth && *SAFAMILY(¶m->sinsr) == AF_INET)? (struct sockaddr_in *)¶m->sinsr : &sin;
|
||||
|
||||
|
||||
if((sock=so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) break;
|
||||
|
||||
Reference in new issue
Block a user