diff options
Diffstat (limited to 'src/cmd/tls_client.cpp')
-rw-r--r-- | src/cmd/tls_client.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/cmd/tls_client.cpp b/src/cmd/tls_client.cpp index 9130cd085..5ab015c33 100644 --- a/src/cmd/tls_client.cpp +++ b/src/cmd/tls_client.cpp @@ -4,6 +4,11 @@ #include <botan/tls_client.h> #include <botan/pkcs8.h> #include <botan/hex.h> + +#if defined(BOTAN_HAS_TLS_SQLITE3_SESSION_MANAGER) + #include <botan/tls_session_manager_sqlite.h> +#endif + #include <string> #include <iostream> #include <memory> @@ -21,10 +26,6 @@ #define MSG_NOSIGNAL 0 #endif -#if defined(BOTAN_HAS_TLS_SQLITE3_SESSION_MANAGER) - #include <botan/tls_session_manager_sqlite.h> -#endif - #include "credentials.h" using namespace Botan; @@ -147,9 +148,12 @@ int tls_client_main(int argc, char* argv[]) TLS::Policy policy; #if defined(BOTAN_HAS_TLS_SQLITE3_SESSION_MANAGER) - TLS::Session_Manager_SQLite session_manager("my secret passphrase", + const std::string passphrase = "correct horse battery staple"; + const std::string sessions_db = "sessions.db"; + + TLS::Session_Manager_SQLite session_manager(passphrase, rng, - "sessions.db"); + sessions_db); #else TLS::Session_Manager_In_Memory session_manager(rng); #endif @@ -188,7 +192,9 @@ int tls_client_main(int argc, char* argv[]) FD_SET(sockfd, &readfds); FD_SET(STDIN_FILENO, &readfds); - ::select(sockfd + 1, &readfds, nullptr, nullptr, nullptr); + struct timeval timeout = { 1, 0 }; + + ::select(sockfd + 1, &readfds, nullptr, nullptr, &timeout); if(FD_ISSET(sockfd, &readfds)) { @@ -247,6 +253,11 @@ int tls_client_main(int argc, char* argv[]) else client.send(buf, got); } + else + { + if(client.timeout_check()) + std::cerr << "Timeout detected\n"; + } } ::close(sockfd); |