From 1dd758c66a29bb9c6253c66a66ef1abc78c6acf7 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 27 Jun 2020 14:17:45 +0300 Subject: [PATCH] Fix send buffer size for app and proxy --- src/browser/BrowserHost.cpp | 15 +++++++++++++++ src/proxy/CMakeLists.txt | 4 ++++ src/proxy/NativeMessagingProxy.cpp | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/browser/BrowserHost.cpp b/src/browser/BrowserHost.cpp index 62c3e9cd8..ac4e996c3 100644 --- a/src/browser/BrowserHost.cpp +++ b/src/browser/BrowserHost.cpp @@ -28,6 +28,16 @@ #include "sodium.h" #include +#ifdef Q_OS_WIN +#include +#include + +#include +#else +#include +#include +#endif + BrowserHost::BrowserHost(QObject* parent) : QObject(parent) { @@ -77,6 +87,11 @@ void BrowserHost::readProxyMessage() } socket->setReadBufferSize(BrowserShared::NATIVEMSG_MAX_LENGTH); + int socketDesc = socket->socketDescriptor(); + if (socketDesc) { + int max = BrowserShared::NATIVEMSG_MAX_LENGTH; + setsockopt(socketDesc, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&max), sizeof(max)); + } QJsonParseError error; auto json = QJsonDocument::fromJson(socket->readAll(), &error); diff --git a/src/proxy/CMakeLists.txt b/src/proxy/CMakeLists.txt index b7bec6deb..bb00f057b 100755 --- a/src/proxy/CMakeLists.txt +++ b/src/proxy/CMakeLists.txt @@ -53,4 +53,8 @@ if(WITH_XC_BROWSER) COMMAND ${CMAKE_COMMAND} -E copy keepassxc-proxy ${PROXY_APP_DIR}/keepassxc-proxy COMMENT "Copying keepassxc-proxy inside the application") endif() + + if(MINGW) + target_link_libraries(keepassxc-proxy Wtsapi32.lib Ws2_32.lib) + endif() endif() diff --git a/src/proxy/NativeMessagingProxy.cpp b/src/proxy/NativeMessagingProxy.cpp index a7bd1c0f3..f5839e92b 100644 --- a/src/proxy/NativeMessagingProxy.cpp +++ b/src/proxy/NativeMessagingProxy.cpp @@ -25,7 +25,12 @@ #ifdef Q_OS_WIN #include +#include + #include +#else +#include +#include #endif NativeMessagingProxy::NativeMessagingProxy() @@ -85,6 +90,11 @@ void NativeMessagingProxy::setupLocalSocket() m_localSocket.reset(new QLocalSocket()); m_localSocket->connectToServer(BrowserShared::localServerPath()); m_localSocket->setReadBufferSize(BrowserShared::NATIVEMSG_MAX_LENGTH); + int socketDesc = m_localSocket->socketDescriptor(); + if (socketDesc) { + int max = BrowserShared::NATIVEMSG_MAX_LENGTH; + setsockopt(socketDesc, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&max), sizeof(max)); + } connect(m_localSocket.data(), SIGNAL(readyRead()), this, SLOT(transferSocketMessage())); connect(m_localSocket.data(), SIGNAL(disconnected()), this, SLOT(socketDisconnected()));