diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-04-28 17:04:33 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-04-28 17:04:33 +0200 |
commit | b96329dc3b775c77e98964c42cb0def7ca65ba0e (patch) | |
tree | 5581f1412bb1f2bda55a506edae3fd35971e4929 | |
parent | 6cfe4011ec0e90718d7d5a449a5330b8e9a18ec3 (diff) |
Add SSLIOHook::IsSSL() to determine whether a socket is using SSL or not
Use it in a few places
-rw-r--r-- | include/modules/ssl.h | 13 | ||||
-rw-r--r-- | src/modules/m_jumpserver.cpp | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/include/modules/ssl.h b/include/modules/ssl.h index 67bfc7b2e..adc78e324 100644 --- a/include/modules/ssl.h +++ b/include/modules/ssl.h @@ -164,6 +164,14 @@ class SSLIOHook : public IOHook } public: + static SSLIOHook* IsSSL(StreamSocket* sock) + { + IOHook* const iohook = sock->GetIOHook(); + if ((iohook) && ((iohook->prov->type == IOHookProvider::IOH_SSL))) + return static_cast<SSLIOHook*>(iohook); + return NULL; + } + SSLIOHook(IOHookProvider* hookprov) : IOHook(hookprov) { @@ -205,11 +213,10 @@ class SSLClientCert */ static ssl_cert* GetCertificate(StreamSocket* sock) { - IOHook* iohook = sock->GetIOHook(); - if ((!iohook) || (iohook->prov->type != IOHookProvider::IOH_SSL)) + SSLIOHook* ssliohook = SSLIOHook::IsSSL(sock); + if (!ssliohook) return NULL; - SSLIOHook* ssliohook = static_cast<SSLIOHook*>(iohook); return ssliohook->GetCertificate(); } diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index 33b9bcd35..f59ef045d 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -140,7 +140,7 @@ class CommandJumpserver : public Command int GetPort(LocalUser* user) { - int p = (SSLClientCert::GetCertificate(&user->eh) ? sslport : port); + int p = (SSLIOHook::IsSSL(&user->eh) ? sslport : port); if (p == 0) p = user->GetServerPort(); return p; |