From e7fda86ce272e5f53a4c3900344b90adb7df8335 Mon Sep 17 00:00:00 2001 From: Markus Rothe Date: Wed, 18 Sep 2013 11:01:49 +0200 Subject: [PATCH 1/2] test_connect_delay: don't listen on public interfaces Tests should only bind to local interfaces. Change listening address from '*' to '127.0.0.1'. Also change instances of 'localhost' to '127.0.0.1' as used in all other tests in this directory. --- tests/test_connect_delay.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_connect_delay.cpp b/tests/test_connect_delay.cpp index db2bd54b..064d9d70 100644 --- a/tests/test_connect_delay.cpp +++ b/tests/test_connect_delay.cpp @@ -48,7 +48,7 @@ int main (void) val = 0; rc = zmq_setsockopt(to, ZMQ_LINGER, &val, sizeof(val)); assert (rc == 0); - rc = zmq_bind (to, "tcp://*:6555"); + rc = zmq_bind (to, "tcp://127.0.0.1:6555"); assert (rc == 0); // Create a socket pushing to two endpoints - only 1 message should arrive. @@ -58,10 +58,10 @@ int main (void) val = 0; zmq_setsockopt (from, ZMQ_LINGER, &val, sizeof (val)); // This pipe will not connect - rc = zmq_connect (from, "tcp://localhost:5556"); + rc = zmq_connect (from, "tcp://127.0.0.1:5556"); assert (rc == 0); // This pipe will - rc = zmq_connect (from, "tcp://localhost:6555"); + rc = zmq_connect (from, "tcp://127.0.0.1:6555"); assert (rc == 0); // We send 10 messages, 5 should just get stuck in the queue @@ -107,7 +107,7 @@ int main (void) // Bind the valid socket to = zmq_socket (context, ZMQ_PULL); assert (to); - rc = zmq_bind (to, "tcp://*:5560"); + rc = zmq_bind (to, "tcp://127.0.0.1:5560"); assert (rc == 0); val = 0; @@ -128,10 +128,10 @@ int main (void) assert (rc == 0); // Connect to the invalid socket - rc = zmq_connect (from, "tcp://localhost:5561"); + rc = zmq_connect (from, "tcp://127.0.0.1:5561"); assert (rc == 0); // Connect to the valid socket - rc = zmq_connect (from, "tcp://localhost:5560"); + rc = zmq_connect (from, "tcp://127.0.0.1:5560"); assert (rc == 0); // Send 10 messages, all should be routed to the connected pipe @@ -181,9 +181,9 @@ int main (void) int on = 1; rc = zmq_setsockopt (frontend, ZMQ_DELAY_ATTACH_ON_CONNECT, &on, sizeof (on)); assert (rc == 0); - rc = zmq_bind (backend, "tcp://*:5560"); + rc = zmq_bind (backend, "tcp://127.0.0.1:5560"); assert (rc == 0); - rc = zmq_connect (frontend, "tcp://localhost:5560"); + rc = zmq_connect (frontend, "tcp://127.0.0.1:5560"); assert (rc == 0); // Ping backend to frontend so we know when the connection is up @@ -213,7 +213,7 @@ int main (void) assert (backend); rc = zmq_setsockopt (backend, ZMQ_LINGER, &zero, sizeof (zero)); assert (rc == 0); - rc = zmq_bind (backend, "tcp://*:5560"); + rc = zmq_bind (backend, "tcp://127.0.0.1:5560"); assert (rc == 0); // Ping backend to frontend so we know when the connection is up From 289db060bdab080c7861e96c058d59398a67c29e Mon Sep 17 00:00:00 2001 From: Markus Rothe Date: Wed, 18 Sep 2013 11:12:58 +0200 Subject: [PATCH 2/2] test_disconnect_inproc: also change comment to make it non-public --- tests/test_disconnect_inproc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_disconnect_inproc.cpp b/tests/test_disconnect_inproc.cpp index d6b68c6a..ebe6a373 100644 --- a/tests/test_disconnect_inproc.cpp +++ b/tests/test_disconnect_inproc.cpp @@ -22,7 +22,7 @@ int main(int argc, char** argv) { zmq_setsockopt(subSocket, ZMQ_SUBSCRIBE, "foo", 3) && printf("zmq_setsockopt: %s\n",zmq_strerror(errno)); zmq_bind(pubSocket, "inproc://someInProcDescriptor") && printf("zmq_bind: %s\n", zmq_strerror(errno)); - //zmq_bind(pubSocket, "tcp://*:30010") && printf("zmq_bind: %s\n", zmq_strerror(errno)); + //zmq_bind(pubSocket, "tcp://127.0.0.1:30010") && printf("zmq_bind: %s\n", zmq_strerror(errno)); int32_t more; size_t more_size = sizeof(more);