mirror of
https://github.com/simon987/sist2.git
synced 2025-04-10 05:56:46 +00:00
Fixes for new mongoose version
This commit is contained in:
parent
7bc2ef9e6c
commit
7a7a0686c2
@ -108,7 +108,6 @@ void stats_files(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
|
|
||||||
cJSON *json = database_get_stats(db, stat_type);
|
cJSON *json = database_get_stats(db, stat_type);
|
||||||
mg_send_json(nc, json);
|
mg_send_json(nc, json);
|
||||||
|
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +168,7 @@ void serve_thumbnail(struct mg_connection *nc, struct mg_http_message *hm, int i
|
|||||||
"Cache-Control: max-age=31536000"
|
"Cache-Control: max-age=31536000"
|
||||||
);
|
);
|
||||||
mg_send(nc, data, data_len);
|
mg_send(nc, data, data_len);
|
||||||
|
nc->is_resp = 0;
|
||||||
free(data);
|
free(data);
|
||||||
} else {
|
} else {
|
||||||
HTTP_REPLY_NOT_FOUND
|
HTTP_REPLY_NOT_FOUND
|
||||||
@ -217,6 +217,7 @@ void search(struct mg_connection *nc, struct mg_http_message *hm) {
|
|||||||
snprintf(url, 4096, "%s/%s/_search", WebCtx.es_url, WebCtx.es_index);
|
snprintf(url, 4096, "%s/%s/_search", WebCtx.es_url, WebCtx.es_index);
|
||||||
|
|
||||||
nc->fn_data = web_post_async(url, body, WebCtx.es_insecure_ssl);
|
nc->fn_data = web_post_async(url, body, WebCtx.es_insecure_ssl);
|
||||||
|
nc->is_resp = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void serve_file_from_url(cJSON *json, index_t *idx, struct mg_connection *nc) {
|
void serve_file_from_url(cJSON *json, index_t *idx, struct mg_connection *nc) {
|
||||||
@ -382,11 +383,7 @@ void index_info(struct mg_connection *nc) {
|
|||||||
cJSON_AddStringToObject(json, "searchBackend", "elasticsearch");
|
cJSON_AddStringToObject(json, "searchBackend", "elasticsearch");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *json_str = cJSON_PrintUnformatted(json);
|
mg_send_json(nc, json);
|
||||||
|
|
||||||
web_send_headers(nc, 200, strlen(json_str), "Content-Type: application/json");
|
|
||||||
mg_send(nc, json_str, strlen(json_str));
|
|
||||||
free(json_str);
|
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,6 +447,7 @@ void status(struct mg_connection *nc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(status);
|
free(status);
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -738,6 +736,7 @@ static void ev_router(struct mg_connection *nc, int ev, void *ev_data) {
|
|||||||
if (r->status_code == 200) {
|
if (r->status_code == 200) {
|
||||||
web_send_headers(nc, 200, r->size, "Content-Type: application/json");
|
web_send_headers(nc, 200, r->size, "Content-Type: application/json");
|
||||||
mg_send(nc, r->body, r->size);
|
mg_send(nc, r->body, r->size);
|
||||||
|
nc->is_resp = 0;
|
||||||
} else if (r->status_code == 0) {
|
} else if (r->status_code == 0) {
|
||||||
sist_log("serve.c", LOG_SIST_ERROR, "Could not connect to elasticsearch!");
|
sist_log("serve.c", LOG_SIST_ERROR, "Could not connect to elasticsearch!");
|
||||||
|
|
||||||
|
@ -5,31 +5,37 @@
|
|||||||
void web_serve_asset_index_html(struct mg_connection *nc) {
|
void web_serve_asset_index_html(struct mg_connection *nc) {
|
||||||
web_send_headers(nc, 200, sizeof(index_html), HTTP_CROSS_ORIGIN_HEADERS "Content-Type: text/html");
|
web_send_headers(nc, 200, sizeof(index_html), HTTP_CROSS_ORIGIN_HEADERS "Content-Type: text/html");
|
||||||
mg_send(nc, index_html, sizeof(index_html));
|
mg_send(nc, index_html, sizeof(index_html));
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void web_serve_asset_index_js(struct mg_connection *nc) {
|
void web_serve_asset_index_js(struct mg_connection *nc) {
|
||||||
web_send_headers(nc, 200, sizeof(index_js), "Content-Type: application/javascript");
|
web_send_headers(nc, 200, sizeof(index_js), "Content-Type: application/javascript");
|
||||||
mg_send(nc, index_js, sizeof(index_js));
|
mg_send(nc, index_js, sizeof(index_js));
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void web_serve_asset_chunk_vendors_js(struct mg_connection *nc) {
|
void web_serve_asset_chunk_vendors_js(struct mg_connection *nc) {
|
||||||
web_send_headers(nc, 200, sizeof(chunk_vendors_js), "Content-Type: application/javascript");
|
web_send_headers(nc, 200, sizeof(chunk_vendors_js), "Content-Type: application/javascript");
|
||||||
mg_send(nc, chunk_vendors_js, sizeof(chunk_vendors_js));
|
mg_send(nc, chunk_vendors_js, sizeof(chunk_vendors_js));
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void web_serve_asset_favicon_ico(struct mg_connection *nc) {
|
void web_serve_asset_favicon_ico(struct mg_connection *nc) {
|
||||||
web_send_headers(nc, 200, sizeof(favicon_ico), "Content-Type: image/x-icon");
|
web_send_headers(nc, 200, sizeof(favicon_ico), "Content-Type: image/x-icon");
|
||||||
mg_send(nc, favicon_ico, sizeof(favicon_ico));
|
mg_send(nc, favicon_ico, sizeof(favicon_ico));
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void web_serve_asset_style_css(struct mg_connection *nc) {
|
void web_serve_asset_style_css(struct mg_connection *nc) {
|
||||||
web_send_headers(nc, 200, sizeof(index_css), "Content-Type: text/css");
|
web_send_headers(nc, 200, sizeof(index_css), "Content-Type: text/css");
|
||||||
mg_send(nc, index_css, sizeof(index_css));
|
mg_send(nc, index_css, sizeof(index_css));
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void web_serve_asset_chunk_vendors_css(struct mg_connection *nc) {
|
void web_serve_asset_chunk_vendors_css(struct mg_connection *nc) {
|
||||||
web_send_headers(nc, 200, sizeof(chunk_vendors_css), "Content-Type: text/css");
|
web_send_headers(nc, 200, sizeof(chunk_vendors_css), "Content-Type: text/css");
|
||||||
mg_send(nc, chunk_vendors_css, sizeof(chunk_vendors_css));
|
mg_send(nc, chunk_vendors_css, sizeof(chunk_vendors_css));
|
||||||
|
nc->is_resp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
index_t *web_get_index_by_id(int index_id) {
|
index_t *web_get_index_by_id(int index_id) {
|
||||||
@ -92,6 +98,7 @@ void mg_send_json(struct mg_connection *nc, const cJSON *json) {
|
|||||||
|
|
||||||
web_send_headers(nc, 200, strlen(json_str), "Content-Type: application/json");
|
web_send_headers(nc, 200, strlen(json_str), "Content-Type: application/json");
|
||||||
mg_send(nc, json_str, strlen(json_str));
|
mg_send(nc, json_str, strlen(json_str));
|
||||||
|
nc->is_resp = 0;
|
||||||
|
|
||||||
free(json_str);
|
free(json_str);
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,24 @@ database_t *web_get_database(int index_id);
|
|||||||
|
|
||||||
__always_inline
|
__always_inline
|
||||||
static char *web_address_to_string(struct mg_addr *addr) {
|
static char *web_address_to_string(struct mg_addr *addr) {
|
||||||
static char address_to_string_buf[INET6_ADDRSTRLEN];
|
static char address_to_string_buf[64];
|
||||||
|
|
||||||
mg_snprintf(address_to_string_buf, sizeof(address_to_string_buf), "%I", addr);
|
if (addr->is_ip6) {
|
||||||
|
snprintf(address_to_string_buf, sizeof(address_to_string_buf),
|
||||||
|
"%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
|
||||||
|
addr->ip[0], addr->ip[1],
|
||||||
|
addr->ip[2], addr->ip[3],
|
||||||
|
addr->ip[4], addr->ip[5],
|
||||||
|
addr->ip[6], addr->ip[7],
|
||||||
|
addr->ip[8], addr->ip[9],
|
||||||
|
addr->ip[10], addr->ip[11],
|
||||||
|
addr->ip[12], addr->ip[13],
|
||||||
|
addr->ip[14], addr->ip[15]);
|
||||||
|
} else {
|
||||||
|
snprintf(address_to_string_buf, sizeof(address_to_string_buf),
|
||||||
|
"%d.%d.%d.%d",
|
||||||
|
addr->ip[0], addr->ip[1], addr->ip[2], addr->ip[3]);
|
||||||
|
}
|
||||||
|
|
||||||
return address_to_string_buf;
|
return address_to_string_buf;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user