强制中断在线会话功能完成。版本升级到v3.0.1.6,准备作为beta版本发布。

pull/105/head
Apex Liu 2018-05-05 00:58:19 +08:00
parent d78a1824c1
commit e7c657e132
28 changed files with 392 additions and 225 deletions

View File

@ -1,3 +1,3 @@
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
VER_TP_SERVER = "3.0.0.5" VER_TP_SERVER = "3.0.1.6"
VER_TP_ASSIST = "3.0.0.5" VER_TP_ASSIST = "3.0.0.5"

View File

@ -9,6 +9,7 @@
//# include <io.h> //# include <io.h>
//# include <stdio.h> //# include <stdio.h>
// #include <direct.h> // #include <direct.h>
#pragma comment(lib, "ws2_32.lib")
#else #else
// #include <dirent.h> // #include <dirent.h>
# include <dlfcn.h> # include <dlfcn.h>

View File

@ -68,9 +68,9 @@ typedef struct TPP_INIT_ARGS
TPP_SESSION_END_FUNC func_session_end; TPP_SESSION_END_FUNC func_session_end;
}TPP_INIT_ARGS; }TPP_INIT_ARGS;
typedef struct TPP_SET_CFG_ARGS { // typedef struct TPP_SET_CFG_ARGS {
ex_u32 noop_timeout; // as second. // ex_u32 noop_timeout; // as second.
}TPP_SET_CFG_ARGS; // }TPP_SET_CFG_ARGS;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
@ -81,7 +81,7 @@ extern "C"
TPP_API ex_rv tpp_start(void); TPP_API ex_rv tpp_start(void);
TPP_API ex_rv tpp_stop(void); TPP_API ex_rv tpp_stop(void);
TPP_API void tpp_timer(void); TPP_API void tpp_timer(void);
TPP_API void tpp_set_cfg(TPP_SET_CFG_ARGS* cfg_args); // TPP_API void tpp_set_cfg(TPP_SET_CFG_ARGS* cfg_args);
TPP_API ex_rv tpp_command(ex_u32 cmd, const char* param); TPP_API ex_rv tpp_command(ex_u32 cmd, const char* param);
@ -93,7 +93,7 @@ typedef ex_rv (*TPP_INIT_FUNC)(TPP_INIT_ARGS* init_args);
typedef ex_rv (*TPP_START_FUNC)(void); typedef ex_rv (*TPP_START_FUNC)(void);
typedef ex_rv(*TPP_STOP_FUNC)(void); typedef ex_rv(*TPP_STOP_FUNC)(void);
typedef void(*TPP_TIMER_FUNC)(void); typedef void(*TPP_TIMER_FUNC)(void);
typedef void(*TPP_SET_CFG_FUNC)(TPP_SET_CFG_ARGS* cfg_args); // typedef void(*TPP_SET_CFG_FUNC)(TPP_SET_CFG_ARGS* cfg_args);
typedef ex_rv(*TPP_COMMAND_FUNC)(ex_u32 cmd, const char* param); // param is a JSON formatted string. typedef ex_rv(*TPP_COMMAND_FUNC)(ex_u32 cmd, const char* param); // param is a JSON formatted string.

Binary file not shown.

View File

@ -46,18 +46,25 @@ bool TppManager::load_tpp(const ex_wstr& libname)
lib->start = (TPP_START_FUNC)GetProcAddress(lib->dylib, "tpp_start"); lib->start = (TPP_START_FUNC)GetProcAddress(lib->dylib, "tpp_start");
lib->stop = (TPP_STOP_FUNC)GetProcAddress(lib->dylib, "tpp_stop"); lib->stop = (TPP_STOP_FUNC)GetProcAddress(lib->dylib, "tpp_stop");
lib->timer = (TPP_TIMER_FUNC)GetProcAddress(lib->dylib, "tpp_timer"); lib->timer = (TPP_TIMER_FUNC)GetProcAddress(lib->dylib, "tpp_timer");
lib->set_cfg = (TPP_SET_CFG_FUNC)GetProcAddress(lib->dylib, "tpp_set_cfg"); // lib->set_cfg = (TPP_SET_CFG_FUNC)GetProcAddress(lib->dylib, "tpp_set_cfg");
lib->command = (TPP_COMMAND_FUNC)GetProcAddress(lib->dylib, "tpp_command"); lib->command = (TPP_COMMAND_FUNC)GetProcAddress(lib->dylib, "tpp_command");
#else #else
lib->init = (TPP_INIT_FUNC)dlsym(lib->dylib, "tpp_init"); lib->init = (TPP_INIT_FUNC)dlsym(lib->dylib, "tpp_init");
lib->start = (TPP_START_FUNC)dlsym(lib->dylib, "tpp_start"); lib->start = (TPP_START_FUNC)dlsym(lib->dylib, "tpp_start");
lib->stop = (TPP_STOP_FUNC)dlsym(lib->dylib, "tpp_stop"); lib->stop = (TPP_STOP_FUNC)dlsym(lib->dylib, "tpp_stop");
lib->timer = (TPP_TIMER_FUNC)dlsym(lib->dylib, "tpp_timer"); lib->timer = (TPP_TIMER_FUNC)dlsym(lib->dylib, "tpp_timer");
lib->set_cfg = (TPP_SET_CFG_FUNC)dlsym(lib->dylib, "tpp_set_cfg"); // lib->set_cfg = (TPP_SET_CFG_FUNC)dlsym(lib->dylib, "tpp_set_cfg");
lib->command = (TPP_COMMAND_FUNC)dlsym(lib->dylib, "tpp_command"); lib->command = (TPP_COMMAND_FUNC)dlsym(lib->dylib, "tpp_command");
#endif #endif
if (lib->init == NULL || lib->start == NULL || lib->stop == NULL || lib->timer == NULL || lib->set_cfg == NULL || lib->command == NULL) if (
lib->init == NULL
|| lib->start == NULL
|| lib->stop == NULL
|| lib->timer == NULL
//|| lib->set_cfg == NULL
|| lib->command == NULL
)
{ {
EXLOGE(L"[core] load dylib `%ls` failed, can not locate all functions.\n", libfile.c_str()); EXLOGE(L"[core] load dylib `%ls` failed, can not locate all functions.\n", libfile.c_str());
delete lib; delete lib;
@ -109,17 +116,17 @@ void TppManager::timer(void) {
} }
} }
void TppManager::set_config(int noop_timeout) { // void TppManager::set_config(int noop_timeout) {
//
TPP_SET_CFG_ARGS args; // TPP_SET_CFG_ARGS args;
args.noop_timeout = noop_timeout; // args.noop_timeout = noop_timeout;
//
tpp_libs::iterator it = m_libs.begin(); // tpp_libs::iterator it = m_libs.begin();
for (; it != m_libs.end(); ++it) // for (; it != m_libs.end(); ++it)
{ // {
(*it)->set_cfg(&args); // (*it)->set_cfg(&args);
} // }
} // }
void TppManager::set_runtime_config(const ex_astr& sp) { void TppManager::set_runtime_config(const ex_astr& sp) {
tpp_libs::iterator it = m_libs.begin(); tpp_libs::iterator it = m_libs.begin();

View File

@ -24,7 +24,7 @@ typedef struct TPP_LIB
TPP_START_FUNC start; TPP_START_FUNC start;
TPP_STOP_FUNC stop; TPP_STOP_FUNC stop;
TPP_TIMER_FUNC timer; TPP_TIMER_FUNC timer;
TPP_SET_CFG_FUNC set_cfg; // TPP_SET_CFG_FUNC set_cfg;
TPP_COMMAND_FUNC command; TPP_COMMAND_FUNC command;
}TPP_LIB; }TPP_LIB;

View File

@ -478,17 +478,15 @@ void TsHttpRpc::_rpc_func_set_config(const Json::Value& json_param, ex_astr& buf
return; return;
} }
// int noop_timeout = json_param["noop_timeout"].asUInt(); int noop_timeout = json_param["noop_timeout"].asUInt();
// if (noop_timeout == 0) { if (noop_timeout == 0) {
// _create_json_ret(buf, TPE_PARAM); _create_json_ret(buf, TPE_PARAM);
// return; return;
// } }
//
// //static TppManager g_tpp_mgr; EXLOGV("[core] set run-time config:\n");
// EXLOGV("[core] no-op timeout set to %d minutes.\n", noop_timeout); EXLOGV("[core] noop_timeout = %dm\n", noop_timeout);
// g_tpp_mgr.set_config(noop_timeout * 60); // 内部按秒计,因此要 *60
EXLOGV("[core] set run-time config.\n");
ex_astr sp = json_param.toStyledString(); ex_astr sp = json_param.toStyledString();
g_tpp_mgr.set_runtime_config(sp); g_tpp_mgr.set_runtime_config(sp);

View File

@ -1,6 +1,6 @@
#ifndef __TS_SERVER_VER_H__ #ifndef __TS_SERVER_VER_H__
#define __TS_SERVER_VER_H__ #define __TS_SERVER_VER_H__
#define TP_SERVER_VER L"3.0.0.5" #define TP_SERVER_VER L"3.0.1.6"
#endif // __TS_SERVER_VER_H__ #endif // __TS_SERVER_VER_H__

View File

@ -83,14 +83,14 @@ void SshProxy::timer() {
} }
} }
void SshProxy::set_cfg(TPP_SET_CFG_ARGS* args) { void SshProxy::set_cfg(ex_u32 noop_timeout) {
m_noop_timeout_sec = args->noop_timeout; m_noop_timeout_sec = noop_timeout;
} }
void SshProxy::kill_sessions(const ex_astrs& sessions) { void SshProxy::kill_sessions(const ex_astrs& sessions) {
ExThreadSmartLock locker(m_lock); ExThreadSmartLock locker(m_lock);
ts_ssh_sessions::iterator it; ts_ssh_sessions::iterator it = m_sessions.begin();
for (it = m_sessions.begin(); it != m_sessions.end(); ++it) { for (; it != m_sessions.end(); ++it) {
for (size_t i = 0; i < sessions.size(); ++i) { for (size_t i = 0; i < sessions.size(); ++i) {
if (it->first->sid() == sessions[i]) { if (it->first->sid() == sessions[i]) {
EXLOGW("[ssh] try to kill %s\n", sessions[i].c_str()); EXLOGW("[ssh] try to kill %s\n", sessions[i].c_str());

View File

@ -15,7 +15,7 @@ public:
bool init(); bool init();
void timer(); void timer();
void set_cfg(TPP_SET_CFG_ARGS* args); void set_cfg(ex_u32 noop_timeout);
void kill_sessions(const ex_astrs& sessions); void kill_sessions(const ex_astrs& sessions);
void session_finished(SshSession* sess); void session_finished(SshSession* sess);

View File

@ -41,8 +41,30 @@ TPP_API void tpp_timer(void) {
g_ssh_proxy.timer(); g_ssh_proxy.timer();
} }
TPP_API void tpp_set_cfg(TPP_SET_CFG_ARGS* cfg_args) { // TPP_API void tpp_set_cfg(TPP_SET_CFG_ARGS* cfg_args) {
g_ssh_proxy.set_cfg(cfg_args); // //g_ssh_proxy.set_cfg(cfg_args);
// }
static ex_rv _set_runtime_config(const char* param) {
Json::Value jp;
Json::Reader jreader;
if (!jreader.parse(param, jp))
return TPE_JSON_FORMAT;
if (!jp.isObject())
return TPE_PARAM;
if (jp["noop_timeout"].isNull() || !jp["noop_timeout"].isUInt())
return TPE_PARAM;
ex_u32 noop_timeout = jp["noop_timeout"].asUInt();
if (noop_timeout == 0)
return TPE_PARAM;
g_ssh_proxy.set_cfg(noop_timeout * 60);
return TPE_PARAM;
} }
static ex_rv _kill_sessions(const char* param) { static ex_rv _kill_sessions(const char* param) {
@ -73,6 +95,10 @@ static ex_rv _kill_sessions(const char* param) {
TPP_API ex_rv tpp_command(ex_u32 cmd, const char* param) { TPP_API ex_rv tpp_command(ex_u32 cmd, const char* param) {
switch (cmd) { switch (cmd) {
case TPP_CMD_SET_RUNTIME_CFG:
if (param == NULL || strlen(param) == 0)
return TPE_PARAM;
return _set_runtime_config(param);
case TPP_CMD_KILL_SESSIONS: case TPP_CMD_KILL_SESSIONS:
if (param == NULL || strlen(param) == 0) if (param == NULL || strlen(param) == 0)
return TPE_PARAM; return TPE_PARAM;
@ -83,6 +109,3 @@ TPP_API ex_rv tpp_command(ex_u32 cmd, const char* param) {
return TPE_NOT_IMPLEMENT; return TPE_NOT_IMPLEMENT;
} }

View File

@ -68,7 +68,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../../common\teleport;../../../../common\libex\include;../../../../external/jsoncpp/include;../../../../external\libssh-win-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../../../common/teleport;../../../../common/libex/include;../../../../external/jsoncpp/include;../../../../external/libssh-win-static/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
@ -86,7 +86,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../../common\teleport;../../../../common\libex\include;../../../../external/jsoncpp/include;../../../../external\libssh-win-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../../../common/teleport;../../../../common/libex/include;../../../../external/jsoncpp/include;../../../../external/libssh-win-static/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -55,8 +55,21 @@ void TelnetProxy::timer() {
} }
} }
void TelnetProxy::set_cfg(TPP_SET_CFG_ARGS* args) { void TelnetProxy::set_cfg(ex_u32 noop_timeout) {
m_noop_timeout_sec = args->noop_timeout; m_noop_timeout_sec = noop_timeout;
}
void TelnetProxy::kill_sessions(const ex_astrs& sessions) {
ExThreadSmartLock locker(m_lock);
ts_telnet_sessions::iterator it = m_sessions.begin();
for (; it != m_sessions.end(); ++it) {
for (size_t i = 0; i < sessions.size(); ++i) {
if (it->first->sid() == sessions[i]) {
EXLOGW("[telnet] try to kill %s\n", sessions[i].c_str());
it->first->check_noop_timeout(0, 0); // Á¢¼´½áÊø
}
}
}
} }
void TelnetProxy::_thread_loop(void) void TelnetProxy::_thread_loop(void)

View File

@ -16,7 +16,8 @@ public:
bool init(); bool init();
void timer(); void timer();
void set_cfg(TPP_SET_CFG_ARGS* args); void set_cfg(ex_u32 noop_timeout);
void kill_sessions(const ex_astrs& sessions);
uv_loop_t* get_loop() { return &m_loop; } uv_loop_t* get_loop() { return &m_loop; }

View File

@ -56,10 +56,12 @@ void TelnetSession::save_record() {
} }
void TelnetSession::check_noop_timeout(ex_u32 t_now, ex_u32 timeout) { void TelnetSession::check_noop_timeout(ex_u32 t_now, ex_u32 timeout) {
if (t_now - m_last_access_timestamp > timeout) { if (t_now == 0)
EXLOGW("[telnet] need close session by timeout.\n"); EXLOGW("[telnet] try close session by kill.\n");
else if (t_now - m_last_access_timestamp > timeout)
EXLOGW("[telnet] try close session by timeout.\n");
if (t_now == 0 || t_now - m_last_access_timestamp > timeout)
_do_close(TP_SESS_STAT_END); _do_close(TP_SESS_STAT_END);
}
} }
void TelnetSession::_session_error(int err_code) { void TelnetSession::_session_error(int err_code) {

View File

@ -51,6 +51,7 @@ public:
} }
// //
void check_noop_timeout(ex_u32 t_now, ex_u32 timeout); void check_noop_timeout(ex_u32 t_now, ex_u32 timeout);
const ex_astr& sid() { return m_sid; }
void client_addr(const char* addr) { m_client_addr = addr; } void client_addr(const char* addr) { m_client_addr = addr; }
const char* client_addr() const { return m_client_addr.c_str(); } const char* client_addr() const { return m_client_addr.c_str(); }

View File

@ -1,6 +1,8 @@
#include "telnet_proxy.h" #include "telnet_proxy.h"
#include "tpp_env.h" #include "tpp_env.h"
#include <teleport_const.h> #include <teleport_const.h>
#include <json/json.h>
TPP_API ex_rv tpp_init(TPP_INIT_ARGS* init_args) TPP_API ex_rv tpp_init(TPP_INIT_ARGS* init_args)
{ {
@ -32,6 +34,72 @@ TPP_API void tpp_timer(void) {
} }
TPP_API void tpp_set_cfg(TPP_SET_CFG_ARGS* cfg_args) { // TPP_API void tpp_set_cfg(TPP_SET_CFG_ARGS* cfg_args) {
g_telnet_proxy.set_cfg(cfg_args); // g_telnet_proxy.set_cfg(cfg_args);
// }
static ex_rv _set_runtime_config(const char* param) {
Json::Value jp;
Json::Reader jreader;
if (!jreader.parse(param, jp))
return TPE_JSON_FORMAT;
if (!jp.isObject())
return TPE_PARAM;
if (jp["noop_timeout"].isNull() || !jp["noop_timeout"].isUInt())
return TPE_PARAM;
ex_u32 noop_timeout = jp["noop_timeout"].asUInt();
if (noop_timeout == 0)
return TPE_PARAM;
g_telnet_proxy.set_cfg(noop_timeout * 60);
return TPE_PARAM;
}
static ex_rv _kill_sessions(const char* param) {
Json::Value jp;
Json::Reader jreader;
if (!jreader.parse(param, jp))
return TPE_JSON_FORMAT;
if (!jp.isArray())
return TPE_PARAM;
ex_astrs ss;
int cnt = jp.size();
for (int i = 0; i < cnt; ++i)
{
if (!jp[i].isString()) {
return TPE_PARAM;
}
ss.push_back(jp[i].asString());
}
g_telnet_proxy.kill_sessions(ss);
return TPE_PARAM;
}
TPP_API ex_rv tpp_command(ex_u32 cmd, const char* param) {
switch (cmd) {
case TPP_CMD_SET_RUNTIME_CFG:
if (param == NULL || strlen(param) == 0)
return TPE_PARAM;
return _set_runtime_config(param);
case TPP_CMD_KILL_SESSIONS:
if (param == NULL || strlen(param) == 0)
return TPE_PARAM;
return _kill_sessions(param);
default:
return TPE_UNKNOWN_CMD;
}
return TPE_NOT_IMPLEMENT;
} }

View File

@ -60,7 +60,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\common\teleport;..\..\..\..\common\libex\include;..\..\..\..\external\mbedtls\include;..\..\..\..\external\libuv\include;..\..\..\..\external\libuv\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../../../common/teleport;../../../../common/libex/include;../../../../external/jsoncpp/include;../../../../external/mbedtls/include;../../../../external/libuv/include;../../../../external/libuv/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
@ -78,7 +78,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\common\teleport;..\..\..\..\common\libex\include;..\..\..\..\external\mbedtls\include;..\..\..\..\external\libuv\include;..\..\..\..\external\libuv\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../../../common/teleport;../../../../common/libex/include;../../../../external/jsoncpp/include;../../../../external/mbedtls/include;../../../../external/libuv/include;../../../../external/libuv/src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile> </ClCompile>
<Link> <Link>
@ -102,6 +102,7 @@
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_util.h" /> <ClInclude Include="..\..\..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_winsrv.h" /> <ClInclude Include="..\..\..\..\common\libex\include\ex\ex_winsrv.h" />
<ClInclude Include="..\..\..\..\common\teleport\teleport_const.h" /> <ClInclude Include="..\..\..\..\common\teleport\teleport_const.h" />
<ClInclude Include="..\..\..\..\external\jsoncpp\include\json\json.h" />
<ClInclude Include="..\..\..\..\external\libuv\include\tree.h" /> <ClInclude Include="..\..\..\..\external\libuv\include\tree.h" />
<ClInclude Include="..\..\..\..\external\libuv\include\uv-errno.h" /> <ClInclude Include="..\..\..\..\external\libuv\include\uv-errno.h" />
<ClInclude Include="..\..\..\..\external\libuv\include\uv-threadpool.h" /> <ClInclude Include="..\..\..\..\external\libuv\include\uv-threadpool.h" />
@ -135,6 +136,9 @@
<ClCompile Include="..\..\..\..\common\libex\src\ex_thread.cpp" /> <ClCompile Include="..\..\..\..\common\libex\src\ex_thread.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_util.cpp" /> <ClCompile Include="..\..\..\..\common\libex\src\ex_util.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_winsrv.cpp" /> <ClCompile Include="..\..\..\..\common\libex\src\ex_winsrv.cpp" />
<ClCompile Include="..\..\..\..\external\jsoncpp\src\lib_json\json_reader.cpp" />
<ClCompile Include="..\..\..\..\external\jsoncpp\src\lib_json\json_value.cpp" />
<ClCompile Include="..\..\..\..\external\jsoncpp\src\lib_json\json_writer.cpp" />
<ClCompile Include="..\..\..\..\external\libuv\src\fs-poll.c" /> <ClCompile Include="..\..\..\..\external\libuv\src\fs-poll.c" />
<ClCompile Include="..\..\..\..\external\libuv\src\inet.c" /> <ClCompile Include="..\..\..\..\external\libuv\src\inet.c" />
<ClCompile Include="..\..\..\..\external\libuv\src\threadpool.c" /> <ClCompile Include="..\..\..\..\external\libuv\src\threadpool.c" />

View File

@ -36,6 +36,9 @@
<Filter Include="libuv\src\win"> <Filter Include="libuv\src\win">
<UniqueIdentifier>{89181d75-3db3-45a5-a35d-9083fb349de3}</UniqueIdentifier> <UniqueIdentifier>{89181d75-3db3-45a5-a35d-9083fb349de3}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="jsoncpp">
<UniqueIdentifier>{fae1b562-5e3f-4b9b-9a5d-41bb15ae2223}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_const.h"> <ClInclude Include="..\..\..\..\common\libex\include\ex\ex_const.h">
@ -146,6 +149,9 @@
<ClInclude Include="..\..\..\..\common\teleport\teleport_const.h"> <ClInclude Include="..\..\..\..\common\teleport\teleport_const.h">
<Filter>common</Filter> <Filter>common</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\external\jsoncpp\include\json\json.h">
<Filter>jsoncpp</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="tptelnet.cpp"> <ClCompile Include="tptelnet.cpp">
@ -301,5 +307,14 @@
<ClCompile Include="..\..\..\..\external\libuv\src\win\process-stdio.c"> <ClCompile Include="..\..\..\..\external\libuv\src\win\process-stdio.c">
<Filter>libuv\src\win</Filter> <Filter>libuv\src\win</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\external\jsoncpp\src\lib_json\json_writer.cpp">
<Filter>jsoncpp</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\external\jsoncpp\src\lib_json\json_reader.cpp">
<Filter>jsoncpp</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\external\jsoncpp\src\lib_json\json_value.cpp">
<Filter>jsoncpp</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

File diff suppressed because one or more lines are too long

View File

@ -221,28 +221,46 @@ $app.on_table_host_render_created = function (render) {
act_btn.push('</li>'); act_btn.push('</li>');
} else { } else {
if (acc.protocol_type === TP_PROTOCOL_TYPE_RDP) { if (acc.protocol_type === TP_PROTOCOL_TYPE_RDP) {
if ((acc.policy_.flag_rdp & TP_FLAG_RDP_DESKTOP) !== 0) { if (!$app.options.core_cfg.rdp.enable) {
act_btn.push('<div class="btn-group btn-group-sm">'); act_btn.push('<li class="remote-action-state state-disabled">');
act_btn.push('<button type="button" class="btn btn-primary" data-action="rdp" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '"><i class="fa fa-desktop fa-fw"></i> RDP</button>'); act_btn.push('<i class="fa fa-ban fa-fw"></i> RDP协议未启用');
act_btn.push('<a href="javascript:;" class="btn btn-primary dropdown-toggle" data-action="rdp-option" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '">'); act_btn.push('</li>');
act_btn.push('<i class="fa fa-cog"></i>'); } else {
act_btn.push('</a>'); if ((acc.policy_.flag_rdp & TP_FLAG_RDP_DESKTOP) !== 0) {
act_btn.push('</div>'); act_btn.push('<div class="btn-group btn-group-sm">');
act_btn.push('<button type="button" class="btn btn-primary" data-action="rdp" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '"><i class="fa fa-desktop fa-fw"></i> RDP</button>');
act_btn.push('<a href="javascript:;" class="btn btn-primary dropdown-toggle" data-action="rdp-option" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_RDP_DESKTOP + '">');
act_btn.push('<i class="fa fa-cog"></i>');
act_btn.push('</a>');
act_btn.push('</div>');
}
} }
} else if (acc.protocol_type === TP_PROTOCOL_TYPE_SSH) { } else if (acc.protocol_type === TP_PROTOCOL_TYPE_SSH) {
act_btn.push('<div class="btn-group btn-group-sm">'); if (!$app.options.core_cfg.ssh.enable) {
if ((acc.policy_.flag_ssh & TP_FLAG_SSH_SHELL) !== 0) { act_btn.push('<li class="remote-action-state state-disabled">');
act_btn.push('<button type="button" class="btn btn-success" data-action="ssh" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SHELL + '"><i class="far fa-keyboard fa-fw"></i> SSH</button>'); act_btn.push('<i class="fa fa-ban fa-fw"></i> SSH协议未启用');
} act_btn.push('</li>');
} else {
act_btn.push('<div class="btn-group btn-group-sm">');
if ((acc.policy_.flag_ssh & TP_FLAG_SSH_SHELL) !== 0) {
act_btn.push('<button type="button" class="btn btn-success" data-action="ssh" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SHELL + '"><i class="far fa-keyboard fa-fw"></i> SSH</button>');
}
if ((acc.policy_.flag_ssh & TP_FLAG_SSH_SFTP) !== 0) { if ((acc.policy_.flag_ssh & TP_FLAG_SSH_SFTP) !== 0) {
act_btn.push('<button type="button" class="btn btn-info" data-action="ssh" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SFTP + '"><i class="fa fa-upload fa-fw"></i> SFTP</button>'); act_btn.push('<button type="button" class="btn btn-info" data-action="ssh" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_SSH_SFTP + '"><i class="fa fa-upload fa-fw"></i> SFTP</button>');
}
act_btn.push('</div>');
} }
act_btn.push('</div>');
} else if (acc.protocol_type === TP_PROTOCOL_TYPE_TELNET) { } else if (acc.protocol_type === TP_PROTOCOL_TYPE_TELNET) {
act_btn.push('<div class="btn-group btn-group-sm">'); if (!$app.options.core_cfg.telnet.enable) {
act_btn.push('<button type="button" class="btn btn-warning" data-action="telnet" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_TELNET_SHELL + '"><i class="far fa-keyboard fa-fw"></i> TELNET</button>'); act_btn.push('<li class="remote-action-state state-disabled">');
act_btn.push('</div>'); act_btn.push('<i class="fa fa-ban fa-fw"></i> TELNET协议未启用');
act_btn.push('</li>');
} else {
act_btn.push('<div class="btn-group btn-group-sm">');
act_btn.push('<button type="button" class="btn btn-warning" data-action="telnet" data-id="' + acc.uni_id + '" data-acc-id="' + acc.a_id + '" data-host-id="' + acc.h_id + '" data-sub-protocol="' + TP_PROTOCOL_TYPE_TELNET_SHELL + '"><i class="far fa-keyboard fa-fw"></i> TELNET</button>');
act_btn.push('</div>');
}
} }
} }
@ -406,7 +424,7 @@ $app.connect_remote = function (uni_id, acc_id, host_id, protocol_type, protocol
console.log('--s--', args); console.log('--s--', args);
if(uni_id === 'none') if (uni_id === 'none')
args.mode = 2; args.mode = 2;
$assist.do_teleport( $assist.do_teleport(

View File

@ -412,8 +412,14 @@ $app.on_btn_kill_sessions_click = function () {
$tp.ajax_post_json('/ops/kill', {sessions: sessions}, $tp.ajax_post_json('/ops/kill', {sessions: sessions},
function (ret) { function (ret) {
if (ret.code === TPE_OK) { if (ret.code === TPE_OK) {
$app.table_session.load_data(); setTimeout(function () {
$tp.notify_success('强行终止会话操作成功!'); var _cb = CALLBACK_STACK.create();
_cb.add($app.check_host_all_selected)
.add($app.table_session.load_data)
.exec();
$tp.notify_success('强行终止会话操作成功!');
}, 1500);
} else { } else {
$tp.notify_error('强行终止会话失败:' + tp_error_msg(ret.code, ret.message)); $tp.notify_error('强行终止会话失败:' + tp_error_msg(ret.code, ret.message));
} }

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
$app.on_init = function (cb_stack) { $app.on_init = function (cb_stack) {
console.log($app.options); //console.log($app.options);
$app.dlg_result = $app.create_dlg_result(); $app.dlg_result = $app.create_dlg_result();
// cb_stack.add($app.dlg_result.init); // cb_stack.add($app.dlg_result.init);

View File

@ -21,142 +21,144 @@
// height: 28px; // height: 28px;
// margin: 0; // margin: 0;
// padding: 0; // padding: 0;
//
// & > li { & > li {
// float: left; float: left;
// position: relative; position: relative;
// display: block; display: block;
// height: 28px; height: 28px;
// padding: 4px 5px; padding: 4px 5px;
//
// background-color: #eee; background-color: #eee;
// border-top: 1px solid #ccc; border-top: 1px solid #ccc;
// border-right: 1px solid #ccc; border-right: 1px solid #ccc;
// border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
//
// &.remote-action-btn { font-size: 12px;
// background: none;
// padding: 0; //&.remote-action-btn {
// border: none; // background: none;
// } // padding: 0;
// // border: none;
// &.remote-action-input { //}
// background: none; //
// padding: 4px 0; //&.remote-action-input {
// // background: none;
// select { // padding: 4px 0;
// border: none; //
// } // select {
// } // border: none;
// // }
// &.remote-action-chk-protocol { //}
// width: 86px; //
// } //&.remote-action-chk-protocol {
// // width: 86px;
// &.remote-action-state { //}
// //width: 64px;
// text-align: center; &.remote-action-state {
// white-space: nowrap; //width: 64px;
// text-align: center;
// &.state-disabled { white-space: nowrap;
// background-color: @color-bg-ignore;
// color: #aaa; &.state-disabled {
// text-shadow: -1px -1px 1px #fff; background-color: @color-bg-ignore;
// color: #aaa;
// & > i.fa { text-shadow: -1px -1px 1px #fff;
// color: #b53a2f;
// } & > i.fa {
// } color: #b53a2f;
// } }
// }
// &.remote-action-username, &.remote-action-name, &.remote-action-protocol { }
// width: 96px;
// text-align: center; //&.remote-action-username, &.remote-action-name, &.remote-action-protocol {
// white-space: nowrap; // width: 96px;
// overflow: hidden; // text-align: center;
// text-overflow: ellipsis; // white-space: nowrap;
// } // overflow: hidden;
// &.remote-action-username { // text-overflow: ellipsis;
// font-size: 90%; //}
// color: #999; //&.remote-action-username {
// } // font-size: 90%;
// &.remote-action-name, &.remote-action-protocol, &.remote-action-chk-protocol { // color: #999;
// color: #000; //}
// } //&.remote-action-name, &.remote-action-protocol, &.remote-action-chk-protocol {
// &.remote-action-name, &.remote-action-chk-protocol { // color: #000;
// font-weight: bold; //}
// } //&.remote-action-name, &.remote-action-chk-protocol {
// // font-weight: bold;
// &.remote-action-password, &.remote-action-sshkey, &.remote-action-noauth { //}
// text-align: center; //
// padding: 4px 8px; //&.remote-action-password, &.remote-action-sshkey, &.remote-action-noauth {
// width: 45px; // text-align: center;
// } // padding: 4px 8px;
// &.remote-action-password { // width: 45px;
// background-color: #e3ffe3; //}
// color: #999; //&.remote-action-password {
// } // background-color: #e3ffe3;
// &.remote-action-sshkey { // color: #999;
// background-color: #fbe9c8; //}
// color: #666; //&.remote-action-sshkey {
// } // background-color: #fbe9c8;
// &.remote-action-noauth { // color: #666;
// background-color: #e0e0e0; //}
// color: #666; //&.remote-action-noauth {
// } // background-color: #e0e0e0;
// // color: #666;
// & > .btn { //}
// line-height: 1.5; //
// margin: 0; //& > .btn {
// padding: 4px 8px; // line-height: 1.5;
// font-size: 12px; // margin: 0;
// border-radius: 0; // padding: 4px 8px;
// } // font-size: 12px;
// // border-radius: 0;
// label { //}
// padding: 0; //
// display: block; //label {
// float: left; // padding: 0;
// margin-top: 1px; // display: block;
// cursor: pointer; // float: left;
// } // margin-top: 1px;
// input[type=checkbox] { // cursor: pointer;
// display: block; //}
// float: left; //input[type=checkbox] {
// margin: 3px 5px 0 0; // display: block;
// } // float: left;
// select { // margin: 3px 5px 0 0;
// margin-top: -3px; //}
// } //select {
// // margin-top: -3px;
// &:first-child { //}
// border-left: 1px solid #ccc; //
// border-top-left-radius: 4px; &:first-child {
// border-bottom-left-radius: 4px; border-left: 1px solid #ccc;
// } border-top-left-radius: 4px;
// border-bottom-left-radius: 4px;
// &.remote-action-btn:first-child { }
// border: none; //
// .btn { //&.remote-action-btn:first-child {
// border-top-left-radius: 4px; // border: none;
// border-bottom-left-radius: 4px; // .btn {
// } // border-top-left-radius: 4px;
// } // border-bottom-left-radius: 4px;
// // }
// &:last-child { //}
// border-top-right-radius: 4px; //
// border-bottom-right-radius: 4px; &:last-child {
// } border-top-right-radius: 4px;
// border-bottom-right-radius: 4px;
// &.remote-action-btn:last-child { }
// border: none; //
// .btn { //&.remote-action-btn:last-child {
// border-top-right-radius: 4px; // border: none;
// border-bottom-right-radius: 4px; // .btn {
// } // border-top-right-radius: 4px;
// } // border-bottom-right-radius: 4px;
// // }
// } //}
}
//} //}
} }
@ -249,7 +251,7 @@
.radio, .checkbox { .radio, .checkbox {
// overwrite bootstrap. // overwrite bootstrap.
margin:0; margin: 0;
font-family: @font-family-mono; font-family: @font-family-mono;
} }

View File

@ -9,6 +9,11 @@
## <script type="text/javascript" src="${ static_url('js/tp-assist.js') }"></script> ## <script type="text/javascript" src="${ static_url('js/tp-assist.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ops/remote-list.js') }"></script> <script type="text/javascript" src="${ static_url('js/ops/remote-list.js') }"></script>
</%block> </%block>
<%block name="embed_js">
<script type="text/javascript">
$app.add_options(${page_param});
</script>
</%block>
<%block name="embed_css"> <%block name="embed_css">
<style> <style>

View File

@ -1,2 +1,2 @@
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
TP_SERVER_VER = "3.0.0.5" TP_SERVER_VER = "3.0.1.6"

View File

@ -34,7 +34,10 @@ class RemoteHandler(TPBaseHandler):
ret = self.check_privilege(TP_PRIVILEGE_OPS) ret = self.check_privilege(TP_PRIVILEGE_OPS)
if ret != TPE_OK: if ret != TPE_OK:
return return
self.render('ops/remote-list.mako') param = {
'core_cfg': tp_cfg().core
}
self.render('ops/remote-list.mako', page_param=json.dumps(param))
class PolicyDetailHandler(TPBaseHandler): class PolicyDetailHandler(TPBaseHandler):

View File

@ -13,7 +13,7 @@ Revision 修订号。主版本号和次版本号都相同但修订号不同
Build 构建号。构建号用于表明此版本发布之前进行了多少次构建及测试。某些情况下此版本号可以省略。 Build 构建号。构建号用于表明此版本发布之前进行了多少次构建及测试。某些情况下此版本号可以省略。
TP_SERVER 3.0.0.5 # 整个服务端打包的版本 TP_SERVER 3.0.1.6 # 整个服务端打包的版本
TP_TPCORE 3.0.0.5 # 核心服务 tp_core 的版本 TP_TPCORE 3.0.1.6 # 核心服务 tp_core 的版本
TP_TPWEB 3.0.0.1 # web服务 tp_web 的版本一般除非升级Python否则不会变化 TP_TPWEB 3.0.0.1 # web服务 tp_web 的版本一般除非升级Python否则不会变化
TP_ASSIST 3.0.0.5 # 助手版本 TP_ASSIST 3.0.0.5 # 助手版本