diff --git a/dap-sdk/net/core/dap_events_socket.c b/dap-sdk/net/core/dap_events_socket.c index acb69b6ae13e015d306b4e8dac4f1be95d6ff544..fb7f844171a219e8ca64d4e7de173810dba8a0f8 100644 --- a/dap-sdk/net/core/dap_events_socket.c +++ b/dap-sdk/net/core/dap_events_socket.c @@ -274,9 +274,9 @@ int dap_events_socket_kill_socket( dap_events_socket_t *a_es ) //dap_events_t *d_ev = w->events; - pthread_mutex_lock( &w->locker_on_count ); + pthread_mutex_lock( &a_es->dap_worker->locker_on_count ); if ( a_es->kill_signal ) { - pthread_mutex_unlock( &w->locker_on_count ); + pthread_mutex_unlock( &a_es->dap_worker ->locker_on_count ); return 0; } @@ -285,7 +285,7 @@ int dap_events_socket_kill_socket( dap_events_socket_t *a_es ) a_es->kill_signal = true; //DL_LIST_ADD_NODE_HEAD( d_ev->to_kill_sockets, a_es, kprev, knext, w->event_to_kill_count ); - pthread_mutex_unlock( &w->locker_on_count ); + pthread_mutex_unlock( &a_es->dap_worker->locker_on_count ); return 0; } diff --git a/modules/net/CMakeLists.txt b/modules/net/CMakeLists.txt index 09cbb1cf9633cd5724c651b7ce5f27f3a27b01e9..990616476d68e2d2a843e53ed33de33bacf1e261 100644 --- a/modules/net/CMakeLists.txt +++ b/modules/net/CMakeLists.txt @@ -39,13 +39,13 @@ endif() add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_NET_SRCS} ${DAP_CHAIN_NET_HEADERS} ${IPUTILS_SRCS} ${IPUTILS_HEADERS}) if(WIN32) - target_link_libraries(dap_chain_net dap_core dap_crypto dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_chain dap_chain_wallet dap_chain_net_srv + target_link_libraries(dap_chain_net dap_core dap_crypto dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_chain dap_chain_crypto dap_chain_wallet dap_chain_net_srv dap_chain_mempool dap_chain_global_db dap_chain_net_srv_stake) endif() if(UNIX) target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_client dap_stream_ch_chain dap_stream_ch_chain_net dap_chain - dap_chain_wallet dap_chain_net_srv dap_chain_mempool dap_chain_global_db dap_chain_net_srv_stake + dap_chain_crypto dap_chain_wallet dap_chain_net_srv dap_chain_net_srv_vpn dap_chain_mempool dap_chain_global_db dap_chain_net_srv_stake resolv ) endif() diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 36bbc500a5ea410fffbb0001590b31583b2f874b..afbd4469e650b599851c52441c2c6f92f89a0128 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -77,6 +77,7 @@ #include "dap_chain_net_srv.h" #ifndef _WIN32 #include "dap_chain_net_news.h" +#include "dap_chain_net_vpn_client.h" #endif #include "dap_chain_cell.h" diff --git a/modules/service/vpn/dap_chain_net_srv_vpn.c b/modules/service/vpn/dap_chain_net_srv_vpn.c index 479cf2a1d563bb8099bf8dc399aed10318a4a35c..666a5dc2e3f855b525743730dbd1d8cc58d88116 100644 --- a/modules/service/vpn/dap_chain_net_srv_vpn.c +++ b/modules/service/vpn/dap_chain_net_srv_vpn.c @@ -444,9 +444,9 @@ int dap_chain_net_srv_vpn_init(dap_config_t * g_config) { } } - int retVal = dap_chain_net_srv_vpn_cmd_init(); - - return retVal; + return 0; + //int retVal = dap_chain_net_srv_vpn_cmd_init(); + //return retVal; } return -1; } diff --git a/modules/service/vpn/dap_chain_net_srv_vpn_cmd.c b/modules/service/vpn/dap_chain_net_srv_vpn_cmd.c deleted file mode 100644 index 10a4b262f1a35cea817c94501bb248ece81d1831..0000000000000000000000000000000000000000 --- a/modules/service/vpn/dap_chain_net_srv_vpn_cmd.c +++ /dev/null @@ -1,114 +0,0 @@ -#include <dap_chain_node_cli.h> -#include "dap_chain_node_cli_cmd.h" -#include "dap_chain_net_srv_vpn_cmd.h" -#include "dap_chain_net_vpn_client.h" - - -/** - * vpn_client command - * - * VPN client control - */ -int com_vpn_client(int a_argc, char ** a_argv, void *arg_func, char **a_str_reply) -{ -#ifndef _WIN32 - enum { - CMD_NONE, CMD_START, CMD_STOP, CMD_STATUS - }; - int l_arg_index = 1; - // find net - dap_chain_net_t *l_net = NULL; - if(dap_chain_node_cli_cmd_values_parse_net_chain(&l_arg_index, a_argc, a_argv, a_str_reply, NULL, &l_net) < 0) - return -2; - - int cmd_num = CMD_NONE; - if(dap_chain_node_cli_find_option_val(a_argv, l_arg_index, min(a_argc, l_arg_index + 1), "start", NULL)) { - cmd_num = CMD_START; - } - else if(dap_chain_node_cli_find_option_val(a_argv, l_arg_index, min(a_argc, l_arg_index + 1), "stop", NULL)) { - cmd_num = CMD_STOP; - } - else if(dap_chain_node_cli_find_option_val(a_argv, l_arg_index, min(a_argc, l_arg_index + 1), "status", NULL)) { - cmd_num = CMD_STATUS; - } - if(cmd_num == CMD_NONE) { - if(!a_argv[1]) - dap_chain_node_cli_set_reply_text(a_str_reply, "invalid parameters"); - else - dap_chain_node_cli_set_reply_text(a_str_reply, "parameter %s not recognized", a_argv[1]); - return -1; - } - - switch (cmd_num) - { - case CMD_START: { - const char * l_str_addr = NULL; // for example, "192.168.100.93" - const char * l_str_port = NULL; // for example, "8079" - dap_chain_node_cli_find_option_val(a_argv, l_arg_index, a_argc, "-addr", &l_str_addr); - if(!l_str_addr) { - dap_chain_node_cli_set_reply_text(a_str_reply, - "VPN server address not defined, use -addr <vpn server ipv4 address> parameter"); - break; - } - dap_chain_node_cli_find_option_val(a_argv, l_arg_index, a_argc, "-port", &l_str_port); - int l_srv_port = (l_str_port) ? (int) strtoll(l_str_port, 0, 10) : 0; - if(!l_srv_port) { - dap_chain_node_cli_set_reply_text(a_str_reply, - "VPN server port not defined, use -port <vpn server port> parameter"); - break; - } - int l_res = dap_chain_net_vpn_client_start(l_net, l_str_addr, NULL, l_srv_port); - switch (l_res) { - case 0: - dap_chain_node_cli_set_reply_text(a_str_reply, "VPN client started successfully"); - break; - case 1: - dap_chain_node_cli_set_reply_text(a_str_reply, "VPN client already started"); - break; - case -2: - case -3: - dap_chain_node_cli_set_reply_text(a_str_reply, "Can't connect to VPN server"); - break; - default: - dap_chain_node_cli_set_reply_text(a_str_reply, "Can't start VPN client"); - break; - } - return l_res; - } - break; - case CMD_STOP: { - int res = dap_chain_net_vpn_client_stop(); - if(!res) - dap_chain_node_cli_set_reply_text(a_str_reply, "VPN client stopped successfully"); - else - dap_chain_node_cli_set_reply_text(a_str_reply, "VPN client not stopped"); - return res; - } - //break; - case CMD_STATUS: - switch (dap_chain_net_vpn_client_status()) { -// switch (0){ - case 0: - dap_chain_node_cli_set_reply_text(a_str_reply, "VPN client stopped"); - return 0; - case 1: - dap_chain_node_cli_set_reply_text(a_str_reply, "VPN client started"); - return 0; - case -1: - dap_chain_node_cli_set_reply_text(a_str_reply, "Can't get VPN state"); - return -1; - } - break; - } -#endif - return 0; -} - - -int dap_chain_net_srv_vpn_cmd_init() -{ - dap_chain_node_cli_cmd_item_create ("vpn_client", com_vpn_client, NULL, "VPN client control", - "vpn_client [start -addr <server address> -port <server port>| stop | status]\n"); - - return 0; -} diff --git a/modules/service/vpn/include/dap_chain_net_srv_vpn_cmd.h b/modules/service/vpn/include/dap_chain_net_srv_vpn_cmd.h deleted file mode 100644 index 1f2ec174546473bc55ac44a0659d3d73701b7c9f..0000000000000000000000000000000000000000 --- a/modules/service/vpn/include/dap_chain_net_srv_vpn_cmd.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -int dap_chain_net_srv_vpn_cmd_init();