summaryrefslogtreecommitdiffstats
path: root/src/async.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-26 00:46:33 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-26 22:46:05 +0200
commit36690c7203f0e46665f328fbe82ae3bd573cc6ff (patch)
tree761707cbd83e499913277fc931e32d05bf3c32cc /src/async.c
parent64ce1c0f51b4d0c07c124071ea2cd8002eccd45d (diff)
downloadfastd-36690c7203f0e46665f328fbe82ae3bd573cc6ff.tar
fastd-36690c7203f0e46665f328fbe82ae3bd573cc6ff.zip
Implement async verify
Diffstat (limited to 'src/async.c')
-rw-r--r--src/async.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/async.c b/src/async.c
index cb9ee14..982543d 100644
--- a/src/async.c
+++ b/src/async.c
@@ -41,9 +41,7 @@ void fastd_async_init(void) {
fastd_setfl(ctx.async_wfd, O_NONBLOCK, 0);
}
-static void handle_resolve_return(const void *buf) {
- const fastd_async_resolve_return_t *resolve_return = buf;
-
+static void handle_resolve_return(const fastd_async_resolve_return_t *resolve_return) {
fastd_peer_t *peer = fastd_peer_find_by_id(resolve_return->peer_id);
if (!peer)
return;
@@ -55,6 +53,20 @@ static void handle_resolve_return(const void *buf) {
fastd_peer_handle_resolve(peer, remote, resolve_return->n_addr, resolve_return->addr);
}
+static void handle_verify_return(const fastd_async_verify_return_t *verify_return) {
+ fastd_peer_t *peer = fastd_peer_find_by_id(verify_return->peer_id);
+ if (!peer)
+ return;
+
+ if (peer->config)
+ exit_bug("verify return for permanent peer");
+
+ fastd_peer_set_verified(peer, verify_return->ok);
+
+ conf.protocol->handle_verify_return(peer, verify_return->sock, &verify_return->local_addr, &verify_return->remote_addr,
+ verify_return->method, verify_return->protocol_data, verify_return->ok);
+}
+
void fastd_async_handle(void) {
fastd_async_hdr_t header;
struct iovec vec[2] = {
@@ -82,7 +94,11 @@ void fastd_async_handle(void) {
switch (header.type) {
case ASYNC_TYPE_RESOLVE_RETURN:
- handle_resolve_return(buf);
+ handle_resolve_return((const fastd_async_resolve_return_t *)buf);
+ break;
+
+ case ASYNC_TYPE_VERIFY_RETURN:
+ handle_verify_return((const fastd_async_verify_return_t *)buf);
break;
default: