mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
"limit" support in authcache to bind sessions to ip
This commit is contained in:
1 parent
336b411ea2
commit
e7e7d2fddf
5 files changed
+33
-8
No files matched your search
+17
-7
@@ -721,15 +721,24 @@ int cacheauth(struct clientparam * param){
|
||||
continue;
|
||||
|
||||
}
|
||||
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
|
||||
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa)))) &&
|
||||
if((!(conf.authcachetype&2) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
|
||||
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password)))) {
|
||||
if(param->username){
|
||||
myfree(param->username);
|
||||
|
||||
if(!(conf.authcachetype&1)
|
||||
|| ((*SAFAMILY(&ac->sa) == *SAFAMILY(¶m->sincr)
|
||||
&& !memcmp(SAADDR(&ac->sa), SAADDR(¶m->sincr), SAADDRLEN(&ac->sa))))){
|
||||
|
||||
if(param->username){
|
||||
myfree(param->username);
|
||||
}
|
||||
param->username = (unsigned char *)mystrdup(ac->username);
|
||||
pthread_mutex_unlock(&hash_mutex);
|
||||
return 0;
|
||||
}
|
||||
else if ((conf.authcachetype&1) && (conf.authcachetype&8)) {
|
||||
pthread_mutex_unlock(&hash_mutex);
|
||||
return 10;
|
||||
}
|
||||
param->username = (unsigned char *)mystrdup(ac->username);
|
||||
pthread_mutex_unlock(&hash_mutex);
|
||||
return 0;
|
||||
}
|
||||
last = ac;
|
||||
ac = ac->next;
|
||||
@@ -790,6 +799,7 @@ int doauth(struct clientparam * param){
|
||||
break;
|
||||
}
|
||||
if(res > ret) ret = res;
|
||||
if(ret > 9) return ret;
|
||||
}
|
||||
if(!res){
|
||||
return alwaysauth(param);
|
||||
|
||||
@@ -1338,6 +1338,7 @@ static int h_authcache(int argc, unsigned char **argv){
|
||||
if(strstr((char *) *(argv + 1), "ip")) conf.authcachetype |= 1;
|
||||
if(strstr((char *) *(argv + 1), "user")) conf.authcachetype |= 2;
|
||||
if(strstr((char *) *(argv + 1), "pass")) conf.authcachetype |= 4;
|
||||
if(strstr((char *) *(argv + 1), "limit")) conf.authcachetype |= 8;
|
||||
if(argc > 2) conf.authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
||||
if(!conf.authcachetype) conf.authcachetype = 6;
|
||||
if(!conf.authcachetime) conf.authcachetime = 600;
|
||||
|
||||
Reference in new issue
Block a user