summaryrefslogtreecommitdiff
path: root/client/SslClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/SslClient.cpp')
-rw-r--r--client/SslClient.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/client/SslClient.cpp b/client/SslClient.cpp
index 885b228..2a599c8 100644
--- a/client/SslClient.cpp
+++ b/client/SslClient.cpp
@@ -4,7 +4,6 @@
#include <QtNetwork>
#include "SslClient.h"
-QSslSocket SslClient::sslSocket;
SslClient::SslClient(): port(13666)
{
@@ -37,6 +36,7 @@ SslClient::SslClient(QString addr): port(13666)
cert_file.close();
/* create ssl socket */
+ sslSocket.setReadBufferSize(8096);
sslSocket.setLocalCertificate(cert);
sslSocket.setPrivateKey(key);
sslSocket.setCaCertificates(ca_certs);
@@ -75,10 +75,7 @@ void SslClient::SendRequest(RequestType type)
{
Logger::Trace("Connecting to server %s:%u\n", server.toLocal8Bit().data(), port);
sslSocket.connectToHostEncrypted(server, port);
- while (! sslSocket.waitForConnected(5000))
- {
- Logger::Trace("Waiting for connection to be established...\n");
- }
+ sslSocket.waitForEncrypted(-1);
}
else
{
@@ -113,10 +110,7 @@ void SslClient::SendFileRequest(string filename)
{
Logger::Trace("Connecting to server %s:%u\n", server.toLocal8Bit().data(), port);
sslSocket.connectToHostEncrypted(server, port);
- while (! sslSocket.waitForConnected(5000))
- {
- Logger::Trace("Waiting for connection to be established...\n");
- }
+ sslSocket.waitForEncrypted(-1);
}
else
{
@@ -132,7 +126,6 @@ void SslClient::SendFileRequest(string filename)
data[2] = rcode;
strncpy(data + 3, file, path_len);
data[pkt_size - 1] = data[pkt_size - 2] = 0x14;
-
QByteArray pkt(data);
sslSocket.write(pkt);
}
@@ -167,7 +160,6 @@ void SslClient::DataRecieved()
char t1 = data[length-3];
char t2 = data[length-2];
char t3 = data[length-1];
-
if ((h1 != 0x13) || (h2 != 0x13) ||
(t1 != 0x14) || (t2 != 0x14) || (t3 != 0x00))
{
@@ -185,6 +177,7 @@ void SslClient::DataRecieved()
case FirewallList:
case DownloadList:
case DeleteList:
+ case RegularFile:
type = (RequestType)rcode;
break;
default:
@@ -193,8 +186,8 @@ void SslClient::DataRecieved()
}
/* remove header and tail */
+ data.remove(data.size()-3, 3);
data.remove(0, 3);
- data.remove(length-1, 3);
emit ReplyRecieved(type, data);
}