Passed args into client and socket
Conflicts: src/lib/client/Client.cpp src/lib/client/Client.h src/lib/synergy/ClientApp.cpp src/test/integtests/net/NetworkTests.cpp
This commit is contained in:
parent
39e183da3e
commit
b4665b9cd5
|
@ -60,8 +60,7 @@ Client::Client(
|
|||
const String& name, const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
synergy::Screen* screen,
|
||||
bool enableDragDrop,
|
||||
bool enableCrypto) :
|
||||
ClientArgs args) :
|
||||
m_mock(false),
|
||||
m_name(name),
|
||||
m_serverAddress(address),
|
||||
|
@ -77,9 +76,9 @@ Client::Client(
|
|||
m_events(events),
|
||||
m_sendFileThread(NULL),
|
||||
m_writeToDropDirThread(NULL),
|
||||
m_enableDragDrop(enableDragDrop),
|
||||
m_socket(NULL),
|
||||
m_useSecureNetwork(false)
|
||||
m_args(args)
|
||||
{
|
||||
assert(m_socketFactory != NULL);
|
||||
assert(m_screen != NULL);
|
||||
|
@ -94,7 +93,7 @@ Client::Client(
|
|||
new TMethodEventJob<Client>(this,
|
||||
&Client::handleResume));
|
||||
|
||||
if (m_enableDragDrop) {
|
||||
if (m_args.m_enableDragDrop) {
|
||||
m_events->adoptHandler(m_events->forIScreen().fileChunkSending(),
|
||||
this,
|
||||
new TMethodEventJob<Client>(this,
|
||||
|
@ -162,6 +161,7 @@ Client::connect()
|
|||
// create the socket
|
||||
IDataSocket* socket = m_socketFactory->create(m_useSecureNetwork);
|
||||
m_socket = dynamic_cast<TCPSocket*>(socket);
|
||||
m_socket->setFingerprintFilename(m_args.m_certFingerprintFilename);
|
||||
|
||||
// filter socket messages, including a packetizing filter
|
||||
m_stream = socket;
|
||||
|
@ -780,7 +780,8 @@ Client::fileChunkReceived(String data)
|
|||
void
|
||||
Client::dragInfoReceived(UInt32 fileNum, String data)
|
||||
{
|
||||
if (!m_enableDragDrop) {
|
||||
// TODO: fix duplicate function from CServer
|
||||
if (!m_args.m_enableDragDrop) {
|
||||
LOG((CLOG_DEBUG "drag drop not enabled, ignoring drag info."));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "synergy/IClipboard.h"
|
||||
#include "synergy/DragInformation.h"
|
||||
#include "synergy/INode.h"
|
||||
#include "synergy/ClientArgs.h"
|
||||
#include "net/NetworkAddress.h"
|
||||
#include "base/EventTypes.h"
|
||||
|
||||
|
@ -59,8 +60,7 @@ public:
|
|||
const String& name, const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
synergy::Screen* screen,
|
||||
bool enableDragDrop,
|
||||
bool enableCrypto);
|
||||
ClientArgs args);
|
||||
~Client();
|
||||
|
||||
#ifdef TEST_ENV
|
||||
|
@ -227,4 +227,5 @@ private:
|
|||
bool m_enableDragDrop;
|
||||
TCPSocket* m_socket;
|
||||
bool m_useSecureNetwork;
|
||||
ClientArgs m_args;
|
||||
};
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
|
||||
virtual void secureConnect() {}
|
||||
virtual void secureAccept() {}
|
||||
virtual void setFingerprintFilename(CString& f) {}
|
||||
|
||||
protected:
|
||||
ArchSocket getSocket() { return m_socket; }
|
||||
|
|
|
@ -46,7 +46,7 @@ CSecureSocket::CSecureSocket(
|
|||
CSocketMultiplexer* socketMultiplexer) :
|
||||
CTCPSocket(events, socketMultiplexer),
|
||||
m_secureReady(false),
|
||||
m_certFingerprint()
|
||||
m_certFingerprintFilename()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -405,6 +405,10 @@ CSecureSocket::disconnect()
|
|||
bool
|
||||
CSecureSocket::verifyCertFingerprint()
|
||||
{
|
||||
if (m_certFingerprintFilename.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate received certificate fingerprint
|
||||
X509 *cert = cert = SSL_get_peer_certificate(m_ssl->m_ssl);
|
||||
EVP_MD* tempDigest;
|
||||
|
@ -426,7 +430,7 @@ CSecureSocket::verifyCertFingerprint()
|
|||
CString fileLine;
|
||||
CString certificateFingerprint;
|
||||
std::ifstream file;
|
||||
file.open(m_certFingerprint.c_str());
|
||||
file.open(m_certFingerprintFilename.c_str());
|
||||
|
||||
while (!file.eof()) {
|
||||
getline(file,fileLine);
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
void secureConnect();
|
||||
void secureAccept();
|
||||
void setFingerprintFilename(CString& f) { m_certFingerprintFilename = f; }
|
||||
bool isReady() const { return m_secureReady; }
|
||||
bool isSecureReady();
|
||||
bool isSecure() { return true; }
|
||||
|
@ -76,5 +77,5 @@ private:
|
|||
private:
|
||||
Ssl* m_ssl;
|
||||
bool m_secureReady;
|
||||
CString m_certFingerprint;
|
||||
CString m_certFingerprintFilename;
|
||||
};
|
||||
|
|
|
@ -91,7 +91,7 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
|
|||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--certificate-fingerprint", 1)) {
|
||||
// define scroll
|
||||
args.m_certFingerprint = argv[++i];
|
||||
args.m_certFingerprintFilename = argv[++i];
|
||||
}
|
||||
else {
|
||||
if (i + 1 == argc) {
|
||||
|
|
|
@ -342,8 +342,7 @@ ClientApp::openClient(const String& name, const NetworkAddress& address,
|
|||
address,
|
||||
new TCPSocketFactory(m_events, getSocketMultiplexer()),
|
||||
screen,
|
||||
args().m_enableDragDrop,
|
||||
args().m_enableCrypto);
|
||||
args());
|
||||
|
||||
try {
|
||||
m_events->adoptHandler(
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
CClientArgs::CClientArgs() :
|
||||
m_yscroll(0),
|
||||
m_certFingerprint()
|
||||
m_certFingerprintFilename()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -27,5 +27,5 @@ public:
|
|||
|
||||
public:
|
||||
int m_yscroll;
|
||||
CString m_certFingerprint;
|
||||
CString m_certFingerprintFilename;
|
||||
};
|
||||
|
|
|
@ -140,7 +140,11 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
|||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true, false);
|
||||
|
||||
ClientArgs args;
|
||||
args.m_enableDragDrop = true;
|
||||
args.m_enableCrypto = false;
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
||||
|
@ -192,7 +196,11 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
|||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true, false);
|
||||
|
||||
ClientArgs args;
|
||||
args.m_enableDragDrop = true;
|
||||
args.m_enableCrypto = false;
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
||||
|
@ -238,7 +246,10 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
|||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true, false);
|
||||
ClientArgs args;
|
||||
args.m_enableDragDrop = true;
|
||||
args.m_enableCrypto = false;
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forClientListener().connected(), &listener,
|
||||
|
@ -290,7 +301,10 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
|||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true, false);
|
||||
ClientArgs args;
|
||||
args.m_enableDragDrop = true;
|
||||
args.m_enableCrypto = false;
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, args);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forClientListener().connected(), &listener,
|
||||
|
|
Loading…
Reference in New Issue