diff --git a/Makefile.am b/Makefile.am index 794e88205..3add0d129 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,7 +141,6 @@ wsd_headers = wsd/Admin.hpp \ wsd/Exceptions.hpp \ wsd/FileServer.hpp \ wsd/LOOLWSD.hpp \ - wsd/LOOLWebSocket.hpp \ wsd/QueueHandler.hpp \ wsd/SenderQueue.hpp \ wsd/Storage.hpp \ @@ -154,6 +153,7 @@ shared_headers = common/Common.hpp \ common/IoUtil.hpp \ common/FileUtil.hpp \ common/Log.hpp \ + common/LOOLWebSocket.hpp \ common/Protocol.hpp \ common/Session.hpp \ common/Unit.hpp \ diff --git a/common/IoUtil.hpp b/common/IoUtil.hpp index 416607b02..8dc2f326a 100644 --- a/common/IoUtil.hpp +++ b/common/IoUtil.hpp @@ -18,7 +18,6 @@ namespace IoUtil { - /// Synchronously process LOOLWebSocket requests and dispatch to handler. /// Handler returns false to end. void SocketProcessor(const std::shared_ptr& ws, diff --git a/wsd/LOOLWebSocket.hpp b/common/LOOLWebSocket.hpp similarity index 100% rename from wsd/LOOLWebSocket.hpp rename to common/LOOLWebSocket.hpp diff --git a/net/ServerSocket.hpp b/net/ServerSocket.hpp index 29381c1da..33d01e316 100644 --- a/net/ServerSocket.hpp +++ b/net/ServerSocket.hpp @@ -15,6 +15,8 @@ #include "Socket.hpp" #include "Log.hpp" +#include + class SocketFactory { public: diff --git a/net/Socket.hpp b/net/Socket.hpp index 708ae39ec..222f7b6a7 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -13,6 +13,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -28,7 +32,6 @@ #include #include -#include #include #include "Common.hpp" diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index 646ec274e..776ba1378 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -15,14 +15,7 @@ #include #include -#include -#include -#include -#include -#include -#include #include -#include #include #include "Admin.hpp" @@ -47,10 +40,7 @@ using namespace LOOLProtocol; using Poco::StringTokenizer; -using Poco::Net::HTTPRequestHandler; using Poco::Net::HTTPResponse; -using Poco::Net::HTTPServerRequest; -using Poco::Net::HTTPServerResponse; using Poco::Util::Application; /// Process incoming websocket messages @@ -118,9 +108,7 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */, { const std::string result = model.query(tokens[0]); if (!result.empty()) - { sendTextFrame(tokens[0] + ' ' + result); - } } else if (tokens[0] == "subscribe" && tokens.count() > 1) { diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp index d288658a5..8dcdfedb2 100644 --- a/wsd/Admin.hpp +++ b/wsd/Admin.hpp @@ -13,8 +13,6 @@ #include #include -#include -#include #include #include #include @@ -41,8 +39,7 @@ public: const Poco::Net::HTTPRequest& request); private: - void handleWSRequests(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response, int sessionId); - + /// Sends text frames simply to authenticated clients. void sendTextFrame(const std::string& message); /// Process incoming websocket messages diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index d74caf87d..58fe90c28 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -21,11 +21,8 @@ #include #include #include -#include #include #include -#include -#include #include #include #include @@ -42,8 +39,6 @@ using Poco::FileInputStream; using Poco::Net::HTMLForm; using Poco::Net::HTTPRequest; using Poco::Net::HTTPResponse; -using Poco::Net::HTTPServerRequest; -using Poco::Net::HTTPServerResponse; using Poco::Net::NameValueCollection; using Poco::Net::HTTPBasicCredentials; using Poco::StreamCopier; diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp index 0163f2318..b27526f3e 100644 --- a/wsd/FileServer.hpp +++ b/wsd/FileServer.hpp @@ -11,13 +11,9 @@ #define INCLUDED_FILESERVER_HPP #include +#include "Socket.hpp" #include -#include -#include -#include - -#include "Socket.hpp" /// Handles file requests over HTTP(S). class FileServerRequestHandler diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 5ed485eb7..8cd381251 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -59,29 +59,15 @@ #include #include #include -#include -#include #include #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include #include #include #include #include #include -#include -#include -#include -#include #include #include #include @@ -112,7 +98,7 @@ #include "ServerSocket.hpp" #include "Session.hpp" #if ENABLE_SSL -#include "SslSocket.hpp" +# include "SslSocket.hpp" #endif #include "Storage.hpp" #include "TraceFile.hpp" @@ -123,11 +109,11 @@ #include "FileUtil.hpp" #ifdef KIT_IN_PROCESS -#include +# include #endif #ifdef FUZZER -#include +# include #endif #include "common/SigUtil.hpp" @@ -139,17 +125,10 @@ using Poco::Exception; using Poco::File; using Poco::Net::HTMLForm; using Poco::Net::HTTPRequest; -using Poco::Net::HTTPRequestHandler; -using Poco::Net::HTTPRequestHandlerFactory; using Poco::Net::HTTPResponse; -using Poco::Net::HTTPServer; -using Poco::Net::HTTPServerParams; -using Poco::Net::HTTPServerRequest; -using Poco::Net::HTTPServerResponse; using Poco::Net::MessageHeader; using Poco::Net::NameValueCollection; using Poco::Net::PartHandler; -using Poco::Net::SecureServerSocket; using Poco::Net::SocketAddress; using Poco::Net::WebSocket; using Poco::Path; @@ -866,9 +845,7 @@ void LOOLWSD::initialize(Application& self) void LOOLWSD::initializeSSL() { if (!LOOLWSD::isSSLEnabled()) - { return; - } const auto ssl_cert_file_path = getPathFromConfig("ssl.cert_file_path"); LOG_INF("SSL Cert file: " << ssl_cert_file_path); @@ -885,34 +862,6 @@ void LOOLWSD::initializeSSL() ssl_key_file_path, ssl_ca_file_path); #endif - - Poco::Crypto::initializeCrypto(); - - Poco::Net::initializeSSL(); - Poco::Net::Context::Params sslParams; - sslParams.certificateFile = ssl_cert_file_path; - sslParams.privateKeyFile = ssl_key_file_path; - sslParams.caLocation = ssl_ca_file_path; - // Don't ask clients for certificate - sslParams.verificationMode = Poco::Net::Context::VERIFY_NONE; - - // FIXME: ConsoleCertificateHandler will block on stdin upon error! - Poco::SharedPtr consoleHandler = new Poco::Net::KeyConsoleHandler(true); - Poco::SharedPtr invalidCertHandler = new Poco::Net::ConsoleCertificateHandler(true); - - Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::SERVER_USE, sslParams); - Poco::Net::SSLManager::instance().initializeServer(consoleHandler, invalidCertHandler, sslContext); - - // Init client - Poco::Net::Context::Params sslClientParams; - // TODO: Be more strict and setup SSL key/certs for owncloud server and us - sslClientParams.verificationMode = Poco::Net::Context::VERIFY_NONE; - - Poco::SharedPtr consoleClientHandler = new Poco::Net::KeyConsoleHandler(false); - Poco::SharedPtr invalidClientCertHandler = new Poco::Net::AcceptCertificateHandler(false); - - Poco::Net::Context::Ptr sslClientContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslClientParams); - Poco::Net::SSLManager::instance().initializeClient(consoleClientHandler, invalidClientCertHandler, sslClientContext); } void LOOLWSD::dumpNewSessionTrace(const std::string& id, const std::string& sessionId, const std::string& uri, const std::string& path)