mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-13 17:27:57 +08:00
Problem: new DRAFT monitoring events are eligible for STABLE
Solution: do it
This commit is contained in:
parent
d349f93c2b
commit
c347aef794
6
NEWS
6
NEWS
@ -17,6 +17,12 @@
|
||||
NOTE: requires the program to be ran as root OR with CAP_NET_RAW
|
||||
- zmq_timers_* APIs. These functions can be used for cross-platforms timed
|
||||
callbacks. See doc/zmq_timers.txt for details.
|
||||
- The following socket monitor events:
|
||||
- ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL: unknown errors during handshake.
|
||||
- ZMQ_EVENT_HANDSHAKE_SUCCEEDED: Handshake completed with authentication.
|
||||
- ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL: Protocol errors with peers or ZAP.
|
||||
- ZMQ_EVENT_HANDSHAKE_FAILED_AUTH: Failed authentication requests.
|
||||
See doc/zmq_socket_monitor.txt for more details and error codes.
|
||||
|
||||
* The build-time configuration option to select the poller has been split, and
|
||||
new API_POLLER (CMake) and --with-api-poller (autoconf) options will now
|
||||
|
@ -99,20 +99,15 @@ ZMQ_EVENT_MONITOR_STOPPED
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Monitoring on this socket ended.
|
||||
|
||||
DRAFT events - subject to change without notice
|
||||
-----------------------------------------------
|
||||
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Unspecified error during handshake.
|
||||
The event value is an errno.
|
||||
NOTE: in DRAFT state, not yet available in stable releases.
|
||||
|
||||
ZMQ_EVENT_HANDSHAKE_SUCCEEDED
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The ZMTP security mechanism handshake succeeded.
|
||||
The event value is unspecified.
|
||||
NOTE: in DRAFT state, not yet available in stable releases.
|
||||
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -141,14 +136,12 @@ ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA
|
||||
NOTE: in DRAFT state, not yet available in stable releases.
|
||||
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_AUTH
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The ZMTP security mechanism handshake failed due to an authentication failure.
|
||||
The event value is the status code returned by the ZAP handler (i.e. 300,
|
||||
400 or 500).
|
||||
NOTE: in DRAFT state, not yet available in stable releases.
|
||||
|
||||
|
||||
|
||||
|
@ -437,6 +437,38 @@ ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg_,
|
||||
#define ZMQ_EVENT_DISCONNECTED 0x0200
|
||||
#define ZMQ_EVENT_MONITOR_STOPPED 0x0400
|
||||
#define ZMQ_EVENT_ALL 0xFFFF
|
||||
/* Unspecified system errors during handshake. Event value is an errno. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800
|
||||
/* Handshake complete successfully with successful authentication (if *
|
||||
* enabled). Event value is unused. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000
|
||||
/* Protocol errors between ZMTP peers or between server and ZAP handler. *
|
||||
* Event value is one of ZMQ_PROTOCOL_ERROR_* */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000
|
||||
/* Failed authentication requests. Event value is the numeric ZAP status *
|
||||
* code, i.e. 300, 400 or 500. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018
|
||||
// the following two may be due to erroneous configuration of a peer
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005
|
||||
|
||||
ZMQ_EXPORT void *zmq_socket (void *, int type_);
|
||||
ZMQ_EXPORT int zmq_close (void *s_);
|
||||
@ -620,44 +652,6 @@ ZMQ_EXPORT void zmq_threadclose (void *thread_);
|
||||
#define ZMQ_MULTICAST_LOOP 96
|
||||
#define ZMQ_ROUTER_NOTIFY 97
|
||||
|
||||
|
||||
/* DRAFT 0MQ socket events and monitoring */
|
||||
/* Unspecified system errors during handshake. Event value is an errno. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800
|
||||
/* Handshake complete successfully with successful authentication (if *
|
||||
* enabled). Event value is unused. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000
|
||||
/* Protocol errors between ZMTP peers or between server and ZAP handler. *
|
||||
* Event value is one of ZMQ_PROTOCOL_ERROR_* */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000
|
||||
/* Failed authentication requests. Event value is the numeric ZAP status *
|
||||
* code, i.e. 300, 400 or 500. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000
|
||||
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018
|
||||
|
||||
// the following two may be due to erroneous configuration of a peer
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002
|
||||
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005
|
||||
|
||||
/* DRAFT Context options */
|
||||
#define ZMQ_THREAD_AFFINITY_CPU_ADD 7
|
||||
#define ZMQ_THREAD_AFFINITY_CPU_REMOVE 8
|
||||
|
@ -950,9 +950,7 @@ void zmq::stream_engine_t::mechanism_ready ()
|
||||
alloc_assert (_metadata);
|
||||
}
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
_socket->event_handshake_succeeded (_endpoint, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int zmq::stream_engine_t::pull_msg_from_session (msg_t *msg_)
|
||||
@ -1068,7 +1066,6 @@ void zmq::stream_engine_t::error (error_reason_t reason_)
|
||||
_session->push_msg (&disconnect_notification);
|
||||
}
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
// protocol errors have been signaled already at the point where they occurred
|
||||
if (reason_ != protocol_error
|
||||
&& (_mechanism == NULL
|
||||
@ -1076,7 +1073,7 @@ void zmq::stream_engine_t::error (error_reason_t reason_)
|
||||
int err = errno;
|
||||
_socket->event_handshake_failed_no_detail (_endpoint, err);
|
||||
}
|
||||
#endif
|
||||
|
||||
_socket->event_disconnected (_endpoint, _s);
|
||||
_session->flush ();
|
||||
_session->engine_error (reason_);
|
||||
|
@ -57,43 +57,6 @@ unsigned long zmq_stopwatch_intermediate (void *watch_);
|
||||
#define ZMQ_MULTICAST_LOOP 96
|
||||
#define ZMQ_ROUTER_NOTIFY 97
|
||||
|
||||
/* DRAFT 0MQ socket events and monitoring */
|
||||
/* Unspecified system errors during handshake. Event value is an errno. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800
|
||||
/* Handshake complete successfully with successful authentication (if *
|
||||
* enabled). Event value is unused. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000
|
||||
/* Protocol errors between ZMTP peers or between server and ZAP handler. *
|
||||
* Event value is one of ZMQ_PROTOCOL_ERROR_* */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000
|
||||
/* Failed authentication requests. Event value is the numeric ZAP status *
|
||||
* code, i.e. 300, 400 or 500. */
|
||||
#define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000
|
||||
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018
|
||||
|
||||
// the following two may be due to erroneous configuration of a peer
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002
|
||||
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004
|
||||
#define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005
|
||||
|
||||
/* DRAFT Context options */
|
||||
#define ZMQ_THREAD_AFFINITY_CPU_ADD 7
|
||||
#define ZMQ_THREAD_AFFINITY_CPU_REMOVE 8
|
||||
|
@ -86,17 +86,13 @@ int main (void)
|
||||
if (event == ZMQ_EVENT_CONNECT_DELAYED)
|
||||
event = get_monitor_event (client_mon, NULL, NULL);
|
||||
assert (event == ZMQ_EVENT_CONNECTED);
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event (client_mon, ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
|
||||
#endif
|
||||
expect_monitor_event (client_mon, ZMQ_EVENT_MONITOR_STOPPED);
|
||||
|
||||
// This is the flow of server events
|
||||
expect_monitor_event (server_mon, ZMQ_EVENT_LISTENING);
|
||||
expect_monitor_event (server_mon, ZMQ_EVENT_ACCEPTED);
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event (server_mon, ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
|
||||
#endif
|
||||
event = get_monitor_event (server_mon, NULL, NULL);
|
||||
// Sometimes the server sees the client closing before it gets closed.
|
||||
if (event != ZMQ_EVENT_DISCONNECTED) {
|
||||
|
@ -125,7 +125,6 @@ void test_null_key (void *ctx_,
|
||||
expect_new_client_curve_bounce_fail (ctx_, server_public_, client_public_,
|
||||
client_secret_, my_endpoint_, server_);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
int handshake_failed_encryption_event_count =
|
||||
expect_monitor_event_multiple (server_mon_,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
@ -142,7 +141,6 @@ void test_null_key (void *ctx_,
|
||||
"ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL/"
|
||||
"ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC events: %i\n",
|
||||
handshake_failed_encryption_event_count);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_curve_security_with_valid_credentials ()
|
||||
@ -157,7 +155,6 @@ void test_curve_security_with_valid_credentials ()
|
||||
int rc = zmq_close (client);
|
||||
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
int event = get_monitor_event_with_timeout (server_mon, NULL, NULL, -1);
|
||||
assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
|
||||
|
||||
@ -170,7 +167,6 @@ void test_curve_security_with_valid_credentials ()
|
||||
|
||||
rc = zmq_close (client_mon);
|
||||
TEST_ASSERT_ZMQ_ERRNO (rc == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_curve_security_with_bogus_client_credentials ()
|
||||
@ -180,22 +176,14 @@ void test_curve_security_with_bogus_client_credentials ()
|
||||
char bogus_secret[41];
|
||||
zmq_curve_keypair (bogus_public, bogus_secret);
|
||||
|
||||
expect_new_client_curve_bounce_fail (ctx, valid_server_public, bogus_public,
|
||||
bogus_secret, my_endpoint, server,
|
||||
NULL,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 400
|
||||
#else
|
||||
0, 0
|
||||
#endif
|
||||
);
|
||||
expect_new_client_curve_bounce_fail (
|
||||
ctx, valid_server_public, bogus_public, bogus_secret, my_endpoint, server,
|
||||
NULL, ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 400);
|
||||
|
||||
int server_event_count = 0;
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
server_event_count = expect_monitor_event_multiple (
|
||||
server_mon, ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 400);
|
||||
TEST_ASSERT_LESS_OR_EQUAL_INT (1, server_event_count);
|
||||
#endif
|
||||
|
||||
// there may be more than one ZAP request due to repeated attempts by the client
|
||||
TEST_ASSERT (0 == server_event_count
|
||||
@ -213,11 +201,9 @@ void expect_zmtp_mechanism_mismatch (void *client_,
|
||||
expect_bounce_fail (server_, client_);
|
||||
close_zero_linger (client_);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (server_mon_,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH);
|
||||
#endif
|
||||
|
||||
TEST_ASSERT_EQUAL_INT (0, zmq_atomic_counter_value (zap_requests_handled));
|
||||
}
|
||||
@ -314,11 +300,9 @@ void test_curve_security_invalid_hello_wrong_length ()
|
||||
// send CURVE HELLO of wrong size
|
||||
send (s, "\x04\x06\x05HELLO");
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (
|
||||
server_mon, ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
@ -391,11 +375,9 @@ void test_curve_security_invalid_hello_command_name ()
|
||||
|
||||
send_command (s, hello);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
@ -416,11 +398,9 @@ void test_curve_security_invalid_hello_version ()
|
||||
|
||||
send_command (s, hello);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (
|
||||
server_mon, ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
@ -480,20 +460,14 @@ void test_curve_security_invalid_initiate_wrong_length ()
|
||||
// receive but ignore WELCOME
|
||||
flush_read (s);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
int res = get_monitor_event_with_timeout (server_mon, NULL, NULL, timeout);
|
||||
TEST_ASSERT_EQUAL_INT (-1, res);
|
||||
#else
|
||||
LIBZMQ_UNUSED (timeout);
|
||||
#endif
|
||||
|
||||
send (s, "\x04\x09\x08INITIATE");
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (
|
||||
server_mon, ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
@ -514,10 +488,8 @@ fd_t connect_exchange_greeting_and_hello_welcome (
|
||||
int res = tools_.process_welcome (welcome + 2, welcome_length, cn_precom);
|
||||
TEST_ASSERT_ZMQ_ERRNO (res == 0);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
res = get_monitor_event_with_timeout (server_mon_, NULL, NULL, timeout_);
|
||||
TEST_ASSERT_EQUAL_INT (-1, res);
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -535,11 +507,9 @@ void test_curve_security_invalid_initiate_command_name ()
|
||||
|
||||
send_command (s, initiate);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
@ -557,11 +527,9 @@ void test_curve_security_invalid_initiate_command_encrypted_cookie ()
|
||||
|
||||
send_command (s, initiate);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
@ -579,11 +547,9 @@ void test_curve_security_invalid_initiate_command_encrypted_content ()
|
||||
|
||||
send_command (s, initiate);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
expect_monitor_event_multiple (server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC);
|
||||
#endif
|
||||
|
||||
close (s);
|
||||
}
|
||||
|
@ -58,8 +58,6 @@ static volatile int zap_deny_all = 0;
|
||||
// Read one event off the monitor socket; return value and address
|
||||
// by reference, if not null, and event number by value. Returns -1
|
||||
// in case of error.
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
static int get_monitor_event (void *monitor_, int *value_, char **address_)
|
||||
{
|
||||
// First frame in message contains event number and value
|
||||
@ -92,7 +90,6 @@ static int get_monitor_event (void *monitor_, int *value_, char **address_)
|
||||
|
||||
return event;
|
||||
}
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// This methods receives and validates ZAP requestes (allowing or denying
|
||||
@ -167,10 +164,8 @@ void test_valid_creds (void *ctx_,
|
||||
rc = zmq_close (client);
|
||||
assert (rc == 0);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
int event = get_monitor_event (server_mon_, NULL, NULL);
|
||||
assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check security with valid but unauthorized credentials
|
||||
@ -199,10 +194,8 @@ void test_unauth_creds (void *ctx_,
|
||||
expect_bounce_fail (server_, client);
|
||||
close_zero_linger (client);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
int event = get_monitor_event (server_mon_, NULL, NULL);
|
||||
assert (event == ZMQ_EVENT_HANDSHAKE_FAILED_AUTH);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check GSSAPI security with NULL client credentials
|
||||
@ -219,12 +212,10 @@ void test_null_creds (void *ctx_,
|
||||
expect_bounce_fail (server_, client);
|
||||
close_zero_linger (client);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
int error;
|
||||
int event = get_monitor_event (server_mon_, &error, NULL);
|
||||
assert (event == ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL);
|
||||
assert (error == ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check GSSAPI security with PLAIN client credentials
|
||||
@ -324,21 +315,17 @@ int main (void)
|
||||
rc = zmq_getsockopt (server, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
|
||||
assert (rc == 0);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
// Monitor handshake events on the server
|
||||
rc = zmq_socket_monitor (server, "inproc://monitor-server",
|
||||
ZMQ_EVENT_HANDSHAKE_SUCCEEDED
|
||||
| ZMQ_EVENT_HANDSHAKE_FAILED_AUTH
|
||||
| ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL);
|
||||
assert (rc == 0);
|
||||
#endif
|
||||
|
||||
// Create socket for collecting monitor events
|
||||
void *server_mon = NULL;
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
server_mon = zmq_socket (ctx, ZMQ_PAIR);
|
||||
assert (server_mon);
|
||||
#endif
|
||||
|
||||
// Connect it to the inproc endpoints so they'll get events
|
||||
rc = zmq_connect (server_mon, "inproc://monitor-server");
|
||||
@ -352,9 +339,7 @@ int main (void)
|
||||
test_unauth_creds (ctx, server, server_mon, my_endpoint);
|
||||
|
||||
// Shutdown
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
close_zero_linger (server_mon);
|
||||
#endif
|
||||
rc = zmq_close (server);
|
||||
assert (rc == 0);
|
||||
rc = zmq_ctx_term (ctx);
|
||||
|
@ -92,10 +92,8 @@ int expect_new_client_bounce_fail_and_count_monitor_events (
|
||||
client_mon_, expected_client_event_, expected_client_value_);
|
||||
|
||||
int events_received = 0;
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
events_received = expect_monitor_event_multiple (
|
||||
server_mon_, expected_server_event_, expected_server_value_);
|
||||
#endif
|
||||
|
||||
return events_received;
|
||||
}
|
||||
@ -139,13 +137,9 @@ void test_zap_unsuccessful_no_handler (void *ctx_,
|
||||
ctx_, my_endpoint_, server_, socket_config_, socket_config_data_,
|
||||
client_mon_, server_mon_, expected_event_, expected_err_);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
// there may be more than one ZAP request due to repeated attempts by the
|
||||
// client
|
||||
assert (events_received > 0);
|
||||
#else
|
||||
LIBZMQ_UNUSED (events_received);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_zap_protocol_error (void *ctx_,
|
||||
@ -157,11 +151,7 @@ void test_zap_protocol_error (void *ctx_,
|
||||
int expected_error_)
|
||||
{
|
||||
test_zap_unsuccessful (ctx_, my_endpoint_, server_, server_mon_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL, expected_error_,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
socket_config_, socket_config_data_);
|
||||
}
|
||||
|
||||
@ -173,22 +163,15 @@ void test_zap_unsuccessful_status_300 (void *ctx_,
|
||||
void *client_socket_config_data_)
|
||||
{
|
||||
void *client_mon;
|
||||
test_zap_unsuccessful (ctx_, my_endpoint_, server_, server_mon_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 300,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
client_socket_config_, client_socket_config_data_,
|
||||
&client_mon);
|
||||
test_zap_unsuccessful (
|
||||
ctx_, my_endpoint_, server_, server_mon_, ZMQ_EVENT_HANDSHAKE_FAILED_AUTH,
|
||||
300, client_socket_config_, client_socket_config_data_, &client_mon);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
// we can use a 0 timeout here, since the client socket is already closed
|
||||
assert_no_more_monitor_events_with_timeout (client_mon, 0);
|
||||
|
||||
int rc = zmq_close (client_mon);
|
||||
assert (rc == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_zap_unsuccessful_status_500 (void *ctx_,
|
||||
@ -199,19 +182,9 @@ void test_zap_unsuccessful_status_500 (void *ctx_,
|
||||
void *client_socket_config_data_)
|
||||
{
|
||||
test_zap_unsuccessful (ctx_, my_endpoint_, server_, server_mon_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 500,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
client_socket_config_, client_socket_config_data_,
|
||||
NULL,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 500
|
||||
#else
|
||||
0, 0
|
||||
#endif
|
||||
);
|
||||
NULL, ZMQ_EVENT_HANDSHAKE_FAILED_AUTH, 500);
|
||||
}
|
||||
|
||||
void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
@ -236,12 +209,7 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
server_socket_config_data_);
|
||||
test_zap_protocol_error (ctx, my_endpoint, server, server_mon,
|
||||
client_socket_config_, client_socket_config_data_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
|
||||
@ -253,12 +221,7 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
server_socket_config_data_);
|
||||
test_zap_protocol_error (ctx, my_endpoint, server, server_mon,
|
||||
client_socket_config_, client_socket_config_data_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
|
||||
@ -270,12 +233,7 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
server_socket_config_data_);
|
||||
test_zap_protocol_error (ctx, my_endpoint, server, server_mon,
|
||||
client_socket_config_, client_socket_config_data_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
|
||||
@ -287,12 +245,7 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
server_socket_config_data_);
|
||||
test_zap_protocol_error (ctx, my_endpoint, server, server_mon,
|
||||
client_socket_config_, client_socket_config_data_,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
|
||||
@ -332,14 +285,10 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
&ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint, NULL,
|
||||
server_socket_config_,
|
||||
server_socket_config_data_ ? server_socket_config_data_ : &enforce);
|
||||
test_zap_unsuccessful_no_handler (
|
||||
ctx, my_endpoint, server, server_mon,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL, EFAULT,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
client_socket_config_, client_socket_config_data_);
|
||||
test_zap_unsuccessful_no_handler (ctx, my_endpoint, server, server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL,
|
||||
EFAULT, client_socket_config_,
|
||||
client_socket_config_data_);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
#endif
|
||||
@ -349,14 +298,10 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
setup_context_and_server_side (
|
||||
&ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint,
|
||||
&zap_handler_disconnect, server_socket_config_);
|
||||
test_zap_unsuccessful_no_handler (
|
||||
ctx, my_endpoint, server, server_mon,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL, EPIPE,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
client_socket_config_, client_socket_config_data_);
|
||||
test_zap_unsuccessful_no_handler (ctx, my_endpoint, server, server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL,
|
||||
EPIPE, client_socket_config_,
|
||||
client_socket_config_data_);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler, true);
|
||||
|
||||
@ -366,14 +311,10 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
setup_context_and_server_side (
|
||||
&ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint,
|
||||
&zap_handler_do_not_recv, server_socket_config_);
|
||||
test_zap_unsuccessful_no_handler (
|
||||
ctx, my_endpoint, server, server_mon,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL, EPIPE,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
client_socket_config_, client_socket_config_data_);
|
||||
test_zap_unsuccessful_no_handler (ctx, my_endpoint, server, server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL,
|
||||
EPIPE, client_socket_config_,
|
||||
client_socket_config_data_);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
|
||||
@ -383,14 +324,10 @@ void test_zap_errors (socket_config_fn server_socket_config_,
|
||||
setup_context_and_server_side (
|
||||
&ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint,
|
||||
&zap_handler_do_not_send, server_socket_config_);
|
||||
test_zap_unsuccessful_no_handler (
|
||||
ctx, my_endpoint, server, server_mon,
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL, EPIPE,
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
client_socket_config_, client_socket_config_data_);
|
||||
test_zap_unsuccessful_no_handler (ctx, my_endpoint, server, server_mon,
|
||||
ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL,
|
||||
EPIPE, client_socket_config_,
|
||||
client_socket_config_data_);
|
||||
shutdown_context_and_server_side (ctx, zap_thread, server, server_mon,
|
||||
handler);
|
||||
}
|
||||
|
@ -409,8 +409,6 @@ void expect_monitor_event (void *monitor_, int expected_event_)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
|
||||
void print_unexpected_event (int event_,
|
||||
int err_,
|
||||
int expected_event_,
|
||||
@ -506,14 +504,11 @@ int expect_monitor_event_multiple (void *server_mon_,
|
||||
assert (event_count == 0); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void setup_handshake_socket_monitor (void *ctx_,
|
||||
void *server_,
|
||||
void **server_mon_,
|
||||
const char *monitor_endpoint_)
|
||||
{
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
// Monitor handshake events on the server
|
||||
int rc = zmq_socket_monitor (server_, monitor_endpoint_,
|
||||
ZMQ_EVENT_HANDSHAKE_SUCCEEDED
|
||||
@ -532,7 +527,6 @@ void setup_handshake_socket_monitor (void *ctx_,
|
||||
// Connect it to the inproc endpoints so they'll get events
|
||||
rc = zmq_connect (*server_mon_, monitor_endpoint_);
|
||||
assert (rc == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup_context_and_server_side (
|
||||
@ -616,10 +610,8 @@ void shutdown_context_and_server_side (void *ctx_,
|
||||
int rc = zmq_close (zap_control_);
|
||||
assert (rc == 0);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
rc = zmq_close (server_mon_);
|
||||
assert (rc == 0);
|
||||
#endif
|
||||
rc = zmq_close (server_);
|
||||
assert (rc == 0);
|
||||
|
||||
@ -672,7 +664,6 @@ void expect_new_client_bounce_fail (void *ctx_,
|
||||
ctx_, my_endpoint_, socket_config_, socket_config_data_, client_mon_);
|
||||
expect_bounce_fail (server_, client);
|
||||
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
if (expected_client_event_ != 0) {
|
||||
int events_received = 0;
|
||||
events_received = expect_monitor_event_multiple (
|
||||
@ -683,7 +674,6 @@ void expect_new_client_bounce_fail (void *ctx_,
|
||||
int rc = zmq_close (my_client_mon);
|
||||
assert (rc == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
close_zero_linger (client);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user