Skip to content

Commit

Permalink
Fix send buffer size for app and proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
varjolintu authored and droidmonkey committed Jun 27, 2020
1 parent 58e8d81 commit 1dd758c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/browser/BrowserHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
#include "sodium.h"
#include <iostream>

#ifdef Q_OS_WIN
#include <fcntl.h>
#include <winsock2.h>

#include <windows.h>
#else
#include <sys/socket.h>
#include <sys/types.h>
#endif

BrowserHost::BrowserHost(QObject* parent)
: QObject(parent)
{
Expand Down Expand Up @@ -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<char*>(&max), sizeof(max));
}

QJsonParseError error;
auto json = QJsonDocument::fromJson(socket->readAll(), &error);
Expand Down
4 changes: 4 additions & 0 deletions src/proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 10 additions & 0 deletions src/proxy/NativeMessagingProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@

#ifdef Q_OS_WIN
#include <fcntl.h>
#include <winsock2.h>

#include <windows.h>
#else
#include <sys/socket.h>
#include <sys/types.h>
#endif

NativeMessagingProxy::NativeMessagingProxy()
Expand Down Expand Up @@ -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<char*>(&max), sizeof(max));
}

connect(m_localSocket.data(), SIGNAL(readyRead()), this, SLOT(transferSocketMessage()));
connect(m_localSocket.data(), SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
Expand Down

0 comments on commit 1dd758c

Please sign in to comment.