summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.c2
-rw-r--r--src/fastd.h4
-rw-r--r--src/peer.c2
3 files changed, 5 insertions, 3 deletions
diff --git a/src/config.c b/src/config.c
index b0ad607..d5fd255 100644
--- a/src/config.c
+++ b/src/config.c
@@ -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->name = strdup("default");
+ conf->peer_group->max_connections = -1;
}
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) {
fastd_peer_group_config_t *group = calloc(1, sizeof(fastd_peer_group_config_t));
group->name = strdup(name);
+ group->max_connections = -1;
group->parent = conf->peer_group;
group->next = group->parent->children;
diff --git a/src/fastd.h b/src/fastd.h
index 703e463..fb7ca25 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -151,8 +151,8 @@ struct fastd_peer_group_config {
char *name;
fastd_string_stack_t *peer_dirs;
- /* contraints */
- unsigned max_connections;
+ /* constraints */
+ int max_connections;
};
struct fastd_peer_group {
diff --git a/src/peer.c b/src/peer.c
index a20e0c8..c3279fb 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -381,7 +381,7 @@ bool fastd_peer_may_connect(fastd_context_t *ctx, fastd_peer_t *peer) {
fastd_peer_group_t *group;
for (group = peer->group; group; group = group->parent) {
- if (!group->conf->max_connections)
+ if (group->conf->max_connections < 0)
continue;
if (count_established_group_peers(ctx, group) >= group->conf->max_connections)