mirror of
https://github.com/neocturne/fastd.git
synced 2025-05-14 20:25:08 +02:00
Make 'peer limit 0' allow no connections
This commit is contained in:
parent
ff78f87f9b
commit
195be08c47
3 changed files with 5 additions and 3 deletions
|
@ -125,6 +125,7 @@ static void default_config(fastd_config_t *conf) {
|
||||||
|
|
||||||
conf->peer_group = calloc(1, sizeof(fastd_peer_group_config_t));
|
conf->peer_group = calloc(1, sizeof(fastd_peer_group_config_t));
|
||||||
conf->peer_group->name = strdup("default");
|
conf->peer_group->name = strdup("default");
|
||||||
|
conf->peer_group->max_connections = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool config_match(const char *opt, ...) {
|
static bool config_match(const char *opt, ...) {
|
||||||
|
@ -255,6 +256,7 @@ void fastd_config_bind_address(fastd_context_t *ctx, fastd_config_t *conf, const
|
||||||
void fastd_config_peer_group_push(fastd_context_t *ctx, fastd_config_t *conf, const char *name) {
|
void fastd_config_peer_group_push(fastd_context_t *ctx, fastd_config_t *conf, const char *name) {
|
||||||
fastd_peer_group_config_t *group = calloc(1, sizeof(fastd_peer_group_config_t));
|
fastd_peer_group_config_t *group = calloc(1, sizeof(fastd_peer_group_config_t));
|
||||||
group->name = strdup(name);
|
group->name = strdup(name);
|
||||||
|
group->max_connections = -1;
|
||||||
|
|
||||||
group->parent = conf->peer_group;
|
group->parent = conf->peer_group;
|
||||||
group->next = group->parent->children;
|
group->next = group->parent->children;
|
||||||
|
|
|
@ -151,8 +151,8 @@ struct fastd_peer_group_config {
|
||||||
char *name;
|
char *name;
|
||||||
fastd_string_stack_t *peer_dirs;
|
fastd_string_stack_t *peer_dirs;
|
||||||
|
|
||||||
/* contraints */
|
/* constraints */
|
||||||
unsigned max_connections;
|
int max_connections;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fastd_peer_group {
|
struct fastd_peer_group {
|
||||||
|
|
|
@ -381,7 +381,7 @@ bool fastd_peer_may_connect(fastd_context_t *ctx, fastd_peer_t *peer) {
|
||||||
fastd_peer_group_t *group;
|
fastd_peer_group_t *group;
|
||||||
|
|
||||||
for (group = peer->group; group; group = group->parent) {
|
for (group = peer->group; group; group = group->parent) {
|
||||||
if (!group->conf->max_connections)
|
if (group->conf->max_connections < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (count_established_group_peers(ctx, group) >= group->conf->max_connections)
|
if (count_established_group_peers(ctx, group) >= group->conf->max_connections)
|
||||||
|
|
Loading…
Add table
Reference in a new issue