Permalink
Browse files

problem: can't require peer from outside the actor

This enables an external discovery actor to introduce zyre nodes.
  • Loading branch information...
JustinAzoff committed Sep 16, 2017
1 parent d314e60 commit bcdaab65801fa7c0d53244b03f712c8ed6f3820e
Showing with 37 additions and 0 deletions.
  1. +5 −0 include/zyre.h
  2. +9 −0 src/zyre.c
  3. +23 −0 src/zyre_node.c
View
@@ -225,6 +225,11 @@ ZYRE_EXPORT void
ZYRE_EXPORT void
zyre_gossip_connect_curve (zyre_t *self, const char *public_key, const char *format, ...) CHECK_PRINTF (3);
// *** Draft method, for development use, may change without warning ***
// Explicitly connect to a peer
ZYRE_EXPORT int
zyre_require_peer (zyre_t *self, const char *uuid, const char *endpoint, const char *public_key);
#endif // ZYRE_BUILD_DRAFT_API
// @end
View
@@ -286,6 +286,15 @@ void zyre_set_zcert(zyre_t *self, zcert_t *zcert)
zstr_sendx (self->actor, "SET SECRETKEY", zcert_secret_txt(zcert), NULL);
}
// Explicitly connect to a peer
int
zyre_require_peer (zyre_t *self, const char *uuid, const char *endpoint, const char *public_key)
{
assert (self);
return zstr_sendx (self->actor, "REQUIRE PEER", uuid, endpoint, public_key, NULL);
}
// --------------------------------------------------------------------------
// Set-up gossip discovery of other nodes. At least one node in the cluster
// must bind to a well-known gossip endpoint, so other nodes can connect to
View
@@ -397,6 +397,12 @@ zyre_node_dump (zyre_node_t *self)
// Here we handle the different control messages from the front-end
#ifdef ZYRE_BUILD_DRAFT_API
// Forward declaration so that REQUIRE PEER works
static zyre_peer_t *
zyre_node_require_peer (zyre_node_t *self, zuuid_t *uuid, const char *endpoint, const char *public_key);
#endif
static void
zyre_node_recv_api (zyre_node_t *self)
{
@@ -601,6 +607,23 @@ zyre_node_recv_api (zyre_node_t *self)
else
if (streq (command, "PEERS"))
zsock_send (self->pipe, "p", zhash_keys (self->peers));
#ifdef ZYRE_BUILD_DRAFT_API
else
if (streq (command, "REQUIRE PEER")) {
char *uuidstr = zmsg_popstr (request);
char *endpoint = zmsg_popstr (request);
char *public_key = zmsg_popstr (request);
if (strneq (endpoint, self->endpoint)) {
zuuid_t *uuid = zuuid_new ();
zuuid_set_str (uuid, uuidstr);
zyre_node_require_peer (self, uuid, endpoint, public_key);
zuuid_destroy (&uuid);
}
zstr_free (&uuidstr);
zstr_free (&endpoint);
zstr_free (&public_key);
}
#endif
else
if (streq (command, "GROUP PEERS")) {
char *name = zmsg_popstr (request);

0 comments on commit bcdaab6

Please sign in to comment.