summaryrefslogtreecommitdiff
path: root/src/analysis/db/cdb.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-01 11:16:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-01 11:16:12 (GMT)
commit29eae5126251eb0f10d02700bb87dac9893bb445 (patch)
tree34e8906f0d6f3948b80cf59b86f2d5179fa379ad /src/analysis/db/cdb.c
parent09f07c9a523dce7b8d7e013857f988f727f1a72b (diff)
Encrypted all communications using TLS.
Diffstat (limited to 'src/analysis/db/cdb.c')
-rw-r--r--src/analysis/db/cdb.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/analysis/db/cdb.c b/src/analysis/db/cdb.c
index bfe6238..fd1f5cf 100644
--- a/src/analysis/db/cdb.c
+++ b/src/analysis/db/cdb.c
@@ -56,7 +56,7 @@
/* Informations relatives à un client */
typedef struct _cdb_client
{
- int fd; /* Canal de communication */
+ SSL *ssl_fd; /* Canal de communication */
rle_string user; /* Utilisateur à l'autre bout */
uint64_t last_time; /* Date de dernier envoi */
@@ -779,7 +779,7 @@ static void on_collection_changed(GDbCollection *collec, DBAction action, GDbIte
g_mutex_lock(&archive->clients_access);
for (i = 0; i < archive->count && status; i++)
- status = send_packed_buffer(&pbuf, archive->clients[i].fd);
+ status = ssl_send_packed_buffer(&pbuf, archive->clients[i].ssl_fd);
g_mutex_unlock(&archive->clients_access);
@@ -849,7 +849,7 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
for (i = 0; i < nfds; i++)
{
- fds[i].fd = archive->clients[i].fd;
+ fds[i].fd = SSL_get_fd(archive->clients[i].ssl_fd);
fds[i].events = POLLIN | POLLPRI;
}
@@ -883,7 +883,7 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
{
init_packed_buffer(&in_pbuf);
- status = recv_packed_buffer(&in_pbuf, fds[i].fd);
+ status = ssl_recv_packed_buffer(&in_pbuf, archive->clients[i].ssl_fd);
if (!status) goto gcap_bad_exchange;
status = extract_packed_buffer(&in_pbuf, &tmp32, sizeof(uint32_t), true);
@@ -906,7 +906,7 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
status = extend_packed_buffer(&out_pbuf, (uint32_t []) { error }, sizeof(uint32_t), true);
if (!status) goto gcap_bad_reply;
- status = send_packed_buffer(&out_pbuf, fds[i].fd);
+ status = ssl_send_packed_buffer(&out_pbuf, archive->clients[i].ssl_fd);
if (!status) goto gcap_bad_reply;
exit_packed_buffer(&out_pbuf);
@@ -1008,7 +1008,7 @@ static void *g_cdb_archive_process(GCdbArchive *archive)
* *
******************************************************************************/
-DBError g_cdb_archive_add_client(GCdbArchive *archive, int fd, const rle_string *user)
+DBError g_cdb_archive_add_client(GCdbArchive *archive, SSL *fd, const rle_string *user)
{
GList *iter; /* Boucle de parcours */
@@ -1028,7 +1028,7 @@ DBError g_cdb_archive_add_client(GCdbArchive *archive, int fd, const rle_string
archive->clients = (cdb_client *)realloc(archive->clients, ++archive->count * sizeof(cdb_client));
- archive->clients[archive->count - 1].fd = fd;
+ archive->clients[archive->count - 1].ssl_fd = fd;
dup_into_rle_string(&archive->clients[archive->count - 1].user, get_rle_string(user));
/* Démarrage ou redémarrage du processus d'écoute */
@@ -1072,7 +1072,7 @@ DBError g_cdb_archive_add_client(GCdbArchive *archive, int fd, const rle_string
}
if (status && get_packed_buffer_payload_length(&out_pbuf) > 0)
- status = send_packed_buffer(&out_pbuf, fd);
+ status = ssl_send_packed_buffer(&out_pbuf, fd);
exit_packed_buffer(&out_pbuf);