change class name, otherwise crash when rdp and ssh work together.

pull/32/head
Apex Liu 2017-04-12 18:08:33 +00:00
parent e7313c6e4e
commit 8e8a06628d
15 changed files with 90 additions and 50 deletions

View File

@ -503,8 +503,8 @@ class BuilderLinux(BuilderBase):
os.chdir(old_p)
def fix_output(self):
# remove .so files, otherwise eom_ts will link to .so but not .a in default.
rm = ['libsqlite3.la', 'libsqlite3.so.0', 'libuv.la', 'libuv.so.1', 'libsqlite3.so', 'libsqlite3.so.0.8.6', 'libuv.so', 'libuv.so.1.0.0']
# remove .so files, otherwise will link to .so but not .a in default.
rm = ['libsqlite3.la', 'libsqlite3.so.0', 'libsqlite3.so', 'libsqlite3.so.0.8.6', 'libuv.la', 'libuv.so.1', 'libuv.so', 'libuv.so.1.0.0']
for i in rm:
_path = os.path.join(self.PATH_RELEASE, 'lib', i)
if os.path.exists(_path):
@ -551,8 +551,8 @@ def main():
builder.build_mbedtls()
builder.build_libssh()
builder.build_sqlite()
#
# builder.fix_output()
builder.fix_output()
if __name__ == '__main__':

View File

@ -2,13 +2,13 @@
#define __EX_INI_H__
/*
<EFBFBD>ر<EFBFBD>ע<EFBFBD>
1. ';' '#'
2.
3.
4. 使GetDumySection()
DumySectionPython
1. <EFBFBD><EFBFBD> <EFBFBD>ֺ<EFBFBD>';' <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>'#' <EFBFBD><EFBFBD>Ϊע<EFBFBD><EFBFBD><EFBFBD>еĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
2. <EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>
3. ֵ<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Ⱥŷָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>пո<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>֮<EFBFBD><EFBFBD>Ŀո<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD>ո<EFBFBD>
4. <EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>С<EFBFBD>ڵ<EFBFBD>ֵ<EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>GetDumySection()<EFBFBD><EFBFBD>ȡ
DumySection<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ򵥵<EFBFBD>Python<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
*/
#include "ex_str.h"
@ -77,6 +77,8 @@ public:
ExIniFile();
~ExIniFile();
const ex_wstr& get_filename(void){return m_file_path;}
void ClearUp(void);
// Read and parse special file.

View File

@ -232,6 +232,8 @@ bool ExIniFile::LoadFromFile(const ex_wstr& strFileName, bool bClearOld)
fseek(f, 0L, SEEK_SET);
fread(&vFile[0], 1, ulFileSize, f);
fclose(f);
m_file_path = strFileName;
#endif
char *pOffset = &vFile[0];

View File

@ -8,15 +8,22 @@
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_ini.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_log.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_util.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/common/base_record.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/common/base_record.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/common/ts_const.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/common/ts_membuf.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/common/ts_membuf.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/common/ts_memstream.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/core/main.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/core/ts_db.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/core/ts_env.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/core/ts_http_rpc.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/core/ts_main.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/rdp/rdp_recorder.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/rdp/rdp_session.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_proxy.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_proxy.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_recorder.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_recorder.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_session.cpp" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_session.h" charset="GBK" />
<file url="file://$PROJECT_DIR$/tp_web/src/main.cpp" charset="GBK" />

View File

@ -1,8 +1,12 @@
#include "ts_membuf.h"
#include <memory.h>
MemBuffer::MemBuffer() : m_buffer(NULL), m_data_size(0), m_buffer_size(0)
MemBuffer::MemBuffer()// : m_buffer(NULL), m_data_size(0), m_buffer_size(0)
{
m_buffer = NULL;
m_data_size = 0;
m_buffer_size = 0;
//EXLOGI("[mbuf:%p] create new instance.\n", this);
}
MemBuffer::~MemBuffer()
@ -16,16 +20,19 @@ MemBuffer::~MemBuffer()
m_buffer_size = 0;
//TSLOGD("[mbuf] #%d destroied with buffer-size: %d, data-size: %d.\n", m_index, m_buffer_size, m_data_size);
//EXLOGI("[mbuf:%p] destroy instance\n", this);
}
void MemBuffer::append(const ex_u8* data, size_t size)
{
//EXLOGD("[mbuf:%p] call reserve() in append()\n", this);
reserve(m_data_size + size);
// TODO: should return boolean.
if(NULL == m_buffer)
return;
//EXLOGD("[mbuf:%p] append(): buffer: %p, m_buf_size: %d, m_data_size: %d, data: %p, size: %d\n", this, m_buffer, m_buffer_size, m_data_size, data, size);
memcpy(m_buffer+m_data_size, data, size);
m_data_size += size;
}
@ -33,26 +40,42 @@ void MemBuffer::append(const ex_u8* data, size_t size)
void MemBuffer::reserve(size_t size)
{
if (size <= m_buffer_size)
{
//EXLOGD("[mbuf:%p] reserve(1): m_buf: %p, m_buf_size: %d, need size: %d, skip.\n", this, m_buffer, m_buffer_size, size);
return;
}
// 将新的缓冲区大小取整到 MEMBUF_BLOCK_SIZE 的整数倍
int new_size = (size + MEMBUF_BLOCK_SIZE - 1) & ~(MEMBUF_BLOCK_SIZE - 1);
size_t new_size = (size + MEMBUF_BLOCK_SIZE - 1) & ~(MEMBUF_BLOCK_SIZE - 1);
//EXLOGD("[mbuf:%p] reserve(2): m_buf: %p, m_buf_size: %d, size: %d, new size: %d.\n", this, m_buffer, m_buffer_size, size, new_size);
if (NULL == m_buffer)
{
//EXLOGD("[mbuf:%p] calloc(%d).\n", this, new_size);
m_buffer = (ex_u8*)calloc(1, new_size);
}
else
{
//EXLOGD("[mbuf:%p] realloc(%d).\n", this, new_size);
m_buffer = (ex_u8*)realloc(m_buffer, new_size);
}
m_buffer_size = new_size;
// TODO: reserve() should return boolean.
if(NULL == m_buffer)
{
//EXLOGD("[mbuf:%p] ----- m_buffer == NULL.\n", this);
m_buffer_size = 0;
m_data_size = 0;
}
//else
//{
//EXLOGD("[mbuf:%p] m_buffer == %p.\n", this, m_buffer);
//}
//TSLOGD("[mbuf] reserve(): #%d, buffer-size: %d, data-size: %d\n", m_index, m_buffer_size, m_data_size);
//EXLOGD("[mbuf:%p] reserve(3): m_buf: %p, buffer-size: %d, data-size: %d\n", this, m_buffer, m_buffer_size, m_data_size);
}
void MemBuffer::concat(const MemBuffer& m)

View File

@ -68,6 +68,8 @@ bool TsEnv::init(bool load_config)
#endif
}
//EXLOGW(L"[core] load config file: %ls.\n", conf_file.c_str());
if (!m_ini.LoadFromFile(conf_file))
{
EXLOGE(L"[core] can not load %ls.\n", conf_file.c_str());

View File

@ -148,7 +148,7 @@ bool TppManager::load_tpp(const ex_wstr& libname)
ex_path_join(libfile, false, filename.c_str(), NULL);
EXLOGV(L"[core] load protocol lib: %ls\n", libfile.c_str());
TPP_LIB* lib = new TPP_LIB;
TPP_LIB* lib = new TPP_LIB;
lib->dylib = ex_dlopen(libfile.c_str());
if (NULL == lib->dylib)
@ -214,11 +214,13 @@ void TppManager::stop_all(void)
int ts_main(void)
{
EXLOGI("\n");
EXLOGI("###############################################################\n");
EXLOGI("Teleport Core Server starting ...\n");
ExIniFile& ini = g_env.get_ini();
EXLOGI(L"\n");
EXLOGI(L"###############################################################\n");
EXLOGI(L"Load config file: %ls.\n", ini.get_filename().c_str());
EXLOGI(L"Teleport Core Server starting ...\n");
ex_ini_sections& secs = ini.GetAllSections();
TsHttpRpc rpc;
@ -228,14 +230,14 @@ int ts_main(void)
do {
if (!g_session_mgr.start())
{
EXLOGE("[core] failed to start session-id manager.\n");
EXLOGE(L"[core] failed to start session-id manager.\n");
all_ok = false;
break;
}
if (!rpc.init() || !rpc.start())
{
EXLOGE("[core] rpc init/start failed.\n");
EXLOGE(L"[core] rpc init/start failed.\n");
all_ok = false;
break;
}

View File

@ -7,12 +7,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${Project_SOURCE_DIR}/../out/server/x64/bin")
aux_source_directory(. DIR_SRCS)
aux_source_directory(../../common DIR_SRCS)
aux_source_directory(../../../../common/libex/src DIR_SRCS)
aux_source_directory(. DIR_SSH_SRCS)
aux_source_directory(../../common DIR_SSH_SRCS)
aux_source_directory(../../../../common/libex/src DIR_SSH_SRCS)
list(REMOVE_ITEM DIR_SRCS "./dllmain.cpp")
list(REMOVE_ITEM DIR_SRCS "./stdafx.cpp")
list(REMOVE_ITEM DIR_SSH_SRCS "./dllmain.cpp")
list(REMOVE_ITEM DIR_SSH_SRCS "./stdafx.cpp")
include_directories(
../../../../common/libex/include
@ -21,5 +21,5 @@ include_directories(
link_directories(../../../../external/linux/release/lib)
add_library(tpssh SHARED ${DIR_SRCS})
add_library(tpssh SHARED ${DIR_SSH_SRCS})
target_link_libraries(tpssh ssh ssl crypto mbedx509 mbedtls mbedcrypto dl pthread rt util)

View File

@ -2,7 +2,7 @@
static ex_u8 TPP_RECORD_MAGIC[4] = { 'T', 'P', 'R', 'R' };
TppRec::TppRec()
TppSshRec::TppSshRec()
{
m_cmd_cache.reserve(MAX_SIZE_PER_FILE);
@ -10,12 +10,12 @@ TppRec::TppRec()
memcpy((ex_u8*)(&m_head.magic), TPP_RECORD_MAGIC, sizeof(ex_u32));
}
TppRec::~TppRec()
TppSshRec::~TppSshRec()
{
end();
}
void TppRec::_on_begin(const TPP_SESSION_INFO* info)
void TppSshRec::_on_begin(const TPP_SESSION_INFO* info)
{
if (NULL == info)
return;
@ -30,7 +30,7 @@ void TppRec::_on_begin(const TPP_SESSION_INFO* info)
memcpy(m_head.ip, info->host_ip, strlen(info->host_ip) > 17 ? 17 : strlen(info->host_ip));
}
void TppRec::_on_end(void)
void TppSshRec::_on_end(void)
{
// 如果还有剩下未写入的数据,写入文件中。
if (m_cache.size() > 0)
@ -58,7 +58,7 @@ void TppRec::_on_end(void)
fclose(f);
}
void TppRec::record(ex_u8 type, const ex_u8* data, size_t size)
void TppSshRec::record(ex_u8 type, const ex_u8* data, size_t size)
{
if (data == NULL || 0 == size)
return;
@ -82,13 +82,13 @@ void TppRec::record(ex_u8 type, const ex_u8* data, size_t size)
m_cache.append(data, size);
}
void TppRec::record_win_size_startup(int width, int height)
void TppSshRec::record_win_size_startup(int width, int height)
{
m_head.width = width;
m_head.height = height;
}
void TppRec::record_win_size_change(int width, int height)
void TppSshRec::record_win_size_change(int width, int height)
{
TS_RECORD_WIN_SIZE pkg;
pkg.width = (ex_u16)width;
@ -96,7 +96,7 @@ void TppRec::record_win_size_change(int width, int height)
record(TS_RECORD_TYPE_SSH_TERM_SIZE, (ex_u8*)&pkg, sizeof(TS_RECORD_WIN_SIZE));
}
void TppRec::record_command(const ex_astr cmd)
void TppSshRec::record_command(const ex_astr cmd)
{
char szTime[100] = { 0 };
#ifdef EX_OS_WIN32
@ -122,7 +122,7 @@ void TppRec::record_command(const ex_astr cmd)
m_cmd_cache.append((ex_u8*)cmd.c_str(), cmd.length());
}
bool TppRec::_save_to_data_file(void)
bool TppSshRec::_save_to_data_file(void)
{
wchar_t _str_file_id[24] = { 0 };
ex_wcsformat(_str_file_id, 24, L".%03d", m_head.file_count);
@ -153,7 +153,7 @@ bool TppRec::_save_to_data_file(void)
return true;
}
bool TppRec::_save_to_cmd_file(void)
bool TppSshRec::_save_to_cmd_file(void)
{
ex_wstr fname = m_base_path;
ex_path_join(fname, false, m_base_fname.c_str(), NULL);

View File

@ -45,11 +45,11 @@ typedef struct TS_RECORD_WIN_SIZE
#pragma pack(pop)
class TppRec : public TppRecBase
class TppSshRec : public TppRecBase
{
public:
TppRec();
virtual ~TppRec();
TppSshRec();
virtual ~TppSshRec();
void record(ex_u8 type, const ex_u8* data, size_t size);
void record_win_size_startup(int width, int height);

View File

@ -89,7 +89,7 @@ private:
int m_retcode;
int m_db_id;
TppRec m_rec;
TppSshRec m_rec;
SshProxy* m_proxy;
ssh_session m_cli_session;

View File

@ -1,14 +1,14 @@
#include "tpp_env.h"
TppEnv g_ssh_env;
TppSshEnv g_ssh_env;
TppEnv::TppEnv()
TppSshEnv::TppSshEnv()
{}
TppEnv::~TppEnv()
TppSshEnv::~TppSshEnv()
{}
bool TppEnv::_on_init(TPP_INIT_ARGS* args)
bool TppSshEnv::_on_init(TPP_INIT_ARGS* args)
{
ex_path_join(replay_path, false, L"ssh", NULL);
@ -28,11 +28,13 @@ bool TppEnv::_on_init(TPP_INIT_ARGS* args)
{
ex_wstr2astr(tmp, bind_ip);
}
EXLOGW("[ssh] bind-ip: %s\n", bind_ip.c_str());
if (!ps->GetInt(L"bind-port", bind_port))
{
bind_port = TS_SSH_PROXY_PORT;
}
EXLOGW(L"[ssh] bind-port: %d\n", bind_port);
return true;
}

View File

@ -3,11 +3,11 @@
#include "../../common/base_env.h"
class TppEnv : public TppEnvBase
class TppSshEnv : public TppEnvBase
{
public:
TppEnv();
~TppEnv();
TppSshEnv();
~TppSshEnv();
public:
ex_astr bind_ip;
@ -17,6 +17,6 @@ private:
bool _on_init(TPP_INIT_ARGS* args);
};
extern TppEnv g_ssh_env;
extern TppSshEnv g_ssh_env;
#endif // __TPP_ENV_H__

View File

@ -173,7 +173,7 @@ ywl.on_host_table_created = function (tbl) {
if (protocol == 1) {
$(cell_obj).find('[ywl-btn-record]').click(function () {
var ip = window.location.hostname;//ywl.page_options.ts_server.ip;
var port = ywl.page_options.ts_server.port;
var port = parseInt(window.location.port);//ywl.page_options.ts_server.port;
var url = 'http://' + ip + ':' + port + '/log/replay/rdp/' + row_data.id;
var tail = 'log/replay/rdp/' + row_data.id;
var args = {};

View File

@ -6,7 +6,7 @@
<%inherit file="../page_base.mako"/>
<%block name="extend_js">
## <script type="text/javascript" src="${ static_url('js/ui/teleport.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ui/teleport.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ui/log.js') }"></script>
</%block>