diff options
author | 2015-09-09 18:06:12 +0300 | |
---|---|---|
committer | 2015-09-09 18:56:11 +0300 | |
commit | 54f8323b3938bf4ab672cde01a06711bfc522a2e (patch) | |
tree | 3454351e53499c2051715641e1b87b3e32f9a333 /src/rpc-server/trex_rpc_server.cpp | |
parent | e33befcf222fd2108d589dede11069d4256bb21a (diff) |
added ownership to RPC server
Diffstat (limited to 'src/rpc-server/trex_rpc_server.cpp')
-rw-r--r-- | src/rpc-server/trex_rpc_server.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/rpc-server/trex_rpc_server.cpp b/src/rpc-server/trex_rpc_server.cpp index 149bb668..a5988cab 100644 --- a/src/rpc-server/trex_rpc_server.cpp +++ b/src/rpc-server/trex_rpc_server.cpp @@ -112,6 +112,7 @@ get_current_date_time() { const std::string TrexRpcServer::s_server_uptime = get_current_date_time(); std::string TrexRpcServer::s_owner = "none"; +std::string TrexRpcServer::s_owner_handler = ""; TrexRpcServer::TrexRpcServer(const TrexRpcServerConfig &req_resp_cfg) { @@ -157,3 +158,22 @@ void TrexRpcServer::set_verbose(bool verbose) { } } +/** + * generate a random connection handler + * + */ +std::string TrexRpcServer::generate_handler() { + std::stringstream ss; + + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + /* generate 8 bytes of random handler */ + for (int i = 0; i < 8; ++i) { + ss << alphanum[rand() % (sizeof(alphanum) - 1)]; + } + + return (ss.str()); +} |