From 48bc75e8a1416745bcd85094628330c6295154fb Mon Sep 17 00:00:00 2001 From: Vincent Tellier Date: Fri, 30 Dec 2016 18:26:56 +0100 Subject: [PATCH] Code formatting + reverted hard error handshake fail - Moved new events in draft section + added to zmq_draft.h - Removed the remainning tabs - Reverted the hard error (back to soft error) in curve_server.cpp => The feature doesn't works anymore --- include/zmq.h | 8 +++++--- src/curve_server.cpp | 13 ++++++------- src/socket_base.cpp | 4 ++-- src/socket_base.hpp | 2 +- src/stream_engine.cpp | 4 ++-- src/zmq_draft.h | 6 +++++- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/zmq.h b/include/zmq.h index be6f962c..004735f9 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -417,8 +417,6 @@ ZMQ_EXPORT const char *zmq_msg_gets (zmq_msg_t *msg, const char *property); #define ZMQ_EVENT_CLOSE_FAILED 0x0100 #define ZMQ_EVENT_DISCONNECTED 0x0200 #define ZMQ_EVENT_MONITOR_STOPPED 0x0400 -#define ZMQ_EVENT_HANDSHAKE_FAILED 0x0800 -#define ZMQ_EVENT_HANDSHAKE_SUCCEED 0x1000 #define ZMQ_EVENT_ALL 0xFFFF ZMQ_EXPORT void *zmq_socket (void *, int type); @@ -563,7 +561,11 @@ ZMQ_EXPORT void zmq_threadclose (void* thread); #define ZMQ_SCATTER 17 #define ZMQ_DGRAM 18 -/* DRAFT Context options */ +/* DRAFT 0MQ socket events and monitoring */ +#define ZMQ_EVENT_HANDSHAKE_FAILED 0x0800 +#define ZMQ_EVENT_HANDSHAKE_SUCCEED 0x1000 + +/* DRAFT Context options */ #define ZMQ_MSG_T_SIZE 6 /* DRAFT Socket methods. */ diff --git a/src/curve_server.cpp b/src/curve_server.cpp index 2230cd08..9b4c4efe 100644 --- a/src/curve_server.cpp +++ b/src/curve_server.cpp @@ -310,14 +310,13 @@ int zmq::curve_server_t::process_hello (msg_t *msg_) sizeof hello_box, hello_nonce, cn_client, secret_key); if (rc != 0) { - // Hard error, the client knows a wrong server public key, it shall not try to reconnect using the same. - status_code = "100"; - state = send_error; - rc = 0; + // Temporary support for security debugging + puts("CURVE I: cannot open client HELLO -- wrong server key?"); + errno = EPROTO; + return -1; } - else - state = send_welcome; - + + state = send_welcome; return rc; } diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 885c270d..27fdfb32 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -1680,12 +1680,12 @@ void zmq::socket_base_t::event_disconnected (const std::string &addr_, zmq::fd_t void zmq::socket_base_t::event_handshake_failed(const std::string &addr_, int err_) { - event(addr_, err_, ZMQ_EVENT_HANDSHAKE_FAILED); + event(addr_, err_, ZMQ_EVENT_HANDSHAKE_FAILED); } void zmq::socket_base_t::event_handshake_succeed(const std::string &addr_, int err_) { - event(addr_, err_, ZMQ_EVENT_HANDSHAKE_SUCCEED); + event(addr_, err_, ZMQ_EVENT_HANDSHAKE_SUCCEED); } void zmq::socket_base_t::event(const std::string &addr_, intptr_t value_, int type_) diff --git a/src/socket_base.hpp b/src/socket_base.hpp index 30fb2c4b..f2074700 100644 --- a/src/socket_base.hpp +++ b/src/socket_base.hpp @@ -134,7 +134,7 @@ namespace zmq void event_close_failed (const std::string &addr_, int err_); void event_disconnected (const std::string &addr_, zmq::fd_t fd_); void event_handshake_failed(const std::string &addr_, int err_); - void event_handshake_succeed(const std::string &addr_, int err_); + void event_handshake_succeed(const std::string &addr_, int err_); protected: diff --git a/src/stream_engine.cpp b/src/stream_engine.cpp index 31df21be..bd7f1436 100644 --- a/src/stream_engine.cpp +++ b/src/stream_engine.cpp @@ -790,8 +790,8 @@ int zmq::stream_engine_t::next_handshake_command (msg_t *msg_) if (rc == 0) msg_->set_flags (msg_t::command); - if(mechanism->status() == mechanism_t::error) - socket->event_handshake_failed(endpoint, 0); + if(mechanism->status() == mechanism_t::error) + socket->event_handshake_failed(endpoint, 0); return rc; } diff --git a/src/zmq_draft.h b/src/zmq_draft.h index 8d5bbd2b..0c8aa71f 100644 --- a/src/zmq_draft.h +++ b/src/zmq_draft.h @@ -46,7 +46,11 @@ #define ZMQ_SCATTER 17 #define ZMQ_DGRAM 18 -/* DRAFT Context options */ +/* DRAFT 0MQ socket events and monitoring */ +#define ZMQ_EVENT_HANDSHAKE_FAILED 0x0800 +#define ZMQ_EVENT_HANDSHAKE_SUCCEED 0x1000 + +/* DRAFT Context options */ #define ZMQ_MSG_T_SIZE 6 /* DRAFT Socket methods. */