From: Patrick Date: Wed, 21 Jun 2023 18:16:44 +0000 (+0200) Subject: get send encrypted to send :) X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/commitdiff_plain/1273c8ea309926e377cbd5cc6dab6740910aa6ff get send encrypted to send :) --- diff --git a/Makefile b/Makefile index 88b1941..8197ee5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CC=gcc +CC=clang++ C_OPTS=-Wall -Wextra -pedantic C_OPTS+=src/matrix.c @@ -9,12 +9,12 @@ C_OPTS+=-I src/ C_OPTS+=-I ext/olm/include/ C_OPTS+=-I ext/mjson/src/ C_OPTS+=-I ext/mongoose/ -C_OPTS+=-L out/olm/ C_OPTS+=-l ws2_32 C_OPTS+=-l ssl C_OPTS+=-l crypto -C_OPTS+=-l olm +C_OPTS+=out/olm/libolm.a C_OPTS+=-D MG_ENABLE_OPENSSL=1 +C_OPTS+=-fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:test.pdb # C_OPTS+=-I ext/curl/include/ # C_OPTS+=-L ext/curl/build/lib/ # C_OPTS+=-l curl diff --git a/src/matrix.c b/src/matrix.c index 28e7634..cc34a0a 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -294,7 +294,7 @@ MatrixClientSendEventEncrypted( "\"algorithm\":\"m.megolm.v1.aes-sha2\"," "\"sender_key\":\"%s\"," "\"ciphertext\":\"%s\"," - "\"session_id\":%s," + "\"session_id\":\"%s\"," "\"device_id\":\"%s\"" "}", senderKey, diff --git a/src/matrix_http_mongoose.c b/src/matrix_http_mongoose.c index 020b4c8..2e500d6 100644 --- a/src/matrix_http_mongoose.c +++ b/src/matrix_http_mongoose.c @@ -36,7 +36,7 @@ MatrixHttpCallback( // If s_url is https://, tell client connection to use TLS if (mg_url_is_ssl(client->server)) { - struct mg_tls_opts opts; + static struct mg_tls_opts opts; opts.srvname = host; mg_tls_init(c, &opts); } @@ -71,7 +71,8 @@ MatrixHttpInit( mg_mgr_init(&conn->mgr); - mg_http_connect(&conn->mgr, client->server, MatrixHttpCallback, client); + struct mg_connection * c = + mg_http_connect(&conn->mgr, client->server, MatrixHttpCallback, client); while (! conn->connected) mg_mgr_poll(&conn->mgr, 1000); @@ -198,6 +199,20 @@ MatrixHttpPut( else authorizationHeader[0] = '\0'; + printf("PUT %s HTTP/1.0\r\n" + "Host: %.*s\r\n" + "%s" + "Content-Type: application/json\r\n" + "Content-Length: %d\r\n" + "\r\n" + "%s" + "\r\n", + url, + host.len, host.ptr, + authorizationHeader, + strlen(requestBuffer), + requestBuffer); + mg_printf(conn->connection, "PUT %s HTTP/1.0\r\n" "Host: %.*s\r\n"