Permalink
Browse files

problem: missing beacon curve support

  • Loading branch information...
wesyoung committed Sep 11, 2017
1 parent f0b8dd8 commit e790b81df8aa45ac5183c4b04b538b3501b0408b
View
@@ -26,3 +26,4 @@ Shannen Saez
Stephen Wolf
Stewart Mackenzie
Victor Perron
Wes Young
View
@@ -102,6 +102,16 @@
<return type = "integer" />
</method>
<method name = "set zcert" state = "draft">
Apply a azcert to a Zyre node.
<argument name = "zcert" type = "zcert"></argument>
</method>
<method name = "beacon set version" state = "draft">
Set the beacon version. Useful when working with ZYREv3 with secure beacons.
<argument name = "version" type = "string"></argument>
</method>
<method name = "gossip bind">
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
@@ -117,6 +127,12 @@
<argument name = "format" type = "format" />
</method>
<method name = "gossip connect curve" state = "draft">
Set-up gossip discovery with CURVE enabled.
<argument name = "public_key" type = "string" />
<argument name = "format" type = "format" />
</method>
<method name = "start">
Start node, after setting header values. When you start a node it
begins discovery and connection. Returns 0 if OK, -1 if it wasn't
@@ -108,6 +108,20 @@ Java_org_zeromq_zyre_Zyre__1_1setEndpoint (JNIEnv *env, jclass c, jlong self, js
return set_endpoint_;
}
JNIEXPORT void JNICALL
Java_org_zeromq_zyre_Zyre__1_1setZcert (JNIEnv *env, jclass c, jlong self, jlong zcert)
{
zyre_set_zcert ((zyre_t *) (intptr_t) self, (zcert_t *) (intptr_t) zcert);
}
JNIEXPORT void JNICALL
Java_org_zeromq_zyre_Zyre__1_1beaconSetVersion (JNIEnv *env, jclass c, jlong self, jstring version)
{
char *version_ = (char *) (*env)->GetStringUTFChars (env, version, NULL);
zyre_beacon_set_version ((zyre_t *) (intptr_t) self, version_);
(*env)->ReleaseStringUTFChars (env, version, version_);
}
JNIEXPORT void JNICALL
Java_org_zeromq_zyre_Zyre__1_1gossipBind (JNIEnv *env, jclass c, jlong self, jstring format)
{
@@ -124,6 +138,16 @@ Java_org_zeromq_zyre_Zyre__1_1gossipConnect (JNIEnv *env, jclass c, jlong self,
(*env)->ReleaseStringUTFChars (env, format, format_);
}
JNIEXPORT void JNICALL
Java_org_zeromq_zyre_Zyre__1_1gossipConnectCurve (JNIEnv *env, jclass c, jlong self, jstring public_key, jstring format)
{
char *public_key_ = (char *) (*env)->GetStringUTFChars (env, public_key, NULL);
char *format_ = (char *) (*env)->GetStringUTFChars (env, format, NULL);
zyre_gossip_connect_curve ((zyre_t *) (intptr_t) self, public_key_, "%s", format_);
(*env)->ReleaseStringUTFChars (env, public_key, public_key_);
(*env)->ReleaseStringUTFChars (env, format, format_);
}
JNIEXPORT jint JNICALL
Java_org_zeromq_zyre_Zyre__1_1start (JNIEnv *env, jclass c, jlong self)
{
@@ -141,6 +141,20 @@ public int setEndpoint (String format) {
return __setEndpoint (self, format);
}
/*
Apply a azcert to a Zyre node.
*/
native static void __setZcert (long self, long zcert);
public void setZcert (Zcert zcert) {
__setZcert (self, zcert.self);
}
/*
Set the beacon version. Useful when working with ZYREv3 with secure beacons.
*/
native static void __beaconSetVersion (long self, String version);
public void beaconSetVersion (String version) {
__beaconSetVersion (self, version);
}
/*
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
it. Note that gossip endpoints are completely distinct from Zyre node
@@ -160,6 +174,13 @@ public void gossipConnect (String format) {
__gossipConnect (self, format);
}
/*
Set-up gossip discovery with CURVE enabled.
*/
native static void __gossipConnectCurve (long self, String publicKey, String format);
public void gossipConnectCurve (String publicKey, String format) {
__gossipConnectCurve (self, publicKey, format);
}
/*
Start node, after setting header values. When you start a node it
begins discovery and connection. Returns 0 if OK, -1 if it wasn't
possible to start the node.
@@ -21,6 +21,7 @@ typedef int SOCKET;
]]
zyre_ffi.ffi.cdef [[
typedef struct _zyre_t zyre_t;
typedef struct _zcert_t zcert_t;
typedef struct _zmsg_t zmsg_t;
typedef struct _zlist_t zlist_t;
typedef struct _zsock_t zsock_t;
@@ -105,6 +106,14 @@ void
int
zyre_set_endpoint (zyre_t *self, const char *format, ...);
// Apply a azcert to a Zyre node.
void
zyre_set_zcert (zyre_t *self, zcert_t *zcert);
// Set the beacon version. Useful when working with ZYREv3 with secure beacons.
void
zyre_beacon_set_version (zyre_t *self, const char *version);
// 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
// it. Note that gossip endpoints are completely distinct from Zyre node
@@ -118,6 +127,10 @@ void
void
zyre_gossip_connect (zyre_t *self, const char *format, ...);
// Set-up gossip discovery with CURVE enabled.
void
zyre_gossip_connect_curve (zyre_t *self, const char *public_key, const char *format, ...);
// Start node, after setting header values. When you start a node it
// begins discovery and connection. Returns 0 if OK, -1 if it wasn't
// possible to start the node.
View
@@ -148,6 +148,18 @@ inproc://, ipc://, or tcp:// transports (for tcp://, use an IP address
that is meaningful to remote as well as local nodes). Returns 0 if
the bind was successful, else -1.
```
nothing my_zyre.setZcert (Zcert)
```
Apply a azcert to a Zyre node.
```
nothing my_zyre.beaconSetVersion (String)
```
Set the beacon version. Useful when working with ZYREv3 with secure beacons.
```
nothing my_zyre.gossipBind (String)
```
@@ -165,6 +177,12 @@ Set-up gossip discovery of other nodes. A node may connect to multiple
other nodes, for redundancy paths. For details of the gossip network
design, see the CZMQ zgossip class.
```
nothing my_zyre.gossipConnectCurve (String, String)
```
Set-up gossip discovery with CURVE enabled.
```
integer my_zyre.start ()
```
View
@@ -44,8 +44,11 @@ NAN_MODULE_INIT (Zyre::Init) {
Nan::SetPrototypeMethod (tpl, "setInterval", _set_interval);
Nan::SetPrototypeMethod (tpl, "setInterface", _set_interface);
Nan::SetPrototypeMethod (tpl, "setEndpoint", _set_endpoint);
Nan::SetPrototypeMethod (tpl, "setZcert", _set_zcert);
Nan::SetPrototypeMethod (tpl, "beaconSetVersion", _beacon_set_version);
Nan::SetPrototypeMethod (tpl, "gossipBind", _gossip_bind);
Nan::SetPrototypeMethod (tpl, "gossipConnect", _gossip_connect);
Nan::SetPrototypeMethod (tpl, "gossipConnectCurve", _gossip_connect_curve);
Nan::SetPrototypeMethod (tpl, "start", _start);
Nan::SetPrototypeMethod (tpl, "stop", _stop);
Nan::SetPrototypeMethod (tpl, "join", _join);
@@ -250,6 +253,27 @@ NAN_METHOD (Zyre::_set_endpoint) {
info.GetReturnValue ().Set (Nan::New<Number>(result));
}
NAN_METHOD (Zyre::_set_zcert) {
Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
Zcert *zcert = Nan::ObjectWrap::Unwrap<Zcert>(info [0].As<Object>());
zyre_set_zcert (zyre->self, zcert->self);
}
NAN_METHOD (Zyre::_beacon_set_version) {
Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
char *version;
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `version`");
else
if (!info [0]->IsString ())
return Nan::ThrowTypeError ("`version` must be a string");
else {
Nan::Utf8String version_utf8 (info [0].As<String>());
version = *version_utf8;
}
zyre_beacon_set_version (zyre->self, (const char *)version);
}
NAN_METHOD (Zyre::_gossip_bind) {
Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
char *format;
@@ -280,6 +304,31 @@ NAN_METHOD (Zyre::_gossip_connect) {
zyre_gossip_connect (zyre->self, "%s", format);
}
NAN_METHOD (Zyre::_gossip_connect_curve) {
Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
char *public_key;
if (info [0]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `public_key`");
else
if (!info [0]->IsString ())
return Nan::ThrowTypeError ("`public_key` must be a string");
else {
Nan::Utf8String public_key_utf8 (info [0].As<String>());
public_key = *public_key_utf8;
}
char *format;
if (info [1]->IsUndefined ())
return Nan::ThrowTypeError ("method requires a `format`");
else
if (!info [1]->IsString ())
return Nan::ThrowTypeError ("`format` must be a string");
else {
Nan::Utf8String format_utf8 (info [1].As<String>());
format = *format_utf8;
}
zyre_gossip_connect_curve (zyre->self, (const char *)public_key, "%s", format);
}
NAN_METHOD (Zyre::_start) {
Zyre *zyre = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ());
int result = zyre_start (zyre->self);
@@ -53,8 +53,11 @@ class Zyre: public Nan::ObjectWrap {
static NAN_METHOD (_set_interval);
static NAN_METHOD (_set_interface);
static NAN_METHOD (_set_endpoint);
static NAN_METHOD (_set_zcert);
static NAN_METHOD (_beacon_set_version);
static NAN_METHOD (_gossip_bind);
static NAN_METHOD (_gossip_connect);
static NAN_METHOD (_gossip_connect_curve);
static NAN_METHOD (_start);
static NAN_METHOD (_stop);
static NAN_METHOD (_join);
@@ -92,10 +92,16 @@ class zyre_event_t(Structure):
lib.zyre_set_interface.argtypes = [zyre_p, c_char_p]
lib.zyre_set_endpoint.restype = c_int
lib.zyre_set_endpoint.argtypes = [zyre_p, c_char_p]
lib.zyre_set_zcert.restype = None
lib.zyre_set_zcert.argtypes = [zyre_p, czmq.zcert_p]
lib.zyre_beacon_set_version.restype = None
lib.zyre_beacon_set_version.argtypes = [zyre_p, c_char_p]
lib.zyre_gossip_bind.restype = None
lib.zyre_gossip_bind.argtypes = [zyre_p, c_char_p]
lib.zyre_gossip_connect.restype = None
lib.zyre_gossip_connect.argtypes = [zyre_p, c_char_p]
lib.zyre_gossip_connect_curve.restype = None
lib.zyre_gossip_connect_curve.argtypes = [zyre_p, c_char_p, c_char_p]
lib.zyre_start.restype = c_int
lib.zyre_start.argtypes = [zyre_p]
lib.zyre_stop.restype = None
@@ -275,6 +281,18 @@ def set_endpoint(self, format, *args):
"""
return lib.zyre_set_endpoint(self._as_parameter_, format, *args)
def set_zcert(self, zcert):
"""
Apply a azcert to a Zyre node.
"""
return lib.zyre_set_zcert(self._as_parameter_, zcert)
def beacon_set_version(self, version):
"""
Set the beacon version. Useful when working with ZYREv3 with secure beacons.
"""
return lib.zyre_beacon_set_version(self._as_parameter_, version)
def gossip_bind(self, format, *args):
"""
Set-up gossip discovery of other nodes. At least one node in the cluster
@@ -292,6 +310,12 @@ def gossip_connect(self, format, *args):
"""
return lib.zyre_gossip_connect(self._as_parameter_, format, *args)
def gossip_connect_curve(self, public_key, format, *args):
"""
Set-up gossip discovery with CURVE enabled.
"""
return lib.zyre_gossip_connect_curve(self._as_parameter_, public_key, format, *args)
def start(self):
"""
Start node, after setting header values. When you start a node it
@@ -118,6 +118,18 @@ def set_endpoint(self, format, ):
"""
return libzyre.zyre_set_endpoint(self._p, format, )
def set_zcert(self, zcert):
"""
Apply a azcert to a Zyre node.
"""
return libzyre.zyre_set_zcert(self._p, zcert._p)
def beacon_set_version(self, version):
"""
Set the beacon version. Useful when working with ZYREv3 with secure beacons.
"""
return libzyre.zyre_beacon_set_version(self._p, to_bytes(version))
def gossip_bind(self, format, ):
"""
Set-up gossip discovery of other nodes. At least one node in the cluster
@@ -135,6 +147,12 @@ def gossip_connect(self, format, ):
"""
return libzyre.zyre_gossip_connect(self._p, format, )
def gossip_connect_curve(self, public_key, format, ):
"""
Set-up gossip discovery with CURVE enabled.
"""
return libzyre.zyre_gossip_connect_curve(self._p, to_bytes(public_key), format, )
def start(self):
"""
Start node, after setting header values. When you start a node it
@@ -9,6 +9,7 @@ zyre_cdefs = list ()
zyre_cdefs.append ('''
typedef struct _zyre_t zyre_t;
typedef struct _zcert_t zcert_t;
typedef struct _zmsg_t zmsg_t;
typedef struct _zlist_t zlist_t;
typedef struct _zsock_t zsock_t;
@@ -93,6 +94,14 @@ void
int
zyre_set_endpoint (zyre_t *self, const char *format, ...);
// Apply a azcert to a Zyre node.
void
zyre_set_zcert (zyre_t *self, zcert_t *zcert);
// Set the beacon version. Useful when working with ZYREv3 with secure beacons.
void
zyre_beacon_set_version (zyre_t *self, const char *version);
// 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
// it. Note that gossip endpoints are completely distinct from Zyre node
@@ -106,6 +115,10 @@ void
void
zyre_gossip_connect (zyre_t *self, const char *format, ...);
// Set-up gossip discovery with CURVE enabled.
void
zyre_gossip_connect_curve (zyre_t *self, const char *public_key, const char *format, ...);
// Start node, after setting header values. When you start a node it
// begins discovery and connection. Returns 0 if OK, -1 if it wasn't
// possible to start the node.
Oops, something went wrong.

0 comments on commit e790b81

Please sign in to comment.