have cyclic use blacklist_lookup_index
This commit is contained in:
parent
3aa0f27b51
commit
d2112701b0
14
src/cyclic.c
14
src/cyclic.c
@ -67,8 +67,10 @@ static const uint64_t psub1_f[] = { 2, 3, 5, 131, 364289 };
|
|||||||
static uint64_t primroot = 0;
|
static uint64_t primroot = 0;
|
||||||
static uint64_t current = 0;
|
static uint64_t current = 0;
|
||||||
|
|
||||||
|
static uint64_t num_addrs = 0;
|
||||||
|
|
||||||
#define COPRIME 1
|
#define COPRIME 1
|
||||||
#define NOT_COPRIME 0
|
#define NOT_COPRIME 0
|
||||||
|
|
||||||
// check whether two integers are coprime
|
// check whether two integers are coprime
|
||||||
static int check_coprime(uint64_t check)
|
static int check_coprime(uint64_t check)
|
||||||
@ -145,6 +147,7 @@ int cyclic_init(uint32_t primroot_, uint32_t current_)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num_addrs = blacklist_count_allowed();
|
||||||
// make sure current is an allowed ip
|
// make sure current is an allowed ip
|
||||||
cyclic_get_next_ip();
|
cyclic_get_next_ip();
|
||||||
|
|
||||||
@ -153,7 +156,7 @@ int cyclic_init(uint32_t primroot_, uint32_t current_)
|
|||||||
|
|
||||||
uint32_t cyclic_get_curr_ip(void)
|
uint32_t cyclic_get_curr_ip(void)
|
||||||
{
|
{
|
||||||
return (uint32_t) current;
|
return (uint32_t) blacklist_lookup_index(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t cyclic_get_primroot(void)
|
uint32_t cyclic_get_primroot(void)
|
||||||
@ -174,11 +177,10 @@ uint32_t cyclic_get_next_ip(void)
|
|||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
uint32_t candidate = cyclic_get_next_elem();
|
uint32_t candidate = cyclic_get_next_elem();
|
||||||
if (!blacklist_is_allowed(candidate)) {
|
if (candidate < num_addrs) {
|
||||||
zsend.blacklisted++;
|
return blacklist_lookup_index(candidate);
|
||||||
} else {
|
|
||||||
return candidate;
|
|
||||||
}
|
}
|
||||||
|
zsend.blacklisted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user