[Libreoffice-commits] online.git: common/IoUtil.hpp common/LOOLWebSocket.hpp Makefile.am net/ServerSocket.hpp net/Socket.hpp wsd/Admin.cpp wsd/Admin.hpp wsd/FileServer.cpp wsd/FileServer.hpp wsd/LOOLWebSocket.hpp wsd/LOOLWSD.cpp

Michael Meeks michael.meeks at collabora.com
Thu Mar 16 18:04:07 UTC 2017


 Makefile.am          |    2 -
 common/IoUtil.hpp    |    1 
 net/ServerSocket.hpp |    2 +
 net/Socket.hpp       |    5 +++-
 wsd/Admin.cpp        |   12 ----------
 wsd/Admin.hpp        |    5 ----
 wsd/FileServer.cpp   |    5 ----
 wsd/FileServer.hpp   |    6 -----
 wsd/LOOLWSD.cpp      |   57 ++-------------------------------------------------
 9 files changed, 12 insertions(+), 83 deletions(-)

New commits:
commit e7ebe0fdaace9f04b622f30994b1da466ca287b5
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Mar 16 17:43:33 2017 +0000

    remove obsolete Poco headers, and Poco SSL pieces.

diff --git a/Makefile.am b/Makefile.am
index 794e8820..3add0d12 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 416607b0..8dc2f326 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<LOOLWebSocket>& 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 29381c1d..33d01e31 100644
--- a/net/ServerSocket.hpp
+++ b/net/ServerSocket.hpp
@@ -15,6 +15,8 @@
 #include "Socket.hpp"
 #include "Log.hpp"
 
+#include <Poco/Net/SocketAddress.h>
+
 class SocketFactory
 {
 public:
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 708ae39e..222f7b6a 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -13,6 +13,10 @@
 #include <poll.h>
 #include <unistd.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
 
 #include <atomic>
 #include <cassert>
@@ -28,7 +32,6 @@
 
 #include <Poco/Timespan.h>
 #include <Poco/Timestamp.h>
-#include <Poco/Net/SocketAddress.h>
 #include <Poco/Net/HTTPResponse.h>
 
 #include "Common.hpp"
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 646ec274..776ba137 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -15,14 +15,7 @@
 
 #include <Poco/Net/HTTPCookie.h>
 #include <Poco/Net/HTTPRequest.h>
-#include <Poco/Net/HTTPRequestHandler.h>
-#include <Poco/Net/HTTPServerParams.h>
-#include <Poco/Net/HTTPServerRequest.h>
-#include <Poco/Net/HTTPServerResponse.h>
-#include <Poco/Net/NetException.h>
-#include <Poco/Net/SecureServerSocket.h>
 #include <Poco/StringTokenizer.h>
-#include <Poco/Util/ServerApplication.h>
 #include <Poco/Util/Timer.h>
 
 #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 d288658a..8dcdfedb 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -13,8 +13,6 @@
 #include <mutex>
 
 #include <Poco/Net/HTTPRequest.h>
-#include <Poco/Net/HTTPRequestHandler.h>
-#include <Poco/Net/HTTPServer.h>
 #include <Poco/Runnable.h>
 #include <Poco/Types.h>
 #include <Poco/Util/Timer.h>
@@ -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 d74caf87..58fe90c2 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -21,11 +21,8 @@
 #include <Poco/Net/HTTPBasicCredentials.h>
 #include <Poco/Net/HTMLForm.h>
 #include <Poco/Net/HTTPRequest.h>
-#include <Poco/Net/HTTPRequestHandler.h>
 #include <Poco/Net/NameValueCollection.h>
 #include <Poco/Net/NetException.h>
-#include <Poco/Net/SecureServerSocket.h>
-#include <Poco/Net/WebSocket.h>
 #include <Poco/RegularExpression.h>
 #include <Poco/Runnable.h>
 #include <Poco/StreamCopier.h>
@@ -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 0163f231..b27526f3 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -11,13 +11,9 @@
 #define INCLUDED_FILESERVER_HPP
 
 #include <string>
+#include "Socket.hpp"
 
 #include <Poco/MemoryStream.h>
-#include <Poco/Net/HTTPRequestHandler.h>
-#include <Poco/Net/HTTPServerRequest.h>
-#include <Poco/Net/HTTPServerResponse.h>
-
-#include "Socket.hpp"
 
 /// Handles file requests over HTTP(S).
 class FileServerRequestHandler
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5ed485eb..8cd38125 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -59,29 +59,15 @@
 #include <Poco/File.h>
 #include <Poco/FileStream.h>
 #include <Poco/MemoryStream.h>
-#include <Poco/Net/AcceptCertificateHandler.h>
-#include <Poco/Net/ConsoleCertificateHandler.h>
 #include <Poco/Net/Context.h>
 #include <Poco/Net/HTMLForm.h>
 #include <Poco/Net/HTTPRequest.h>
-#include <Poco/Net/HTTPRequestHandler.h>
-#include <Poco/Net/HTTPRequestHandlerFactory.h>
-#include <Poco/Net/HTTPServer.h>
-#include <Poco/Net/HTTPServerParams.h>
-#include <Poco/Net/HTTPServerRequest.h>
-#include <Poco/Net/HTTPServerResponse.h>
 #include <Poco/Net/IPAddress.h>
-#include <Poco/Net/InvalidCertificateHandler.h>
-#include <Poco/Net/KeyConsoleHandler.h>
 #include <Poco/Net/MessageHeader.h>
 #include <Poco/Net/NameValueCollection.h>
 #include <Poco/Net/Net.h>
 #include <Poco/Net/NetException.h>
 #include <Poco/Net/PartHandler.h>
-#include <Poco/Net/PrivateKeyPassphraseHandler.h>
-#include <Poco/Net/SSLManager.h>
-#include <Poco/Net/SecureServerSocket.h>
-#include <Poco/Net/ServerSocket.h>
 #include <Poco/Net/SocketAddress.h>
 #include <Poco/Path.h>
 #include <Poco/Pipe.h>
@@ -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 <Kit.hpp>
+#  include <Kit.hpp>
 #endif
 
 #ifdef FUZZER
-#include <tools/Replay.hpp>
+#  include <tools/Replay.hpp>
 #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<Poco::Net::PrivateKeyPassphraseHandler> consoleHandler = new Poco::Net::KeyConsoleHandler(true);
-    Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> 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<Poco::Net::PrivateKeyPassphraseHandler> consoleClientHandler = new Poco::Net::KeyConsoleHandler(false);
-    Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> 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)


More information about the Libreoffice-commits mailing list