diff --git a/dap-sdk/net/client/dap_client_http.c b/dap-sdk/net/client/dap_client_http.c index 7177418ac9f095a06e1b91542112f474404b0410..8ad1f99eb537e6ded2cc08c49e168ec8e27f990e 100644 --- a/dap-sdk/net/client/dap_client_http.c +++ b/dap-sdk/net/client/dap_client_http.c @@ -76,7 +76,7 @@ typedef struct dap_http_client_internal { #define PVT(a) (a ? (dap_client_http_pvt_t *) (a)->_inheritor : NULL) static void s_http_connected(dap_events_socket_t * a_esocket); // Connected callback -static void s_http_delete(dap_events_socket_t * a_es, void * arg); +static void s_client_http_delete(dap_client_http_pvt_t * a_http_pvt); static void s_http_read(dap_events_socket_t * a_es, void * arg); static void s_http_error(dap_events_socket_t * a_es, int a_arg); @@ -147,12 +147,6 @@ static void s_http_read(dap_events_socket_t * a_es, void * arg) // process data if(l_client_http_internal->content_length) { l_client_http_internal->is_header_read = false; - /* debug - if(l_client_internal->content_length != (l_client_internal->response_size - l_client_internal->header_length)) { - log_it(L_DEBUG, "s_http_read error!!! content_length(%d)!=response_size-header_size(%d)=%d", - l_client_internal->content_length, l_client_internal->header_length, - l_client_internal->response_size - l_client_internal->header_length); - }*/ // received not enough data if(l_client_http_internal->content_length @@ -169,15 +163,11 @@ static void s_http_read(dap_events_socket_t * a_es, void * arg) l_client_http_internal->response_size -= l_client_http_internal->content_length; l_client_http_internal->header_length = 0; l_client_http_internal->content_length = 0; - // if the data remains, then read once more - if(l_client_http_internal->response_size > 0) { - s_http_read(a_es, arg); - } - else { - // close connection - a_es->kill_signal=true; - //dap_events_socket_remove_and_delete(a_es, true); //dap_events_socket_delete(a_es, true); - } + + s_client_http_delete(l_client_http_internal); + a_es->_inheritor = NULL; + a_es->kill_signal=true; + a_es->flags &= DAP_SOCK_SIGNAL_CLOSE; } } @@ -207,6 +197,8 @@ static void s_http_error(dap_events_socket_t * a_es, int a_errno) if(l_client_http_internal->error_callback) l_client_http_internal->error_callback(a_errno, l_client_http_internal->obj); + s_client_http_delete(l_client_http_internal); + a_es->_inheritor = NULL; // close connection. // TODO merge this things into the one (I expect better it would be flag ) a_es->flags &= DAP_SOCK_SIGNAL_CLOSE; @@ -214,25 +206,30 @@ static void s_http_error(dap_events_socket_t * a_es, int a_errno) } /** - * @brief s_http_delete - * @param a_es - * @param arg + * @brief s_client_http_delete + * @param a_http_pvt */ -static void s_http_delete(dap_events_socket_t *a_es, void *arg) +static void s_client_http_delete(dap_client_http_pvt_t * a_http_pvt) { - UNUSED(arg); // call from dap_events_socket_delete(ev_socket, true); - log_it(L_DEBUG, "HTTP client disconnected"); - dap_client_http_pvt_t * l_client_http_internal = PVT(a_es); - if(!l_client_http_internal) { + log_it(L_DEBUG, "HTTP client delete"); + if(!a_http_pvt) { log_it(L_ERROR, "s_http_write: l_client_http_internal is NULL!"); return; } - if (l_client_http_internal->response){ - DAP_DELETE(l_client_http_internal->response); - l_client_http_internal->response = NULL; + if (a_http_pvt->response){ + DAP_DELETE(a_http_pvt->response); + a_http_pvt->response = NULL; + } + + if(a_http_pvt->request_custom_headers != NULL) { + for( size_t i = 0; i < a_http_pvt->request_custom_headers_count; i++) { + DAP_DELETE( a_http_pvt->request_custom_headers[i]); + } + //DAP_DELETE( l_client_http_pvt->request_custom_headers); } + } @@ -263,8 +260,7 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin static dap_events_socket_callbacks_t l_s_callbacks = { .connected_callback = s_http_connected, .read_callback = s_http_read, - .error_callback = s_http_error, - .delete_callback = s_http_delete + .error_callback = s_http_error }; // create socket @@ -296,25 +292,26 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin dap_events_socket_t *l_ev_socket = dap_events_socket_wrap_no_add(dap_events_get_default(), l_socket, &l_s_callbacks); // create private struct - dap_client_http_pvt_t *l_client_http_internal = DAP_NEW_Z(dap_client_http_pvt_t); - l_ev_socket->_inheritor = l_client_http_internal; - l_client_http_internal->error_callback = a_error_callback; - l_client_http_internal->response_callback = a_response_callback; + dap_client_http_pvt_t *l_http_pvt = DAP_NEW_Z(dap_client_http_pvt_t); + l_ev_socket->_inheritor = l_http_pvt; + l_http_pvt->error_callback = a_error_callback; + l_http_pvt->response_callback = a_response_callback; //l_client_http_internal->socket = l_socket; - l_client_http_internal->obj = a_obj; - l_client_http_internal->method = a_method; - l_client_http_internal->path = a_path; - l_client_http_internal->request_content_type = a_request_content_type; - l_client_http_internal->request = a_request; - l_client_http_internal->request_size = a_request_size; - l_client_http_internal->uplink_addr = a_uplink_addr; - l_client_http_internal->uplink_port = a_uplink_port; - l_client_http_internal->cookie = a_cookie; - l_client_http_internal->request_custom_headers = a_custom; - l_client_http_internal->request_custom_headers_count = a_custom_count; - - l_client_http_internal->response_size_max = DAP_CLIENT_HTTP_RESPONSE_SIZE_MAX; - l_client_http_internal->response = (uint8_t*) DAP_NEW_Z_SIZE(uint8_t, DAP_CLIENT_HTTP_RESPONSE_SIZE_MAX); + l_http_pvt->obj = a_obj; + l_http_pvt->method = a_method; + l_http_pvt->path = a_path; + l_http_pvt->request_content_type = a_request_content_type; + l_http_pvt->request = a_request; + l_http_pvt->request_size = a_request_size; + l_http_pvt->uplink_addr = a_uplink_addr; + l_http_pvt->uplink_port = a_uplink_port; + l_http_pvt->cookie = a_cookie; + l_http_pvt->request_custom_headers = a_custom; + l_http_pvt->request_custom_headers_count = a_custom_count; + + l_http_pvt->response_size_max = DAP_CLIENT_HTTP_RESPONSE_SIZE_MAX; + l_http_pvt->response = (uint8_t*) DAP_NEW_Z_SIZE(uint8_t, DAP_CLIENT_HTTP_RESPONSE_SIZE_MAX); + l_http_pvt->worker = a_worker; // get struct in_addr from ip_str @@ -323,6 +320,8 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin if(!l_ev_socket->remote_addr.sin_addr.s_addr) { if(dap_net_resolve_host(a_uplink_addr, AF_INET, (struct sockaddr*) &l_ev_socket->remote_addr.sin_addr) < 0) { log_it(L_ERROR, "Wrong remote address '%s:%u'", a_uplink_addr, a_uplink_port); + s_client_http_delete( l_http_pvt); + l_ev_socket->_inheritor = NULL; dap_events_socket_delete_unsafe( l_ev_socket, true); return NULL; } @@ -334,19 +333,21 @@ void* dap_client_http_request_custom(dap_worker_t * a_worker,const char *a_uplin int l_err = connect(l_socket, (struct sockaddr *) &l_ev_socket->remote_addr, sizeof(struct sockaddr_in)); if (l_err == 0){ log_it(L_DEBUG, "Connected momentaly with %s:%u!", a_uplink_addr, a_uplink_port); - l_client_http_internal->worker = a_worker?a_worker: dap_events_worker_get_auto(); - dap_worker_add_events_socket(l_ev_socket,l_client_http_internal->worker); - return l_client_http_internal; + l_http_pvt->worker = a_worker?a_worker: dap_events_worker_get_auto(); + dap_worker_add_events_socket(l_ev_socket,l_http_pvt->worker); + return l_http_pvt; }else if( errno == EINPROGRESS && l_err == -1){ log_it(L_DEBUG, "Connecting to %s:%u", a_uplink_addr, a_uplink_port); - l_client_http_internal->worker = a_worker?a_worker: dap_events_worker_get_auto(); - dap_worker_add_events_socket(l_ev_socket,l_client_http_internal->worker); - return l_client_http_internal; + l_http_pvt->worker = a_worker?a_worker: dap_events_worker_get_auto(); + dap_worker_add_events_socket(l_ev_socket,l_http_pvt->worker); + return l_http_pvt; }else{ char l_errbuf[128]; l_errbuf[0] = '\0'; strerror_r(l_err, l_errbuf, sizeof (l_errbuf)); log_it(L_ERROR, "Connecting error: \"%s\" (code %d)", l_errbuf, l_err); + s_client_http_delete( l_http_pvt); + l_ev_socket->_inheritor = NULL; dap_events_socket_delete_unsafe( l_ev_socket, true); return NULL; } @@ -382,9 +383,10 @@ static void s_http_connected(dap_events_socket_t * a_esocket) // Add custom headers if(l_http_pvt->request_custom_headers) { for( size_t i = 0; i < l_http_pvt->request_custom_headers_count; i++) { - l_request_headers = dap_string_append(l_request_headers, (char*) l_http_pvt->request_custom_headers[i]); + l_request_headers = dap_string_append(l_request_headers, l_http_pvt->request_custom_headers[i]); l_request_headers = dap_string_append(l_request_headers, "\r\n"); } + } // Setup cookie header @@ -413,14 +415,14 @@ static void s_http_connected(dap_events_socket_t * a_esocket) } // send header - dap_events_socket_write_f_mt(l_worker, a_esocket, "%s /%s%s HTTP/1.1\r\n" + dap_events_socket_write_f_unsafe( a_esocket, "%s /%s%s HTTP/1.1\r\n" "Host: %s\r\n" "%s" "\r\n", l_http_pvt->method, l_http_pvt->path, l_get_str ? l_get_str : "", l_http_pvt->uplink_addr, l_request_headers->str); // send data for POST request if(!l_get_str) - dap_events_socket_write_mt(l_worker, a_esocket, l_http_pvt->request, l_http_pvt->request_size); + dap_events_socket_write_unsafe( a_esocket, l_http_pvt->request, l_http_pvt->request_size); DAP_DELETE(l_get_str); dap_string_free(l_request_headers, true); diff --git a/dap-sdk/net/client/dap_client_pvt.c b/dap-sdk/net/client/dap_client_pvt.c index 3e5b2d31237ddcec3102b90af20f3f0a99ebc6b1..2814a5bfb682fc41c5db136b8dfa8889c9e75897 100644 --- a/dap-sdk/net/client/dap_client_pvt.c +++ b/dap-sdk/net/client/dap_client_pvt.c @@ -127,6 +127,9 @@ void dap_client_pvt_deinit() */ void dap_client_pvt_new(dap_client_pvt_t * a_client_internal) { + a_client_internal->session_key_type = DAP_ENC_KEY_TYPE_BF_OFB; + a_client_internal->session_key_open_type = DAP_ENC_KEY_TYPE_MSRLN; + a_client_internal->stage = STAGE_BEGIN; // start point of state machine a_client_internal->stage_status = STAGE_STATUS_DONE; a_client_internal->uplink_protocol_version = DAP_PROTOCOL_VERSION; @@ -218,7 +221,7 @@ void dap_client_pvt_delete_n_wait(dap_client_pvt_t * a_client_pvt) */ static void s_stream_connected(dap_client_pvt_t * a_client_pvt) { - log_it(L_INFO, "Remote address connected (%s:%u) with sock_id %d (assign on worker #%u)", a_client_pvt->uplink_addr, + log_it(L_INFO, "Remote address connected for streaming on (%s:%u) with sock_id %d (assign on worker #%u)", a_client_pvt->uplink_addr, a_client_pvt->uplink_port, a_client_pvt->stream_socket, a_client_pvt->stream_worker->worker->id); a_client_pvt->stage_status = STAGE_STATUS_DONE; s_stage_status_after(a_client_pvt); @@ -242,7 +245,9 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) switch (l_stage) { case STAGE_ENC_INIT: { log_it(L_INFO, "Go to stage ENC: prepare the request"); - a_client_pvt->session_key_open = dap_enc_key_new_generate(DAP_ENC_KEY_TYPE_MSRLN, NULL, 0, NULL, 0, 0); + + + a_client_pvt->session_key_open = dap_enc_key_new_generate(a_client_pvt->session_key_open_type, NULL, 0, NULL, 0, 0); if (!a_client_pvt->session_key_open) { log_it(L_ERROR, "Insufficient memory! May be a huge memory leak present"); a_client_pvt->stage_status = STAGE_STATUS_ERROR; @@ -266,7 +271,13 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) // DAP_ENC_DATA_TYPE_B64_URLSAFE not need because send it by POST request size_t l_data_str_enc_size = dap_enc_base64_encode(l_data, l_key_size + l_sign_size, l_data_str, DAP_ENC_DATA_TYPE_B64); log_it(L_DEBUG, "ENC request size %u", l_data_str_enc_size); - int l_res = dap_client_pvt_request(a_client_pvt, DAP_UPLINK_PATH_ENC_INIT "/gd4y5yh78w42aaagh", + + char * l_enc_init_url = dap_strdup_printf(DAP_UPLINK_PATH_ENC_INIT + "/gd4y5yh78w42aaagh" "?enc_type=%d,pkey_exchange_type=%d,pkey_exchange_size=%zd", + a_client_pvt->session_key_type, a_client_pvt->session_key_open_type, + l_key_size ); + + int l_res = dap_client_pvt_request(a_client_pvt, l_enc_init_url, l_data_str, l_data_str_enc_size, s_enc_init_response, s_enc_init_error); // bad request if(l_res<0){ @@ -289,14 +300,15 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) l_suburl = dap_strdup_printf("stream_ctl,channels=%s", a_client_pvt->active_channels); }else{ - l_suburl = dap_strdup_printf("stream_ctl,channels=%s,enc_type=%d,enc_headers=%d", - a_client_pvt->active_channels,dap_stream_get_preferred_encryption_type(),0); + l_suburl = dap_strdup_printf("channels=%s,enc_type=%d,enc_headers=%d", + a_client_pvt->active_channels,a_client_pvt->session_key_type,0); } - // + log_it(L_DEBUG, "Prepared enc request for streaming"); dap_client_pvt_request_enc(a_client_pvt, DAP_UPLINK_PATH_STREAM_CTL, l_suburl, "type=tcp,maxconn=4", l_request, l_request_size, s_stream_ctl_response, s_stream_ctl_error); + log_it(L_DEBUG, "Sent enc request for streaming"); DAP_DELETE(l_request); DAP_DELETE(l_suburl); } @@ -305,13 +317,23 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) log_it(L_INFO, "Go to stage STREAM_SESSION: process the state ops"); a_client_pvt->stream_socket = socket( PF_INET, SOCK_STREAM, 0); - fcntl( a_client_pvt->stream_socket, F_SETFL, O_NONBLOCK); if (a_client_pvt->stream_socket == -1) { log_it(L_ERROR, "Error %d with socket create", errno); a_client_pvt->stage_status = STAGE_STATUS_ERROR; break; } + // Get socket flags + int l_socket_flags = fcntl(a_client_pvt->stream_socket, F_GETFL); + if (l_socket_flags == -1){ + log_it(L_ERROR, "Error %d can't get socket flags", errno); + break;; + } + // Make it non-block + if (fcntl( a_client_pvt->stream_socket, F_SETFL,l_socket_flags| O_NONBLOCK) == -1){ + log_it(L_ERROR, "Error %d can't get socket flags", errno); + break;; + } #ifdef _WIN32 { int buffsize = 65536*4; @@ -335,7 +357,7 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) };// a_client_pvt->stream_es = dap_events_socket_wrap_no_add(a_client_pvt->events, a_client_pvt->stream_socket, &l_s_callbacks); - a_client_pvt->stream_es->flags &= DAP_SOCK_CONNECTING ; // To catch non-blocking error when connecting we should ar WRITE flag + a_client_pvt->stream_es->flags |= DAP_SOCK_CONNECTING ; // To catch non-blocking error when connecting we should ar WRITE flag a_client_pvt->stream_es->_inheritor = a_client_pvt; a_client_pvt->stream = dap_stream_new_es_client(a_client_pvt->stream_es); @@ -348,7 +370,6 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) a_client_pvt->stream_worker = DAP_STREAM_WORKER(l_worker); a_client_pvt->stream->stream_worker = a_client_pvt->stream_worker; - // connect memset(&a_client_pvt->stream_es->remote_addr, 0, sizeof(a_client_pvt->stream_es->remote_addr)); a_client_pvt->stream_es->remote_addr.sin_family = AF_INET; @@ -368,7 +389,7 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) sizeof(struct sockaddr_in))) ==0) { log_it(L_DEBUG, "Connected momentaly with %s:%u", a_client_pvt->uplink_addr, a_client_pvt->uplink_port); // add to dap_worker - dap_worker_add_events_socket_unsafe( a_client_pvt->stream_es, l_worker); + dap_worker_add_events_socket( a_client_pvt->stream_es, l_worker); } else if (l_err != EINPROGRESS && l_err != -1){ char l_errbuf[128]; @@ -386,13 +407,13 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) s_stage_status_after(a_client_pvt); }else{ - log_it(L_INFO,"Connecting to remote %s:%s",a_client_pvt->uplink_addr, a_client_pvt->uplink_port); + log_it(L_INFO,"Connecting stream to remote %s:%u",a_client_pvt->uplink_addr, a_client_pvt->uplink_port); // add to dap_worker - dap_worker_add_events_socket_unsafe(a_client_pvt->stream_es, l_worker); + dap_worker_add_events_socket( a_client_pvt->stream_es, l_worker); } } } - break; + break; case STAGE_STREAM_CONNECTED: { log_it(L_INFO, "Go to stage STAGE_STREAM_CONNECTED"); size_t count_channels = a_client_pvt->active_channels? strlen(a_client_pvt->active_channels) : 0; @@ -443,11 +464,8 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) } } } - break; - // case STAGE_STATUS_ABORTING: { - // log_it(L_ERROR, "Aborting state"); - // } - break; + break; + case STAGE_STATUS_ERROR: { // limit the number of attempts int MAX_ATTEMPTS = 3; @@ -514,8 +532,6 @@ static void s_stage_status_after(dap_client_pvt_t * a_client_pvt) // Expecting that its one-shot callback a_client_pvt->stage_target_done_callback = NULL; } - } else if (a_client_pvt->stage != STAGE_STREAM_CTL) { // need wait for dap_client_pvt_request_enc response - log_it(L_ERROR, "!! dap_CLIENT_STAGE_STATUS_DONE but not l_is_last_stage (cur stage=%d, target=%d)!!",a_client_pvt->stage, a_client_pvt->stage_target); } //l_is_unref = true; } @@ -672,27 +688,22 @@ void dap_client_pvt_request_enc(dap_client_pvt_t * a_client_internal, const char } } - size_t l_key_hdr_str_size_max = a_client_internal->session_key_id ? strlen(a_client_internal->session_key_id) + 10 : 12; - char *l_key_hdr_str = DAP_NEW_Z_SIZE(char, l_key_hdr_str_size_max); - snprintf(l_key_hdr_str, l_key_hdr_str_size_max, "KeyID: %s", - a_client_internal->session_key_id ? a_client_internal->session_key_id : "NULL"); - - char *a_custom_new[2]; - size_t a_custom_count = 1; - a_custom_new[0] = l_key_hdr_str; + size_t l_custom_count = 1; + char **l_custom_new = DAP_NEW_Z_SIZE(char*,2*sizeof (char*)); + l_custom_new[0] = dap_strdup_printf("KeyID: %s", a_client_internal->session_key_id ? + a_client_internal->session_key_id : "NULL"); // close session if(a_client_internal->is_close_session) { - a_custom_new[1] = "SessionCloseAfterRequest: true"; - a_custom_count++; + l_custom_new[1] = dap_strdup("SessionCloseAfterRequest: true"); + l_custom_count++; } dap_client_http_request_custom(a_client_internal->worker, a_client_internal->uplink_addr, a_client_internal->uplink_port, a_request ? "POST" : "GET", "text/text", l_path, l_request_enc, l_request_enc_size, NULL, - s_request_response, s_request_error, a_client_internal, a_custom_new, a_custom_count); + s_request_response, s_request_error, a_client_internal, l_custom_new, l_custom_count); // dap_http_client_simple_request_custom(l_url_full, a_request ? "POST" : "GET", "text/text", // l_request_enc, l_request_enc_size, NULL, // m_request_response, a_client_internal->curl_sockfd ,m_request_error, a_client_internal, a_custom_new, a_custom_count); - DAP_DELETE(l_key_hdr_str); if(l_sub_url_enc) DAP_DELETE(l_sub_url_enc); @@ -827,7 +838,7 @@ static void s_enc_init_response(dap_client_t * a_client, void * a_response, size l_client_pvt->session_key_open, l_client_pvt->session_key_open->priv_key_data, l_bob_message_size, (unsigned char*) l_bob_message); - l_client_pvt->session_key = dap_enc_key_new_generate(DAP_ENC_KEY_TYPE_IAES, + l_client_pvt->session_key = dap_enc_key_new_generate(l_client_pvt->session_key_type, l_client_pvt->session_key_open->priv_key_data, // shared key l_client_pvt->session_key_open->priv_key_data_size, l_client_pvt->session_key_id, strlen(l_client_pvt->session_key_id), 0); @@ -916,7 +927,7 @@ static void s_stream_ctl_response(dap_client_t * a_client, void * a_data, size_t char l_stream_id[26] = { 0 }; char *l_stream_key = DAP_NEW_Z_SIZE(char, 4096 * 3); uint32_t l_remote_protocol_version; - dap_enc_key_type_t l_enc_type = DAP_ENC_KEY_TYPE_OAES; + dap_enc_key_type_t l_enc_type = l_client_internal->session_key_type; int l_enc_headers = 0; l_arg_count = sscanf(l_response_str, "%25s %4096s %u %d %d" @@ -1044,6 +1055,7 @@ static void s_stage_stream_streaming(dap_client_t * a_client, void* arg) */ static void s_stream_es_callback_connected(dap_events_socket_t * a_es) { + dap_client_pvt_t * l_client_pvt =(dap_client_pvt_t*) a_es->_inheritor; s_stream_connected(l_client_pvt); } diff --git a/dap-sdk/net/client/include/dap_client.h b/dap-sdk/net/client/include/dap_client.h index aa0da2b35f2f8a91d66ded9b9c2dcbec06c530fa..2d481b5ddf5386216a09f76d80729be9f397037e 100644 --- a/dap-sdk/net/client/include/dap_client.h +++ b/dap-sdk/net/client/include/dap_client.h @@ -81,13 +81,11 @@ typedef void (*dap_client_callback_t) (dap_client_t *, void*); typedef void (*dap_client_callback_int_t) (dap_client_t *, int); typedef void (*dap_client_callback_data_size_t) (dap_client_t *, void *, size_t); -#define DAP_UPLINK_PATH_ENC_INIT "enc_init" //"1901248124123459" -#define DAP_UPLINK_PATH_DB "01094787531354" -#define DAP_UPLINK_PATH_STREAM_CTL "stream_ctl" //"091348758013553" -#define DAP_UPLINK_PATH_STREAM "stream" //"874751843144" +#define DAP_UPLINK_PATH_ENC_INIT "enc_init" +#define DAP_UPLINK_PATH_STREAM_CTL "stream_ctl" +#define DAP_UPLINK_PATH_STREAM "stream" #define DAP_UPLINK_PATH_LICENSE "license" //#define DAP_UPLINK_PATH_NODE_LIST "nodelist" -#define DAP_UPLINK_PATH_SERVER_LIST "slist" #ifdef __cplusplus extern "C" { diff --git a/dap-sdk/net/client/include/dap_client_pvt.h b/dap-sdk/net/client/include/dap_client_pvt.h index b7c8db758d549208706894ef53bd9c722059d2b1..7ca76b349c844bf96c7198a09bbdc61e40790c84 100644 --- a/dap-sdk/net/client/include/dap_client_pvt.h +++ b/dap-sdk/net/client/include/dap_client_pvt.h @@ -45,6 +45,9 @@ typedef struct dap_client_internal dap_worker_t * worker; dap_events_t * events; + dap_enc_key_type_t session_key_type; + dap_enc_key_type_t session_key_open_type; + dap_enc_key_t * session_key_open; // Open assymetric keys exchange dap_enc_key_t * session_key; // Symmetric private key for session encryption dap_enc_key_t * stream_key; // Stream private key for stream encryption diff --git a/dap-sdk/net/core/dap_worker.c b/dap-sdk/net/core/dap_worker.c index 04ecef1b1b43ab46692c8932cccb51a34ae24256..5187a36dfdb3ffb8a106bf73bf88b244a4bf9c9a 100644 --- a/dap-sdk/net/core/dap_worker.c +++ b/dap-sdk/net/core/dap_worker.c @@ -333,7 +333,7 @@ void *dap_worker_thread(void *arg) }else if(l_error == EINPROGRESS) { log_it(L_DEBUG, "Connecting with %s in progress...", l_cur->remote_addr_str[0]? l_cur->remote_addr_str: "(NULL)"); }else{ - log_it(L_NOTICE, "Connected with %s",l_cur->remote_addr_str[0]? l_cur->remote_addr_str: "(NULL)"); + // log_it(L_NOTICE, "Connected with %s",l_cur->remote_addr_str[0]? l_cur->remote_addr_str: "(NULL)"); l_cur->flags ^= DAP_SOCK_CONNECTING; if (l_cur->callbacks.connected_callback) l_cur->callbacks.connected_callback(l_cur); diff --git a/dap-sdk/net/stream/stream/dap_stream_ctl.c b/dap-sdk/net/stream/stream/dap_stream_ctl.c index 54d92f87fe718056876c25d058891697443a2f80..9dd71b81a625189e6dd403c21bed1e278a952589 100644 --- a/dap-sdk/net/stream/stream/dap_stream_ctl.c +++ b/dap-sdk/net/stream/stream/dap_stream_ctl.c @@ -129,17 +129,17 @@ void s_proc(struct dap_http_simple *a_http_simple, void * a_arg) char * l_subtok_name = strtok_r(l_tok, "=",&l_subtok_tmp); char * l_subtok_value = strtok_r(NULL, "=",&l_subtok_tmp); if (l_subtok_value){ - log_it(L_DEBUG, "tok = %s value =%s",l_subtok_name,l_subtok_value); + //log_it(L_DEBUG, "tok = %s value =%s",l_subtok_name,l_subtok_value); if ( strcmp(l_subtok_name,"channels")==0 ){ strncpy(l_channels_str,l_subtok_value,sizeof (l_channels_str)-1); - log_it(L_DEBUG,"Param: channels=%s",l_channels_str); + //log_it(L_DEBUG,"Param: channels=%s",l_channels_str); }else if(strcmp(l_subtok_name,"enc_type")==0){ l_enc_type = atoi(l_subtok_value); - log_it(L_DEBUG,"Param: enc_type=%s",dap_enc_get_type_name(l_enc_type)); + //log_it(L_DEBUG,"Param: enc_type=%s",dap_enc_get_type_name(l_enc_type)); l_is_legacy = false; }else if(strcmp(l_subtok_name,"enc_headers")==0){ l_enc_headers = atoi(l_subtok_value); - log_it(L_DEBUG,"Param: enc_headers=%d",l_enc_headers); + //log_it(L_DEBUG,"Param: enc_headers=%d",l_enc_headers); } } l_tok = strtok_r(NULL, ",",&l_tok_tmp) ; @@ -184,26 +184,6 @@ void s_proc(struct dap_http_simple *a_http_simple, void * a_arg) return; } - unsigned int conn_t = 0; - char *ct_str = strstr(l_dg->in_query, "connection_type"); - if (ct_str) - { - sscanf(ct_str, "connection_type=%u", &conn_t); - if (conn_t < 0 || conn_t >= STREAM_SESSION_END_TYPE) - { - log_it(L_WARNING,"Error connection type : %i",conn_t); - conn_t = STEAM_SESSION_HTTP; - } - - if (ss) - { - ss->conn_type = conn_t; - } - - } - - log_it(L_INFO,"setup connection_type: %s", connection_type_str[conn_t]); - enc_http_reply_encode(a_http_simple,l_dg); enc_http_delegate_delete(l_dg); }else{ diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 442e6e4f6c41de23425a4b7a5168d65039d09f1b..e5e13eccf28b80a7b47e6f756cf9cb54a2479561 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -868,6 +868,7 @@ int dap_chain_net_init() dap_chain_net_load_all(); dap_enc_http_set_acl_callback(dap_chain_net_set_acl); + log_it(L_NOTICE,"Chain networks initialized"); return 0; } @@ -903,6 +904,12 @@ void dap_chain_net_load_all() s_net_load(l_dir_entry->d_name, l_acl_idx++); } closedir(l_net_dir); + }else{ + int l_errno = errno; + char l_errbuf[128]; + l_errbuf[0] = 0; + strerror_r(l_errno,l_errbuf,sizeof (l_errbuf)); + log_it(L_WARNING,"Can't open entries on path %s: \"%s\" (code %d)", l_net_dir_str, l_errbuf, l_errno); } DAP_DELETE (l_net_dir_str); }