X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=examples%2Fchat.c;h=88fe127a1df25368512078c89868a0dddc2336c6;hb=f3e15df2c965d014a3281416e502be96170063e8;hp=c26a642de5fef96b59cadec75752814b2429f4a5;hpb=dc0e52cb3e42620c3139e713b373d130aa30b698;p=meshlink diff --git a/examples/chat.c b/examples/chat.c index c26a642d..88fe127a 100644 --- a/examples/chat.c +++ b/examples/chat.c @@ -59,7 +59,7 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { return; } - invitation = meshlink_invite(mesh, arg); + invitation = meshlink_invite(mesh, NULL, arg); if(!invitation) { fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); @@ -99,9 +99,31 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { return; } - meshlink_blacklist(mesh, node); + if(!meshlink_blacklist(mesh, node)) { + fprintf(stderr, "Error blacklising '%s': %s", arg, meshlink_strerror(meshlink_errno)); + return; + } printf("Node '%s' blacklisted.\n", arg); + } else if(!strcasecmp(buf, "whitelist")) { + if(!arg) { + fprintf(stderr, "/whitelist requires an argument!\n"); + return; + } + + meshlink_node_t *node = meshlink_get_node(mesh, arg); + + if(!node) { + fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); + return; + } + + if(!meshlink_whitelist(mesh, node)) { + fprintf(stderr, "Error whitelising '%s': %s", arg, meshlink_strerror(meshlink_errno)); + return; + } + + printf("Node '%s' whitelisted.\n", arg); } else if(!strcasecmp(buf, "who")) { if(!arg) { nodes = meshlink_get_all_nodes(mesh, nodes, &nnodes);