mirror of https://github.com/tp4a/teleport
fix bug #10.
parent
c7cd8ba1b8
commit
32bea1a67d
|
@ -63,31 +63,24 @@ class BuilderLinux(BuilderBase):
|
|||
super().__init__()
|
||||
|
||||
def build_server(self):
|
||||
cc.n('build tp_web...')
|
||||
cc.n('build server app (tp_core/libtpssh/tp_web)...')
|
||||
|
||||
###################
|
||||
# out_path = os.path.join(ROOT_PATH, 'out', 'eom_ts', ctx.target_path, ctx.dist_path)
|
||||
out_path = os.path.join(ROOT_PATH, 'out', 'server', ctx.bits_path, 'bin')
|
||||
out_file = os.path.join(out_path, 'tp_web')
|
||||
out_files = [os.path.join(out_path, 'tp_core'), os.path.join(out_path, 'libtpssh.so'),
|
||||
os.path.join(out_path, 'tp_web')]
|
||||
|
||||
if os.path.exists(out_file):
|
||||
utils.remove(out_file)
|
||||
for f in out_files:
|
||||
if os.path.exists(f):
|
||||
utils.remove(f)
|
||||
|
||||
utils.makedirs(out_path)
|
||||
|
||||
utils.cmake(os.path.join(ROOT_PATH, 'server', 'cmake-build'), ctx.target_path, False)
|
||||
utils.strip(out_file)
|
||||
# utils.strip(out_file)
|
||||
|
||||
|
||||
# wscript_file = os.path.join(ROOT_PATH, 'wscript')
|
||||
# utils.waf_build(wscript_file, ctx.target_path, False)
|
||||
|
||||
# chk_file = os.path.join(ROOT_PATH, 'waf_build', ctx.target_path, 'eom_ts')
|
||||
# utils.ensure_file_exists(chk_file)
|
||||
# os.chmod(chk_file, 0o777)
|
||||
|
||||
# shutil.copy(chk_file, out_file)
|
||||
utils.ensure_file_exists(out_file)
|
||||
for f in out_files:
|
||||
if os.path.exists(f):
|
||||
utils.ensure_file_exists(f)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<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/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/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" />
|
||||
|
|
|
@ -46,20 +46,20 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_rpc.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_session.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_rpc.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_db.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/CMakeLists.txt" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_env.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_db.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_session.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/ts_membuf.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_env.cpp" isTestSource="false" />
|
||||
|
@ -73,9 +73,9 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_proxy.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/tpssh.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_recorder.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_proxy.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_session.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/tpp_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_session.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_proxy.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_web/src/main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_web/src/ts_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_web/src/CMakeLists.txt" isTestSource="false" />
|
||||
|
|
|
@ -21,6 +21,11 @@ MemBuffer::~MemBuffer()
|
|||
void MemBuffer::append(const ex_u8* data, size_t size)
|
||||
{
|
||||
reserve(m_data_size + size);
|
||||
|
||||
// TODO: should return boolean.
|
||||
if(NULL == m_buffer)
|
||||
return;
|
||||
|
||||
memcpy(m_buffer+m_data_size, data, size);
|
||||
m_data_size += size;
|
||||
}
|
||||
|
@ -40,6 +45,13 @@ void MemBuffer::reserve(size_t size)
|
|||
|
||||
m_buffer_size = new_size;
|
||||
|
||||
// TODO: reserve() should return boolean.
|
||||
if(NULL == m_buffer)
|
||||
{
|
||||
m_buffer_size = 0;
|
||||
m_data_size = 0;
|
||||
}
|
||||
|
||||
//TSLOGD("[mbuf] reserve(): #%d, buffer-size: %d, data-size: %d\n", m_index, m_buffer_size, m_data_size);
|
||||
}
|
||||
|
||||
|
|
|
@ -937,7 +937,7 @@ int SshSession::_on_server_channel_data(ssh_session session, ssh_channel channel
|
|||
" - authroized by %s\r\n"\
|
||||
"=============================================\r\n"\
|
||||
"\r\n"\
|
||||
"\033]0;TP#telnet://%s\007",
|
||||
"\033]0;tpssh://%s\007",
|
||||
_this->m_server_ip.c_str(),
|
||||
_this->m_server_port, auth_mode,
|
||||
_this->m_server_ip.c_str()
|
||||
|
@ -955,9 +955,13 @@ int SshSession::_on_server_channel_data(ssh_session session, ssh_channel channel
|
|||
{
|
||||
ret = ssh_channel_write_stderr(info->channel, data, len);
|
||||
}
|
||||
else if(info->type != TS_SSH_CHANNEL_TYPE_SHELL)
|
||||
{
|
||||
ret = ssh_channel_write(info->channel, data, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len > 5)
|
||||
if (len > 5 && len < 256)
|
||||
{
|
||||
const ex_u8* _begin = ex_memmem((const ex_u8*)data, len, (const ex_u8*)"\033]0;", 4);
|
||||
if (NULL != _begin)
|
||||
|
@ -975,18 +979,25 @@ int SshSession::_on_server_channel_data(ssh_session session, ssh_channel channel
|
|||
if (len_before > 0)
|
||||
mbuf.append((ex_u8*)data, len_before);
|
||||
|
||||
mbuf.append((ex_u8*)"\033]0;TP#ssh://", 13);
|
||||
mbuf.append((ex_u8*)"\033]0;tpssh://", 13);
|
||||
mbuf.append((ex_u8*)_this->m_server_ip.c_str(), _this->m_server_ip.length());
|
||||
mbuf.append((ex_u8*)"\007", 1);
|
||||
|
||||
if (len_end > 0)
|
||||
mbuf.append((ex_u8*)_end, len_end);
|
||||
|
||||
ret = ssh_channel_write(info->channel, mbuf.data(), mbuf.size());
|
||||
if (ret <= 0)
|
||||
EXLOGE("[ssh] send to client failed (1).\n");
|
||||
else
|
||||
ret = len;
|
||||
if(mbuf.size() > 0)
|
||||
{
|
||||
ret = ssh_channel_write(info->channel, mbuf.data(), mbuf.size());
|
||||
if (ret <= 0)
|
||||
EXLOGE("[ssh] send to client failed (1).\n");
|
||||
else
|
||||
ret = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = ssh_channel_write(info->channel, data, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue