Commit acaaaa53 authored by Ian Barber's avatar Ian Barber

Merge pull request #585 from hintjens/master

Problem: allows CURVE security even if libzmq was built without libsodium
parents 675bd464 fadfcac1
...@@ -180,6 +180,7 @@ Option value unit:: milliseconds ...@@ -180,6 +180,7 @@ Option value unit:: milliseconds
Default value:: 10000 Default value:: 10000
Applicable socket types:: all, when using multicast transports Applicable socket types:: all, when using multicast transports
ZMQ_SNDBUF: Set kernel transmit buffer size ZMQ_SNDBUF: Set kernel transmit buffer size
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size
......
...@@ -102,8 +102,8 @@ int zmq::lb_t::send (msg_t *msg_) ...@@ -102,8 +102,8 @@ int zmq::lb_t::send (msg_t *msg_)
return -1; return -1;
} }
// If it's final part of the message we can fluch it downstream and // If it's final part of the message we can flush it downstream and
// continue round-robinning (load balance). // continue round-robining (load balance).
more = msg_->flags () & msg_t::more? true: false; more = msg_->flags () & msg_t::more? true: false;
if (!more) { if (!more) {
pipes [current]->flush (); pipes [current]->flush ();
......
...@@ -286,6 +286,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, ...@@ -286,6 +286,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break; break;
case ZMQ_CURVE_SERVER: case ZMQ_CURVE_SERVER:
# ifndef HAVE_LIBSODIUM
puts ("E: libzmq was not built using libsodium, CURVE not available");
assert (false);
# endif
if (is_int && (value == 0 || value == 1)) { if (is_int && (value == 0 || value == 1)) {
as_server = value; as_server = value;
mechanism = value? ZMQ_CURVE: ZMQ_NULL; mechanism = value? ZMQ_CURVE: ZMQ_NULL;
...@@ -294,6 +298,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, ...@@ -294,6 +298,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break; break;
case ZMQ_CURVE_PUBLICKEY: case ZMQ_CURVE_PUBLICKEY:
# ifndef HAVE_LIBSODIUM
puts ("E: libzmq was not built using libsodium, CURVE not available");
assert (false);
# endif
if (optvallen_ == CURVE_KEYSIZE) { if (optvallen_ == CURVE_KEYSIZE) {
memcpy (curve_public_key, optval_, CURVE_KEYSIZE); memcpy (curve_public_key, optval_, CURVE_KEYSIZE);
mechanism = ZMQ_CURVE; mechanism = ZMQ_CURVE;
...@@ -302,6 +310,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, ...@@ -302,6 +310,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break; break;
case ZMQ_CURVE_SECRETKEY: case ZMQ_CURVE_SECRETKEY:
# ifndef HAVE_LIBSODIUM
puts ("E: libzmq was not built using libsodium, CURVE not available");
assert (false);
# endif
if (optvallen_ == CURVE_KEYSIZE) { if (optvallen_ == CURVE_KEYSIZE) {
memcpy (curve_secret_key, optval_, CURVE_KEYSIZE); memcpy (curve_secret_key, optval_, CURVE_KEYSIZE);
mechanism = ZMQ_CURVE; mechanism = ZMQ_CURVE;
...@@ -310,6 +322,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, ...@@ -310,6 +322,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break; break;
case ZMQ_CURVE_SERVERKEY: case ZMQ_CURVE_SERVERKEY:
# ifndef HAVE_LIBSODIUM
puts ("E: libzmq was not built using libsodium, CURVE not available");
assert (false);
# endif
if (optvallen_ == CURVE_KEYSIZE) { if (optvallen_ == CURVE_KEYSIZE) {
memcpy (curve_server_key, optval_, CURVE_KEYSIZE); memcpy (curve_server_key, optval_, CURVE_KEYSIZE);
as_server = 0; as_server = 0;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "../include/zmq.h" #include "../include/zmq.h"
#include <pthread.h> #include <pthread.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include "testutil.hpp" #include "testutil.hpp"
// REQ socket events handled // REQ socket events handled
...@@ -215,7 +216,7 @@ int main (void) ...@@ -215,7 +216,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
rc = pthread_create (&threads [1], NULL, req_socket_monitor, ctx); rc = pthread_create (&threads [1], NULL, req_socket_monitor, ctx);
assert (rc == 0); assert (rc == 0);
sleep(1); sleep (1);
// Bind REQ and REP // Bind REQ and REP
rc = zmq_bind (rep, addr.c_str()); rc = zmq_bind (rep, addr.c_str());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment