From 72583eb6767db701bf3b4410d4c71baaa2eb580b Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Mon, 6 Mar 2017 15:47:45 +0800 Subject: [PATCH] add core-json-rpc `get_config` --- external/libssh-win-static/include/config.h | 4 + .../libssh-win-static/libssh.vs2015.vcxproj | 4 +- external/readme.md | 4 +- .../core/tp_core.vs2015.vcxproj.vcxproj | 339 ------------------ server/tp_core/core/ts_http_rpc.cpp | 35 +- 5 files changed, 29 insertions(+), 357 deletions(-) delete mode 100644 server/tp_core/core/tp_core.vs2015.vcxproj.vcxproj diff --git a/external/libssh-win-static/include/config.h b/external/libssh-win-static/include/config.h index 6f33c03..a280de5 100644 --- a/external/libssh-win-static/include/config.h +++ b/external/libssh-win-static/include/config.h @@ -1,3 +1,7 @@ +#ifdef _DEBUG +#include +#endif + /* Name of package */ #define PACKAGE "libssh" diff --git a/external/libssh-win-static/libssh.vs2015.vcxproj b/external/libssh-win-static/libssh.vs2015.vcxproj index 2f46104..0147563 100644 --- a/external/libssh-win-static/libssh.vs2015.vcxproj +++ b/external/libssh-win-static/libssh.vs2015.vcxproj @@ -85,7 +85,7 @@ Level3 Disabled WIN32;_DEBUG;LIBSSH_STATIC;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - .\include;..\openssl\inc32;..\..\zlib\include;%(AdditionalIncludeDirectories) + .\include;..\openssl\inc32;%(AdditionalIncludeDirectories) MultiThreadedDebug @@ -118,7 +118,7 @@ true true WIN32;NDEBUG;LIBSSH_STATIC;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - .\include;..\openssl\inc32;..\..\zlib\include + .\include;..\openssl\inc32 MultiThreaded diff --git a/external/readme.md b/external/readme.md index abb6771..6277233 100644 --- a/external/readme.md +++ b/external/readme.md @@ -5,7 +5,9 @@ teleport项目用到的第三方库 - openssl https://www.openssl.org openssl-1.0.2h - 请按openssl文档所述,编译出openssl的静态库。 + 请按openssl文档所述,编译出openssl的静态库。要编译openssl,需要 + - perl 建议安装ActivePerl http://www.activestate.com/ActivePerl + - nasm http://www.nasm.us - jsoncpp diff --git a/server/tp_core/core/tp_core.vs2015.vcxproj.vcxproj b/server/tp_core/core/tp_core.vs2015.vcxproj.vcxproj deleted file mode 100644 index fb46243..0000000 --- a/server/tp_core/core/tp_core.vs2015.vcxproj.vcxproj +++ /dev/null @@ -1,339 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {6548CB1D-A7BA-4A68-9B3F-A5129F77868B} - Win32Proj - tp_core - 8.1 - tp_core - - - - Application - true - v140_xp - Unicode - - - Application - false - v140_xp - true - Unicode - - - Application - true - v140 - Unicode - - - Application - false - v140 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - ..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - ..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - - - true - ..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - ..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - - - false - ..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - ..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - - - false - ..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - ..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\ - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;LIBSSH_STATIC;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions) - true - ../../external/windows/libuv/include;../../external/windows/openssl/include;../../external/windows/zlib/include;../../external/windows/mbedtls/include;../../external/windows/libssh/include;../../external/common/jsoncpp/include;../../external/common/sqlite;../../../pyshell/pys/include;../../../pyshell/pys/external/windows/python/include;d:/apps/vld/include - MultiThreadedDebug - - - Console - ../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib;../../../pyshell/pys/lib;d:/apps/vld/lib/win32 - libcmt.lib - - - - - - - Level3 - Disabled - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - ../../external/windows/libuv/include;../../external/windows/openssl/include;../../external/windows/zlib/include;../../external/windows/mbedtls/include;../../external/windows/libssh/include;../../external/common/jsoncpp/include;../../external/common/sqlite;d:/apps/vld/include - - - Windows - true - ../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;LIBSSH_STATIC;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions) - true - ../../external/windows/libuv/include;../../external/windows/openssl/include;../../external/windows/zlib/include;../../external/windows/mbedtls/include;../../external/windows/libssh/include;../../external/common/jsoncpp/include;../../external/common/sqlite;../../../pyshell/pys/include;../../../pyshell/pys/external/windows/python/include - MultiThreaded - - - Console - true - true - ../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib;../../../pyshell/pys/lib - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - ../../external/windows/libuv/include;../../external/windows/openssl/include;../../external/windows/zlib/include;../../external/windows/mbedtls/include;../../external/windows/libssh/include;../../external/common/jsoncpp/include;../../external/common/sqlite - - - Windows - true - true - true - ../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)mbedtls_error.obj - $(IntDir)mbedtlserror.obj - $(IntDir)mbedtlserror.obj - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/server/tp_core/core/ts_http_rpc.cpp b/server/tp_core/core/ts_http_rpc.cpp index 6fedd47..27361df 100644 --- a/server/tp_core/core/ts_http_rpc.cpp +++ b/server/tp_core/core/ts_http_rpc.cpp @@ -256,6 +256,10 @@ void TsHttpRpc::_process_request(const ex_astr& func_cmd, const Json::Value& jso { _rpc_func_request_session(json_param, buf); } + else if (func_cmd == "get_config") + { + _rpc_func_get_config(json_param, buf); + } else if (func_cmd == "enc") { _rpc_func_enc(json_param, buf); @@ -290,28 +294,29 @@ void TsHttpRpc::_rpc_func_get_config(const Json::Value& json_param, ex_astr& buf { if (it->first.length() > 9 && 0 == wcsncmp(it->first.c_str(), L"protocol-", 9)) { - ex_wstr libname; - if (!it->second->GetStr(L"lib", libname)) - continue; + ex_wstr name; + name.assign(it->first, 9); + ex_astr _name; + ex_wstr2astr(name, _name); bool enabled = false; it->second->GetBool(L"enabled", enabled, false); - if (!enabled) - { - EXLOGV(L"[core] `%ls` not enabled.\n", libname.c_str()); - continue; - } -// if (!g_tpp_mgr.load_tpp(libname)) -// { -// all_ok = false; -// break; -// } + ex_wstr ip; + if (!it->second->GetStr(L"bind-ip", ip)) + continue; + ex_astr _ip; + ex_wstr2astr(ip, _ip); + + int port; + it->second->GetInt(L"bind-port", port, 52189); + + jr_data[_name.c_str()]["enable"] = enabled; + jr_data[_name.c_str()]["ip"] = _ip; + jr_data[_name.c_str()]["port"] = port; } } - jr_data["sid"] = sid; - _create_json_ret(buf, TSR_OK, jr_data); }