From 107d3c9bb6684f6076e13b1352f16c6b8301ab42 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Mon, 12 Aug 2013 11:22:45 -0500 Subject: [PATCH] add set_remote_endpoint method to iostream transport --- changelog.md | 3 +- websocketpp/transport/iostream/connection.hpp | 31 ++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 5ffca3b189..aabd0c3abd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ HEAD -- Add `set_secure` method to iostream transport +- Add `set_remote_endpoint` method to iostream transport. +- Add `set_secure` method to iostream transport. - Fix typo in .gitattributes file. Thank you jstarasov for reporting this. #280 - Add missing locale include. Thank you Toninoso for reporting this. #281 - Refactors `asio_transport` endpoint and adds full documentation and exception diff --git a/websocketpp/transport/iostream/connection.hpp b/websocketpp/transport/iostream/connection.hpp index 015ea64c49..98443b4390 100644 --- a/websocketpp/transport/iostream/connection.hpp +++ b/websocketpp/transport/iostream/connection.hpp @@ -76,6 +76,7 @@ public: , m_is_secure(false) , m_alog(alog) , m_elog(elog) + , m_remote_endpoint("iostream transport") { m_alog.write(log::alevel::devel,"iostream con transport constructor"); } @@ -166,20 +167,39 @@ public: bool is_secure() const { return m_is_secure; } + + /// Set human readable remote endpoint address + /** + * Sets the remote endpoint address returned by `get_remote_endpoint`. This + * value should be a human readable string that describes the remote + * endpoint. Typically an IP address or hostname, perhaps with a port. But + * may be something else depending on the nature of the underlying + * transport. + * + * If none is set the default is "iostream transport". + * + * @since 0.3.0-alpha4 + * + * @param value The remote endpoint address to set. + */ + void set_remote_endpoint(std::string value) { + m_remote_endpoint = value; } - /// Get the remote endpoint address + /// Get human readable remote endpoint address /** * The iostream transport has no information about the ultimate remote - * endpoint. It will return the string "iostream transport". To indicate - * this. + * endpoint. It will return the string "iostream transport". The + * `set_remote_endpoint` method may be used by external network code to set + * a more accurate value. * - * TODO: allow user settable remote endpoint addresses if this seems useful + * This value is used in access and error logs and is available to the end + * application for including in user facing interfaces and messages. * * @return A string identifying the address of the remote endpoint */ std::string get_remote_endpoint() const { - return "iostream transport"; + return m_remote_endpoint; } /// Get the connection handle @@ -436,6 +456,7 @@ private: bool m_is_secure; alog_type & m_alog; elog_type & m_elog; + std::string m_remote_endpoint; // This lock ensures that only one thread can edit read data for this // connection. This is a very coarse lock that is basically locked all the