From 110ef47742058517eff0118315172ba8cca0ca9d Mon Sep 17 00:00:00 2001 From: Roman Khlopkov <roman.khlopkov@demlabs.net> Date: Mon, 16 Aug 2021 21:29:19 +0300 Subject: [PATCH 1/2] [+] Mime type for http simple cache --- dap-sdk/net/server/http_server/dap_http_simple.c | 2 +- dap-sdk/net/server/http_server/http_client/dap_http_client.c | 2 +- modules/modules_dynamic/cdb/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dap-sdk/net/server/http_server/dap_http_simple.c b/dap-sdk/net/server/http_server/dap_http_simple.c index 2ced45409..8712e0df4 100644 --- a/dap-sdk/net/server/http_server/dap_http_simple.c +++ b/dap-sdk/net/server/http_server/dap_http_simple.c @@ -469,7 +469,7 @@ size_t dap_http_simple_reply(dap_http_simple_t *a_http_simple, void *a_data, siz dap_http_cache_t * dap_http_simple_make_cache_from_reply(dap_http_simple_t * a_http_simple, time_t a_ts_expire ) { // Because we call it from callback, we have no headers ready for output - a_http_simple->http_client->out_content_length = a_http_simple->reply_size; + _copy_reply_and_mime_to_response(a_http_simple); a_http_simple->http_client->reply_status_code = 200; dap_http_client_out_header_generate(a_http_simple->http_client); return dap_http_cache_update(a_http_simple->http_client->proc, diff --git a/dap-sdk/net/server/http_server/http_client/dap_http_client.c b/dap-sdk/net/server/http_server/http_client/dap_http_client.c index 99c55ad51..f99a91552 100644 --- a/dap-sdk/net/server/http_server/http_client/dap_http_client.c +++ b/dap-sdk/net/server/http_server/http_client/dap_http_client.c @@ -578,7 +578,7 @@ void dap_http_client_write( dap_events_socket_t * a_esocket, void *a_arg ) } dap_events_socket_set_readable_unsafe( a_esocket, true ); } else { - //log_it(L_WARNING,"Output: header %s: %s",hdr->name,hdr->value); + //log_it(L_DEBUG,"Output: header %s: %s",hdr->name,hdr->value); dap_events_socket_write_f_unsafe(a_esocket, "%s: %s\r\n", hdr->name, hdr->value); dap_events_socket_set_writable_unsafe(a_esocket, true); dap_http_header_remove( &l_http_client->out_headers, hdr ); diff --git a/modules/modules_dynamic/cdb/CMakeLists.txt b/modules/modules_dynamic/cdb/CMakeLists.txt index 261911380..1d2ef0120 100644 --- a/modules/modules_dynamic/cdb/CMakeLists.txt +++ b/modules/modules_dynamic/cdb/CMakeLists.txt @@ -7,7 +7,7 @@ file(GLOB DAP_MODULES_DYNAMIC_CDB_HEADERS include/*.h) add_library(${PROJECT_NAME} STATIC ${DAP_MODULES_DYNAMIC_CDB_SRCS} ${DAP_MODULES_DYNAMIC_CDB_HEADERS}) -#target_link_libraries(dap_chain_net_srv dap_core dap_crypto dap_chain dap_chain_net dap_chain_wallet) +#target_link_libraries(${PROJECT_NAME} dap_chain_net_srv dap_chain_net_srv_vpn dap_crypto dap_chain dap_chain_net dap_chain_wallet zip) target_link_libraries(${PROJECT_NAME} dap_core dap_http_server ${CMAKE_DL_LIBS}) target_include_directories(${PROJECT_NAME} INTERFACE .) -- GitLab From 62e0fe7f226c48a493fc53f3fad3b573a8925c6e Mon Sep 17 00:00:00 2001 From: Roman Khlopkov <roman.khlopkov@demlabs.net> Date: Mon, 16 Aug 2021 21:44:57 +0300 Subject: [PATCH 2/2] [*] Smth warnings fixed --- dap-sdk/net/client/dap_client_http.c | 9 ++++----- dap-sdk/net/client/dap_client_pvt.c | 8 ++++---- modules/service/vpn/dap_chain_net_vpn_client_tun.c | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dap-sdk/net/client/dap_client_http.c b/dap-sdk/net/client/dap_client_http.c index a8a3e6c47..e7afb9f25 100644 --- a/dap-sdk/net/client/dap_client_http.c +++ b/dap-sdk/net/client/dap_client_http.c @@ -185,9 +185,8 @@ static bool s_timer_timeout_after_connected_check(void * a_arg) dap_worker_t * l_worker = dap_events_get_current_worker(dap_events_get_default()); // We're in own esocket context assert(l_worker); - dap_events_socket_t * l_es; - if(l_es = dap_worker_esocket_find_uuid( l_worker, l_es_handler->esocket_uuid ) ){ - + dap_events_socket_t * l_es = dap_worker_esocket_find_uuid( l_worker, l_es_handler->esocket_uuid); + if(l_es){ dap_client_http_pvt_t * l_http_pvt = PVT(l_es); assert(l_http_pvt); if ( time(NULL)- l_http_pvt->ts_last_read >= (time_t) s_client_timeout_read_after_connect_ms){ @@ -224,8 +223,8 @@ static bool s_timer_timeout_check(void * a_arg) dap_worker_t * l_worker = dap_events_get_current_worker(dap_events_get_default()); // We're in own esocket context assert(l_worker); - dap_events_socket_t * l_es; - if(l_es = dap_worker_esocket_find_uuid(l_worker, *l_es_uuid)){ + dap_events_socket_t * l_es = dap_worker_esocket_find_uuid(l_worker, *l_es_uuid); + if(l_es){ if (l_es->flags & DAP_SOCK_CONNECTING ){ dap_client_http_pvt_t * l_http_pvt = PVT(l_es); log_it(L_WARNING,"Connecting timeout for request http://%s:%u/%s, possible network problems or host is down", diff --git a/dap-sdk/net/client/dap_client_pvt.c b/dap-sdk/net/client/dap_client_pvt.c index fdd01a854..14daedc7b 100644 --- a/dap-sdk/net/client/dap_client_pvt.c +++ b/dap-sdk/net/client/dap_client_pvt.c @@ -227,8 +227,8 @@ static bool s_stream_timer_timeout_check(void * a_arg) dap_worker_t *l_worker = dap_events_get_current_worker(dap_events_get_default()); assert(l_worker); - dap_events_socket_t * l_es; - if(l_es = dap_worker_esocket_find_uuid(l_worker, l_es_handler->esocket_uuid ) ){ + dap_events_socket_t * l_es = dap_worker_esocket_find_uuid(l_worker, l_es_handler->esocket_uuid); + if(l_es){ if (l_es->flags & DAP_SOCK_CONNECTING ){ dap_client_pvt_t * l_client_pvt =(dap_client_pvt_t *) l_es->_inheritor;//(l_client) ? DAP_CLIENT_PVT(l_client) : NULL; @@ -265,8 +265,8 @@ static bool s_stream_timer_timeout_after_connected_check(void * a_arg) dap_worker_t * l_worker = dap_events_get_current_worker(dap_events_get_default()); assert(l_worker); - dap_events_socket_t * l_es; - if( l_es = dap_worker_esocket_find_uuid(l_worker, l_es_handler->esocket_uuid) ){ + dap_events_socket_t * l_es = dap_worker_esocket_find_uuid(l_worker, l_es_handler->esocket_uuid); + if( l_es ){ dap_client_pvt_t * l_client_pvt =(dap_client_pvt_t *) l_es->_inheritor;//(l_client) ? DAP_CLIENT_PVT(l_client) : NULL; if ( time(NULL)- l_client_pvt->ts_last_read >= s_client_timeout_read_after_connect){ diff --git a/modules/service/vpn/dap_chain_net_vpn_client_tun.c b/modules/service/vpn/dap_chain_net_vpn_client_tun.c index 1890dc69b..a2e8370e1 100644 --- a/modules/service/vpn/dap_chain_net_vpn_client_tun.c +++ b/modules/service/vpn/dap_chain_net_vpn_client_tun.c @@ -310,7 +310,7 @@ static void m_client_tun_read(dap_events_socket_t * a_es, void * arg) pthread_mutex_lock(&s_clients_mutex); // sent packet to vpn server - dap_stream_ch_pkt_write_mt(l_ch->stream_worker,l_ch, DAP_STREAM_CH_PKT_TYPE_NET_SRV_VPN_DATA, pkt_out, + dap_stream_ch_pkt_write_mt(l_ch->stream_worker,l_ch->uuid, DAP_STREAM_CH_PKT_TYPE_NET_SRV_VPN_DATA, pkt_out, pkt_out->header.op_data.data_size + sizeof(pkt_out->header)); pthread_mutex_unlock(&s_clients_mutex); @@ -466,7 +466,7 @@ int dap_chain_net_vpn_client_tun_delete(void) { if(s_tun_events_socket) { pthread_mutex_lock(&s_clients_mutex); - dap_events_socket_remove_and_delete_mt(s_tun_events_socket->worker, s_tun_events_socket); + dap_events_socket_remove_and_delete_mt(s_tun_events_socket->worker, s_tun_events_socket->uuid); s_tun_events_socket = NULL; pthread_mutex_unlock(&s_clients_mutex); } -- GitLab