add encryption

This commit is contained in:
2024-09-11 15:44:02 +03:00
parent 0d94699206
commit b24b5a1346
5 changed files with 25 additions and 6 deletions

View File

@@ -91,6 +91,11 @@ void PIClientServer::Server::setMaxClients(int new_max_clients) {
}
void PIClientServer::Server::enableSymmetricEncryption(const PIByteArray & key) {
crypt_key = key;
}
void PIClientServer::Server::stopServer() {
if (!tcp_server) return;
tcp_server->stopAndWait();
@@ -98,8 +103,9 @@ void PIClientServer::Server::stopServer() {
void PIClientServer::Server::newClient(Client * c) {
c->readed_func = [this, c](PIByteArray ba) { readed(c, ba); };
clients << c;
c->enableSymmetricEncryption(crypt_key);
c->readed_func = [this, c](PIByteArray ba) { readed(c, ba); };
c->tcp->startThreadedRead();
c->connected();
piCout << "New client";