From d786dcd7c46b27980f04c83cc6f06c436ed76a2c Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net> Date: Sun, 3 Nov 2019 14:49:16 +0700 Subject: [PATCH] [*] Options for server list export --- CMakeLists.txt | 2 +- dist/share/configs/cellframe-node.cfg.tpl | 2 +- libdap-chain | 2 +- libdap-chain-mempool | 2 +- libdap-chain-net | 2 +- libdap-chain-net-srv | 2 +- libdap-chain-net-srv-vpn | 2 +- sources/main.c | 76 +++++++++++------------ 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea634b63b..e6f0a33c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ SET( CPACK_GENERATOR "DEB") SET( CPACK_PACKAGE_NAME "${PROJECT_NAME}") SET( CPACK_PACKAGE_VERSION_MAJOR 2) SET( CPACK_PACKAGE_VERSION_MINOR 5) -SET( CPACK_PACKAGE_VERSION_PATCH 10) +SET( CPACK_PACKAGE_VERSION_PATCH 11) SET( CPACK_SYSTEM_NAME "debian-9.9-amd64") SET( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}") diff --git a/dist/share/configs/cellframe-node.cfg.tpl b/dist/share/configs/cellframe-node.cfg.tpl index 38ebeec71..10f67c556 100644 --- a/dist/share/configs/cellframe-node.cfg.tpl +++ b/dist/share/configs/cellframe-node.cfg.tpl @@ -25,6 +25,7 @@ accept=false enabled=false db_path=mongodb://localhost/db servers_list_enabled=false +networks=[kelvin-testnet,private] # Central Database authorization [cdb_auth] @@ -59,5 +60,4 @@ wallets_path=/opt/cellframe-node/var/lib/wallet ca_folders=[/opt/cellframe-node/var/lib/ca,/opt/cellframe-node/share/ca] dap_global_db_path=/opt/cellframe-node/var/lib/global_db dap_global_db_driver=cdb -#servers_list_file=/opt/cellframe-node/var/lib/servers/vpn-servers.xml diff --git a/libdap-chain b/libdap-chain index bf998ca0c..008b7a650 160000 --- a/libdap-chain +++ b/libdap-chain @@ -1 +1 @@ -Subproject commit bf998ca0c85d3d364f0a4edf654b81369510d726 +Subproject commit 008b7a65045c6b20b7daf743b112ba16aa0172a9 diff --git a/libdap-chain-mempool b/libdap-chain-mempool index fd7c74df1..6a91d6b8a 160000 --- a/libdap-chain-mempool +++ b/libdap-chain-mempool @@ -1 +1 @@ -Subproject commit fd7c74df13d963215d88dd3622bde5b39f5ca7bd +Subproject commit 6a91d6b8a821b5e3ad470bf75452cfaeab1899a0 diff --git a/libdap-chain-net b/libdap-chain-net index 225a0ed26..b7a478ff5 160000 --- a/libdap-chain-net +++ b/libdap-chain-net @@ -1 +1 @@ -Subproject commit 225a0ed262c7a5321fd94e654b4caa70030b15cb +Subproject commit b7a478ff558fa108232cb37a20c98171a3cb15b4 diff --git a/libdap-chain-net-srv b/libdap-chain-net-srv index 2fb8e26ad..f15809e9a 160000 --- a/libdap-chain-net-srv +++ b/libdap-chain-net-srv @@ -1 +1 @@ -Subproject commit 2fb8e26ad227773243fd7a60751553aa602f7437 +Subproject commit f15809e9abf5d54642cc84dae4fe73666eda5a38 diff --git a/libdap-chain-net-srv-vpn b/libdap-chain-net-srv-vpn index 4eb24e386..90a2ac6cb 160000 --- a/libdap-chain-net-srv-vpn +++ b/libdap-chain-net-srv-vpn @@ -1 +1 @@ -Subproject commit 4eb24e3867ac97c62a85825017fa7c3804c575e6 +Subproject commit 90a2ac6cbbea9e9528aa03c641a82e82f0937029 diff --git a/sources/main.c b/sources/main.c index c7714c5e1..a65e18333 100644 --- a/sources/main.c +++ b/sources/main.c @@ -308,19 +308,6 @@ int main( int argc, const char **argv ) } -#ifdef DAP_OS_LINUX - if (dap_config_get_item_bool_default( g_config, - "cdb", - "servers_list_enabled", - false)) { - - if (dap_chain_net_srv_vpn_cdb_server_list_init(dap_config_get_item_str_default(g_config, - "resources", "servers_list_file", "" )) != 0) { - log_it(L_CRITICAL,"Can't init vpn servers list"); - return -10; - } - } -#endif if ( enc_http_init() != 0 ) { log_it( L_CRITICAL, "Can't init encryption http session storage module" ); @@ -407,31 +394,6 @@ int main( int argc, const char **argv ) dap_stream_add_proc_http( DAP_HTTP(l_server), STREAM_URL ); dap_stream_ctl_add_proc( DAP_HTTP(l_server), STREAM_CTL_URL ); - // If CDB module switched on - if( dap_config_get_item_bool_default(g_config,"cdb","enabled",false) ) { - if((rc=db_core_init(dap_config_get_item_str_default(g_config, - "cdb", - "db_path", - "mongodb://localhost/db")))!=0 ){ - log_it(L_CRITICAL,"Can't init CDB module, return code %d",rc); - return -3; - } - if( dap_config_get_item_bool_default( g_config,"cdb_auth","enabled",false) ){ - db_auth_init( dap_config_get_item_str_default(g_config,"cdb_auth","collection_name","cdb") ); - } - db_http_add_proc( DAP_HTTP( l_server ) , DB_URL ); - db_http_file_proc_add( DAP_HTTP( l_server ) , DB_FILE_URL ); - - if (dap_config_get_item_bool_default( g_config, - "cdb", - "servers_list_enabled", - false)) { - dap_chain_net_srv_vpn_cdb_server_list_add_proc ( DAP_HTTP(l_server), SLIST_URL); - } - - } - - const char *str_start_mempool = dap_config_get_item_str( g_config, "mempool", "accept" ); if ( str_start_mempool && !strcmp(str_start_mempool, "true")) { @@ -478,6 +440,44 @@ int main( int argc, const char **argv ) // Load all chain networks dap_chain_net_load_all(); +#ifdef DAP_OS_LINUX + if (dap_config_get_item_bool_default( g_config, + "cdb", + "servers_list_enabled", + false)) { + + if (dap_chain_net_srv_vpn_cdb_server_list_init() != 0) { + log_it(L_CRITICAL,"Can't init vpn servers list"); + return -10; + } + } +#endif + + // If CDB module switched on + if( dap_config_get_item_bool_default(g_config,"cdb","enabled",false) ) { + if((rc=db_core_init(dap_config_get_item_str_default(g_config, + "cdb", + "db_path", + "mongodb://localhost/db")))!=0 ){ + log_it(L_CRITICAL,"Can't init CDB module, return code %d",rc); + return -3; + } + if( dap_config_get_item_bool_default( g_config,"cdb_auth","enabled",false) ){ + db_auth_init( dap_config_get_item_str_default(g_config,"cdb_auth","collection_name","cdb") ); + } + db_http_add_proc( DAP_HTTP( l_server ) , DB_URL ); + db_http_file_proc_add( DAP_HTTP( l_server ) , DB_FILE_URL ); + + if (dap_config_get_item_bool_default( g_config, + "cdb", + "servers_list_enabled", + false)) { + dap_chain_net_srv_vpn_cdb_server_list_add_proc ( DAP_HTTP(l_server), SLIST_URL); + } + + } + + // Endless loop for server's requests processing rc = dap_server_loop(l_server); // After loop exit actions -- GitLab