diff options
-rw-r--r-- | src/config.c | 38 | ||||
-rw-r--r-- | src/fastd.c | 4 | ||||
-rw-r--r-- | src/fastd.h | 7 | ||||
-rw-r--r-- | src/protocol_ec25519_fhmqvc.c | 6 |
4 files changed, 7 insertions, 48 deletions
diff --git a/src/config.c b/src/config.c index 16a9a80..50cf5bb 100644 --- a/src/config.c +++ b/src/config.c @@ -511,41 +511,13 @@ bool fastd_read_config(fastd_context_t *ctx, fastd_config_t *conf, const char *f return ret; } -static void count_peers(fastd_context_t *ctx, fastd_config_t *conf) { - conf->n_floating = 0; - conf->n_v4 = 0; - conf->n_v6 = 0; - conf->n_dynamic = 0; - conf->n_dynamic_v4 = 0; - conf->n_dynamic_v6 = 0; +static void assess_peers(fastd_context_t *ctx, fastd_config_t *conf) { + conf->has_floating = false; fastd_peer_config_t *peer; for (peer = conf->peers; peer; peer = peer->next) { - switch (peer->address.sa.sa_family) { - case AF_UNSPEC: - if (peer->hostname) - conf->n_dynamic++; - else - conf->n_floating++; - break; - - case AF_INET: - if (peer->hostname) - conf->n_dynamic_v4++; - else - conf->n_v4++; - break; - - case AF_INET6: - if (peer->hostname) - conf->n_dynamic_v6++; - else - conf->n_v6++; - break; - - default: - exit_bug(ctx, "invalid peer address family"); - } + if (fastd_peer_config_is_floating(peer)) + conf->has_floating = true; if (peer->dynamic_float_deprecated) pr_warn(ctx, "peer `%s' uses deprecated float syntax, please update your configuration", peer->name); @@ -1009,7 +981,7 @@ void fastd_config_load_peer_dirs(fastd_context_t *ctx, fastd_config_t *conf) { peer_dirs_handle_old_peers(ctx, &conf->peers, &temp_conf.peers); peer_dirs_handle_new_peers(ctx, &conf->peers, temp_conf.peers); - count_peers(ctx, conf); + assess_peers(ctx, conf); } void fastd_config_release(fastd_context_t *ctx, fastd_config_t *conf) { diff --git a/src/fastd.c b/src/fastd.c index b78fa34..e35584a 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -959,9 +959,7 @@ static inline void handle_socket_receive_known(fastd_context_t *ctx, fastd_socke } static inline bool is_unknown_peer_valid(fastd_context_t *ctx, const fastd_peer_address_t *remote_addr) { - return ctx->conf->n_floating || ctx->conf->n_dynamic || ctx->conf->on_verify || - (remote_addr->sa.sa_family == AF_INET && ctx->conf->n_dynamic_v4) || - (remote_addr->sa.sa_family == AF_INET6 && ctx->conf->n_dynamic_v6); + return ctx->conf->has_floating || ctx->conf->on_verify; } static inline void handle_socket_receive_unknown(fastd_context_t *ctx, fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_buffer_t buffer) { diff --git a/src/fastd.h b/src/fastd.h index 4ce5bb4..a155c80 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -225,12 +225,7 @@ struct fastd_config { fastd_peer_group_config_t *peer_group; fastd_peer_config_t *peers; - unsigned n_floating; - unsigned n_v4; - unsigned n_v6; - unsigned n_dynamic; - unsigned n_dynamic_v4; - unsigned n_dynamic_v6; + bool has_floating; fastd_protocol_config_t *protocol_config; diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c index 78f5ebf..9e7174b 100644 --- a/src/protocol_ec25519_fhmqvc.c +++ b/src/protocol_ec25519_fhmqvc.c @@ -555,12 +555,6 @@ static fastd_peer_t* find_sender_key(fastd_context_t *ctx, const fastd_peer_addr if (memcmp(peer->protocol_config->public_key.p, key, PUBLICKEYBYTES) != 0) continue; - if (peer->config && fastd_peer_config_matches_dynamic(peer->config, address)) { - fastd_resolve_peer(ctx, peer); - errno = EAGAIN; - return NULL; - } - if (fastd_peer_is_floating(peer)) return peer; |