Commit 0e404ec8 authored by KAPP Arnaud's avatar KAPP Arnaud

Merge pull request #1309 from rodgert/master

Add 'Peer-Address' property to connection metadata
parents 2e76bbe4 cf2bd3b6
...@@ -137,3 +137,4 @@ zeromq-*.tar.gz ...@@ -137,3 +137,4 @@ zeromq-*.tar.gz
zeromq-*.zip zeromq-*.zip
core core
build build
test-suite.log
...@@ -29,6 +29,10 @@ function: ...@@ -29,6 +29,10 @@ function:
Identity Identity
Resource Resource
Additionally, when available for the underlying transport, the *Peer-Address*
property will return the IP address of the remote endpoint as returned by
getnameinfo(2).
Other properties may be defined based on the underlying security, see ZAP Other properties may be defined based on the underlying security, see ZAP
auththenticated connection sample below. auththenticated connection sample below.
......
...@@ -671,7 +671,7 @@ bool zmq::stream_engine_t::handshake () ...@@ -671,7 +671,7 @@ bool zmq::stream_engine_t::handshake ()
options.mechanism == ZMQ_GSSAPI? "GSSAPI": options.mechanism == ZMQ_GSSAPI? "GSSAPI":
"OTHER", "OTHER",
mechanism); mechanism);
error (protocol_error); error (protocol_error);
return false; return false;
} }
...@@ -806,21 +806,18 @@ void zmq::stream_engine_t::mechanism_ready () ...@@ -806,21 +806,18 @@ void zmq::stream_engine_t::mechanism_ready ()
properties_t properties; properties_t properties;
properties_t::const_iterator it; properties_t::const_iterator it;
// If we have a peer_address, add it to metadata
if (!peer_address.empty()) {
properties.insert(std::make_pair("Peer-Address", peer_address));
}
// Add ZAP properties. // Add ZAP properties.
const properties_t& zap_properties = mechanism->get_zap_properties (); const properties_t& zap_properties = mechanism->get_zap_properties ();
it = zap_properties.begin (); properties.insert(zap_properties.begin (), zap_properties.end ());
while (it != zap_properties.end ()) {
properties.insert (properties_t::value_type (it->first, it->second));
++it;
}
// Add ZMTP properties. // Add ZMTP properties.
const properties_t& zmtp_properties = mechanism->get_zmtp_properties (); const properties_t& zmtp_properties = mechanism->get_zmtp_properties ();
it = zmtp_properties.begin (); properties.insert(zmtp_properties.begin (), zmtp_properties.end ());
while (it != zmtp_properties.end ()) {
properties.insert (properties_t::value_type (it->first, it->second));
++it;
}
zmq_assert (metadata == NULL); zmq_assert (metadata == NULL);
if (!properties.empty ()) if (!properties.empty ())
......
...@@ -41,7 +41,7 @@ zap_handler (void *handler) ...@@ -41,7 +41,7 @@ zap_handler (void *handler)
assert (streq (version, "1.0")); assert (streq (version, "1.0"));
assert (streq (mechanism, "NULL")); assert (streq (mechanism, "NULL"));
s_sendmore (handler, version); s_sendmore (handler, version);
s_sendmore (handler, sequence); s_sendmore (handler, sequence);
if (streq (domain, "DOMAIN")) { if (streq (domain, "DOMAIN")) {
...@@ -100,6 +100,8 @@ int main (void) ...@@ -100,6 +100,8 @@ int main (void)
assert (streq (zmq_msg_gets (&msg, "Hello"), "World")); assert (streq (zmq_msg_gets (&msg, "Hello"), "World"));
assert (streq (zmq_msg_gets (&msg, "Socket-Type"), "DEALER")); assert (streq (zmq_msg_gets (&msg, "Socket-Type"), "DEALER"));
assert (streq (zmq_msg_gets (&msg, "User-Id"), "anonymous")); assert (streq (zmq_msg_gets (&msg, "User-Id"), "anonymous"));
assert (streq (zmq_msg_gets (&msg, "Peer-Address"), "127.0.0.1"));
assert (zmq_msg_gets (&msg, "No Such") == NULL); assert (zmq_msg_gets (&msg, "No Such") == NULL);
assert (zmq_errno () == EINVAL); assert (zmq_errno () == EINVAL);
zmq_msg_close (&msg); zmq_msg_close (&msg);
......
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