summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config.c12
-rw-r--r--src/fastd.c7
-rw-r--r--src/peer.c2
3 files changed, 12 insertions, 9 deletions
diff --git a/src/config.c b/src/config.c
index abd386f..0febd15 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1000,19 +1000,17 @@ static void peer_dirs_handle_old_peers(fastd_context_t *ctx, fastd_peer_config_t
}
static void peer_dirs_handle_new_peers(fastd_context_t *ctx, fastd_peer_config_t **peers, fastd_peer_config_t *new_peers) {
- fastd_peer_config_t *peer, *next;
- for (peer = new_peers; peer; peer = next) {
- next = peer->next;
-
- ctx->conf->protocol->peer_configure(ctx, peer);
- if (peer->enabled)
- fastd_peer_add(ctx, peer);
+ fastd_peer_config_t *peer;
+ for (peer = new_peers; peer; peer = peer->next) {
+ if (peer->next)
+ continue;
peer->next = *peers;
*peers = peer;
}
}
+
void fastd_config_load_peer_dirs(fastd_context_t *ctx, fastd_config_t *conf) {
fastd_config_t temp_conf;
temp_conf.peer_group = conf->peer_group;
diff --git a/src/fastd.c b/src/fastd.c
index 686df31..fec0838 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -616,6 +616,10 @@ static void delete_peer_groups(fastd_context_t *ctx) {
static void init_peers(fastd_context_t *ctx) {
fastd_peer_config_t *peer_conf;
for (peer_conf = ctx->conf->peers; peer_conf; peer_conf = peer_conf->next) {
+ if (peer_conf->enabled)
+ continue;
+
+ peer_conf->enabled = true;
ctx->conf->protocol->peer_configure(ctx, peer_conf);
if (peer_conf->enabled)
@@ -1138,8 +1142,8 @@ int main(int argc, char *argv[]) {
init_tuntap(&ctx);
init_peer_groups(&ctx);
- init_peers(&ctx);
fastd_config_load_peer_dirs(&ctx, &conf);
+ init_peers(&ctx);
if (conf.daemon) {
pid_t pid = fork();
@@ -1188,6 +1192,7 @@ int main(int argc, char *argv[]) {
init_log(&ctx);
fastd_config_load_peer_dirs(&ctx, &conf);
+ init_peers(&ctx);
}
if (dump) {
diff --git a/src/peer.c b/src/peer.c
index c3279fb..55f0467 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -210,7 +210,7 @@ static void delete_peer(fastd_context_t *ctx, fastd_peer_t *peer) {
fastd_peer_config_t* fastd_peer_config_new(fastd_context_t *ctx, fastd_config_t *conf) {
fastd_peer_config_t *peer = malloc(sizeof(fastd_peer_config_t));
- peer->enabled = true;
+ peer->enabled = false;
peer->hostname = NULL;
memset(&peer->address, 0, sizeof(fastd_peer_address_t));