mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 10:32:58 +01:00
Add 'Peer-Address' property to connection metadata
Allows non-C/C++ based clients easy access to the peer's IP address via zmq_msg_gets(&msg, "Peer-Address") instead of zmq_msg_get(&msg, ZMQ_SRCFD) followed by calls to getpeername and getnameinfo
This commit is contained in:
@@ -671,7 +671,7 @@ bool zmq::stream_engine_t::handshake ()
|
||||
options.mechanism == ZMQ_GSSAPI? "GSSAPI":
|
||||
"OTHER",
|
||||
mechanism);
|
||||
|
||||
|
||||
error (protocol_error);
|
||||
return false;
|
||||
}
|
||||
@@ -806,6 +806,11 @@ 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 ();
|
||||
|
||||
Reference in New Issue
Block a user