MCPcopy Create free account
hub / github.com/3proxy/3proxy / cacheauth

Function cacheauth

src/auth.c:645–682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643
644
645int cacheauth(struct clientparam * param){
646 struct authcache *ac, *last=NULL;
647
648 pthread_mutex_lock(&hash_mutex);
649 for(ac = authc; ac; ){
650 if(ac->expires <= conf.time){
651 if(ac->username)myfree(ac->username);
652 if(ac->password)myfree(ac->password);
653 if(!last){
654 authc = ac->next;
655 myfree(ac);
656 ac = authc;
657 }
658 else {
659 last->next = ac->next;
660 myfree(ac);
661 ac = last->next;
662 }
663 continue;
664
665 }
666 if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
667 ((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), SAADDR(&param->sincr), SAADDRLEN(&ac->sa)))) &&
668 (!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password)))) {
669 if(param->username){
670 myfree(param->username);
671 }
672 param->username = (unsigned char *)mystrdup(ac->username);
673 pthread_mutex_unlock(&hash_mutex);
674 return 0;
675 }
676 last = ac;
677 ac = ac->next;
678 }
679
680 pthread_mutex_unlock(&hash_mutex);
681 return 4;
682}
683
684int doauth(struct clientparam * param){
685 int res = 0;

Callers

nothing calls this directly

Calls 2

myfreeFunction · 0.85
mystrdupFunction · 0.85

Tested by

no test coverage detected