diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-26 00:46:33 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-26 22:46:05 +0200 |
commit | 36690c7203f0e46665f328fbe82ae3bd573cc6ff (patch) | |
tree | 761707cbd83e499913277fc931e32d05bf3c32cc /src/peer.c | |
parent | 64ce1c0f51b4d0c07c124071ea2cd8002eccd45d (diff) | |
download | fastd-36690c7203f0e46665f328fbe82ae3bd573cc6ff.tar fastd-36690c7203f0e46665f328fbe82ae3bd573cc6ff.zip |
Implement async verify
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 42 |
1 files changed, 8 insertions, 34 deletions
@@ -688,7 +688,8 @@ fastd_peer_t* fastd_peer_add(fastd_peer_config_t *peer_conf) { peer->group = ctx.peer_group; - fastd_peer_seen(peer); + peer->verify_timeout = ctx.now; + peer->verify_valid_timeout = ctx.now; pr_debug("adding temporary peer"); } @@ -701,35 +702,6 @@ fastd_peer_t* fastd_peer_add(fastd_peer_config_t *peer_conf) { return peer; } -bool fastd_peer_verify_temporary(fastd_peer_t *peer, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *peer_addr) { - if (!fastd_shell_command_isset(&conf.on_verify)) - exit_bug("tried to verify temporary peer without on-verify command"); - - /* TODO: async not supported yet */ - - fastd_shell_env_t *env = fastd_shell_env_alloc(); - fastd_peer_set_shell_env(env, peer, local_addr, peer_addr); - - int ret; - bool ok = fastd_shell_command_exec_sync(&conf.on_verify, env, &ret); - - fastd_shell_env_free(env); - - if (!ok) - return false; - - if (WIFSIGNALED(ret)) { - pr_error("verify command exited with signal %i", WTERMSIG(ret)); - return false; - } - else if (WEXITSTATUS(ret)) { - pr_debug("verify command exited with status %i", WEXITSTATUS(ret)); - return false; - } - - return true; -} - static inline void no_valid_address_debug(const fastd_peer_t *peer) { pr_debug("not sending a handshake to %P (no valid address resolved)", peer); } @@ -895,14 +867,16 @@ static bool maintain_peer(fastd_peer_t *peer) { if (fastd_peer_is_temporary(peer) || fastd_peer_is_established(peer)) { /* check for peer timeout */ if (fastd_timed_out(&peer->timeout)) { - if (fastd_peer_is_temporary(peer)) { + if (fastd_peer_is_temporary(peer) && + fastd_timed_out(&peer->verify_timeout) && + fastd_timed_out(&peer->verify_valid_timeout)) { fastd_peer_delete(peer); return false; } - else { + + if (fastd_peer_is_established(peer)) fastd_peer_reset(peer); - return true; - } + return true; } /* check for keepalive timeout */ |