aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_session_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tls/tls_session_manager.cpp')
-rw-r--r--src/tls/tls_session_manager.cpp23
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;
}
}