Makefile.am | 6 + loleaflet/main.js | 2 loolwsd.spec.in | 4 net/loolnb.cpp | 264 ------------------------------------------------------ 4 files changed, 10 insertions(+), 266 deletions(-)
New commits: commit 83d5e878e0fb3c343c96576a7e378a8f18f9c62f Author: Jan Holesovsky <ke...@collabora.com> Date: Tue May 16 17:07:24 2017 +0200 Add a missing semicolon. Change-Id: I899503f9f1627cf07812f517923138a619195d7e diff --git a/loleaflet/main.js b/loleaflet/main.js index 7b080577..fac14aaa 100644 --- a/loleaflet/main.js +++ b/loleaflet/main.js @@ -1,6 +1,6 @@ // If not debug, don't print anything on the console // except in tile debug mode (Ctrl-Shift-Alt-d) -console.log2 = console.log +console.log2 = console.log; if (loleaflet_logging !== 'true') { var methods = ['warn', 'info', 'debug', 'trace', 'log', 'assert', 'time', 'timeEnd']; for (var i = 0; i < methods.length; i++) { commit 0033a7ffd6ba875785cb210c1282d8e7087178d6 Author: Michael Meeks <michael.me...@collabora.com> Date: Fri May 5 18:53:00 2017 +0100 loolnb - kill obsolete test app. Change-Id: I5943cc0752f16d62d6eedf96351bb6f71a2311e6 diff --git a/Makefile.am b/Makefile.am index 83f6f455..0ccabbae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -81,7 +81,6 @@ noinst_PROGRAMS = clientnb \ connect \ lokitclient \ loolforkit-nocaps \ - loolnb \ loolwsd_fuzzer connect_SOURCES = tools/Connect.cpp \ diff --git a/net/loolnb.cpp b/net/loolnb.cpp deleted file mode 100644 index e268b067..00000000 --- a/net/loolnb.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "config.h" - -#include <atomic> -#include <cerrno> -#include <cstdlib> -#include <cstring> -#include <iostream> -#include <mutex> -#include <thread> -#include <assert.h> - -#include <Poco/MemoryStream.h> -#include <Poco/Net/SocketAddress.h> -#include <Poco/Util/ServerApplication.h> -#include <Poco/StringTokenizer.h> -#include <Poco/Runnable.h> -#include <Poco/Thread.h> - -#include "Socket.hpp" -#include "ServerSocket.hpp" -#if ENABLE_SSL -#include "SslSocket.hpp" -#endif -#include "WebSocketHandler.hpp" - -using Poco::MemoryInputStream; -using Poco::StringTokenizer; - -constexpr int HttpPortNumber = 9191; -constexpr int SslPortNumber = 9193; - -class SimpleResponseClient : public WebSocketHandler -{ -public: - SimpleResponseClient() : WebSocketHandler() - { - } - - virtual void handleIncomingMessage(SocketDisposition &disposition) override - { - LOG_TRC("incoming WebSocket message"); - if (_wsState == WSState::HTTP) - { - auto socket = _socket.lock(); - - int number = 0; - Poco::MemoryInputStream message(&socket->_inBuffer[0], socket->_inBuffer.size()); - Poco::Net::HTTPRequest req; - req.read(message); - - // if we succeeded - remove that from our input buffer - // FIXME: We should check if this is GET or POST. For GET, we only - // can have a single request (headers only). For POST, we can/should - // use Poco HTMLForm to parse the post message properly. - // Otherwise, we should catch exceptions from the previous read/parse - // and assume we don't have sufficient data, so we wait some more. - socket->_inBuffer.clear(); - - LOG_DBG("URI: " << req.getURI()); - - Poco::StringTokenizer tokens(req.getURI(), "/?"); - if (tokens.count() == 4) - { - std::string subpool = tokens[2]; - number = std::stoi(tokens[3]); - - // complex algorithmic core: - number = number + 1; - - std::string numberString = std::to_string(number); - std::ostringstream oss; - oss << "HTTP/1.1 200 OK\r\n" - << "Date: Once, Upon a time GMT\r\n" // Mon, 27 Jul 2009 12:28:53 GMT - << "Server: madeup string (Linux)\r\n" - << "Content-Length: " << numberString.size() << "\r\n" - << "Content-Type: text/plain\r\n" - << "Connection: Closed\r\n" - << "\r\n" - << numberString; - - std::string str = oss.str(); - socket->_outBuffer.insert(socket->_outBuffer.end(), str.begin(), str.end()); - return; - } - else if (tokens.count() == 2 && tokens[1] == "ws") - { - upgradeToWebSocket(req); - return; - } - } - - WebSocketHandler::handleIncomingMessage(disposition); - } - - virtual void handleMessage(const bool fin, const WSOpCode code, std::vector<char> &data) override - { - std::cerr << "Message: fin? " << fin << " code " << code << " data size " << data.size(); - if (code == WSOpCode::Text) - { - std::string text(data.begin(), data.end()); - std::cerr << " text is '" << text << "'\n"; - - return; - } - else - std::cerr << " binary\n"; - - std::vector<char> reply; - if (data.size() == sizeof(size_t)) - { - // ping pong test - assert (data.size() >= sizeof(size_t)); - size_t *countPtr = reinterpret_cast<size_t *>(&data[0]); - size_t count = *countPtr; - count++; - std::cerr << "count is " << count << "\n"; - reply.insert(reply.end(), reinterpret_cast<char *>(&count), - reinterpret_cast<char *>(&count) + sizeof(count)); - } - else - { - // echo tests - reply.insert(reply.end(), data.begin(), data.end()); - } - - sendMessage(reply.data(), reply.size(), code); - } -}; - -// FIXME: use Poco Thread instead (?) - -/// Generic thread class. -class Thread -{ -public: - Thread(const std::function<void(std::atomic<bool>&)>& cb) : - _cb(cb), - _stop(false) - { - _thread = std::thread([this]() { _cb(_stop); }); - } - - Thread(Thread&& other) = delete; - const Thread& operator=(Thread&& other) = delete; - - ~Thread() - { - stop(); - if (_thread.joinable()) - { - _thread.join(); - } - } - - void stop() - { - _stop = true; - } - -private: - const std::function<void(std::atomic<bool>&)> _cb; - std::atomic<bool> _stop; - std::thread _thread; -}; - -Poco::Net::SocketAddress addrHttp("127.0.0.1", HttpPortNumber); -Poco::Net::SocketAddress addrSsl("127.0.0.1", SslPortNumber); - -void server(const Poco::Net::SocketAddress& addr, SocketPoll& clientPoller, - std::unique_ptr<SocketFactory> sockFactory) -{ - // Start server. - auto server = std::make_shared<ServerSocket>(clientPoller, std::move(sockFactory)); - if (!server->bind(addr)) - { - const std::string msg = "Failed to bind. (errno: "; - throw std::runtime_error(msg + std::strerror(errno) + ")"); - } - - if (!server->listen()) - { - const std::string msg = "Failed to listen. (errno: "; - throw std::runtime_error(msg + std::strerror(errno) + ")"); - } - - SocketPoll serverPoll("srv_poll"); - - serverPoll.insertNewSocket(server); - - std::cout << "Listening." << std::endl; - while (true) - sleep(1); -} - -class LOOLNB : public Poco::Util::ServerApplication -{ -public: - int main(const std::vector<std::string>& args) override - { - const char* logLevel = std::getenv("LOOL_LOGLEVEL"); - std::map<std::string, std::string> props; - if (logLevel) - Log::initialize("loolnb", logLevel ? logLevel : "", - false, false, props); - -#if ENABLE_SSL - // TODO: These would normally come from config. - SslContext::initialize("/etc/loolwsd/cert.pem", - "/etc/loolwsd/key.pem", - "/etc/loolwsd/ca-chain.cert.pem"); -#endif - - // Used to poll client sockets. - SocketPoll poller("client_poll"); - - class PlainSocketFactory : public SocketFactory - { - std::shared_ptr<Socket> create(const int fd) override - { - return StreamSocket::create<StreamSocket>(fd, std::unique_ptr<SocketHandlerInterface>{ new SimpleResponseClient }); - } - }; - -#if ENABLE_SSL - class SslSocketFactory : public SocketFactory - { - std::shared_ptr<Socket> create(const int fd) override - { - return StreamSocket::create<SslStreamSocket>(fd, std::unique_ptr<SocketHandlerInterface>{ new SimpleResponseClient }); - } - }; - - // Start the server. - if (!args.empty() && args.back() == "ssl") - server(addrSsl, poller, std::unique_ptr<SocketFactory>{new SslSocketFactory}); - else -#endif - server(addrHttp, poller, std::unique_ptr<SocketFactory>{new PlainSocketFactory}); - - std::cout << "Shutting down server." << std::endl; - - poller.stop(); - -#if ENABLE_SSL - SslContext::uninitialize(); -#endif - - (void)args; - return 0; - } -}; - -POCO_SERVER_MAIN(LOOLNB) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b521afa39b9a8e314908ae5ce4ee5df23e1e357f Author: Andras Timar <andras.ti...@collabora.com> Date: Wed May 3 14:13:37 2017 +0200 add loolwsd documentation to distribution Change-Id: I18ebfff9eb4a87abd311086d6780514293ce6c7a diff --git a/Makefile.am b/Makefile.am index 1be07e43..83f6f455 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,11 @@ bin_PROGRAMS = loolwsd loolforkit loolmap loolmount looltool loolstress dist_bin_SCRIPTS = loolwsd-systemplate-setup +dist_doc_DATA = wsd/README \ + wsd/README.vars \ + wsd/protocol.txt \ + wsd/reference.txt + loolwsddatadir = @LOOLWSD_DATADIR@ loolwsddata_DATA = discovery.xml \ diff --git a/loolwsd.spec.in b/loolwsd.spec.in index cd2706ae..db2b1941 100644 --- a/loolwsd.spec.in +++ b/loolwsd.spec.in @@ -100,6 +100,10 @@ echo "0 0 */1 * * root find /var/cache/loolwsd -name \"*.png\" -a -atime +10 -ex /usr/share/loolwsd/favicon.ico /usr/share/loolwsd/robots.txt /usr/share/loolwsd/loleaflet +/usr/share/doc/loolwsd/README +/usr/share/doc/loolwsd/README.vars +/usr/share/doc/loolwsd/protocol.txt +/usr/share/doc/loolwsd/reference.txt %{_unitdir}/loolwsd.service %if 0%{?fedora} || 0%{?rhel} >= 7 %config(noreplace) /etc/sysconfig/loolwsd _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits