From f2ae653886d5cdca8947803e1399394e2110073f Mon Sep 17 00:00:00 2001 From: simon987 Date: Sat, 16 May 2020 08:16:49 -0400 Subject: [PATCH] Revert "wip" This reverts commit 5686bc86 --- .gitmodules | 3 --- CMakeLists.txt | 10 +++++----- src/index/web.c | 17 ++++------------- src/index/web.h | 2 +- third-party/mongoose | 1 - 5 files changed, 10 insertions(+), 23 deletions(-) delete mode 160000 third-party/mongoose diff --git a/.gitmodules b/.gitmodules index efa1f71..1b29252 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "third-party/argparse"] path = third-party/argparse url = https://github.com/cofyc/argparse -[submodule "third-party/mongoose"] - path = third-party/mongoose - url = https://github.com/cesanta/mongoose/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cce9c1..ae2d9f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,22 +28,20 @@ add_executable( # argparse third-party/argparse/argparse.h third-party/argparse/argparse.c - third-party/mongoose/mongoose.h third-party/mongoose/mongoose.c src/cli.c src/cli.h ) -target_compile_definitions(sist2 PUBLIC MG_ENABLE_SSL=1) - target_link_directories(sist2 PRIVATE BEFORE ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/) set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib) find_package(lmdb CONFIG REQUIRED) find_package(cJSON CONFIG REQUIRED) find_package(unofficial-glib CONFIG REQUIRED) +find_package(unofficial-mongoose CONFIG REQUIRED) find_library(UUID_LIB NAMES uuid) -find_package(OpenSSL REQUIRED) +#find_package(OpenSSL REQUIRED) target_include_directories( @@ -74,6 +72,7 @@ if (SIST_DEBUG) sist2 PRIVATE -fsanitize=address +# -static ) set_target_properties( sist2 @@ -104,7 +103,8 @@ target_link_libraries( cjson argparse unofficial::glib::glib - OpenSSL::SSL OpenSSL::Crypto + unofficial::mongoose::mongoose +# OpenSSL::SSL OpenSSL::Crypto ${UUID_LIB} pthread diff --git a/src/index/web.c b/src/index/web.c index a776586..8eaa16a 100644 --- a/src/index/web.c +++ b/src/index/web.c @@ -2,6 +2,9 @@ #include "src/sist.h" #include "src/ctx.h" +#include +#include + void free_response(response_t *resp) { if (resp->body != NULL) { @@ -74,19 +77,7 @@ subreq_ctx_t *http_req(const char *url, const char *extra_headers, const char *p char address[8196]; snprintf(address, sizeof(address), "tcp://%.*s:%u", (int) host.len, host.p, port); - struct mg_connect_opts opts; - memset(&opts, 0, sizeof(opts)); - opts.ssl_key = "./a.key"; - opts.ssl_cert = "./cert.crt"; - opts.ssl_ca_cert = "*"; - opts.ssl_server_name = "dev2.simon987.net:443"; - const char* tmp[256]; - opts.error_string = tmp; - - struct mg_connection *nc = mg_connect_opt(&ctx->mgr, address, http_req_ev, opts); - printf("%d\n", nc->err); - - + struct mg_connection *nc = mg_connect(&ctx->mgr, address, http_req_ev); nc->user_data = &ctx->ev_data; mg_set_protocol_http_websocket(nc); diff --git a/src/index/web.h b/src/index/web.h index 4045090..be525ac 100644 --- a/src/index/web.h +++ b/src/index/web.h @@ -2,7 +2,7 @@ #define SIST2_WEB_H #include "src/sist.h" -#include "third-party/mongoose/mongoose.h" +#include typedef struct response { char *body; diff --git a/third-party/mongoose b/third-party/mongoose deleted file mode 160000 index 359060a..0000000 --- a/third-party/mongoose +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 359060a151998c5ab08e54af1420b7406005dc6b