diff --git a/build/builder/build-external.py b/build/builder/build-external.py
index fdd9447..70b34db 100644
--- a/build/builder/build-external.py
+++ b/build/builder/build-external.py
@@ -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__':
diff --git a/common/libex/include/ex/ex_ini.h b/common/libex/include/ex/ex_ini.h
index 7bd7f0a..746afa2 100644
--- a/common/libex/include/ex/ex_ini.h
+++ b/common/libex/include/ex/ex_ini.h
@@ -2,13 +2,13 @@
#define __EX_INI_H__
/*
-特别注意:
+锟截憋拷注锟解:
-1. 以 分号';' 或者 井号'#' 作为注释行的第一个字符
-2. 不支持行内注释
-3. 值对以第一个等号分隔,等号前后如果有空格会被忽略,之后的空格会保留,包括行尾空格
-4. 如果有不属于某个小节的值对,可以使用GetDumySection()获取
- DumySection主要是为了能够兼容简单的Python文件做配置文件。
+1. 锟斤拷 锟街猴拷';' 锟斤拷锟斤拷 锟斤拷锟斤拷'#' 锟斤拷为注锟斤拷锟叫的碉拷一锟斤拷锟街凤拷
+2. 锟斤拷支锟斤拷锟斤拷锟斤拷注锟斤拷
+3. 值锟斤拷锟皆碉拷一锟斤拷锟饺号分革拷锟斤拷锟饺猴拷前锟斤拷锟斤拷锟斤拷锌崭锟结被锟斤拷锟皆o拷之锟斤拷目崭锟结保锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷尾锟秸革拷
+4. 锟斤拷锟斤拷胁锟斤拷锟斤拷锟侥筹拷锟叫★拷诘锟街碉拷裕锟斤拷锟斤拷锟绞癸拷锟紾etDumySection()锟斤拷取
+ DumySection锟斤拷要锟斤拷为锟斤拷锟杰癸拷锟斤拷锟捷简单碉拷Python锟侥硷拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
*/
#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.
diff --git a/common/libex/src/ex_ini.cpp b/common/libex/src/ex_ini.cpp
index 71ac593..cbd60fc 100644
--- a/common/libex/src/ex_ini.cpp
+++ b/common/libex/src/ex_ini.cpp
@@ -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];
diff --git a/server/.idea/encodings.xml b/server/.idea/encodings.xml
index 2f77846..e2ddfa7 100644
--- a/server/.idea/encodings.xml
+++ b/server/.idea/encodings.xml
@@ -8,15 +8,22 @@
+
+
+
+
-
+
+
+
+
diff --git a/server/tp_core/common/ts_membuf.cpp b/server/tp_core/common/ts_membuf.cpp
index 13a3b79..c5f063f 100644
--- a/server/tp_core/common/ts_membuf.cpp
+++ b/server/tp_core/common/ts_membuf.cpp
@@ -1,8 +1,12 @@
#include "ts_membuf.h"
#include
-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)
diff --git a/server/tp_core/core/ts_env.cpp b/server/tp_core/core/ts_env.cpp
index d9a9314..f835d38 100644
--- a/server/tp_core/core/ts_env.cpp
+++ b/server/tp_core/core/ts_env.cpp
@@ -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());
diff --git a/server/tp_core/core/ts_main.cpp b/server/tp_core/core/ts_main.cpp
index 321fb3d..db58208 100644
--- a/server/tp_core/core/ts_main.cpp
+++ b/server/tp_core/core/ts_main.cpp
@@ -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;
}
diff --git a/server/tp_core/protocol/ssh/CMakeLists.txt b/server/tp_core/protocol/ssh/CMakeLists.txt
index 1d38269..1ffc4de 100644
--- a/server/tp_core/protocol/ssh/CMakeLists.txt
+++ b/server/tp_core/protocol/ssh/CMakeLists.txt
@@ -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)
diff --git a/server/tp_core/protocol/ssh/ssh_recorder.cpp b/server/tp_core/protocol/ssh/ssh_recorder.cpp
index a48a9f8..74cb654 100644
--- a/server/tp_core/protocol/ssh/ssh_recorder.cpp
+++ b/server/tp_core/protocol/ssh/ssh_recorder.cpp
@@ -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);
diff --git a/server/tp_core/protocol/ssh/ssh_recorder.h b/server/tp_core/protocol/ssh/ssh_recorder.h
index a9534bf..a4f5a6c 100644
--- a/server/tp_core/protocol/ssh/ssh_recorder.h
+++ b/server/tp_core/protocol/ssh/ssh_recorder.h
@@ -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);
diff --git a/server/tp_core/protocol/ssh/ssh_session.h b/server/tp_core/protocol/ssh/ssh_session.h
index c400d37..c69f2a8 100644
--- a/server/tp_core/protocol/ssh/ssh_session.h
+++ b/server/tp_core/protocol/ssh/ssh_session.h
@@ -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;
diff --git a/server/tp_core/protocol/ssh/tpp_env.cpp b/server/tp_core/protocol/ssh/tpp_env.cpp
index db9977e..a5594b3 100644
--- a/server/tp_core/protocol/ssh/tpp_env.cpp
+++ b/server/tp_core/protocol/ssh/tpp_env.cpp
@@ -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;
}
diff --git a/server/tp_core/protocol/ssh/tpp_env.h b/server/tp_core/protocol/ssh/tpp_env.h
index 25e2e0a..65e4d9b 100644
--- a/server/tp_core/protocol/ssh/tpp_env.h
+++ b/server/tp_core/protocol/ssh/tpp_env.h
@@ -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__
diff --git a/server/www/teleport/static/js/ui/log.js b/server/www/teleport/static/js/ui/log.js
index 858a59d..d988a90 100644
--- a/server/www/teleport/static/js/ui/log.js
+++ b/server/www/teleport/static/js/ui/log.js
@@ -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 = {};
diff --git a/server/www/teleport/view/log/index.mako b/server/www/teleport/view/log/index.mako
index 06581fa..a36f5bf 100644
--- a/server/www/teleport/view/log/index.mako
+++ b/server/www/teleport/view/log/index.mako
@@ -6,7 +6,7 @@
<%inherit file="../page_base.mako"/>
<%block name="extend_js">
-##
+
%block>