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
zeromq-*.zip
core
build
test-suite.log
......@@ -29,6 +29,10 @@ function:
Identity
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
auththenticated connection sample below.
......
......@@ -671,7 +671,7 @@ bool zmq::stream_engine_t::handshake ()
options.mechanism == ZMQ_GSSAPI? "GSSAPI":
"OTHER",
mechanism);
error (protocol_error);
return false;
}
......@@ -806,21 +806,18 @@ void zmq::stream_engine_t::mechanism_ready ()
properties_t properties;
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.
const properties_t& zap_properties = mechanism->get_zap_properties ();
it = zap_properties.begin ();
while (it != zap_properties.end ()) {
properties.insert (properties_t::value_type (it->first, it->second));
++it;
}
properties.insert(zap_properties.begin (), zap_properties.end ());
// Add ZMTP properties.
const properties_t& zmtp_properties = mechanism->get_zmtp_properties ();
it = zmtp_properties.begin ();
while (it != zmtp_properties.end ()) {
properties.insert (properties_t::value_type (it->first, it->second));
++it;
}
properties.insert(zmtp_properties.begin (), zmtp_properties.end ());
zmq_assert (metadata == NULL);
if (!properties.empty ())
......
......@@ -41,7 +41,7 @@ zap_handler (void *handler)
assert (streq (version, "1.0"));
assert (streq (mechanism, "NULL"));
s_sendmore (handler, version);
s_sendmore (handler, sequence);
if (streq (domain, "DOMAIN")) {
......@@ -100,6 +100,8 @@ int main (void)
assert (streq (zmq_msg_gets (&msg, "Hello"), "World"));
assert (streq (zmq_msg_gets (&msg, "Socket-Type"), "DEALER"));
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_errno () == EINVAL);
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