mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Minor hashtable refactor
This commit is contained in:
1 parent
d9b1493260
commit
083a70393f
5 files changed
+80
-90
No files matched your search
-29
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "proxy.h"
|
||||
#include "libs/blake2.h"
|
||||
|
||||
static FILTER_ACTION (*ext_ssl_parent)(struct clientparam * param) = NULL;
|
||||
|
||||
@@ -776,34 +775,6 @@ int checkACL(struct clientparam * param){
|
||||
return 3;
|
||||
}
|
||||
|
||||
struct authcache {
|
||||
unsigned char username[64];
|
||||
#ifndef NOIPv6
|
||||
uint8_t sincr_addr[16];
|
||||
uint8_t sinsl_addr[16];
|
||||
#else
|
||||
uint8_t sincr_addr[4];
|
||||
uint8_t sinsl_addr[4];
|
||||
#endif
|
||||
uint16_t sincr_family;
|
||||
uint16_t sinsl_family;
|
||||
};
|
||||
|
||||
void param2hash(const void *index, uint8_t *hash, const unsigned char *rnd){
|
||||
blake2b_state S;
|
||||
const struct clientparam *param = (struct clientparam *)index;
|
||||
|
||||
blake2b_init_key(&S, HASH_SIZE, rnd, sizeof(unsigned)*4);
|
||||
if((conf.authcachetype & 1) && !(conf.authcachetype & 8))blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||
if((conf.authcachetype & 2) && param->username)blake2b_update(&S, param->username, strlen((const char *)param->username));
|
||||
if((conf.authcachetype & 4) && param->password)blake2b_update(&S, param->password, strlen((const char *)param->password));
|
||||
if((conf.authcachetype & 16))blake2b_update(&S, ¶m->srv->acl, sizeof(param->srv->acl));
|
||||
blake2b_final(&S, hash, HASH_SIZE);
|
||||
}
|
||||
|
||||
struct hashtable auth_table = {0, sizeof(struct authcache), {0,0,0,0}, NULL, NULL, 0, param2hash};
|
||||
|
||||
|
||||
int cacheauth(struct clientparam * param){
|
||||
struct authcache ac;
|
||||
uint32_t ttl;
|
||||
|
||||
Reference in new issue
Block a user