summaryrefslogtreecommitdiffstats
path: root/src/protocol_ec25519_fhmqvc.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-11-05 22:24:42 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-11-05 22:24:42 +0100
commit8f60a96b84b1f952b0f3073e5df52f024162ef4b (patch)
tree7f4374bf7e0f1d10bc238093b1de9c264692a3f6 /src/protocol_ec25519_fhmqvc.c
parentf631c10660c7c0bcdbf793bb1588670fb9ea82e6 (diff)
downloadfastd-8f60a96b84b1f952b0f3073e5df52f024162ef4b.tar
fastd-8f60a96b84b1f952b0f3073e5df52f024162ef4b.zip
Implement peer limit constraints
Diffstat (limited to 'src/protocol_ec25519_fhmqvc.c')
-rw-r--r--src/protocol_ec25519_fhmqvc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c
index f2582f2..6ebb771 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocol_ec25519_fhmqvc.c
@@ -559,6 +559,11 @@ static void protocol_handshake_handle(fastd_context *ctx, fastd_socket *sock, co
fastd_peer *peer = get_peer(ctx, peer_conf);
+ if (!fastd_peer_may_connect(ctx, peer)) {
+ pr_debug(ctx, "ignoring handshake from %P[%I] because of local constraints", peer, address);
+ return;
+ }
+
if (backoff(ctx, peer)) {
pr_debug(ctx, "received repeated handshakes from %P[%I], ignoring", peer, address);
return;
@@ -726,7 +731,7 @@ static void session_send(fastd_context *ctx, fastd_peer *peer, fastd_buffer buff
}
static void protocol_send(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) {
- if (!peer->protocol_state || !is_session_valid(ctx, &peer->protocol_state->session)) {
+ if (!peer->protocol_state || !fastd_peer_is_established(peer) || !is_session_valid(ctx, &peer->protocol_state->session)) {
fastd_buffer_free(buffer);
return;
}