diff options
author | lloyd <[email protected]> | 2012-07-12 22:00:11 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-07-12 22:00:11 +0000 |
commit | 389e815371681c5f076c0ff2563bf300789ff429 (patch) | |
tree | 266af42fc51d483a7ce57516cfba7a4afb34b84f /src/tls/tls_session_manager.cpp | |
parent | 43836c6fd15a944dce1ca25bb0d019ede3ef75e7 (diff) |
Add an optional parameter to TLS::Client specifying the port number.
Pass this down into the session managers.
Also document how to use session tickets with TLS servers.
Diffstat (limited to 'src/tls/tls_session_manager.cpp')
-rw-r--r-- | src/tls/tls_session_manager.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/tls/tls_session_manager.cpp b/src/tls/tls_session_manager.cpp index 55c06bc16..823f4c123 100644 --- a/src/tls/tls_session_manager.cpp +++ b/src/tls/tls_session_manager.cpp @@ -49,15 +49,16 @@ bool Session_Manager_In_Memory::load_from_host_info( { std::lock_guard<std::mutex> lock(m_mutex); - std::map<std::string, std::string>::iterator i; - - if(port > 0) - i = m_host_sessions.find(hostname + ":" + std::to_string(port)); - else - i = m_host_sessions.find(hostname); + auto i = m_host_sessions.find(hostname + ":" + std::to_string(port)); if(i == m_host_sessions.end()) - return false; + { + if(port > 0) + i = m_host_sessions.find(hostname + ":" + std::to_string(0)); + + if(i == m_host_sessions.end()) + return false; + } if(load_from_session_str(i->second, session)) return true; @@ -79,7 +80,7 @@ void Session_Manager_In_Memory::remove_entry( m_sessions.erase(i); } -void Session_Manager_In_Memory::save(const Session& session) +void Session_Manager_In_Memory::save(const Session& session, u16bit port) { std::lock_guard<std::mutex> lock(m_mutex); @@ -97,8 +98,10 @@ void Session_Manager_In_Memory::save(const Session& session) m_sessions[session_id_str] = session; - if(session.side() == CLIENT && session.sni_hostname() != "") - m_host_sessions[session.sni_hostname()] = session_id_str; + const std::string hostname = session.sni_hostname(); + + if(session.side() == CLIENT && hostname != "") + m_host_sessions[hostname + ":" + std::to_string(port)] = session_id_str; } } |