Merge remote-tracking branch 'remotes/origin/dev'

# Conflicts:
#	config.ini.in
pull/32/merge
apexliu 2017-04-16 23:54:51 +08:00
commit 1b762f71f3
103 changed files with 8934 additions and 5603 deletions

3
.gitignore vendored
View File

@ -44,6 +44,7 @@ __pycache__
/external/libssh-win-static/lib
/external/mbedtls
/external/sqlite
/external/libuv
/client/tools/putty
/client/tools/winscp
@ -69,3 +70,5 @@ __pycache__
# for not finished code
/common/libex/test
/client/tp_rdp
/server/tp_core/protocol/rdp
/client/tools/tprdp

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/builder" />
<orderEntry type="jdk" jdkName="py" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="py34" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">

View File

@ -58,72 +58,27 @@ class BuilderWin(BuilderBase):
self._build_installer()
# last_ver = 'teleport-assist-last-win.zip'
# if os.path.exists(os.path.join(ROOT_PATH, 'dist', last_ver)):
# utils.remove(os.path.join(ROOT_PATH, 'dist', last_ver))
# utils.copy_file(os.path.join(ROOT_PATH, 'dist'), os.path.join(ROOT_PATH, 'dist'), ('{}.zip'.format(name), last_ver))
# cc.n('build assist package for backend...')
# name = 'teleport-assist-last-win'
# utils.remove(os.path.join(ROOT_PATH, 'dist', '{}.zip'.format(name)))
# self._build_installer(name)
# utils.copy_file(os.path.join(ROOT_PATH, 'dist'), os.path.join(ROOT_PATH, 'web', 'site', 'teleport', 'static', 'download'), 'teleport-assist-win.zip')
utils.ensure_file_exists(out_file)
# @staticmethod
# def _build_installer(name):
# base_path = os.path.join(ROOT_PATH, 'out', 'client')
# base_tmp = os.path.join(base_path, '_tmp_')
# tmp_path = os.path.join(base_tmp, name)
#
# if os.path.exists(base_tmp):
# utils.remove(base_tmp)
#
# utils.makedirs(tmp_path)
#
# utils.copy_file(os.path.join(ROOT_PATH, 'out', 'client', ctx.bits_path, ctx.target_path), tmp_path, 'tp_assist.exe')
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tp_assist', 'cfg'), tmp_path, ('ssh_client.ini', 'ssh_client.ini'))
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tp_assist', 'cfg'), tmp_path, ('scp_client.ini', 'scp_client.ini'))
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tp_assist', 'cfg'), tmp_path, ('telnet_client.ini', 'telnet_client.ini'))
#
# utils.copy_ex(os.path.join(ROOT_PATH, 'client', 'tp_assist'), tmp_path, 'site')
#
# # utils.makedirs(os.path.join(tmp_path, 'tools', 'tprdp'))
# utils.makedirs(os.path.join(tmp_path, 'tools', 'putty'))
# utils.makedirs(os.path.join(tmp_path, 'tools', 'winscp'))
# # utils.copy_file(os.path.join(ROOT_PATH, 'out', 'tp_rdp', ctx.bits_path, ctx.target_path), os.path.join(tmp_path, 'tools', 'tprdp'), 'tp_rdp.exe')
# # utils.copy_file(os.path.join(ROOT_PATH, 'tools', 'tprdp'), os.path.join(tmp_path, 'tools', 'tprdp'), 'tprdp-client.exe')
# # utils.copy_file(os.path.join(ROOT_PATH, 'tools', 'tprdp'), os.path.join(tmp_path, 'tools', 'tprdp'), 'tprdp-replay.exe')
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tools', 'putty'), os.path.join(tmp_path, 'tools', 'putty'), 'putty.exe')
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tools', 'winscp'), os.path.join(tmp_path, 'tools', 'winscp'), 'WinSCP.exe')
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tools', 'winscp'), os.path.join(tmp_path, 'tools', 'winscp'), 'license.txt')
# utils.copy_file(os.path.join(ROOT_PATH, 'client', 'tools'), os.path.join(tmp_path, 'tools'), 'securecrt-telnet.vbs')
#
# # utils.makedirs(os.path.join(tmp_path, 'data'))
# # utils.copy_file(os.path.join(ROOT_PATH, 'tp_assist'), os.path.join(tmp_path, 'data'), 'ssl.cert')
#
# out_file = os.path.join(ROOT_PATH, 'dist', '{}.zip'.format(name))
# utils.make_zip(base_tmp, out_file)
@staticmethod
def _build_installer():
tmp_path = os.path.join(env.root_path, 'dist', 'client', 'windows', 'assist')
tmp_app_path = os.path.join(tmp_path, 'apps')
tmp_cfg_path = os.path.join(tmp_path, 'cfg')
tmp_cfg_path = os.path.join(tmp_app_path, 'cfg')
if os.path.exists(tmp_app_path):
utils.remove(tmp_app_path)
if os.path.exists(tmp_cfg_path):
utils.remove(tmp_cfg_path)
# if os.path.exists(tmp_cfg_path):
# utils.remove(tmp_cfg_path)
utils.makedirs(tmp_app_path)
utils.makedirs(tmp_cfg_path)
utils.copy_file(os.path.join(env.root_path, 'out', 'client', ctx.bits_path, ctx.target_path), tmp_app_path, 'tp_assist.exe')
# utils.copy_file(os.path.join(env.root_path, 'client', 'tp_assist', 'cfg'), tmp_cfg_path, 'ssh.ini')
# utils.copy_file(os.path.join(env.root_path, 'client', 'tp_assist', 'cfg'), tmp_cfg_path, 'scp.ini')
# utils.copy_file(os.path.join(env.root_path, 'client', 'tp_assist', 'cfg'), tmp_cfg_path, 'telnet.ini')
utils.copy_file(os.path.join(env.root_path, 'client', 'tp_assist', 'cfg'), tmp_cfg_path, 'ssh.ini')
utils.copy_file(os.path.join(env.root_path, 'client', 'tp_assist', 'cfg'), tmp_cfg_path, 'scp.ini')
utils.copy_file(os.path.join(env.root_path, 'client', 'tp_assist', 'cfg'), tmp_cfg_path, 'telnet.ini')
@ -131,10 +86,18 @@ class BuilderWin(BuilderBase):
utils.copy_ex(os.path.join(env.root_path, 'client', 'tp_assist'), tmp_app_path, 'site')
utils.makedirs(os.path.join(tmp_app_path, 'tools', 'putty'))
utils.makedirs(os.path.join(tmp_app_path, 'tools', 'winscp'))
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'putty'), os.path.join(tmp_app_path, 'tools', 'putty'), 'putty.exe')
utils.makedirs(os.path.join(tmp_app_path, 'tools', 'winscp'))
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'winscp'), os.path.join(tmp_app_path, 'tools', 'winscp'), 'WinSCP.exe')
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'winscp'), os.path.join(tmp_app_path, 'tools', 'winscp'), 'license.txt')
utils.makedirs(os.path.join(tmp_app_path, 'tools', 'tprdp'))
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'tprdp'), os.path.join(tmp_app_path, 'tools', 'tprdp'), 'tprdp-client.exe')
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'tprdp'), os.path.join(tmp_app_path, 'tools', 'tprdp'), 'tprdp-replay.exe')
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'tprdp'), os.path.join(tmp_app_path, 'tools', 'tprdp'), 'libeay32.dll')
utils.copy_file(os.path.join(env.root_path, 'client', 'tools', 'tprdp'), os.path.join(tmp_app_path, 'tools', 'tprdp'), 'ssleay32.dll')
utils.copy_file(os.path.join(env.root_path, 'client', 'tools'), os.path.join(tmp_app_path, 'tools'), 'securecrt-telnet.vbs')
utils.nsis_build(os.path.join(env.root_path, 'dist', 'client', 'windows', 'assist', 'installer.nsi'))

View File

@ -100,6 +100,7 @@ class BuilderWin(BuilderBase):
self.JSONCPP_PATH_SRC = os.path.join(PATH_EXTERNAL, 'jsoncpp')
self.MONGOOSE_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mongoose')
self.MBEDTLS_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mbedtls')
self.LIBUV_PATH_SRC = os.path.join(PATH_EXTERNAL, 'libuv')
self.LIBSSH_PATH_SRC = os.path.join(PATH_EXTERNAL, 'libssh-win-static')
self._prepare_python_header()
@ -226,6 +227,23 @@ class BuilderWin(BuilderBase):
os.rename(os.path.join(PATH_EXTERNAL, 'mbedtls-mbedtls-{}'.format(env.ver_mbedtls)), self.MBEDTLS_PATH_SRC)
else:
cc.w('already exists, skip.')
return
cc.v('')
# fix source file
utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls', 'config.h'))
utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls'), os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls'), 'config.h')
utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library', 'rsa.c'))
utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library'), os.path.join(self.MBEDTLS_PATH_SRC, 'library'), 'rsa.c')
def _build_libuv(self, file_name):
cc.n('prepare libuv source code... ', end='')
if not os.path.exists(self.LIBUV_PATH_SRC):
cc.v('')
utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL)
os.rename(os.path.join(PATH_EXTERNAL, 'libuv-{}'.format(env.ver_libuv)), self.LIBUV_PATH_SRC)
else:
cc.w('already exists, skip.')
def build_sqlite(self):
cc.w('sqlite not need for Windows, skip.')
@ -308,7 +326,7 @@ class BuilderLinux(BuilderBase):
old_p = os.getcwd()
os.chdir(self.LIBUV_PATH_SRC)
os.system('sh autogen.sh')
os.system('./configure --prefix={}'.format(self.PATH_RELEASE))
os.system('./configure --prefix={} --with-pic'.format(self.PATH_RELEASE))
os.system('make')
os.system('make install')
os.chdir(old_p)
@ -346,52 +364,54 @@ class BuilderLinux(BuilderBase):
f.writelines(fl)
f.close()
# fix config.h
mkfile = os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls', 'config.h')
f = open(mkfile)
fl = f.readlines()
f.close()
for i in range(len(fl)):
if fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED') >= 0:
fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED\n'
elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED') >= 0:
fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED\n'
elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED') >= 0:
fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED\n'
elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED') >= 0:
fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED\n'
elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED') >= 0:
fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED\n'
elif fl[i].find('#define MBEDTLS_SELF_TEST') >= 0:
fl[i] = '//#define MBEDTLS_SELF_TEST\n'
elif fl[i].find('#define MBEDTLS_SSL_RENEGOTIATION') >= 0:
fl[i] = '//#define MBEDTLS_SSL_RENEGOTIATION\n'
elif fl[i].find('#define MBEDTLS_ECDH_C') >= 0:
fl[i] = '//#define MBEDTLS_ECDH_C\n'
elif fl[i].find('#define MBEDTLS_ECDSA_C') >= 0:
fl[i] = '//#define MBEDTLS_ECDSA_C\n'
elif fl[i].find('#define MBEDTLS_ECP_C') >= 0:
fl[i] = '//#define MBEDTLS_ECP_C\n'
elif fl[i].find('#define MBEDTLS_NET_C') >= 0:
fl[i] = '//#define MBEDTLS_NET_C\n'
elif fl[i].find('#define MBEDTLS_RSA_NO_CRT') >= 0:
fl[i] = '#define MBEDTLS_RSA_NO_CRT\n'
elif fl[i].find('#define MBEDTLS_SSL_PROTO_SSL3') >= 0:
fl[i] = '#define MBEDTLS_SSL_PROTO_SSL3\n'
f = open(mkfile, 'w')
f.writelines(fl)
f.close()
# # fix config.h
# mkfile = os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls', 'config.h')
# f = open(mkfile)
# fl = f.readlines()
# f.close()
#
# for i in range(len(fl)):
# if fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED') >= 0:
# fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED\n'
# elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED') >= 0:
# fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED\n'
# elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED') >= 0:
# fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED\n'
# elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED') >= 0:
# fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED\n'
# elif fl[i].find('#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED') >= 0:
# fl[i] = '//#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED\n'
# elif fl[i].find('#define MBEDTLS_SELF_TEST') >= 0:
# fl[i] = '//#define MBEDTLS_SELF_TEST\n'
# elif fl[i].find('#define MBEDTLS_SSL_RENEGOTIATION') >= 0:
# fl[i] = '//#define MBEDTLS_SSL_RENEGOTIATION\n'
# elif fl[i].find('#define MBEDTLS_ECDH_C') >= 0:
# fl[i] = '//#define MBEDTLS_ECDH_C\n'
# elif fl[i].find('#define MBEDTLS_ECDSA_C') >= 0:
# fl[i] = '//#define MBEDTLS_ECDSA_C\n'
# elif fl[i].find('#define MBEDTLS_ECP_C') >= 0:
# fl[i] = '//#define MBEDTLS_ECP_C\n'
# elif fl[i].find('#define MBEDTLS_NET_C') >= 0:
# fl[i] = '//#define MBEDTLS_NET_C\n'
#
# elif fl[i].find('#define MBEDTLS_RSA_NO_CRT') >= 0:
# fl[i] = '#define MBEDTLS_RSA_NO_CRT\n'
# elif fl[i].find('#define MBEDTLS_SSL_PROTO_SSL3') >= 0:
# fl[i] = '#define MBEDTLS_SSL_PROTO_SSL3\n'
#
# f = open(mkfile, 'w')
# f.writelines(fl)
# f.close()
# fix source file
utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls', 'config.h'))
utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'include', 'mbedtls'), os.path.join(self.MBEDTLS_PATH_SRC, 'include', 'mbedtls'), 'config.h')
utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library', 'rsa.c'))
utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'mbedtls', 'library'), os.path.join(self.MBEDTLS_PATH_SRC, 'library'), 'rsa.c')
old_p = os.getcwd()
os.chdir(self.MBEDTLS_PATH_SRC)
os.system('make lib')
os.system('make CFLAGS="-fPIC" lib')
os.system('make install')
os.chdir(old_p)
@ -483,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):
@ -527,12 +547,12 @@ def main():
builder.build_jsoncpp()
builder.build_mongoose()
builder.build_openssl()
####builder.build_libuv()
builder.build_libuv()
builder.build_mbedtls()
builder.build_libssh()
builder.build_sqlite()
#
# builder.fix_output()
builder.fix_output()
if __name__ == '__main__':

View File

@ -128,6 +128,7 @@ class BuilderLinux(BuilderBase):
utils.copy_ex(out_path, bin_path, 'tp_web')
utils.copy_ex(out_path, bin_path, 'tp_core')
utils.copy_ex(out_path, bin_path, 'libtpssh.so')
utils.copy_ex(out_path, bin_path, 'libtprdp.so')
utils.copy_ex(os.path.join(env.root_path, 'out', 'pysrt'), bin_path, (ctx.dist_path, 'pysrt'))

View File

@ -25,12 +25,16 @@ class BuilderWin(BuilderBase):
def build_server(self):
cc.n('build web server ...')
sln_file = os.path.join(env.root_path, 'server', 'tp_web', 'src', 'tp_web.vs2015.sln')
out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_web.exe')
if os.path.exists(out_file):
utils.remove(out_file)
utils.msvc_build(sln_file, 'tp_web', ctx.target_path, ctx.bits_path, False)
utils.ensure_file_exists(out_file)
# notice: now we can not build debug version of tp_web.exe
if ctx.target_path == 'debug':
cc.w('cannot build debug version of tp_web, skip.')
else:
sln_file = os.path.join(env.root_path, 'server', 'tp_web', 'src', 'tp_web.vs2015.sln')
out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_web.exe')
if os.path.exists(out_file):
utils.remove(out_file)
utils.msvc_build(sln_file, 'tp_web', ctx.target_path, ctx.bits_path, False)
utils.ensure_file_exists(out_file)
cc.n('build core server ...')
sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'core', 'tp_core.vs2015.sln')
@ -48,11 +52,14 @@ class BuilderWin(BuilderBase):
utils.msvc_build(sln_file, 'tpssh', ctx.target_path, ctx.bits_path, False)
utils.ensure_file_exists(out_file)
#
# s = os.path.join(env.root_path, 'out', 'console', ctx.bits_path, ctx.target_path, 'console.exe')
# t = os.path.join(env.root_path, 'out', 'eom_agent', ctx.target_path, ctx.dist_path, 'eom_agent.com')
# shutil.copy(s, t)
# utils.ensure_file_exists(t)
if os.path.exists(os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'ssh', 'tpssh.vs2015.sln')):
cc.n('build RDP protocol ...')
sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'rdp', 'tprdp.vs2015.sln')
out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tprdp.dll')
if os.path.exists(out_file):
utils.remove(out_file)
utils.msvc_build(sln_file, 'tprdp', ctx.target_path, ctx.bits_path, False)
utils.ensure_file_exists(out_file)
class BuilderLinux(BuilderBase):

View File

@ -1,3 +1,3 @@
# -*- coding: utf8 -*-
VER_TELEPORT_SERVER = "2.1.2.1"
VER_TELEPORT_ASSIST = "2.1.2.1"
VER_TELEPORT_SERVER = "2.2.5.1"
VER_TELEPORT_ASSIST = "2.2.5.1"

View File

@ -16,9 +16,6 @@
<link href="plugins/gritter/css/jquery.gritter.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet" type="text/css"/>
<!--<link href="css/desktop.css" rel="stylesheet" type="text/css"/>-->
<!--<link href="${ static_url('css/main.css') }" rel="stylesheet" type="text/css"/>-->
</head>
<body>
@ -33,7 +30,7 @@
<div class="footer">
<div class="container">
<p>触维软件旗下产品 | TELEPORT | &copy;2015 - 2016 <a href="http://www.eomsoft.net/" target="_blank">触维软件</a>,保留所有权利。</p>
<p>触维软件旗下产品 | TELEPORT | &copy;2015 - 2017 <a href="http://teleport.eomsoft.net/" target="_blank">触维软件</a>,保留所有权利。</p>
</div>
</div>
@ -82,21 +79,6 @@
</div>
</div>
<!--<div class="form-group form-group-sm">-->
<!--<div class="col-sm-1"></div>-->
<!--<div class="col-sm-6">-->
<!--<div class="arg-detail">-->
<!--<span>命令参数中需要传递主机信息和登录信息,可以用以下变量替换(注意大小写!):</span>-->
<!--<ul>-->
<!--<li><strong>{host_ip}</strong> 替换主机IP地址</li>-->
<!--<li><strong>{host_port}</strong> 替换主机端口号</li>-->
<!--<li><strong>{user_name}</strong> 替换用户名</li>-->
<!--<li><strong>{real_ip}</strong> 替换远程主机真实IP仅用于显示</li>-->
<!--</ul>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<div class="form-group form-group-sm">
<div class="col-sm-1"></div>
<div class="col-sm-6">

Binary file not shown.

View File

@ -1,185 +1,185 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{63B7A8F2-9722-487C-A92A-3DB5D8CA1473}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tp_assist</RootNamespace>
<ProjectName>tp_assist</ProjectName>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\out\client\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
<IncludePath>D:\apps\vld\include;$(IncludePath)</IncludePath>
<LibraryPath>D:\apps\vld\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\out\client\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\common\teleport;..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\..\external\openssl\out32\ssleay32.lib;..\..\external\openssl\out32\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\common\teleport;..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>..\..\external\openssl\out32\ssleay32.lib;..\..\external\openssl\out32\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\common\libex\include\ex.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_const.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_ini.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_log.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_path.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_platform.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_str.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_thread.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_types.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\common\teleport\teleport_const.h" />
<ClInclude Include="..\..\external\mongoose\mongoose.h" />
<ClInclude Include="dlg_main.h" />
<ClInclude Include="msocketx.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="tp_assist.h" />
<ClInclude Include="ts_cfg.h" />
<ClInclude Include="ts_const.h" />
<ClInclude Include="ts_env.h" />
<ClInclude Include="ts_http_rpc.h" />
<ClInclude Include="ts_network.h" />
<ClInclude Include="ts_ver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\common\libex\src\ex_ini.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_log.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_path.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_str.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_thread.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_util.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\jsoncpp\src\lib_json\json_reader.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\jsoncpp\src\lib_json\json_value.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\jsoncpp\src\lib_json\json_writer.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\mongoose\mongoose.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="dlg_main.cpp" />
<ClCompile Include="msocketx.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="tp_assist.cpp" />
<ClCompile Include="ts_cfg.cpp" />
<ClCompile Include="ts_env.cpp" />
<ClCompile Include="ts_http_rpc.cpp" />
<ClCompile Include="ts_network.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="tp_assist.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\tp.ico" />
<Image Include="res\tp_small.ico" />
<Image Include="res\tray_normal.ico" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\external\jsoncpp\src\lib_json\json_valueiterator.inl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{63B7A8F2-9722-487C-A92A-3DB5D8CA1473}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tp_assist</RootNamespace>
<ProjectName>tp_assist</ProjectName>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\out\client\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\out\client\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\common\teleport;..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\..\external\openssl\out32\ssleay32.lib;..\..\external\openssl\out32\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\common\teleport;..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>..\..\external\openssl\out32\ssleay32.lib;..\..\external\openssl\out32\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\common\libex\include\ex.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_const.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_ini.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_log.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_path.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_platform.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_str.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_thread.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_types.h" />
<ClInclude Include="..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\common\teleport\teleport_const.h" />
<ClInclude Include="..\..\external\mongoose\mongoose.h" />
<ClInclude Include="dlg_main.h" />
<ClInclude Include="msocketx.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="tp_assist.h" />
<ClInclude Include="ts_cfg.h" />
<ClInclude Include="ts_const.h" />
<ClInclude Include="ts_env.h" />
<ClInclude Include="ts_http_rpc.h" />
<ClInclude Include="ts_network.h" />
<ClInclude Include="ts_ver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\common\libex\src\ex_ini.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_log.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_path.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_str.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_thread.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\common\libex\src\ex_util.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\jsoncpp\src\lib_json\json_reader.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\jsoncpp\src\lib_json\json_value.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\jsoncpp\src\lib_json\json_writer.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\external\mongoose\mongoose.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="dlg_main.cpp" />
<ClCompile Include="msocketx.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="tp_assist.cpp" />
<ClCompile Include="ts_cfg.cpp" />
<ClCompile Include="ts_env.cpp" />
<ClCompile Include="ts_http_rpc.cpp" />
<ClCompile Include="ts_network.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="tp_assist.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\tp.ico" />
<Image Include="res\tp_small.ico" />
<Image Include="res\tray_normal.ico" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\external\jsoncpp\src\lib_json\json_valueiterator.inl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -4,7 +4,7 @@
#include <time.h>
#ifdef EX_OS_WIN32
# include <direct.h>
# include <ShlObj.h>
//# include <ShlObj.h>
#endif
TsEnv g_env;
@ -28,20 +28,31 @@ bool TsEnv::init(void)
if (!ex_dirname(m_exec_path))
return false;
#ifdef _DEBUG
m_ssh_client_conf_file = m_exec_path;
ex_path_join(m_ssh_client_conf_file, false, L"ssh.ini", NULL);
ex_path_join(m_ssh_client_conf_file, false, L"cfg", L"ssh.ini", NULL);
m_scp_client_conf_file = m_exec_path;
ex_path_join(m_scp_client_conf_file, false, L"scp.ini", NULL);
ex_path_join(m_scp_client_conf_file, false, L"cfg", L"scp.ini", NULL);
m_telnet_client_conf_file = m_exec_path;
ex_path_join(m_telnet_client_conf_file, false, L"telnet.ini", NULL);
ex_path_join(m_telnet_client_conf_file, false, L"cfg", L"telnet.ini", NULL);
m_log_path = m_exec_path;
ex_path_join(m_log_path, false, L"log", NULL);
#ifdef _DEBUG
// m_ssh_client_conf_file = m_exec_path;
// ex_path_join(m_ssh_client_conf_file, false, L"ssh.ini", NULL);
//
// m_scp_client_conf_file = m_exec_path;
// ex_path_join(m_scp_client_conf_file, false, L"scp.ini", NULL);
//
// m_telnet_client_conf_file = m_exec_path;
// ex_path_join(m_telnet_client_conf_file, false, L"telnet.ini", NULL);
//
// m_log_path = m_exec_path;
// ex_path_join(m_log_path, false, L"log", NULL);
m_site_path = m_exec_path;
ex_path_join(m_site_path, true, L"..", L"..", L"..", L"..", L"client", L"tp_assist", L"site", NULL);
@ -49,20 +60,20 @@ bool TsEnv::init(void)
ex_path_join(m_tools_path, true, L"..", L"..", L"..", L"..", L"client", L"tools", NULL);
#else
TCHAR szBuf[PATH_MAX] = { 0 };
SHGetSpecialFolderPathW(NULL, szBuf, CSIDL_APPDATA, FALSE);
m_ssh_client_conf_file = szBuf;// m_exec_path;
ex_path_join(m_ssh_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"ssh.ini", NULL);
m_scp_client_conf_file = szBuf;// m_exec_path;
ex_path_join(m_scp_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"scp.ini", NULL);
m_telnet_client_conf_file = szBuf;// m_exec_path;
ex_path_join(m_telnet_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"telnet.ini", NULL);
m_log_path = szBuf;// m_exec_path;
ex_path_join(m_log_path, false, L"eomsoft", L"teleport", L"assist", L"log", NULL);
// TCHAR szBuf[PATH_MAX] = { 0 };
// SHGetSpecialFolderPathW(NULL, szBuf, CSIDL_APPDATA, FALSE);
//
// m_ssh_client_conf_file = szBuf;// m_exec_path;
// ex_path_join(m_ssh_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"ssh.ini", NULL);
//
// m_scp_client_conf_file = szBuf;// m_exec_path;
// ex_path_join(m_scp_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"scp.ini", NULL);
//
// m_telnet_client_conf_file = szBuf;// m_exec_path;
// ex_path_join(m_telnet_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"telnet.ini", NULL);
//
// m_log_path = szBuf;// m_exec_path;
// ex_path_join(m_log_path, false, L"eomsoft", L"teleport", L"assist", L"log", NULL);
m_site_path = m_exec_path;
ex_path_join(m_site_path, false, L"site", NULL);

View File

@ -44,8 +44,15 @@ End Sub
ubuntuLinuxSecureCRT
*/
// #define RDP_CLIENT_SYSTEM_BUILTIN
// #define RDP_CLIENT_SYSTEM_ACTIVE_CONTROL
#define RDP_CLIENT_FREERDP
#ifdef RDP_CLIENT_SYSTEM_BUILTIN
#include <WinCrypt.h>
#pragma comment(lib, "Crypt32.lib")
#if 0
std::string rdp_content = "\
connect to console:i:%d\n\
screen mode id:i:%d\n\
@ -64,31 +71,30 @@ audiocapturemode:i:0\n\
negotiate security layer:i:1\n\
videoplaybackmode:i:1\n\
connection type:i:2\n\
prompt for credentials on client:i:1\r\n\
prompt for credentials on client:i:0\n\
displayconnectionbar:i:1\n\
disable wallpaper:i:1\n\
allow font smoothing:i:0\n\
allow desktop composition:i:0\n\
disable full window drag:i:1\n\
disable menu anims:i:1\n\
disable themes:i:0\n\
disable themes:i:1\n\
disable cursor setting:i:0\n\
bitmapcachepersistenable:i:1\n\
audiomode:i:0\n\
redirectprinters:i:1\n\
redirectprinters:i:0\n\
redirectcomports:i:0\n\
redirectsmartcards:i:1\n\
redirectsmartcards:i:0\n\
redirectclipboard:i:1\n\
redirectposdevices:i:0\n\
redirectdirectx:i:1\n\
autoreconnection enabled:i:1\n\
autoreconnection enabled:i:1\n\
redirectdirectx:i:0\n\
autoreconnection enabled:i:0\n\
drivestoredirect:s:*\n\
password 51:b:01000000D08C9DDF0115D1118C7A00C04FC297EB0100000052A9E191EA75A948B359790578C9371A0000000008000000700073007700000003660000A8000000100000000A1DCCD2E50775CA25EC3857164B34DC0000000004800000A000000010000000FCE1A645B9B61AA450946BB6F955058108020000D83591CA47562D6DDAA689F050AE145039EBE22E00D1D3AEAA98373C7B63C3E8E7149072DF989EA43EFCE20513AD3D27B11BE7F17066A688E1DCE828AF85460AAC327B38E90776DB962888E4393D19637578984B19A187AAD95F6D2726ADE7DD315FF56C15FF5B3031014EDDCC3C24D1B81779AFDB006EE575F5BEFB8D2D2138D9D9D642BBB251CC5ED7226968764856EC660A646BACE748A13D6002A9A537AA70710615650B9387EED66DE28BD57B304BBDD7B581B943DA628EB0289E30A8BA784B76F7885BECCAB4FEF7820E97EE3C6E036EEAF6EAA669288DF2FCACC9BEC045C907EBBDE87AFB8CC6B07A600BD63AC891B61D95C2265DD9FD5E635D61BFBF5EDC28311375066611C610FB533D64515B643C82F57D9B183B05C156D91BC0974D38E546022B139E82452E6F1EDF76E52F732C3904E5E433F8F3D488DB0698427DBB0791A9F207F8CB6654CB8410BAF4A59C4F9E821E589ABC1E6E6E1D432181B690408F6884FE1007895A4D26D4A5A2C7458EE747DA35D44AC9FB08AB5477EA3E7CCDB3E37EE20FAFD0D0CF9584E420598B7003B347943AC28048F45E0FD21AD08148FFADCE0E7877219259A7BE722FFAE845A429BA2CF0A71F2D19EA7495530FABDB5106E8D404A38A7E6394C38457640EA7398C5D55F0C4D342CC6A39C77E10A2A5145AEA40B14F5C7C3760334D83C9BE748383FADE231248537353817D51F7B44F61B406ABC61400000071C354139F458B02D978015F785B97F7F6B307380\n\
password 51:b:%s\n\
";
//password\n\
//51:b:01000000";
//password 51:b:01000000D08C9DDF0115D1118C7A00C04FC297EB0100000052A9E191EA75A948B359790578C9371A0000000008000000700073007700000003660000A8000000100000000A1DCCD2E50775CA25EC3857164B34DC0000000004800000A000000010000000FCE1A645B9B61AA450946BB6F955058108020000D83591CA47562D6DDAA689F050AE145039EBE22E00D1D3AEAA98373C7B63C3E8E7149072DF989EA43EFCE20513AD3D27B11BE7F17066A688E1DCE828AF85460AAC327B38E90776DB962888E4393D19637578984B19A187AAD95F6D2726ADE7DD315FF56C15FF5B3031014EDDCC3C24D1B81779AFDB006EE575F5BEFB8D2D2138D9D9D642BBB251CC5ED7226968764856EC660A646BACE748A13D6002A9A537AA70710615650B9387EED66DE28BD57B304BBDD7B581B943DA628EB0289E30A8BA784B76F7885BECCAB4FEF7820E97EE3C6E036EEAF6EAA669288DF2FCACC9BEC045C907EBBDE87AFB8CC6B07A600BD63AC891B61D95C2265DD9FD5E635D61BFBF5EDC28311375066611C610FB533D64515B643C82F57D9B183B05C156D91BC0974D38E546022B139E82452E6F1EDF76E52F732C3904E5E433F8F3D488DB0698427DBB0791A9F207F8CB6654CB8410BAF4A59C4F9E821E589ABC1E6E6E1D432181B690408F6884FE1007895A4D26D4A5A2C7458EE747DA35D44AC9FB08AB5477EA3E7CCDB3E37EE20FAFD0D0CF9584E420598B7003B347943AC28048F45E0FD21AD08148FFADCE0E7877219259A7BE722FFAE845A429BA2CF0A71F2D19EA7495530FABDB5106E8D404A38A7E6394C38457640EA7398C5D55F0C4D342CC6A39C77E10A2A5145AEA40B14F5C7C3760334D83C9BE748383FADE231248537353817D51F7B44F61B406ABC61400000071C354139F458B02D978015F785B97F7F6B307380\n\
//password 51:b:01000000";
#endif
@ -116,7 +122,6 @@ void http_rpc_stop(void)
g_http_interface.stop();
}
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
int ts_url_decode(const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded)
@ -154,6 +159,34 @@ int ts_url_decode(const char *src, int src_len, char *dst, int dst_len, int is_f
return i >= src_len ? j : -1;
}
#ifdef RDP_CLIENT_SYSTEM_BUILTIN
bool calc_psw51b(const char* password, std::string& ret)
{
DATA_BLOB DataIn;
DATA_BLOB DataOut;
ex_wstr w_pswd;
ex_astr2wstr(password, w_pswd, EX_CODEPAGE_ACP);
DataIn.cbData = w_pswd.length() * sizeof(wchar_t);
DataIn.pbData = (BYTE*)w_pswd.c_str();
if (!CryptProtectData(&DataIn, L"psw", NULL, NULL, NULL, 0, &DataOut))
return false;
char szRet[5] = {0};
for (int i = 0; i < DataOut.cbData; ++i)
{
sprintf_s(szRet, 5, "%02X", DataOut.pbData[i]);
ret += szRet;
}
LocalFree(DataOut.pbData);
return true;
}
#endif
TsHttpRpc::TsHttpRpc()
{
m_stop = false;
@ -582,9 +615,9 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
//==============================================
// RDP
//==============================================
#if 1
//#if 1
#if 0
#if defined(RDP_CLIENT_SYSTEM_ACTIVE_CONTROL)
int split_pos = session_id.length() - 2;
std::string real_s_id = session_id.substr(0, split_pos);
std::string str_pwd_len = session_id.substr(split_pos, session_id.length());
@ -624,7 +657,7 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
w_exe_path += w_szCommandLine;
//BOOL bRet = DeleteFile(w_sz_file_name.c_str());
#else
#elif defined(RDP_CLIENT_FREERDP)
wchar_t* w_screen = NULL;
switch (windows_size)
@ -677,9 +710,9 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
w_exe_path += w_szCommandLine;
#endif
//#endif
#else
#elif defined(RDP_CLIENT_SYSTEM_BUILTIN)
int width = 800;
int higth = 600;
int cx = 0;
@ -741,12 +774,21 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
int split_pos = sid.length() - 2;
std::string real_sid = sid.substr(0, split_pos);
std::string psw51b;
if (!calc_psw51b("Abcd1234", psw51b))
{
printf("calc password failed.\n");
_create_json_ret(buf, TPE_FAILED);
return;
}
char sz_rdp_file_content[4096] = { 0 };
sprintf_s(sz_rdp_file_content, rdp_content.c_str(),
console, display, width, higth
, cx, cy, cx + width + 20, cy + higth + 40
, teleport_ip.c_str(), teleport_port
, real_sid.c_str()
, psw51b.c_str()
);
char sz_file_name[MAX_PATH] = { 0 };
@ -755,29 +797,32 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
if (ret <= 0)
{
printf("fopen failed (%d).\n", GetLastError());
_create_json_ret(buf, TSR_GETTEMPPATH_ERROR);
_create_json_ret(buf, TPE_FAILED);
return;
}
ex_wstr w_s_id;
ex_astr2str(real_sid, w_s_id);
ex_astr2wstr(real_sid, w_s_id);
ex_astr temp_host_ip = replace_all_distinct(real_host_ip, ("."), "-");
ex_astr temp_host_ip = real_host_ip;// replace_all_distinct(real_host_ip, ("."), "-");
ex_replace_all(temp_host_ip, ".", "-");
sprintf_s(sz_file_name, ("%s\\%s.rdp"), temp_path, temp_host_ip.c_str());
FILE* f = fopen(sz_file_name, ("wt"));
if (f == NULL)
sprintf_s(sz_file_name, ("%s%s.rdp"), temp_path, temp_host_ip.c_str());
//FILE* f = fopen(sz_file_name, ("wt"));
//if (f == NULL)
FILE* f = NULL;
if(fopen_s(&f, sz_file_name, "wt") != 0)
{
printf("fopen failed (%d).\n", GetLastError());
_create_json_ret(buf, TSR_OPENFILE_ERROR);
_create_json_ret(buf, TPE_OPENFILE);
return;
}
// Write a string into the file.
fwrite(sz_rdp_file_content, strlen(sz_rdp_file_content), 1, f);
fclose(f);
ex_wstr w_sz_file_name;
ex_astr2str(sz_file_name, w_sz_file_name);
ex_astr2wstr(sz_file_name, w_sz_file_name);
swprintf_s(w_szCommandLine, _T("mstsc %s"), w_sz_file_name.c_str());
swprintf_s(w_szCommandLine, _T("mstsc \"%s\""), w_sz_file_name.c_str());
w_exe_path = w_szCommandLine;
//BOOL bRet = DeleteFile(w_sz_file_name.c_str());
#endif

View File

@ -1,6 +1,6 @@
#ifndef __TS_ASSIST_VER_H__
#define __TS_ASSIST_VER_H__
#define TP_ASSIST_VER L"2.1.2.1"
#define TP_ASSIST_VER L"2.2.5.1"
#endif // __TS_ASSIST_VER_H__

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

@ -61,6 +61,7 @@ protected:
void EXLOG_USE_LOGGER(ExLogger* logger);
void EXLOG_LEVEL(int min_level);
void EXLOG_DEBUG(bool debug_mode);
// 设定日志文件名及路径如未指定路径则为可执行程序所在目录下的log目录。
void EXLOG_FILE(const wchar_t* log_file, const wchar_t* log_path = NULL, ex_u32 max_filesize = EX_LOG_FILE_MAX_SIZE, ex_u8 max_filecount = EX_LOG_FILE_MAX_COUNT);

View File

@ -1,118 +1,143 @@
#ifndef __LIB_EX_PLATFORM_H__
#define __LIB_EX_PLATFORM_H__
#if defined(_WIN32) || defined(WIN32)
# define EX_OS_WIN32
#elif defined(__linux__)
# define EX_OS_LINUX
# define EX_OS_UNIX
#elif defined(__APPLE__)
# define EX_OS_MACOS
# define EX_OS_UNIX
#else
# error unsupported platform.
#endif
// compiler
#ifdef EX_OS_WIN32
# ifndef _MSC_VER
# error need VisualStudio on Windows.
# endif
# if _MSC_VER < 1900 // need VisualStudio 2015 and above.
# error need VisualStudio 2015 and above.
# endif
#endif
#ifdef EX_OS_WIN32
# if !defined(UNICODE) && !defined(_UNICODE)
# error "Does not support `Multi-Byte Character Set` on Windows."
# endif
# ifdef _DEBUG
# ifndef EX_DEBUG
# define EX_DEBUG
# endif
# endif
#endif
#ifdef EX_OS_WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500 // 0x0500 = Windows2000
# endif
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
# define _CRT_RAND_S // for rand_s().
# include <windows.h>
# include <tchar.h>
# include <shlwapi.h>
# include <shellapi.h>
# define _CSTDIO_
# define _CSTRING_
# define _CWCHAR_
# include <strsafe.h>
# include <WinSock2.h>
# include <direct.h>
#else
# include <locale.h>
# include <string.h>
# include <stdio.h>
# include <stdlib.h> // free()
# include <stdarg.h> // va_start()
# include <unistd.h> // readlink()
# include <wchar.h>
# include <sys/stat.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
#endif
/*
* On Windows PATH_MAX does not exist but MAX_PATH does.
* WinAPI MAX_PATH limit is only 256. MSVCR fuctions does not have this limit.
* Redefine PATH_MAX for Windows to support longer path names.
*/
#if defined(EX_OS_WIN32)
# ifdef PATH_MAX
# undef PATH_MAX /* On Windows override PATH_MAX if defined. */
# endif
# define PATH_MAX 1024
#elif defined(EX_OS_LINUX)
# ifndef PATH_MAX
# define PATH_MAX 1024
# endif
#elif defined(EX_OS_MACOS)
# define PATH_MAX 1024 /* Recommended value for OSX. */
#endif
// assert
#ifdef EX_DEBUG
# define ASSERT(exp)
# define CHECK(exp) do { if (!(exp)) abort(); } while (0)
//# define DEBUG_CHECKS (0)
#else
# include <assert.h>
# define ASSERT(exp) assert(exp)
# define CHECK(exp) assert(exp)
//# define DEBUG_CHECKS (1)
#endif
#ifndef UNUSED
# if defined(_MSC_VER)
# define UNUSED(x) (void)(x)
# elif defined(__GUNC__)
# defined UNUSED(x) UNUSED_ ## x __attribute__((unused))
# elif defined(__LCLINT__)
# define UNUSED(x) /*@unused@*/ x
# elif defined(__cplusplus)
# define UNUSED(x)
# else
# define UNUSED(x) (void)(x)
# endif
#endif
#ifdef EX_OS_WIN32
# pragma comment(lib, "shlwapi.lib")
#endif
#endif // __LIB_EX_PLATFORM_H__
#ifndef __LIB_EX_PLATFORM_H__
#define __LIB_EX_PLATFORM_H__
#if defined(_WIN32) || defined(WIN32)
# define EX_OS_WIN32
#elif defined(__linux__)
# define EX_OS_LINUX
# define EX_OS_UNIX
#elif defined(__APPLE__)
# define EX_OS_MACOS
# define EX_OS_UNIX
#else
# error unsupported platform.
#endif
// compiler
#ifdef EX_OS_WIN32
# ifndef _MSC_VER
# error need VisualStudio on Windows.
# endif
# if _MSC_VER < 1900 // need VisualStudio 2015 and above.
# error need VisualStudio 2015 and above.
# endif
#endif
#ifdef EX_OS_WIN32
# if !defined(UNICODE) && !defined(_UNICODE)
# error "Does not support `Multi-Byte Character Set` on Windows."
# endif
# ifdef _DEBUG
# ifndef EX_DEBUG
# define EX_DEBUG
# endif
# endif
#endif
#ifdef EX_OS_WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0502 // 0x0502 = WinServer2003 (libuv need this) 0x0501 = WinXP, 0x0500 = Win2000
# endif
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
# define _CRT_RAND_S // for rand_s().
# include <windows.h>
# include <tchar.h>
# include <shlwapi.h>
# include <shellapi.h>
# define _CSTDIO_
# define _CSTRING_
# define _CWCHAR_
# include <strsafe.h>
# include <WinSock2.h>
# include <direct.h>
#else
# include <locale.h>
# include <string.h>
# include <stdio.h>
# include <stdlib.h> // free()
# include <stdarg.h> // va_start()
# include <unistd.h> // readlink()
# include <wchar.h>
# include <sys/stat.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
#endif
/*
* On Windows PATH_MAX does not exist but MAX_PATH does.
* WinAPI MAX_PATH limit is only 256. MSVCR fuctions does not have this limit.
* Redefine PATH_MAX for Windows to support longer path names.
*/
#if defined(EX_OS_WIN32)
# ifdef PATH_MAX
# undef PATH_MAX /* On Windows override PATH_MAX if defined. */
# endif
# define PATH_MAX 1024
#elif defined(EX_OS_LINUX)
# ifndef PATH_MAX
# define PATH_MAX 1024
# endif
#elif defined(EX_OS_MACOS)
# define PATH_MAX 1024 /* Recommended value for OSX. */
#endif
// assert
#ifdef EX_DEBUG
# define ASSERT(exp)
# define CHECK(exp) do { if (!(exp)) abort(); } while (0)
//# define DEBUG_CHECKS (0)
#else
# include <assert.h>
# define ASSERT(exp) assert(exp)
# define CHECK(exp) assert(exp)
//# define DEBUG_CHECKS (1)
#endif
#define UNREACHABLE() CHECK(!"Unreachable code reached.")
#ifndef UNUSED
# if defined(_MSC_VER)
# define UNUSED(x) (void)(x)
# elif defined(__GUNC__)
# defined UNUSED(x) UNUSED_ ## x __attribute__((unused))
# elif defined(__LCLINT__)
# define UNUSED(x) /*@unused@*/ x
# elif defined(__cplusplus)
# define UNUSED(x)
# else
# define UNUSED(x) (void)(x)
# endif
#endif
/* check endian */
#if !(defined(L_ENDIAN) || defined(B_ENDIAN))
# if !defined(__BYTE_ORDER) && defined(__linux__)
# include <endian.h>
# endif
# if defined(BYTE_ORDER)
# if BYTE_ORDER == BIG_ENDIAN
# define B_ENDIAN
# else
# define L_ENDIAN
# endif
# endif
# if !(defined(L_ENDIAN) || defined(B_ENDIAN))
# if defined(__sparc__) || defined(__PPC__) || defined(__ppc__) || defined(__hppa__)
# define B_ENDIAN
# else
# define L_ENDIAN
# endif
# endif
#endif
#ifdef EX_OS_WIN32
# pragma comment(lib, "shlwapi.lib")
#endif
#endif // __LIB_EX_PLATFORM_H__

View File

@ -1,83 +1,86 @@
#ifndef __LIB_EX_STR_H__
#define __LIB_EX_STR_H__
#include "ex_types.h"
#define EX_CODEPAGE_ACP 0
#define EX_CODEPAGE_UTF8 1
#ifdef EX_OS_WIN32
# define EX_CODEPAGE_DEFAULT EX_CODEPAGE_ACP
#else
# define EX_CODEPAGE_DEFAULT EX_CODEPAGE_UTF8
#endif
#define EX_RSC_BEGIN 0x01
#define EX_RSC_END 0x02
#define EX_RSC_ALL EX_RSC_BEGIN | EX_RSC_END
//=================================================
// C Interface
//=================================================
// copy a string from `source` to `target`.
// `size` is size of target buffer.
// if buffer is to small, NULL will return, but `size-1` characters have been copied.
char* ex_strcpy(char* target, size_t size, const char* source);
wchar_t* ex_wcscpy(wchar_t* target, size_t size, const wchar_t* source);
// dupilicate a string.
// must use ex_free() to release the returned value.
char* ex_strdup(const char* src);
wchar_t* ex_wcsdup(const wchar_t* src);
// convert between mutli-bytes and wide char string.
// must use ex_free() to release the returned value.
wchar_t* ex_str2wcs_alloc(const char* in_buffer, int code_page);
char* ex_wcs2str_alloc(const wchar_t* in_buffer, int code_page);
// convert char** argv to wchar_t** argv.
// must use ex_free_argv() to release the returned value.
wchar_t** ex_make_wargv(int argc, char** argv);
void ex_free_wargv(int argc, wchar_t** argv);
EX_BOOL ex_str_only_white_space(const wchar_t* src);
EX_BOOL ex_wcs_only_white_space(const char* src);
int ex_strformat(char* out_buf, size_t buf_size, const char* fmt, ...);
int ex_wcsformat(wchar_t* out_buf, size_t buf_size, const wchar_t* fmt, ...);
//=================================================
// C++ Interface
//=================================================
#ifdef __cplusplus
#include <string>
#include <vector>
typedef std::string ex_astr;
typedef std::wstring ex_wstr;
typedef std::vector<ex_astr> ex_astrs;
typedef std::vector<ex_wstr> ex_wstrs;
bool ex_wstr2astr(const ex_wstr& in_str, ex_astr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_wstr2astr(const wchar_t* in_str, ex_astr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_astr2wstr(const ex_astr& in_str, ex_wstr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_astr2wstr(const char* in_str, ex_wstr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_only_white_space(const ex_astr& str_check);
bool ex_only_white_space(const ex_wstr& str_check);
void ex_remove_white_space(ex_astr& str_fix, int ulFlag = EX_RSC_ALL);
void ex_remove_white_space(ex_wstr& str_fix, int ulFlag = EX_RSC_ALL);
ex_astr& ex_replace_all(ex_astr& str, const ex_astr& old_value, const ex_astr& new_value);
ex_wstr& ex_replace_all(ex_wstr& str, const ex_wstr& old_value, const ex_wstr& new_value);
#endif
#endif // __LIB_EX_STR_H__
#ifndef __LIB_EX_STR_H__
#define __LIB_EX_STR_H__
#include "ex_types.h"
#define EX_CODEPAGE_ACP 0
#define EX_CODEPAGE_UTF8 1
#ifdef EX_OS_WIN32
# define EX_CODEPAGE_DEFAULT EX_CODEPAGE_ACP
#else
# define EX_CODEPAGE_DEFAULT EX_CODEPAGE_UTF8
#endif
#define EX_RSC_BEGIN 0x01
#define EX_RSC_END 0x02
#define EX_RSC_ALL EX_RSC_BEGIN | EX_RSC_END
//=================================================
// C Interface
//=================================================
// copy a string from `source` to `target`.
// `size` is size of target buffer.
// if buffer is to small, NULL will return, but `size-1` characters have been copied.
char* ex_strcpy(char* target, size_t size, const char* source);
wchar_t* ex_wcscpy(wchar_t* target, size_t size, const wchar_t* source);
// dupilicate a string.
// must use ex_free() to release the returned value.
char* ex_strdup(const char* src);
wchar_t* ex_wcsdup(const wchar_t* src);
// convert between mutli-bytes and wide char string.
// must use ex_free() to release the returned value.
wchar_t* ex_str2wcs_alloc(const char* in_buffer, int code_page);
char* ex_wcs2str_alloc(const wchar_t* in_buffer, int code_page);
// convert char** argv to wchar_t** argv.
// must use ex_free_argv() to release the returned value.
wchar_t** ex_make_wargv(int argc, char** argv);
void ex_free_wargv(int argc, wchar_t** argv);
EX_BOOL ex_str_only_white_space(const wchar_t* src);
EX_BOOL ex_wcs_only_white_space(const char* src);
int ex_strformat(char* out_buf, size_t buf_size, const char* fmt, ...);
int ex_wcsformat(wchar_t* out_buf, size_t buf_size, const wchar_t* fmt, ...);
//=================================================
// C++ Interface
//=================================================
#ifdef __cplusplus
#include <string>
#include <vector>
typedef std::string ex_astr;
typedef std::wstring ex_wstr;
typedef std::vector<ex_astr> ex_astrs;
typedef std::vector<ex_wstr> ex_wstrs;
typedef std::vector<ex_utf16> ex_str_utf16le;
bool ex_wstr2astr(const ex_wstr& in_str, ex_astr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_wstr2astr(const wchar_t* in_str, ex_astr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_astr2wstr(const ex_astr& in_str, ex_wstr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_astr2wstr(const char* in_str, ex_wstr& out_str, int code_page = EX_CODEPAGE_DEFAULT);
bool ex_only_white_space(const ex_astr& str_check);
bool ex_only_white_space(const ex_wstr& str_check);
void ex_remove_white_space(ex_astr& str_fix, int ulFlag = EX_RSC_ALL);
void ex_remove_white_space(ex_wstr& str_fix, int ulFlag = EX_RSC_ALL);
ex_astr& ex_replace_all(ex_astr& str, const ex_astr& old_value, const ex_astr& new_value);
ex_wstr& ex_replace_all(ex_wstr& str, const ex_wstr& old_value, const ex_wstr& new_value);
// 将UTF8字符串转换为UTF16-LE字符串输出结果包含\0结束符
bool ex_utf8_to_utf16le(const std::string& from, ex_str_utf16le& to);
#endif
#endif // __LIB_EX_STR_H__

View File

@ -1,44 +1,44 @@
#ifndef __LIB_EX_TYPE_H__
#define __LIB_EX_TYPE_H__
#include "ex_platform.h"
#include <vector>
typedef signed char ex_i8;
typedef signed short ex_i16;
typedef unsigned char ex_u8;
typedef unsigned short ex_u16;
typedef unsigned int ex_u32;
typedef unsigned long ex_ulong;
#if defined(EX_OS_WIN32)
typedef unsigned __int64 ex_u64;
typedef signed __int64 ex_i64;
typedef wchar_t ex_utf16;
#else
typedef unsigned long long ex_u64;
typedef signed long long ex_i64;
typedef ex_u16 ex_utf16;
#endif
typedef int EX_BOOL;
#define EX_TRUE 1
#define EX_FALSE 0
typedef std::vector<ex_u8> ex_bin;
typedef std::vector<char> ex_chars;
typedef ex_u32 ex_rv;
#if defined(EX_OS_WIN32)
# define EX_DYLIB_HANDLE HINSTANCE
#else
# define EX_DYLIB_HANDLE void*
#endif
#endif // __LIB_EX_TYPE_H__
#ifndef __LIB_EX_TYPE_H__
#define __LIB_EX_TYPE_H__
#include "ex_platform.h"
#include <vector>
typedef signed char ex_i8;
typedef signed short ex_i16;
typedef unsigned char ex_u8;
typedef unsigned short ex_u16;
typedef unsigned int ex_u32;
typedef unsigned long ex_ulong;
#if defined(EX_OS_WIN32)
typedef unsigned __int64 ex_u64;
typedef signed __int64 ex_i64;
typedef wchar_t ex_utf16;
#else
typedef unsigned long long ex_u64;
typedef signed long long ex_i64;
typedef ex_i16 ex_utf16;
#endif
typedef int EX_BOOL;
#define EX_TRUE 1
#define EX_FALSE 0
typedef std::vector<ex_u8> ex_bin;
typedef std::vector<char> ex_chars;
typedef ex_u32 ex_rv;
#if defined(EX_OS_WIN32)
# define EX_DYLIB_HANDLE HINSTANCE
#else
# define EX_DYLIB_HANDLE void*
#endif
#endif // __LIB_EX_TYPE_H__

View File

@ -1,44 +1,45 @@
#ifndef __LIB_EX_UTIL_H__
#define __LIB_EX_UTIL_H__
#include <ex/ex_types.h>
#include <ex/ex_str.h>
#ifdef EX_OS_WIN32
# include <time.h>
//# include <io.h>
//# include <stdio.h>
// #include <direct.h>
#else
// #include <dirent.h>
# include <dlfcn.h>
# include <sys/time.h>
#endif
EX_BOOL ex_initialize(const char* lc_ctype);
void ex_free(void* buffer);
// 在haystack长度为haystacklen字节中查找needle长度为needlelen的起始地址返回NULL表示没有找到
const ex_u8* ex_memmem(const ex_u8* haystack, size_t haystacklen, const ex_u8* needle, size_t needlelen);
void ex_printf(const char* fmt, ...);
void ex_wprintf(const wchar_t* fmt, ...);
ex_u64 ex_get_tick_count(void);
void ex_sleep_ms(int ms);
EX_BOOL ex_localtime_now(int* t, struct tm* dt);
FILE* ex_fopen(const ex_wstr& filename, const wchar_t* mode);
EX_DYLIB_HANDLE ex_dlopen(const wchar_t* dylib_path);
void ex_dlclose(EX_DYLIB_HANDLE dylib);
// inet...
int ex_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
#endif // __LIB_EX_UTIL_H__
#ifndef __LIB_EX_UTIL_H__
#define __LIB_EX_UTIL_H__
#include <ex/ex_types.h>
#include <ex/ex_str.h>
#ifdef EX_OS_WIN32
# include <time.h>
//# include <io.h>
//# include <stdio.h>
// #include <direct.h>
#else
// #include <dirent.h>
# include <dlfcn.h>
# include <sys/time.h>
#endif
EX_BOOL ex_initialize(const char* lc_ctype);
void ex_free(void* buffer);
// 在haystack长度为haystacklen字节中查找needle长度为needlelen的起始地址返回NULL表示没有找到
const ex_u8* ex_memmem(const ex_u8* haystack, size_t haystacklen, const ex_u8* needle, size_t needlelen);
void ex_mem_reverse(ex_u8* p, size_t l);
void ex_printf(const char* fmt, ...);
void ex_wprintf(const wchar_t* fmt, ...);
ex_u64 ex_get_tick_count(void);
void ex_sleep_ms(int ms);
EX_BOOL ex_localtime_now(int* t, struct tm* dt);
FILE* ex_fopen(const ex_wstr& filename, const wchar_t* mode);
EX_DYLIB_HANDLE ex_dlopen(const wchar_t* dylib_path);
void ex_dlclose(EX_DYLIB_HANDLE dylib);
// inet...
int ex_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
#endif // __LIB_EX_UTIL_H__

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

@ -31,6 +31,12 @@ void EXLOG_LEVEL(int min_level)
g_exlog->min_level = min_level;
}
void EXLOG_DEBUG(bool debug_mode)
{
if (NULL != g_exlog)
g_exlog->debug_mode = debug_mode;
}
void EXLOG_CONSOLE(bool output_to_console)
{
if(NULL != g_exlog)

File diff suppressed because it is too large Load Diff

View File

@ -1,251 +1,264 @@
#include <ex/ex_platform.h>
#include <ex/ex_util.h>
#include <ex/ex_str.h>
#include <ex/ex_log.h>
EX_BOOL ex_initialize(const char* lc_ctype)
{
#ifdef EX_OS_UNIX
const char* _lc_default = "en_US.UTF-8";
const char* _lc_ctype = NULL;
char* _loc = NULL;
if(NULL == lc_ctype)
_lc_ctype = _lc_default;
else
_lc_ctype = lc_ctype;
_loc = setlocale(LC_CTYPE, _lc_ctype);
if(NULL == _loc)
return EX_FALSE;
// if(0 != strcmp(_loc, _lc_ctype))
// return EX_FALSE;
return EX_TRUE;
#else
return EX_TRUE;
#endif
}
void ex_free(void* buffer)
{
if (NULL == buffer)
return;
free(buffer);
}
const ex_u8* ex_memmem(const ex_u8* haystack, size_t haystacklen, const ex_u8* needle, size_t needlelen)
{
const ex_u8* cursor = NULL;
const ex_u8* last_possible_needle_location = haystack + haystacklen - needlelen;
/** Easy answers */
if (needlelen > haystacklen) return(NULL);
if (needle == NULL) return(NULL);
if (haystack == NULL) return(NULL);
if (needlelen == 0) return(NULL);
if (haystacklen == 0) return(NULL);
for (cursor = haystack; cursor <= last_possible_needle_location; cursor++)
{
if (memcmp(needle, cursor, needlelen) == 0)
return cursor;
}
return(NULL);
}
void ex_printf(const char* fmt, ...)
{
if (NULL == fmt || 0 == strlen(fmt))
return;
va_list valist;
va_start(valist, fmt);
//_ts_printf_a(TS_COLOR_GRAY, TS_COLOR_BLACK, fmt, valist);
char _tmp[4096] = { 0 };
#ifdef EX_OS_WIN32
vsnprintf_s(_tmp, 4096, 4095, fmt, valist);
printf_s("%s", _tmp);
fflush(stdout);
#else
vsnprintf(_tmp, 4095, fmt, valist);
printf("%s", _tmp);
fflush(stdout);
#endif
va_end(valist);
}
void ex_wprintf(const wchar_t* fmt, ...)
{
if (NULL == fmt || 0 == wcslen(fmt))
return;
va_list valist;
va_start(valist, fmt);
wchar_t _tmp[4096] = { 0 };
#ifdef EX_OS_WIN32
_vsnwprintf_s(_tmp, 4096, 4095, fmt, valist);
wprintf_s(L"%s", _tmp);
fflush(stdout);
#else
vswprintf(_tmp, 4095, fmt, valist);
ex_astr _astr_tmp;
ex_wstr2astr(_tmp, _astr_tmp);
printf("%s", _astr_tmp.c_str());
fflush(stdout);
#endif
va_end(valist);
}
ex_u64 ex_get_tick_count(void)
{
#ifdef EX_OS_WIN32
# if (_WIN32_WINNT >= 0x0600)
return GetTickCount64();
# else
LARGE_INTEGER TicksPerSecond = { 0 };
LARGE_INTEGER Tick;
if (!TicksPerSecond.QuadPart)
QueryPerformanceFrequency(&TicksPerSecond);
QueryPerformanceCounter(&Tick);
ex_u64 Seconds = Tick.QuadPart / TicksPerSecond.QuadPart;
ex_u64 LeftPart = Tick.QuadPart - (TicksPerSecond.QuadPart*Seconds);
ex_u64 MillSeconds = LeftPart * 1000 / TicksPerSecond.QuadPart;
ex_u64 Ret = Seconds * 1000 + MillSeconds;
return Ret;
# endif
#else
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ((ex_u64)ts.tv_sec * 1000 + (ex_u64)ts.tv_nsec / 1000000);
#endif
}
void ex_sleep_ms(int ms)
{
#ifdef EX_OS_WIN32
Sleep(ms);
#else
usleep(ms * 1000);
#endif
}
EX_BOOL ex_localtime_now(int* t, struct tm* dt)
{
// if (NULL == dt)
// return EX_FALSE;
//struct tm *_tmp;
#ifdef EX_OS_WIN32
struct tm _tmp;
__time32_t timep;
_time32(&timep);
if (0 != _localtime32_s(&_tmp, &timep))
return EX_FALSE;
if(NULL != dt)
memcpy(dt, &_tmp, sizeof(struct tm));
#else
struct tm *_tmp;
time_t timep;
time(&timep);
_tmp = localtime(&timep); //get server's time
if (_tmp == NULL)
return NULL;
if(NULL != dt)
memcpy(dt, _tmp, sizeof(struct tm));
#endif
if (NULL != t)
*t = (int)timep;
return EX_TRUE;
}
FILE* ex_fopen(const ex_wstr& filename, const wchar_t* mode)
{
FILE* f = NULL;
#ifdef EX_OS_WIN32
errno_t err = 0;
err = _wfopen_s(&f, filename.c_str(), mode);
if (0 == err)
return f;
else
return NULL;
#else
ex_astr _fname;
ex_wstr2astr(filename, _fname);
ex_astr _mode;
ex_wstr2astr(mode, _mode);
f = fopen(_fname.c_str(), _mode.c_str());
return f;
#endif
}
EX_DYLIB_HANDLE ex_dlopen(const wchar_t* dylib_path)
{
EX_DYLIB_HANDLE handle = NULL;
#ifdef EX_OS_WIN32
handle = LoadLibraryExW(dylib_path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (NULL == handle)
{
EXLOGE_WIN(L"LoadLibraryEx('%ls') failed.\n", dylib_path);
return NULL;
}
#else
ex_astr path;
if (!ex_wstr2astr(dylib_path, path, EX_CODEPAGE_UTF8))
{
EXLOGE("convert dylib_path failed.\n");
return NULL;
}
handle = dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (NULL == handle)
{
EXLOGE("dlopen() failed: %s.\n", dlerror());
return NULL;
}
#endif
return handle;
}
void ex_dlclose(EX_DYLIB_HANDLE dylib)
{
#ifdef EX_OS_WIN32
FreeLibrary(dylib);
#else
dlclose(dylib);
#endif
}
static int _inet_ntop4(const unsigned char *src, char *dst, size_t size) {
static const char fmt[] = "%u.%u.%u.%u";
char tmp[32];
int l;
l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
if (l <= 0 || (size_t)l >= size) {
return -1;
}
ex_strcpy(dst, size, tmp);
dst[size - 1] = '\0';
return 0;
}
int ex_ip4_name(const struct sockaddr_in* src, char* dst, size_t size)
{
return _inet_ntop4((const unsigned char*)&(src->sin_addr), dst, size);
}
#include <ex/ex_platform.h>
#include <ex/ex_util.h>
#include <ex/ex_str.h>
#include <ex/ex_log.h>
EX_BOOL ex_initialize(const char* lc_ctype)
{
#ifdef EX_OS_UNIX
const char* _lc_default = "en_US.UTF-8";
const char* _lc_ctype = NULL;
char* _loc = NULL;
if(NULL == lc_ctype)
_lc_ctype = _lc_default;
else
_lc_ctype = lc_ctype;
_loc = setlocale(LC_CTYPE, _lc_ctype);
if(NULL == _loc)
return EX_FALSE;
// if(0 != strcmp(_loc, _lc_ctype))
// return EX_FALSE;
return EX_TRUE;
#else
return EX_TRUE;
#endif
}
void ex_free(void* buffer)
{
if (NULL == buffer)
return;
free(buffer);
}
const ex_u8* ex_memmem(const ex_u8* haystack, size_t haystacklen, const ex_u8* needle, size_t needlelen)
{
const ex_u8* cursor = NULL;
const ex_u8* last_possible_needle_location = haystack + haystacklen - needlelen;
/** Easy answers */
if (needlelen > haystacklen) return(NULL);
if (needle == NULL) return(NULL);
if (haystack == NULL) return(NULL);
if (needlelen == 0) return(NULL);
if (haystacklen == 0) return(NULL);
for (cursor = haystack; cursor <= last_possible_needle_location; cursor++)
{
if (memcmp(needle, cursor, needlelen) == 0)
return cursor;
}
return(NULL);
}
void ex_mem_reverse(ex_u8* p, size_t l)
{
ex_u8 temp = 0;
size_t i = 0, j = 0;
for (i = 0, j = l - 1; i < j; i++, j--)
{
temp = p[i];
p[i] = p[j];
p[j] = temp;
}
}
void ex_printf(const char* fmt, ...)
{
if (NULL == fmt || 0 == strlen(fmt))
return;
va_list valist;
va_start(valist, fmt);
//_ts_printf_a(TS_COLOR_GRAY, TS_COLOR_BLACK, fmt, valist);
char _tmp[4096] = { 0 };
#ifdef EX_OS_WIN32
vsnprintf_s(_tmp, 4096, 4095, fmt, valist);
printf_s("%s", _tmp);
fflush(stdout);
#else
vsnprintf(_tmp, 4095, fmt, valist);
printf("%s", _tmp);
fflush(stdout);
#endif
va_end(valist);
}
void ex_wprintf(const wchar_t* fmt, ...)
{
if (NULL == fmt || 0 == wcslen(fmt))
return;
va_list valist;
va_start(valist, fmt);
wchar_t _tmp[4096] = { 0 };
#ifdef EX_OS_WIN32
_vsnwprintf_s(_tmp, 4096, 4095, fmt, valist);
wprintf_s(L"%s", _tmp);
fflush(stdout);
#else
vswprintf(_tmp, 4095, fmt, valist);
ex_astr _astr_tmp;
ex_wstr2astr(_tmp, _astr_tmp);
printf("%s", _astr_tmp.c_str());
fflush(stdout);
#endif
va_end(valist);
}
ex_u64 ex_get_tick_count(void)
{
#ifdef EX_OS_WIN32
# if (_WIN32_WINNT >= 0x0600)
return GetTickCount64();
# else
LARGE_INTEGER TicksPerSecond = { 0 };
LARGE_INTEGER Tick;
if (!TicksPerSecond.QuadPart)
QueryPerformanceFrequency(&TicksPerSecond);
QueryPerformanceCounter(&Tick);
ex_u64 Seconds = Tick.QuadPart / TicksPerSecond.QuadPart;
ex_u64 LeftPart = Tick.QuadPart - (TicksPerSecond.QuadPart*Seconds);
ex_u64 MillSeconds = LeftPart * 1000 / TicksPerSecond.QuadPart;
ex_u64 Ret = Seconds * 1000 + MillSeconds;
return Ret;
# endif
#else
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ((ex_u64)ts.tv_sec * 1000 + (ex_u64)ts.tv_nsec / 1000000);
#endif
}
void ex_sleep_ms(int ms)
{
#ifdef EX_OS_WIN32
Sleep(ms);
#else
usleep(ms * 1000);
#endif
}
EX_BOOL ex_localtime_now(int* t, struct tm* dt)
{
// if (NULL == dt)
// return EX_FALSE;
//struct tm *_tmp;
#ifdef EX_OS_WIN32
struct tm _tmp;
__time32_t timep;
_time32(&timep);
if (0 != _localtime32_s(&_tmp, &timep))
return EX_FALSE;
if(NULL != dt)
memcpy(dt, &_tmp, sizeof(struct tm));
#else
struct tm *_tmp;
time_t timep;
time(&timep);
_tmp = localtime(&timep); //get server's time
if (_tmp == NULL)
return NULL;
if(NULL != dt)
memcpy(dt, _tmp, sizeof(struct tm));
#endif
if (NULL != t)
*t = (int)timep;
return EX_TRUE;
}
FILE* ex_fopen(const ex_wstr& filename, const wchar_t* mode)
{
FILE* f = NULL;
#ifdef EX_OS_WIN32
errno_t err = 0;
err = _wfopen_s(&f, filename.c_str(), mode);
if (0 == err)
return f;
else
return NULL;
#else
ex_astr _fname;
ex_wstr2astr(filename, _fname);
ex_astr _mode;
ex_wstr2astr(mode, _mode);
f = fopen(_fname.c_str(), _mode.c_str());
return f;
#endif
}
EX_DYLIB_HANDLE ex_dlopen(const wchar_t* dylib_path)
{
EX_DYLIB_HANDLE handle = NULL;
#ifdef EX_OS_WIN32
handle = LoadLibraryExW(dylib_path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (NULL == handle)
{
EXLOGE_WIN(L"LoadLibraryEx('%ls') failed.\n", dylib_path);
return NULL;
}
#else
ex_astr path;
if (!ex_wstr2astr(dylib_path, path, EX_CODEPAGE_UTF8))
{
EXLOGE("convert dylib_path failed.\n");
return NULL;
}
handle = dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (NULL == handle)
{
EXLOGE("dlopen() failed: %s.\n", dlerror());
return NULL;
}
#endif
return handle;
}
void ex_dlclose(EX_DYLIB_HANDLE dylib)
{
#ifdef EX_OS_WIN32
FreeLibrary(dylib);
#else
dlclose(dylib);
#endif
}
static int _inet_ntop4(const unsigned char *src, char *dst, size_t size) {
static const char fmt[] = "%u.%u.%u.%u";
char tmp[32];
int l;
l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
if (l <= 0 || (size_t)l >= size) {
return -1;
}
ex_strcpy(dst, size, tmp);
dst[size - 1] = '\0';
return 0;
}
int ex_ip4_name(const struct sockaddr_in* src, char* dst, size_t size)
{
return _inet_ntop4((const unsigned char*)&(src->sin_addr), dst, size);
}

View File

@ -27,22 +27,22 @@
#define TPE_UNKNOWN_CMD 124 // 未知的命令
#define TPE_JSON_FORMAT 125 // 错误的JSON格式需要JSON格式数据但是却无法按JSON格式解码
#define TPE_PARAM 126 // 参数错误
#define TPE_DATA 127 // 数据错误
#define TPE_PARAM 126 // 参数错误
#define TPE_DATA 127 // 数据错误
// #define TPE_OPENFILE_ERROR 0x1007 // 无法打开文件
// #define TPE_GETTEMPPATH_ERROR 0x1007
#define TPE_OPENFILE 300
//-------------------------------------------------------
// 助手程序专用错误值
//-------------------------------------------------------
#define TPE_NO_ASSIST 100000 // 未能检测到助手程序
#define TPE_NO_ASSIST 100000 // 未能检测到助手程序
#define TPE_OLD_ASSIST 100001 // 助手程序版本太低
#define TPE_START_CLIENT 100002 // 无法启动客户端程序(无法创建进程)
#define TPE_START_CLIENT 100002 // 无法启动客户端程序(无法创建进程)

View File

@ -33,7 +33,7 @@ cmake = /opt/cmake/bin/cmake
[external_ver]
openssl = 1.0.2h,1000208f
libuv = 1.9.1
libuv = 1.11.0
mbedtls = 2.3.0
sqlite = 3170000
libssh = 0.7.4

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,16 @@
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* RSA was designed by Ron Rivest, Adi Shamir and Len Adleman.
* The following sources were referenced in the design of this implementation
* of the RSA algorithm:
*
* [1] A method for obtaining digital signatures and public-key cryptosystems
* R Rivest, A Shamir, and L Adleman
* http://people.csail.mit.edu/rivest/pubs.html#RSA78
*
* [2] Handbook of Applied Cryptography - 1997, Chapter 8
* Menezes, van Oorschot and Vanstone
*
* http://theory.lcs.mit.edu/~rivest/rsapaper.pdf
* http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf
*/
#if !defined(MBEDTLS_CONFIG_FILE)
@ -96,7 +102,8 @@ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
if( f_rng == NULL || nbits < 128 || exponent < 3 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 );
mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
/*
* find primes P and Q with Q < P so that:
@ -106,14 +113,19 @@ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
do
{
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, ( nbits + 1 ) >> 1, 0,
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, nbits >> 1, 0,
f_rng, p_rng ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, ( nbits + 1 ) >> 1, 0,
if( nbits % 2 )
{
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, ( nbits >> 1 ) + 1, 0,
f_rng, p_rng ) );
if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 )
mbedtls_mpi_swap( &ctx->P, &ctx->Q );
}
else
{
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, nbits >> 1, 0,
f_rng, p_rng ) );
}
if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 )
continue;
@ -366,7 +378,7 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
#else
if (ctx->N.p == NULL || ctx->P.p == NULL || ctx->Q.p == NULL || ctx->D.p == NULL)
#endif
//if (ctx->P.p == NULL || ctx->Q.p == NULL || ctx->D.p == NULL)
/*if (ctx->P.p == NULL || ctx->Q.p == NULL || ctx->D.p == NULL)*/
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
mbedtls_mpi_init( &T ); mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 );
@ -471,8 +483,7 @@ static void mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src,
hlen = mbedtls_md_get_size( md_ctx->md_info );
// Generate and apply dbMask
//
/* Generate and apply dbMask */
p = dst;
while( dlen > 0 )
@ -529,22 +540,21 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
olen = ctx->len;
hlen = mbedtls_md_get_size( md_info );
if( olen < ilen + 2 * hlen + 2 )
/* first comparison checks for overflow */
if( ilen + 2 * hlen + 2 < ilen || olen < ilen + 2 * hlen + 2 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
memset( output, 0, olen );
*p++ = 0;
// Generate a random octet string seed
//
/* Generate a random octet string seed */
if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 )
return( MBEDTLS_ERR_RSA_RNG_FAILED + ret );
p += hlen;
// Construct DB
//
/* Construct DB */
mbedtls_md( md_info, label, label_len, p );
p += hlen;
p += olen - 2 * hlen - 2 - ilen;
@ -552,15 +562,17 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
memcpy( p, input, ilen );
mbedtls_md_init( &md_ctx );
mbedtls_md_setup( &md_ctx, md_info, 0 );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
{
mbedtls_md_free( &md_ctx );
return( ret );
}
// maskedDB: Apply dbMask to DB
//
/* maskedDB: Apply dbMask to DB */
mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen,
&md_ctx );
// maskedSeed: Apply seedMask to seed
//
/* maskedSeed: Apply seedMask to seed */
mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1,
&md_ctx );
@ -590,12 +602,14 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
if( f_rng == NULL )
// We don't check p_rng because it won't be dereferenced here
if( f_rng == NULL || input == NULL || output == NULL )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
olen = ctx->len;
if( olen < ilen + 11 )
/* first comparison checks for overflow */
if( ilen + 11 < ilen || olen < ilen + 11 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
nb_pad = olen - 3 - ilen;
@ -613,8 +627,7 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
ret = f_rng( p_rng, p, 1 );
} while( *p == 0 && --rng_dl && ret == 0 );
// Check if RNG failed to generate data
//
/* Check if RNG failed to generate data */
if( rng_dl == 0 || ret != 0 )
return( MBEDTLS_ERR_RSA_RNG_FAILED + ret );
@ -705,6 +718,12 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
if( md_info == NULL )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
hlen = mbedtls_md_get_size( md_info );
// checking for integer underflow
if( 2 * hlen + 2 > ilen )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
/*
* RSA operation
*/
@ -718,10 +737,13 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
/*
* Unmask data and generate lHash
*/
hlen = mbedtls_md_get_size( md_info );
mbedtls_md_init( &md_ctx );
mbedtls_md_setup( &md_ctx, md_info, 0 );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
{
mbedtls_md_free( &md_ctx );
return( ret );
}
/* Generate lHash */
mbedtls_md( md_info, label, label_len, lhash );
@ -854,6 +876,8 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
bad |= *p++; /* Must be zero */
}
bad |= ( pad_count < 8 );
if( bad )
return( MBEDTLS_ERR_RSA_INVALID_PADDING );
@ -930,8 +954,7 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
if( md_alg != MBEDTLS_MD_NONE )
{
// Gather length of hash to sign
//
/* Gather length of hash to sign */
md_info = mbedtls_md_info_from_type( md_alg );
if( md_info == NULL )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
@ -951,13 +974,11 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
memset( sig, 0, olen );
// Generate salt of length slen
//
/* Generate salt of length slen */
if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 )
return( MBEDTLS_ERR_RSA_RNG_FAILED + ret );
// Note: EMSA-PSS encoding is over the length of N - 1 bits
//
/* Note: EMSA-PSS encoding is over the length of N - 1 bits */
msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
p += olen - hlen * 2 - 2;
*p++ = 0x01;
@ -965,23 +986,24 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
p += slen;
mbedtls_md_init( &md_ctx );
mbedtls_md_setup( &md_ctx, md_info, 0 );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
{
mbedtls_md_free( &md_ctx );
return( ret );
}
// Generate H = Hash( M' )
//
/* Generate H = Hash( M' ) */
mbedtls_md_starts( &md_ctx );
mbedtls_md_update( &md_ctx, p, 8 );
mbedtls_md_update( &md_ctx, hash, hashlen );
mbedtls_md_update( &md_ctx, salt, slen );
mbedtls_md_finish( &md_ctx, p );
// Compensate for boundary condition when applying mask
//
/* Compensate for boundary condition when applying mask */
if( msb % 8 == 0 )
offset = 1;
// maskedDB: Apply dbMask to DB
//
/* maskedDB: Apply dbMask to DB */
mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen, &md_ctx );
mbedtls_md_free( &md_ctx );
@ -1175,13 +1197,13 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
int ret;
size_t siglen;
unsigned char *p;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
unsigned char result[MBEDTLS_MD_MAX_SIZE];
unsigned char zeros[8];
unsigned int hlen;
size_t slen, msb;
const mbedtls_md_info_t *md_info;
mbedtls_md_context_t md_ctx;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
@ -1205,8 +1227,7 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
if( md_alg != MBEDTLS_MD_NONE )
{
// Gather length of hash to sign
//
/* Gather length of hash to sign */
md_info = mbedtls_md_info_from_type( md_alg );
if( md_info == NULL )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
@ -1223,12 +1244,12 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
memset( zeros, 0, 8 );
// Note: EMSA-PSS verification is over the length of N - 1 bits
//
/*
* Note: EMSA-PSS verification is over the length of N - 1 bits
*/
msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
// Compensate for boundary condition when applying mask
//
/* Compensate for boundary condition when applying mask */
if( msb % 8 == 0 )
{
p++;
@ -1238,7 +1259,11 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
mbedtls_md_init( &md_ctx );
mbedtls_md_setup( &md_ctx, md_info, 0 );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
{
mbedtls_md_free( &md_ctx );
return( ret );
}
mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx );
@ -1264,8 +1289,9 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
return( MBEDTLS_ERR_RSA_INVALID_PADDING );
}
// Generate H = Hash( M' )
//
/*
* Generate H = Hash( M' )
*/
mbedtls_md_starts( &md_ctx );
mbedtls_md_update( &md_ctx, zeros, 8 );
mbedtls_md_update( &md_ctx, hash, hashlen );
@ -1320,10 +1346,10 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
int ret;
size_t len, siglen, asn1_len;
unsigned char *p, *end;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
mbedtls_md_type_t msg_md_alg;
const mbedtls_md_info_t *md_info;
mbedtls_asn1_buf oid;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
@ -1370,8 +1396,9 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
end = p + len;
// Parse the ASN.1 structure inside the PKCS#1 v1.5 structure
//
/*
* Parse the ASN.1 structure inside the PKCS#1 v1.5 structure
*/
if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len,
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
@ -1666,7 +1693,7 @@ int mbedtls_rsa_self_test( int verbose )
#if defined(MBEDTLS_SHA1_C)
if( verbose != 0 )
mbedtls_printf( "PKCS#1 data sign : " );
mbedtls_printf( " PKCS#1 data sign : " );
mbedtls_sha1( rsa_plaintext, PT_LEN, sha1sum );

8
external/readme.md vendored
View File

@ -31,5 +31,13 @@ teleport项目用到的第三方库
https://git.libssh.org/projects/libssh.git/snapshot
libssh-0.7.4.zip
Windows平台使用预制的libssh-static工程进行编译。
- libuv
https://github.com/libuv/libuv
v1.11.0.zip
注意teleport项目使用源代码直接编译因此解压缩源代码到此即可。

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

@ -10,3 +10,5 @@ cmake_minimum_required(VERSION 3.5)
add_subdirectory(tp_web/src)
add_subdirectory(tp_core/core)
add_subdirectory(tp_core/protocol/ssh)
add_subdirectory(tp_core/protocol/rdp)

View File

@ -13,6 +13,8 @@
# LOG_LEVEL_ERROR 4 log error message only.
log-level=2
debug=0
; 'replay-path' define the replay file location. if not set, default location
; to $INSTDIR%/data/replay/
;replay-path=/var/lib/teleport/data/replay
@ -32,14 +34,14 @@ bind-ip=0.0.0.0
bind-port=52189
[protocol-rdp]
enabled=false
lib=rdp
enabled=true
lib=tprdp
bind-ip=0.0.0.0
bind-port=52089
[protocol-telnet]
enabled=false
lib=telnet
lib=tptelnet
bind-ip=0.0.0.0
bind-port=52389

View File

@ -21,10 +21,11 @@ bool TppEnvBase::init(TPP_INIT_ARGS* args)
replay_path = args->replay_path;
take_session = args->func_take_session;
free_session = args->func_free_session;
session_begin = args->func_session_begin;
session_end = args->func_session_end;
if (NULL == take_session || NULL == session_begin || NULL == session_end)
if (NULL == take_session || NULL == free_session || NULL == session_begin || NULL == session_end)
{
EXLOGE("invalid init args(2).\n");
return false;
@ -36,19 +37,6 @@ bool TppEnvBase::init(TPP_INIT_ARGS* args)
return false;
}
// ExIniSection* ps = args->cfg->GetSection(L"common");
// if (NULL == ps)
// {
// EXLOGE("invalid config(1).\n");
// return false;
// }
//
// if (!ps->GetStr(L"replay-path", replay_path))
// {
// replay_path = exec_path;
// ex_path_join(replay_path, true, L"..", L"data", L"replay", NULL);
// }
if (!_on_init(args))
{
EXLOGE("invalid init args(4).\n");

View File

@ -17,6 +17,7 @@ public:
ex_wstr replay_path;
TPP_TAKE_SESSION_FUNC take_session;
TPP_FREE_SESSION_FUNC free_session;
TPP_SESSION_BEGIN_FUNC session_begin;
TPP_SESSION_END_FUNC session_end;

View File

@ -5,238 +5,6 @@
#include "base_record.h"
#if 0
base_record::base_record()
{
//g_env.m_record_ssh_path
m_buf = new unsigned char[MAX_SIZE_PER_FILE];
memset(m_buf, 0, MAX_SIZE_PER_FILE);
m_buf_offset = 0;
m_begin_time = 0;
m_last_time = 0;
m_file_current_index = 0;
m_current_file = 0;
m_totol_size = 0;
}
base_record::~base_record()
{
if (NULL != m_buf)
{
delete[] m_buf;
m_buf = NULL;
}
}
void base_record::begin(int record_id, int record_type)
{
char szPath[1024] = { 0 };
ex_astr ssh_path;
m_begin_time = ex_get_tick_count();
m_last_time = m_begin_time;
m_file_current_index = 0;
m_current_file = 0;
if (record_type == 2)
{
//ex_mkdirs()
#ifdef EX_OS_WIN32
ts_str2astr(g_env.m_record_ssh_path, ssh_path);
sprintf_s(szPath, "%s\\%d\\", ssh_path.c_str(), record_id);
int ret = _mkdir(szPath);
#else
ssh_path = g_env.m_record_ssh_path;
snprintf(szPath, 1024, "%s/%d", ssh_path.c_str(), record_id);
EXLOGV("try to create folder for record: [%s]\n", szPath);
int status = mkdir(szPath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
EXLOGV("create folder for record return %d, errno=%d.\n", status, errno);
#endif
m_current_path = szPath;
open_next_file();
}
}
void base_record::end()
{
ex_u64 current_time = ex_get_tick_count();
ex_u64 internal_time = m_last_time - m_begin_time;
save_buffer_to_file(int(internal_time));
if (m_buf)
{
delete[] m_buf;
m_buf = NULL;
}
if (m_current_file)
{
fclose(m_current_file);
}
ts_replay_header header = {0};
ex_strcpy(header.ID, 16, "teleport");
ex_strcpy(header.version, 16, "1.0.0.1");
header.total_time = (ex_u32)internal_time;
header.total_file_count = (ex_u8)m_file_current_index;
header.total_size = (ex_u8)m_totol_size;
int ts_replay_header_len = sizeof(ts_replay_header);
char szPath[1024] = { 0 };
#ifdef EX_OS_WIN32
sprintf_s(szPath, "%s\\head.init", m_current_path.c_str());
#else
snprintf(szPath, 1024, "%s/head.init", m_current_path.c_str());
#endif
FILE* f = NULL;
if ((f = fopen(szPath, "wb")) == NULL) /* open file TEST.$$$ */
{
return;
}
int ret = fwrite(&header, sizeof(ts_replay_header), 1, f);
ret = fwrite(&m_timelist[0], m_timelist.size() * sizeof(int), 1, f);
fclose(f);
char szTermPath[1024] = { 0 };
#ifdef EX_OS_WIN32
sprintf_s(szTermPath, "%s\\term.init", m_current_path.c_str());
#else
snprintf(szTermPath, 1024, "%s/term.init", m_current_path.c_str());
#endif
if ((f = fopen(szTermPath, "wb")) == NULL)
{
return;
}
ssh_terms_data_header terms_header = { 0 };
ex_strcpy(terms_header.ID, 16,"teleport");
ex_strcpy(terms_header.version, 16,"1.0.0.1");
terms_header.term_count = (ex_u32)m_windows_size_list.size();
ret = fwrite(&terms_header,sizeof(ssh_terms_data_header), 1, f);
if (m_windows_size_list.size() > 0)
{
ret = fwrite(&m_windows_size_list[0], m_windows_size_list.size() * sizeof(ssh_terms_data), 1, f);
}
fclose(f);
}
void base_record::windows_size(ssh_terms_data size_info)
{
ex_u64 internal_time = ex_get_tick_count() - m_begin_time;
size_info.time = (ex_u32)internal_time;
m_windows_size_list.push_back(size_info);
}
void base_record::record(unsigned char* buf, int len, int cmd)
{
ex_u64 current_time = ex_get_tick_count();
ex_u64 internal_time = current_time - m_begin_time;
m_last_time = current_time;
//bool bSwitchFile = false;
//bool bWriteFile = false;
ts_replay_data_header replay_header = {0};
replay_header.action = (ex_u8)cmd;
replay_header.time = (ex_u32)internal_time;
replay_header.size = (ex_u32)len;
//int header_len = sizeof(ts_replay_data_header);
bool bRet = cached_buffer(&replay_header, buf, len);
if (!bRet)
{
//缓存已满,把缓存存文件,并且清空缓存
save_buffer_to_file(int(internal_time));
//打开下个文件
open_next_file();
bRet = cached_buffer(&replay_header, buf, len);
if (!bRet)
{
//如果还是太大,不能缓存,直接存文件
save_to_file(ex_u32(internal_time), &replay_header, buf, len);
open_next_file();
}
}
}
bool base_record::cached_buffer(ts_replay_data_header* header, unsigned char* buf, int len)
{
size_t header_len = sizeof(ts_replay_data_header);
if ((m_buf_offset + len + header_len) > MAX_SIZE_PER_FILE)
{
return false;
}
//长度够长直接存缓存
memcpy(m_buf + m_buf_offset, header, header_len);
m_buf_offset += header_len;
memcpy(m_buf + m_buf_offset, buf, len);
m_buf_offset += len;
return true;
}
bool base_record::open_next_file()
{
char szPath[1024] = { 0 };
#ifdef EX_OS_WIN32
sprintf_s(szPath, "%s\\%d.ts", m_current_path.c_str(), m_file_current_index);
#else
snprintf(szPath, 1024, "%s/%d.ts", m_current_path.c_str(), m_file_current_index);
#endif
if (NULL != m_current_file)
{
fclose(m_current_file);
}
if ((m_current_file = fopen(szPath, "wb")) == NULL) /* open file TEST.$$$ */
{
return false;
}
m_file_current_index++;
return true;
}
bool base_record::save_buffer_to_file(int internal_time)
{
if(NULL == m_current_file)
return false;
int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* 写的struct文件*/
m_totol_size += m_buf_offset;
m_buf_offset = 0;
m_timelist.push_back(ex_u32(internal_time));
return true;
}
bool base_record::save_to_file(int internal_time,ts_replay_data_header* header, unsigned char* buf, int len)
{
if(NULL == m_current_file)
return false;
int ret = fwrite(header, sizeof(ts_replay_data_header), 1, m_current_file);
ret = fwrite(buf, len, 1, m_current_file);
m_totol_size += sizeof(ts_replay_data_header);
m_totol_size += len;
m_timelist.push_back(ex_u32(internal_time));
return true;
}
#endif
//====================================================
// NEW INTERFACE
//====================================================
TppRecBase::TppRecBase()
{
m_cache.reserve(MAX_SIZE_PER_FILE);
@ -248,7 +16,7 @@ TppRecBase::~TppRecBase()
{
}
void TppRecBase::begin(const wchar_t* base_path, const wchar_t* base_fname, int record_id, const TS_SESSION_INFO& info)
void TppRecBase::begin(const wchar_t* base_path, const wchar_t* base_fname, int record_id, const TPP_SESSION_INFO* info)
{
m_start_time = ex_get_tick_count();

View File

@ -8,133 +8,43 @@
#include <ex.h>
#define MAX_SIZE_PER_FILE 4194304 // 4M = 1024*1024*4
//#define MAX_SIZE_PER_FILE 40*1024
// #define SSH_DATA 1
// #define SSH_WINDOWS_SIZE 2
#if 0
#pragma pack(push,1)
struct ts_replay_data_header
// 录像文件头
typedef struct TS_RECORD_HEADER
{
ex_u8 action;
ex_u32 time;
ex_u32 size;
//char* buf;
};
struct ts_replay_header
ex_u32 magic; // "TPPR" 标志 TelePort Protocol Record
ex_u16 ver; // 录像文件版本目前为2
ex_u16 protocol; // 协议1=RDP, 2=SSH, 3=Telnet
ex_u64 timestamp; // 本次录像的起始时间UTC时间戳
ex_u32 packages; // 总包数
ex_u32 time_ms; // 总耗时(毫秒)
ex_u16 width; // 初始屏幕尺寸:宽
ex_u16 height; // 初始屏幕尺寸:高
ex_u16 file_count; // 数据文件总数
ex_u32 file_size; // 所有数据文件的总大小不包括每个数据文件的头即4字节的每文件大小
char account[16]; // teleport账号
char username[16]; // 远程主机用户名
char ip[18];
ex_u16 port;
// RDP专有
ex_u8 rdp_security; // 0 = RDP, 1 = TLS
ex_u8 reserve[128 - 4 - 2 - 2 - 8 - 4 - 4 - 2 - 2 - 2 - 4 - 16 - 16 - 18 - 2 - 1]; // 保留
}TS_RECORD_HEADER;
// 一个数据包的头
typedef struct TS_RECORD_PKG
{
char ID[16];
char version[16];
ex_u8 total_size;
ex_u8 total_file_count;
ex_u32 total_time;
//数组,每个数组元素的内容是每个文件的播放时长
};
struct ssh_terms_data_header
{
char ID[16];
char version[16];
ex_u32 term_count;
//数组,每个数组元素的内容是每个文件的播放时长
};
struct ssh_terms_data {
//char term[16];
ex_u32 time;
ex_u32 w;
ex_u32 h;
//ex_u32 px;
//ex_u32 py;
};
ex_u8 type; // 包的数据类型
ex_u32 size; // 这个包的总大小(不含包头)
ex_u32 time_ms; // 这个包距起始时间的时间差毫秒意味着一个连接不能持续超过49天
ex_u8 reserve[3]; // 保留
}TS_RECORD_PKG;
#pragma pack(pop)
typedef std::vector<ex_u32> file_time_list;
typedef std::vector<ssh_terms_data> windows_size_list;
class base_record
{
public:
base_record();
~base_record();
public:
void begin(int record_id, int record_type);
void record(unsigned char* buf, int len, int cmd);
void windows_size(ssh_terms_data size_info);
void end();
ex_astr get_replay_path() {
return m_current_path;
}
protected:
bool open_next_file();
bool cached_buffer(ts_replay_data_header* header, unsigned char* buf,int len);
bool save_buffer_to_file(int internal_time);
bool save_to_file(int internal_time, ts_replay_data_header* header, unsigned char* buf, int len);
protected:
ex_u64 m_begin_time;
ex_u64 m_last_time;
int m_file_current_index;
ex_astr m_current_path;
FILE* m_current_file;
unsigned char* m_buf;
int m_buf_offset;
file_time_list m_timelist;
windows_size_list m_windows_size_list;
int m_totol_size;
//Json::Value m_ts_replay;
};
#endif
//====================================================
// NEW INTERFACE
//====================================================
// #define TS_RECORD_TYPE_RDP_CURSOR_POS 0x10 // 鼠标坐标位置改变,用于绘制虚拟鼠标
// #define TS_RECORD_TYPE_RDP_SERVER_PKG 0x11 // 服务端返回的数据包,用于展示
// #pragma pack(push,1)
//
// // 录像文件头
// typedef struct TS_RECORD_HEADER
// {
// ex_u32 magic; // "TPPR" 标志 TelePort Protocol Record
// ex_u32 timestamp; // 本次录像的起始时间UTC时间戳
// ex_u32 packages; // 总包数
// ex_u32 time_ms; // 总耗时(毫秒)
// ex_u16 width; // 初始屏幕尺寸:宽
// ex_u16 height; // 初始屏幕尺寸:高
// ex_u8 security; // 0 = RDP, 1 = SSL
// ex_u16 file_count; // 数据文件总数
// ex_u32 file_size; // 所有数据文件的总大小不包括每个数据文件的头即4字节的每文件大小
// char account[16]; // teleport账号
// char username[16]; // 远程主机用户名
// char ip[18];
// ex_u16 port;
//
// ex_u8 reserve[128 - 20 - 1 - 2 - 4 - 16 - 16 - 18 - 2]; // 保留
// }TS_RECORD_HEADER;
//
// // 一个数据包的头
// typedef struct TS_RECORD_PKG
// {
// ex_u8 type; // 包的数据类型目前暂时保留未使用必须为0
// ex_u32 size; // 这个包的总大小
// ex_u32 time_ms; // 这个包距起始时间的时间差毫秒意味着一个连接不能持续超过49天
// ex_u8 reserve[3]; // 保留
// }TS_RECORD_PKG;
//
// RDP鼠标移动
// typedef struct TS_RECORD_RDP_MOUSE_POS
// {
// ex_u16 x;
// ex_u16 y;
// }TS_RECORD_RDP_MOUSE_POS;
// #pragma pack(pop)
class TppRecBase
{
@ -142,13 +52,13 @@ public:
TppRecBase();
virtual ~TppRecBase();
void begin(const wchar_t* base_path, const wchar_t* base_fname, int record_id, const TS_SESSION_INFO& info);
void begin(const wchar_t* base_path, const wchar_t* base_fname, int record_id, const TPP_SESSION_INFO* info);
void end(void);
virtual void record(ex_u8 type, const ex_u8* data, size_t size) = 0;
protected:
virtual void _on_begin(const TS_SESSION_INFO& info) = 0;
virtual void _on_begin(const TPP_SESSION_INFO* info) = 0;
virtual void _on_end(void) = 0;
protected:

View File

@ -14,28 +14,26 @@
# define TPP_API
#endif
typedef struct TS_SESSION_INFO
typedef struct TPP_SESSION_INFO
{
ex_astr sid;
ex_astr account_name; // 申请本次连接的用户名
int auth_id;
ex_astr host_ip;
char* sid;
char* account_name; // 申请本次连接的用户名
char* host_ip;
char* user_name;
char* user_auth;
char* user_param;
int host_port;
int protocol;
ex_astr user_name;
ex_astr user_auth;
ex_astr user_param;
int auth_id;
int auth_mode;
int sys_type;
int ref_count; // 这个session可以被take_session()多少次
ex_u64 ticket_start;
}TS_SESSION_INFO;
}TPP_SESSION_INFO;
typedef bool(*TPP_TAKE_SESSION_FUNC)(const ex_astr& sid, TS_SESSION_INFO& info);
typedef bool(*TPP_SESSION_BEGIN_FUNC)(TS_SESSION_INFO& info, int& db_id);
typedef TPP_SESSION_INFO* (*TPP_TAKE_SESSION_FUNC)(const char* sid);
typedef void(*TPP_FREE_SESSION_FUNC)(TPP_SESSION_INFO* info);
typedef bool(*TPP_SESSION_BEGIN_FUNC)(const TPP_SESSION_INFO* info, int* db_id);
typedef bool(*TPP_SESSION_END_FUNC)(int db_id, int ret);
@ -48,6 +46,7 @@ typedef struct TPP_INIT_ARGS
ExIniFile* cfg;
TPP_TAKE_SESSION_FUNC func_take_session;
TPP_FREE_SESSION_FUNC func_free_session;
TPP_SESSION_BEGIN_FUNC func_session_begin;
TPP_SESSION_END_FUNC func_session_end;
}TPP_INIT_ARGS;

View File

@ -1,67 +1,68 @@
#ifndef __TS_ERRNO_H__
#define __TS_ERRNO_H__
//#include "ts_types.h"
// #define TS_RDP_PROXY_PORT 3389
// #define TS_RDP_PROXY_HOST "0.0.0.0"
#define TS_SSH_PROXY_PORT 22
#define TS_SSH_PROXY_HOST "0.0.0.0"
//
// #define TS_TELNET_PROXY_PORT 23
// #define TS_TELNET_PROXY_HOST "0.0.0.0"
#define TS_HTTP_RPC_PORT 52080
//#define TS_HTTP_RPC_HOST "127.0.0.1"
#define TS_HTTP_RPC_HOST "0.0.0.0"
#define TS_RDP_PROTOCOL_RDP 0
#define TS_RDP_PROTOCOL_SSL 1
#define TS_RDP_PROTOCOL_HYBRID 2
#define TS_RDP_PROTOCOL_HYBRID_EX 8
#define TS_AUTH_MODE_NONE 0
#define TS_AUTH_MODE_PASSWORD 1
#define TS_AUTH_MODE_PRIVATE_KEY 2
#define TS_PROXY_PROTOCOL_RDP 1
#define TS_PROXY_PROTOCOL_SSH 2
#define TS_PROXY_PROTOCOL_TELNET 3
//typedef ex_u32 ts_rv;
#define TSR_OK 0x0000
#define TSR_INVALID_DATA 0x0001
#define TSR_SEND_ERROR 0x0002
#define TSR_NEED_MORE_DATA 0x0005
#define TSR_FAILED 0x0006
#define TSR_DATA_LEN_ZERO 0x0007
#define TSR_MAX_CONN_REACHED 0x0010
#define TSR_MAX_HOST_REACHED 0x0011
#define TSR_INVALID_REQUEST 0x1000
#define TSR_INVALID_URI 0x1001
#define TSR_INVALID_URL_ENCODE 0x1002
#define TSR_NO_SUCH_METHOD 0x1003
#define TSR_INVALID_JSON_FORMAT 0x1004
#define TSR_INVALID_JSON_PARAM 0x1005
#define TSR_GETAUTH_INFO_ERROR 0x1006
#define TSR_HOST_LOCK_ERROR 0x1007
#define TSR_ACCOUNT_LOCK_ERROR 0x1008
//================================================
#define SESS_STAT_RUNNING 0 // 会话开始了,尚未结束
#define SESS_STAT_END 9999 // 会话成功结束
#define SESS_STAT_ERR_AUTH_DENIED 1 // 会话结束,因为认证失败
#define SESS_STAT_ERR_CONNECT 2 // 会话结束,因为无法连接到远程主机
#define SESS_STAT_ERR_BAD_SSH_KEY 3 // 会话结束因为无法识别SSH私钥
#define SESS_STAT_ERR_INTERNAL 4 // 会话结束,因为内部错误
#define SESS_STAT_ERR_UNSUPPORT_PROTOCOL 5 // 会话结束,因为协议不支持(RDP)
#define SESS_STAT_ERR_BAD_PKG 6 // 会话结束,因为收到错误的报文
#define SESS_STAT_ERR_RESET 7 // 会话结束因为teleport核心服务重置了
#endif // __TS_ERRNO_H__
#ifndef __TS_ERRNO_H__
#define __TS_ERRNO_H__
//#include "ts_types.h"
#define TS_RDP_PROXY_PORT 3389
#define TS_RDP_PROXY_HOST "0.0.0.0"
#define TS_SSH_PROXY_PORT 22
#define TS_SSH_PROXY_HOST "0.0.0.0"
#define TS_TELNET_PROXY_PORT 23
#define TS_TELNET_PROXY_HOST "0.0.0.0"
#define TS_HTTP_RPC_PORT 52080
#define TS_HTTP_RPC_HOST "127.0.0.1"
//#define TS_HTTP_RPC_HOST "0.0.0.0"
#define TS_RDP_PROTOCOL_RDP 0
#define TS_RDP_PROTOCOL_TLS 1
#define TS_RDP_PROTOCOL_HYBRID 2
#define TS_RDP_PROTOCOL_RDSTLS 4
#define TS_RDP_PROTOCOL_HYBRID_EX 8
#define TS_AUTH_MODE_NONE 0
#define TS_AUTH_MODE_PASSWORD 1
#define TS_AUTH_MODE_PRIVATE_KEY 2
#define TS_PROXY_PROTOCOL_RDP 1
#define TS_PROXY_PROTOCOL_SSH 2
#define TS_PROXY_PROTOCOL_TELNET 3
//typedef ex_u32 ts_rv;
#define TSR_OK 0x0000
#define TSR_INVALID_DATA 0x0001
#define TSR_SEND_ERROR 0x0002
#define TSR_NEED_MORE_DATA 0x0005
#define TSR_FAILED 0x0006
#define TSR_DATA_LEN_ZERO 0x0007
#define TSR_MAX_CONN_REACHED 0x0010
#define TSR_MAX_HOST_REACHED 0x0011
#define TSR_INVALID_REQUEST 0x1000
#define TSR_INVALID_URI 0x1001
#define TSR_INVALID_URL_ENCODE 0x1002
#define TSR_NO_SUCH_METHOD 0x1003
#define TSR_INVALID_JSON_FORMAT 0x1004
#define TSR_INVALID_JSON_PARAM 0x1005
#define TSR_GETAUTH_INFO_ERROR 0x1006
#define TSR_HOST_LOCK_ERROR 0x1007
#define TSR_ACCOUNT_LOCK_ERROR 0x1008
//================================================
#define SESS_STAT_RUNNING 0 // 会话开始了,尚未结束
#define SESS_STAT_END 9999 // 会话成功结束
#define SESS_STAT_ERR_AUTH_DENIED 1 // 会话结束,因为认证失败
#define SESS_STAT_ERR_CONNECT 2 // 会话结束,因为无法连接到远程主机
#define SESS_STAT_ERR_BAD_SSH_KEY 3 // 会话结束因为无法识别SSH私钥
#define SESS_STAT_ERR_INTERNAL 4 // 会话结束,因为内部错误
#define SESS_STAT_ERR_UNSUPPORT_PROTOCOL 5 // 会话结束,因为协议不支持(RDP)
#define SESS_STAT_ERR_BAD_PKG 6 // 会话结束,因为收到错误的报文
#define SESS_STAT_ERR_RESET 7 // 会话结束因为teleport核心服务重置了
#endif // __TS_ERRNO_H__

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

@ -0,0 +1,219 @@
#include "ts_memstream.h"
MemStream::MemStream(MemBuffer& mbuf) : m_mbuf(mbuf)
{
m_offset = 0;
}
MemStream::~MemStream()
{}
void MemStream::reset(void)
{
m_mbuf.empty();
rewind();
}
bool MemStream::seek(size_t offset)
{
if (offset >= m_mbuf.size())
return false;
m_offset = offset;
return true;
}
bool MemStream::skip(size_t n)
{
if (m_offset + n >= m_mbuf.size())
return false;
m_offset += n;
return true;
}
bool MemStream::rewind(size_t n)
{
if (m_offset < n)
return false;
if (0 == n)
m_offset = 0;
else
m_offset -= n;
return true;
}
ex_u8 MemStream::get_u8(void)
{
ASSERT(m_offset + 1 <= m_mbuf.size());
ex_u8 v = (m_mbuf.data() + m_offset)[0];
m_offset++;
return v;
}
ex_u16 MemStream::get_u16_le(void)
{
ASSERT(m_offset + 2 <= m_mbuf.size());
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
ex_u16 v = (ex_u16)(p[0] | (p[1] << 8));
#else
ex_u16 v = ((ex_u16*)p)[0];
#endif
m_offset += 2;
return v;
}
ex_u16 MemStream::get_u16_be(void)
{
ASSERT(m_offset + 2 <= m_mbuf.size());
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
ex_u16 v = ((ex_u16*)p)[0];
#else
ex_u16 v = (ex_u16)((p[0] << 8) | p[1]);
#endif
m_offset += 2;
return v;
}
ex_u32 MemStream::get_u32_le(void)
{
ASSERT(m_offset + 4 <= m_mbuf.size());
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
ex_u32 v = (ex_u32)(p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24));
#else
ex_u32 v = ((ex_u32*)p)[0];
#endif
m_offset += 4;
return v;
}
ex_u32 MemStream::get_u32_be(void)
{
ASSERT(m_offset + 4 <= m_mbuf.size());
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
ex_u32 v = ((ex_u32*)p)[0];
#else
ex_u32 v = (ex_u32)((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
#endif
m_offset += 4;
return v;
}
ex_u8* MemStream::get_bin(size_t n)
{
ASSERT(m_offset + 4 <= m_mbuf.size());
ex_u8* p = m_mbuf.data() + m_offset;
m_offset += n;
return p;
}
void MemStream::put_zero(size_t n)
{
m_mbuf.reserve(m_mbuf.size() + n);
memset(m_mbuf.data() + m_offset, 0, n);
m_offset += n;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}
void MemStream::put_u8(ex_u8 v)
{
m_mbuf.reserve(m_mbuf.size() + 1);
(m_mbuf.data() + m_offset)[0] = v;
m_offset++;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}
void MemStream::put_u16_le(ex_u16 v)
{
m_mbuf.reserve(m_mbuf.size() + 2);
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
p[0] = (ex_u8)v;
p[1] = (ex_u8)(v >> 8);
#else
((ex_u16*)p)[0] = v;
#endif
m_offset += 2;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}
void MemStream::put_u16_be(ex_u16 v)
{
m_mbuf.reserve(m_mbuf.size() + 2);
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
((ex_u16*)p)[0] = v;
#else
ex_u8* _v = (ex_u8*)&v;
p[0] = _v[1];
p[1] = _v[0];
#endif
m_offset += 2;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}
void MemStream::put_u32_le(ex_u32 v)
{
m_mbuf.reserve(m_mbuf.size() + 4);
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
p[0] = (ex_u8)v;
p[1] = (ex_u8)(v >> 8);
p[2] = (ex_u8)(v >> 16);
p[3] = (ex_u8)(v >> 24);
#else
((ex_u32*)p)[0] = v;
#endif
m_offset += 4;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}
void MemStream::put_u32_be(ex_u32 v)
{
m_mbuf.reserve(m_mbuf.size() + 4);
ex_u8* p = m_mbuf.data() + m_offset;
#if defined(B_ENDIAN)
((ex_u32*)p)[0] = v;
#else
ex_u8* _v = (ex_u8*)&v;
p[0] = _v[3];
p[1] = _v[2];
p[2] = _v[1];
p[3] = _v[0];
#endif
m_offset += 4;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}
void MemStream::put_bin(const ex_u8* p, size_t n)
{
m_mbuf.reserve(m_mbuf.size() + n);
memcpy(m_mbuf.data() + m_offset, p, n);
m_offset += n;
if (m_mbuf.size() < m_offset)
m_mbuf.size(m_offset);
}

View File

@ -0,0 +1,45 @@
#ifndef __TS_MEMSTREAM_H__
#define __TS_MEMSTREAM_H__
#include "ts_membuf.h"
class MemStream
{
public:
MemStream(MemBuffer& mbuf);
~MemStream();
void reset(void); // 清空缓冲区数据(但不释放内存),指针移动到头部
bool seek(size_t offset); // 移动指针到指定偏移,如果越界,则返回错误
bool rewind(size_t n = 0); // 回退n字节如果越界返回错误如果n为0则回退到最开始处
bool skip(size_t n); // 跳过n字节如果越界则返回错误
ex_u8* ptr(void) { return m_mbuf.data() + m_offset; } // 返回当前数据指针
size_t offset(void) { return m_offset; } // 返回当前指针相对数据起始的偏移
size_t left(void) { return m_mbuf.size() - m_offset; } // 返回剩余数据的大小(从当前数据指针到缓冲区结尾)
ex_u8 get_u8(void);
ex_u16 get_u16_le(void);
ex_u16 get_u16_be(void);
ex_u32 get_u32_le(void);
ex_u32 get_u32_be(void);
ex_u8* get_bin(size_t n); // 返回当前指向的数据的指针内部偏移会向后移动n字节
void put_zero(size_t n); // 填充n字节的0
void put_u8(ex_u8 v);
void put_u16_le(ex_u16 v);
void put_u16_be(ex_u16 v);
void put_u32_le(ex_u32 v);
void put_u32_be(ex_u32 v);
void put_bin(const ex_u8* p, size_t n); // 填充p指向的n字节数据
size_t size(void) { return m_mbuf.size(); }
private:
MemBuffer& m_mbuf;
size_t m_offset;
};
#endif // __TS_MEMSTREAM_H__

Binary file not shown.

View File

@ -1,229 +1,229 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6548CB1D-A7BA-4A68-9B3F-A5129F77868B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tp_core</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>tp_core</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
<IncludePath>D:\apps\vld\include;$(IncludePath)</IncludePath>
<LibraryPath>D:\apps\vld\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>Debug</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../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</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_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)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../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</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\common\libex\src\ex_ini.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_log.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_path.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_str.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_thread.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_util.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\mbedtls\library\aes.c" />
<ClCompile Include="..\..\..\external\mbedtls\library\base64.c" />
<ClCompile Include="..\..\..\external\mbedtls\library\sha1.c" />
<ClCompile Include="..\..\..\external\mongoose\mongoose.c" />
<ClCompile Include="main.cpp" />
<ClCompile Include="ts_crypto.cpp" />
<ClCompile Include="ts_web_rpc.cpp" />
<ClCompile Include="ts_env.cpp" />
<ClCompile Include="ts_http_client.cpp" />
<ClCompile Include="ts_http_rpc.cpp" />
<ClCompile Include="ts_main.cpp" />
<ClCompile Include="ts_session.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\common\libex\include\ex.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_const.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_ini.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_log.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_path.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_platform.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_str.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_thread.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_types.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_winsrv.h" />
<ClInclude Include="..\..\..\external\jsoncpp\include\json\json.h" />
<ClInclude Include="..\..\..\external\mongoose\mongoose.h" />
<ClInclude Include="..\common\protocol_interface.h" />
<ClInclude Include="..\common\ts_const.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="ts_crypto.h" />
<ClInclude Include="ts_web_rpc.h" />
<ClInclude Include="ts_env.h" />
<ClInclude Include="ts_http_client.h" />
<ClInclude Include="ts_http_rpc.h" />
<ClInclude Include="ts_main.h" />
<ClInclude Include="ts_session.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="tp_core.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\tp_core.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6548CB1D-A7BA-4A68-9B3F-A5129F77868B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tp_core</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>tp_core</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\out\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>Debug</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../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</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_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)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../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</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>../../external/windows/openssl/lib;../../external/windows/zlib/lib;../../external/windows/libssh/lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\common\libex\src\ex_ini.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_log.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_path.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_str.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_thread.cpp" />
<ClCompile Include="..\..\..\common\libex\src\ex_util.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\mbedtls\library\aes.c" />
<ClCompile Include="..\..\..\external\mbedtls\library\base64.c" />
<ClCompile Include="..\..\..\external\mbedtls\library\sha1.c" />
<ClCompile Include="..\..\..\external\mongoose\mongoose.c" />
<ClCompile Include="main.cpp" />
<ClCompile Include="ts_crypto.cpp" />
<ClCompile Include="ts_web_rpc.cpp" />
<ClCompile Include="ts_env.cpp" />
<ClCompile Include="ts_http_client.cpp" />
<ClCompile Include="ts_http_rpc.cpp" />
<ClCompile Include="ts_main.cpp" />
<ClCompile Include="ts_session.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\common\libex\include\ex.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_const.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_ini.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_log.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_path.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_platform.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_str.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_thread.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_types.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\..\common\libex\include\ex\ex_winsrv.h" />
<ClInclude Include="..\..\..\external\jsoncpp\include\json\json.h" />
<ClInclude Include="..\..\..\external\mongoose\mongoose.h" />
<ClInclude Include="..\common\protocol_interface.h" />
<ClInclude Include="..\common\ts_const.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="ts_crypto.h" />
<ClInclude Include="ts_web_rpc.h" />
<ClInclude Include="ts_env.h" />
<ClInclude Include="ts_http_client.h" />
<ClInclude Include="ts_http_rpc.h" />
<ClInclude Include="ts_main.h" />
<ClInclude Include="ts_session.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="tp_core.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\tp_core.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -63,11 +63,13 @@ bool TsEnv::init(bool load_config)
#else
m_etc_path = L"/etc/teleport";
conf_file = L"/etc/teleport/core.ini";
m_replay_path = L"/var/lib/teleport/data/replay";
m_replay_path = L"/var/lib/teleport/replay";
log_path = L"/var/log/teleport";
#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());
@ -109,6 +111,11 @@ bool TsEnv::init(bool load_config)
EXLOG_LEVEL(log_level);
}
int debug_mode = 0;
ps->GetInt(L"debug", debug_mode, 0);
if (debug_mode == 1)
EXLOG_DEBUG(true);
ex_wstr tmp;
ps = m_ini.GetSection(L"rpc");
if (!ps->GetStr(L"bind-ip", tmp))

View File

@ -9,14 +9,74 @@
bool g_exit_flag = false;
bool tpp_take_session(const ex_astr& sid, TS_SESSION_INFO& info)
TPP_SESSION_INFO* tpp_take_session(const char* sid)
{
return g_session_mgr.take_session(sid, info);
TS_SESSION_INFO sinfo;
bool ret = g_session_mgr.take_session(sid, sinfo);
if (!ret)
return NULL;
TPP_SESSION_INFO* info = (TPP_SESSION_INFO*)calloc(1, sizeof(TPP_SESSION_INFO));
info->sid = (char*)calloc(1, sinfo.sid.length() + 1);
ex_strcpy(info->sid, sinfo.sid.length() + 1, sinfo.sid.c_str());
info->account_name = (char*)calloc(1, sinfo.account_name.length() + 1);
ex_strcpy(info->account_name, sinfo.account_name.length() + 1, sinfo.account_name.c_str());
info->host_ip = (char*)calloc(1, sinfo.host_ip.length() + 1);
ex_strcpy(info->host_ip, sinfo.host_ip.length() + 1, sinfo.host_ip.c_str());
info->user_name = (char*)calloc(1, sinfo.user_name.length() + 1);
ex_strcpy(info->user_name, sinfo.user_name.length() + 1, sinfo.user_name.c_str());
info->user_auth = (char*)calloc(1, sinfo.user_auth.length() + 1);
ex_strcpy(info->user_auth, sinfo.user_auth.length() + 1, sinfo.user_auth.c_str());
info->user_param = (char*)calloc(1, sinfo.user_param.length() + 1);
ex_strcpy(info->user_param, sinfo.user_param.length() + 1, sinfo.user_param.c_str());
info->auth_id = sinfo.auth_id;
info->host_port = sinfo.host_port;
info->protocol = sinfo.protocol;
info->auth_mode = sinfo.auth_mode;
info->sys_type = sinfo.sys_type;
info->ref_count = sinfo.ref_count;
info->ticket_start = sinfo.ticket_start;
return info;
}
bool tpp_session_begin(TS_SESSION_INFO& info, int& db_id)
void tpp_free_session(TPP_SESSION_INFO* info)
{
return ts_web_rpc_session_begin(info, db_id);
if (NULL == info)
return;
free(info->sid);
free(info->account_name);
free(info->host_ip);
free(info->user_name);
free(info->user_auth);
free(info->user_param);
free(info);
}
bool tpp_session_begin(const TPP_SESSION_INFO* info, int* db_id)
{
if (NULL == info || NULL == db_id)
return false;
TS_SESSION_INFO sinfo;
sinfo.sid = info->sid;
sinfo.account_name = info->account_name;
sinfo.auth_id = info->auth_id;
sinfo.host_ip = info->host_ip;
sinfo.host_port = info->host_port;
sinfo.protocol = info->protocol;
sinfo.user_name = info->user_name;
sinfo.user_auth = info->user_auth;
sinfo.user_param = info->user_param;
sinfo.auth_mode = info->auth_mode;
sinfo.sys_type = info->sys_type;
sinfo.ref_count = info->ref_count;
sinfo.ticket_start = info->ticket_start;
return ts_web_rpc_session_begin(sinfo, *db_id);
}
bool tpp_session_end(int db_id, int ret)
@ -88,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)
@ -122,6 +182,7 @@ bool TppManager::load_tpp(const ex_wstr& libname)
init_args.replay_path = g_env.m_replay_path;
init_args.cfg = &g_env.get_ini();
init_args.func_take_session = tpp_take_session;
init_args.func_free_session = tpp_free_session;
init_args.func_session_begin = tpp_session_begin;
init_args.func_session_end = tpp_session_end;
@ -153,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;
@ -167,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

@ -113,16 +113,19 @@ bool TsSessionManager::take_session(const ex_astr& sid, TS_SESSION_INFO& info)
return false;
info.sid = it->second->sid;
info.account_name = it->second->account_name;
info.auth_id = it->second->auth_id;
info.host_ip = it->second->host_ip;
info.host_port = it->second->host_port;
info.protocol = it->second->protocol;
info.account_name = it->second->account_name;
info.sys_type = it->second->sys_type;
info.user_name = it->second->user_name;
info.user_param = it->second->user_param;
info.user_auth = it->second->user_auth;
info.user_param = it->second->user_param;
info.auth_mode = it->second->auth_mode;
info.sys_type = it->second->sys_type;
info.ref_count = it->second->ref_count;
info.ticket_start = it->second->ticket_start;
it->second->ref_count--;
@ -145,7 +148,7 @@ bool TsSessionManager::_add_session(ex_astr& sid, TS_SESSION_INFO* info)
for (;;)
{
_gen_session_id(_sid, info, 6);
it = m_sessions.find(sid);
it = m_sessions.find(_sid);
if (it == m_sessions.end())
break;

View File

@ -6,6 +6,25 @@
#include <ex.h>
typedef struct TS_SESSION_INFO
{
ex_astr sid;
ex_astr account_name; // 申请本次连接的用户名
int auth_id;
ex_astr host_ip;
int host_port;
int protocol;
ex_astr user_name;
ex_astr user_auth;
ex_astr user_param;
int auth_mode;
int sys_type;
int ref_count; // 这个session可以被take_session()多少次
ex_u64 ticket_start;
}TS_SESSION_INFO;
typedef std::map<ex_astr, TS_SESSION_INFO*> ts_sessiones;
class TsSessionManager : public ExThreadBase

View File

@ -1,6 +1,6 @@
#ifndef __TS_SERVER_VER_H__
#define __TS_SERVER_VER_H__
#define TP_SERVER_VER L"2.1.2.1"
#define TP_SERVER_VER L"2.2.5.1"
#endif // __TS_SERVER_VER_H__

View File

@ -7,22 +7,19 @@ 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(../../../../external/jsoncpp/src/lib_json 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
../../../../external/jsoncpp/include
../../../../external/linux/release/include
)
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)
#target_link_libraries(tpssh ssh mbedx509 mbedtls mbedcrypto dl pthread rt util)

View File

@ -1,255 +1,255 @@
#include "ssh_proxy.h"
#include "tpp_env.h"
SshProxy g_ssh_proxy;
SshProxy::SshProxy() :
ExThreadBase("ssh-proxy-thread"),
m_bind(NULL)
{
}
SshProxy::~SshProxy()
{
if (NULL != m_bind)
ssh_bind_free(m_bind);
ssh_finalize();
ts_sftp_sessions::iterator it = m_sftp_sessions.begin();
for (; it != m_sftp_sessions.end(); ++it)
{
delete it->second;
}
m_sftp_sessions.clear();
}
bool SshProxy::init(void)
{
m_host_ip = g_ssh_env.bind_ip;
m_host_port = g_ssh_env.bind_port;
m_bind = ssh_bind_new();
if (NULL == m_bind)
{
EXLOGE("[ssh] can not create bind.\n");
return false;
}
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_BINDADDR, m_host_ip.c_str()))
{
EXLOGE("[ssh] can not set bind option: SSH_BIND_OPTIONS_BINDADDR.\n");
return false;
}
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_BINDPORT, &m_host_port))
{
EXLOGE("[ssh] can not set bind option: SSH_BIND_OPTIONS_BINDPORT.\n");
return false;
}
ex_wstr _key_file = g_ssh_env.etc_path;
ex_path_join(_key_file, false, L"tp_ssh_server.key", NULL);
ex_astr key_file;
ex_wstr2astr(_key_file, key_file);
EXLOGV("[ssh] try to load ssh-server-key: %s\n", key_file.c_str());
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_RSAKEY, key_file.c_str()))
{
EXLOGE("[ssh] can not set bind option: SSH_BIND_OPTIONS_RSAKEY.\n");
return false;
}
if (ssh_bind_listen(m_bind) < 0)
{
EXLOGE("[ssh] listening to socket: %s\n", ssh_get_error(m_bind));
return false;
}
return true;
}
void SshProxy::_thread_loop(void)
{
EXLOGV("[ssh] TeleportServer-SSH ready on %s:%d\n", m_host_ip.c_str(), m_host_port);
_run();
EXLOGV("[ssh] main-loop end.\n");
}
void SshProxy::_set_stop_flag(void)
{
m_stop_flag = true;
if (m_is_running)
{
// 用一个变通的方式来结束阻塞中的监听,就是连接一下它。
ex_astr host_ip = m_host_ip;
if (host_ip == "0.0.0.0")
host_ip = "127.0.0.1";
ssh_session _session = ssh_new();
ssh_options_set(_session, SSH_OPTIONS_HOST, host_ip.c_str());
ssh_options_set(_session, SSH_OPTIONS_PORT, &m_host_port);
int _timeout_us = 100000;
ssh_options_set(_session, SSH_OPTIONS_TIMEOUT_USEC, &_timeout_us);
ssh_connect(_session);
ssh_free(_session);
}
m_thread_mgr.stop_all();
}
void SshProxy::_run(void)
{
for (;;)
{
// 注意ssh_new()出来的指针如果遇到停止标志本函数内部就释放了否则这个指针交给了SshSession类实例管理其析构时会释放。
ssh_session sess_to_client = ssh_new();
struct sockaddr_storage sock_client;
char ip[32] = { 0 };
int len = sizeof(ip);
if (ssh_bind_accept(m_bind, sess_to_client) != SSH_OK)
{
EXLOGE("[ssh] accepting a connection failed: %s.\n", ssh_get_error(m_bind));
continue;
}
EXLOGD("[ssh] ssh_bind_accept() returned...\n");
if (m_stop_flag)
{
ssh_free(sess_to_client);
break;
}
SshSession* sess = new SshSession(this, sess_to_client);
#ifdef EX_OS_WIN32
getpeername(ssh_get_fd(sess_to_client), (struct sockaddr*)&sock_client, &len);
#else
getpeername(ssh_get_fd(sess_to_client), (struct sockaddr*)&sock_client, (unsigned int*)&len);
#endif
sockaddr_in* addrin = (sockaddr_in*)&sock_client;
if (0 == ex_ip4_name(addrin, ip, sizeof(ip)))
{
sess->client_ip(ip);
sess->client_port(addrin->sin_port);
}
EXLOGV("[ssh] ------ NEW SSH CLIENT [%s:%d] ------\n", sess->client_ip(), sess->client_port());
{
ExThreadSmartLock locker(m_lock);
m_sessions.insert(std::make_pair(sess, 0));
}
sess->start();
}
// 等待所有工作线程退出
m_thread_mgr.stop_all();
}
void SshProxy::_dump_sftp_sessions(void)
{
ts_sftp_sessions::iterator it = m_sftp_sessions.begin();
for (; it != m_sftp_sessions.end(); ++it)
{
EXLOGD("ssh-proxy session: sid: %s\n", it->first.c_str());
}
}
void SshProxy::add_sftp_session_info(const ex_astr& sid, const ex_astr& host_ip, int host_port, const ex_astr& user_name, const ex_astr& user_auth, int auth_mode)
{
ExThreadSmartLock locker(m_lock);
EXLOGD("[ssh] add sftp session-id: %s\n", sid.c_str());
ts_sftp_sessions::iterator it = m_sftp_sessions.find(sid);
if (it != m_sftp_sessions.end())
{
EXLOGD("[ssh] sftp-session-id '%s' already exists.\n", sid.c_str());
it->second->ref_count++;
return;
}
TS_SFTP_SESSION_INFO* info = new TS_SFTP_SESSION_INFO;
info->host_ip = host_ip;
info->host_port = host_port;
info->user_name = user_name;
info->user_auth = user_auth;
info->auth_mode = auth_mode;
info->ref_count = 1;
if (!m_sftp_sessions.insert(std::make_pair(sid, info)).second)
{
EXLOGE("[ssh] ssh-proxy can not insert a sftp-session-id.\n");
}
_dump_sftp_sessions();
}
bool SshProxy::get_sftp_session_info(const ex_astr& sid, TS_SFTP_SESSION_INFO& info)
{
ExThreadSmartLock locker(m_lock);
EXLOGD("[ssh] try to get info by sftp session-id: %s\n", sid.c_str());
_dump_sftp_sessions();
ts_sftp_sessions::iterator it = m_sftp_sessions.find(sid);
if (it == m_sftp_sessions.end())
{
EXLOGD("sftp-session '%s' not exists.\n", sid.c_str());
return false;
}
info.host_ip = it->second->host_ip;
info.host_port = it->second->host_port;
info.user_name = it->second->user_name;
info.user_auth = it->second->user_auth;
info.auth_mode = it->second->auth_mode;
info.ref_count = it->second->ref_count;
return true;
}
void SshProxy::remove_sftp_sid(const ex_astr& sid)
{
EXLOGD("[ssh] try to remove sftp session-id: %s\n", sid.c_str());
ExThreadSmartLock locker(m_lock);
ts_sftp_sessions::iterator it = m_sftp_sessions.find(sid);
if (it == m_sftp_sessions.end())
{
EXLOGE("[ssh] ssh-proxy when remove sftp sid, it not in charge.\n");
return;
}
it->second->ref_count--;
if (it->second->ref_count <= 0)
{
delete it->second;
m_sftp_sessions.erase(it);
EXLOGD("[ssh] sftp session-id '%s' removed.\n", sid.c_str());
}
}
void SshProxy::session_finished(SshSession* sess)
{
ExThreadSmartLock locker(m_lock);
ts_ssh_sessions::iterator it = m_sessions.find(sess);
if (it != m_sessions.end())
{
m_sessions.erase(it);
EXLOGV("[ssh] client %s:%d session removed.\n", sess->client_ip(), sess->client_port());
}
else
{
EXLOGW("[ssh] when session %s:%d end, it not in charge.\n", sess->client_ip(), sess->client_port());
}
delete sess;
}
#include "ssh_proxy.h"
#include "tpp_env.h"
SshProxy g_ssh_proxy;
SshProxy::SshProxy() :
ExThreadBase("ssh-proxy-thread"),
m_bind(NULL)
{
}
SshProxy::~SshProxy()
{
if (NULL != m_bind)
ssh_bind_free(m_bind);
ssh_finalize();
ts_sftp_sessions::iterator it = m_sftp_sessions.begin();
for (; it != m_sftp_sessions.end(); ++it)
{
delete it->second;
}
m_sftp_sessions.clear();
}
bool SshProxy::init(void)
{
m_host_ip = g_ssh_env.bind_ip;
m_host_port = g_ssh_env.bind_port;
m_bind = ssh_bind_new();
if (NULL == m_bind)
{
EXLOGE("[ssh] can not create bind.\n");
return false;
}
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_BINDADDR, m_host_ip.c_str()))
{
EXLOGE("[ssh] can not set bind option: SSH_BIND_OPTIONS_BINDADDR.\n");
return false;
}
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_BINDPORT, &m_host_port))
{
EXLOGE("[ssh] can not set bind option: SSH_BIND_OPTIONS_BINDPORT.\n");
return false;
}
ex_wstr _key_file = g_ssh_env.etc_path;
ex_path_join(_key_file, false, L"tp_ssh_server.key", NULL);
ex_astr key_file;
ex_wstr2astr(_key_file, key_file);
EXLOGV("[ssh] try to load ssh-server-key: %s\n", key_file.c_str());
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_RSAKEY, key_file.c_str()))
{
EXLOGE("[ssh] can not set bind option: SSH_BIND_OPTIONS_RSAKEY.\n");
return false;
}
if (ssh_bind_listen(m_bind) < 0)
{
EXLOGE("[ssh] listening to socket: %s\n", ssh_get_error(m_bind));
return false;
}
return true;
}
void SshProxy::_thread_loop(void)
{
EXLOGV("[ssh] TeleportServer-SSH ready on %s:%d\n", m_host_ip.c_str(), m_host_port);
_run();
EXLOGV("[ssh] main-loop end.\n");
}
void SshProxy::_set_stop_flag(void)
{
m_stop_flag = true;
if (m_is_running)
{
// 用一个变通的方式来结束阻塞中的监听,就是连接一下它。
ex_astr host_ip = m_host_ip;
if (host_ip == "0.0.0.0")
host_ip = "127.0.0.1";
ssh_session _session = ssh_new();
ssh_options_set(_session, SSH_OPTIONS_HOST, host_ip.c_str());
ssh_options_set(_session, SSH_OPTIONS_PORT, &m_host_port);
int _timeout_us = 100000;
ssh_options_set(_session, SSH_OPTIONS_TIMEOUT_USEC, &_timeout_us);
ssh_connect(_session);
ssh_free(_session);
}
m_thread_mgr.stop_all();
}
void SshProxy::_run(void)
{
for (;;)
{
// 注意ssh_new()出来的指针如果遇到停止标志本函数内部就释放了否则这个指针交给了SshSession类实例管理其析构时会释放。
ssh_session sess_to_client = ssh_new();
struct sockaddr_storage sock_client;
char ip[32] = { 0 };
int len = sizeof(ip);
if (ssh_bind_accept(m_bind, sess_to_client) != SSH_OK)
{
EXLOGE("[ssh] accepting a connection failed: %s.\n", ssh_get_error(m_bind));
continue;
}
EXLOGD("[ssh] ssh_bind_accept() returned...\n");
if (m_stop_flag)
{
ssh_free(sess_to_client);
break;
}
SshSession* sess = new SshSession(this, sess_to_client);
#ifdef EX_OS_WIN32
getpeername(ssh_get_fd(sess_to_client), (struct sockaddr*)&sock_client, &len);
#else
getpeername(ssh_get_fd(sess_to_client), (struct sockaddr*)&sock_client, (unsigned int*)&len);
#endif
sockaddr_in* addrin = (sockaddr_in*)&sock_client;
if (0 == ex_ip4_name(addrin, ip, sizeof(ip)))
{
sess->client_ip(ip);
sess->client_port(addrin->sin_port);
}
EXLOGV("[ssh] ------ NEW SSH CLIENT [%s:%d] ------\n", sess->client_ip(), sess->client_port());
{
ExThreadSmartLock locker(m_lock);
m_sessions.insert(std::make_pair(sess, 0));
}
sess->start();
}
// 等待所有工作线程退出
m_thread_mgr.stop_all();
}
void SshProxy::_dump_sftp_sessions(void)
{
ts_sftp_sessions::iterator it = m_sftp_sessions.begin();
for (; it != m_sftp_sessions.end(); ++it)
{
EXLOGD("ssh-proxy session: sid: %s\n", it->first.c_str());
}
}
void SshProxy::add_sftp_session_info(const ex_astr& sid, const ex_astr& host_ip, int host_port, const ex_astr& user_name, const ex_astr& user_auth, int auth_mode)
{
ExThreadSmartLock locker(m_lock);
EXLOGD("[ssh] add sftp session-id: %s\n", sid.c_str());
ts_sftp_sessions::iterator it = m_sftp_sessions.find(sid);
if (it != m_sftp_sessions.end())
{
EXLOGD("[ssh] sftp-session-id '%s' already exists.\n", sid.c_str());
it->second->ref_count++;
return;
}
TS_SFTP_SESSION_INFO* info = new TS_SFTP_SESSION_INFO;
info->host_ip = host_ip;
info->host_port = host_port;
info->user_name = user_name;
info->user_auth = user_auth;
info->auth_mode = auth_mode;
info->ref_count = 1;
if (!m_sftp_sessions.insert(std::make_pair(sid, info)).second)
{
EXLOGE("[ssh] ssh-proxy can not insert a sftp-session-id.\n");
}
_dump_sftp_sessions();
}
bool SshProxy::get_sftp_session_info(const ex_astr& sid, TS_SFTP_SESSION_INFO& info)
{
ExThreadSmartLock locker(m_lock);
EXLOGD("[ssh] try to get info by sftp session-id: %s\n", sid.c_str());
_dump_sftp_sessions();
ts_sftp_sessions::iterator it = m_sftp_sessions.find(sid);
if (it == m_sftp_sessions.end())
{
EXLOGD("sftp-session '%s' not exists.\n", sid.c_str());
return false;
}
info.host_ip = it->second->host_ip;
info.host_port = it->second->host_port;
info.user_name = it->second->user_name;
info.user_auth = it->second->user_auth;
info.auth_mode = it->second->auth_mode;
info.ref_count = it->second->ref_count;
return true;
}
void SshProxy::remove_sftp_sid(const ex_astr& sid)
{
EXLOGD("[ssh] try to remove sftp session-id: %s\n", sid.c_str());
ExThreadSmartLock locker(m_lock);
ts_sftp_sessions::iterator it = m_sftp_sessions.find(sid);
if (it == m_sftp_sessions.end())
{
EXLOGE("[ssh] ssh-proxy when remove sftp sid, it not in charge.\n");
return;
}
it->second->ref_count--;
if (it->second->ref_count <= 0)
{
delete it->second;
m_sftp_sessions.erase(it);
EXLOGD("[ssh] sftp session-id '%s' removed.\n", sid.c_str());
}
}
void SshProxy::session_finished(SshSession* sess)
{
ExThreadSmartLock locker(m_lock);
ts_ssh_sessions::iterator it = m_sessions.find(sess);
if (it != m_sessions.end())
{
m_sessions.erase(it);
EXLOGV("[ssh] client %s:%d session removed.\n", sess->client_ip(), sess->client_port());
}
else
{
EXLOGW("[ssh] when session %s:%d end, it not in charge.\n", sess->client_ip(), sess->client_port());
}
delete sess;
}

View File

@ -1,29 +1,38 @@
#include "ssh_recorder.h"
static ex_u8 TPP_RECORD_MAGIC[4] = { 'T', 'P', 'R', 'R' };
static ex_u8 TPP_RECORD_MAGIC[4] = { 'T', 'P', 'P', 'R' };
TppRec::TppRec()
TppSshRec::TppSshRec()
{
m_cmd_cache.reserve(MAX_SIZE_PER_FILE);
memset(&m_head, 0, sizeof(TS_RECORD_HEADER));
memcpy((ex_u8*)(&m_head.magic), TPP_RECORD_MAGIC, sizeof(ex_u32));
m_head.ver = 0x02;
m_head.protocol = TS_PROXY_PROTOCOL_SSH;
}
TppRec::~TppRec()
TppSshRec::~TppSshRec()
{
end();
}
void TppRec::_on_begin(const TS_SESSION_INFO& info)
void TppSshRec::_on_begin(const TPP_SESSION_INFO* info)
{
m_head.port = info.host_port;
memcpy(m_head.account, info.account_name.c_str(), info.account_name.length() > 15 ? 15 : info.account_name.length());
memcpy(m_head.username, info.user_name.c_str(), info.user_name.length() > 15 ? 15 : info.user_name.length());
memcpy(m_head.ip, info.host_ip.c_str(), info.host_ip.length() > 17 ? 17 : info.host_ip.length());
if (NULL == info)
return;
m_head.timestamp = time(NULL);
m_head.port = info->host_port;
// memcpy(m_head.account, info.account_name.c_str(), info.account_name.length() > 15 ? 15 : info.account_name.length());
// memcpy(m_head.username, info.user_name.c_str(), info.user_name.length() > 15 ? 15 : info.user_name.length());
// memcpy(m_head.ip, info.host_ip.c_str(), info.host_ip.length() > 17 ? 17 : info.host_ip.length());
memcpy(m_head.account, info->account_name, strlen(info->account_name) > 15 ? 15 : strlen(info->account_name));
memcpy(m_head.username, info->user_name, strlen(info->user_name) > 15 ? 15 : strlen(info->user_name));
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)
@ -32,7 +41,7 @@ void TppRec::_on_end(void)
_save_to_cmd_file();
// 更新头信息
m_head.timestamp = m_start_time;
//m_head.timestamp = m_start_time;
m_head.time_ms = (ex_u32)(m_last_time - m_start_time);
ex_wstr fname = m_base_path;
@ -51,7 +60,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;
@ -75,13 +84,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;
@ -89,7 +98,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
@ -115,7 +124,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);
@ -146,7 +155,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

@ -9,32 +9,32 @@
#pragma pack(push,1)
// 录像文件头
typedef struct TS_RECORD_HEADER
{
ex_u32 magic; // "TPPR" 标志 TelePort Protocol Record
ex_u64 timestamp; // 本次录像的起始时间UTC时间戳
ex_u32 packages; // 总包数
ex_u32 time_ms; // 总耗时(毫秒)
ex_u16 width; // 初始屏幕尺寸:宽
ex_u16 height; // 初始屏幕尺寸:高
ex_u16 file_count; // 数据文件总数
ex_u32 file_size; // 所有数据文件的总大小不包括每个数据文件的头即4字节的每文件大小
char account[16]; // teleport账号
char username[16]; // 远程主机用户名
char ip[18];
ex_u16 port;
ex_u8 reserve[128 - 4 - 8 - 4 - 4 - 2 - 2 - 2 - 4 - 16 - 16 - 18 - 2]; // 保留
}TS_RECORD_HEADER;
// 一个数据包的头
typedef struct TS_RECORD_PKG
{
ex_u8 type; // 包的数据类型
ex_u32 size; // 这个包的总大小(不含包头)
ex_u32 time_ms; // 这个包距起始时间的时间差毫秒意味着一个连接不能持续超过49天
ex_u8 reserve[3]; // 保留
}TS_RECORD_PKG;
// typedef struct TS_RECORD_HEADER
// {
// ex_u32 magic; // "TPPR" 标志 TelePort Protocol Record
// ex_u64 timestamp; // 本次录像的起始时间UTC时间戳
// ex_u32 packages; // 总包数
// ex_u32 time_ms; // 总耗时(毫秒)
// ex_u16 width; // 初始屏幕尺寸:宽
// ex_u16 height; // 初始屏幕尺寸:高
// ex_u16 file_count; // 数据文件总数
// ex_u32 file_size; // 所有数据文件的总大小不包括每个数据文件的头即4字节的每文件大小
// char account[16]; // teleport账号
// char username[16]; // 远程主机用户名
// char ip[18];
// ex_u16 port;
//
// ex_u8 reserve[128 - 4 - 8 - 4 - 4 - 2 - 2 - 2 - 4 - 16 - 16 - 18 - 2]; // 保留
// }TS_RECORD_HEADER;
//
// // 一个数据包的头
// typedef struct TS_RECORD_PKG
// {
// ex_u8 type; // 包的数据类型
// ex_u32 size; // 这个包的总大小(不含包头)
// ex_u32 time_ms; // 这个包距起始时间的时间差毫秒意味着一个连接不能持续超过49天
// ex_u8 reserve[3]; // 保留
// }TS_RECORD_PKG;
// 记录窗口大小改变的数据包
typedef struct TS_RECORD_WIN_SIZE
@ -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);
@ -57,7 +57,7 @@ public:
void record_command(const ex_astr cmd);
protected:
void _on_begin(const TS_SESSION_INFO& info);
void _on_begin(const TPP_SESSION_INFO* info);
void _on_end(void);
bool _save_to_data_file(void);

View File

@ -71,9 +71,9 @@ void SshSession::_set_stop_flag(void) {
}
}
bool SshSession::_on_session_begin(TS_SESSION_INFO& info)
bool SshSession::_on_session_begin(const TPP_SESSION_INFO* info)
{
if (!g_ssh_env.session_begin(info, m_db_id))
if (!g_ssh_env.session_begin(info, &m_db_id))
{
EXLOGD("[ssh] session_begin error. %d\n", m_db_id);
return false;
@ -229,12 +229,11 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
_this->m_sid = user;
EXLOGV("[ssh] authenticating, session-id: %s\n", _this->m_sid.c_str());
bool bRet = true;
TS_SESSION_INFO sess_info;
//bRet = _this->m_proxy->get_session_mgr()->take_session(_this->m_sid, sess_info);
bRet = g_ssh_env.take_session(_this->m_sid, sess_info);
//bool bRet = true;
int protocol = 0;
TPP_SESSION_INFO* sess_info = g_ssh_env.take_session(_this->m_sid.c_str());
if (!bRet) {
if (NULL == sess_info) {
EXLOGW("[ssh] try to get login-info from ssh-sftp-session.\n");
// 尝试从sftp连接记录中获取连接信息一个ssh会话如果成为sftp会话内部会将连接信息记录下来备用
TS_SFTP_SESSION_INFO sftp_info;
@ -251,25 +250,28 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
_this->m_user_name = sftp_info.user_name;
_this->m_user_auth = sftp_info.user_auth;
sess_info.host_ip = sftp_info.host_ip;
sess_info.host_port = sftp_info.host_port;
sess_info.auth_mode = sftp_info.auth_mode;
sess_info.user_name = sftp_info.user_name;
sess_info.user_auth = sftp_info.user_auth;
sess_info.protocol = TS_PROXY_PROTOCOL_SSH;
// sess_info.host_ip = sftp_info.host_ip;
// sess_info.host_port = sftp_info.host_port;
// sess_info.auth_mode = sftp_info.auth_mode;
// sess_info.user_name = sftp_info.user_name;
// sess_info.user_auth = sftp_info.user_auth;
// sess_info.protocol = TS_PROXY_PROTOCOL_SSH;
protocol = TS_PROXY_PROTOCOL_SSH;
// 因为是从sftp会话得来的登录数据因此限制本会话只能用于sftp不允许再使用shell了。
_this->_enter_sftp_mode();
} else {
_this->m_server_ip = sess_info.host_ip;
_this->m_server_port = sess_info.host_port;
_this->m_auth_mode = sess_info.auth_mode;
_this->m_user_name = sess_info.user_name;
_this->m_user_auth = sess_info.user_auth;
_this->m_server_ip = sess_info->host_ip;
_this->m_server_port = sess_info->host_port;
_this->m_auth_mode = sess_info->auth_mode;
_this->m_user_name = sess_info->user_name;
_this->m_user_auth = sess_info->user_auth;
protocol = sess_info->protocol;
}
//EXLOGE("[ssh---------1] auth info [password:%s:%s:%d]\n", _this->m_user_name.c_str(),_this->m_user_auth.c_str(), _this->m_auth_mode);
if (sess_info.protocol != TS_PROXY_PROTOCOL_SSH) {
if (protocol != TS_PROXY_PROTOCOL_SSH) {
g_ssh_env.free_session(sess_info);
EXLOGE("[ssh] session '%s' is not for SSH.\n", _this->m_sid.c_str());
_this->m_have_error = true;
_this->m_retcode = SESS_STAT_ERR_AUTH_DENIED;
@ -278,19 +280,23 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
if (!_this->_on_session_begin(sess_info))
{
g_ssh_env.free_session(sess_info);
_this->m_have_error = true;
_this->m_retcode = SESS_STAT_ERR_AUTH_DENIED;
return SSH_AUTH_DENIED;
}
// 现在尝试根据session-id获取得到的信息连接并登录真正的SSH服务器
EXLOGV("[ssh] try to connect to real SSH server %s:%d\n", sess_info.host_ip.c_str(), sess_info.host_port);
_this->m_srv_session = ssh_new();
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_HOST, sess_info.host_ip.c_str());
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_PORT, &sess_info.host_port);
g_ssh_env.free_session(sess_info);
sess_info = NULL;
if (sess_info.auth_mode != TS_AUTH_MODE_NONE)
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_USER, sess_info.user_name.c_str());
// 现在尝试根据session-id获取得到的信息连接并登录真正的SSH服务器
EXLOGV("[ssh] try to connect to real SSH server %s:%d\n", _this->m_server_ip.c_str(), _this->m_server_port);
_this->m_srv_session = ssh_new();
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_HOST, _this->m_server_ip.c_str());
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_PORT, &_this->m_server_port);
if (_this->m_auth_mode != TS_AUTH_MODE_NONE)
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_USER, _this->m_user_name.c_str());
int _timeout_us = 30000000; // 30 sec.
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_TIMEOUT_USEC, &_timeout_us);
@ -298,25 +304,24 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
int rc = 0;
rc = ssh_connect(_this->m_srv_session);
if (rc != SSH_OK) {
EXLOGE("[ssh] can not connect to real SSH server %s:%d.\n", sess_info.host_ip.c_str(), sess_info.host_port);
EXLOGE("[ssh] can not connect to real SSH server %s:%d.\n", _this->m_server_ip.c_str(), _this->m_server_port);
_this->m_have_error = true;
_this->m_retcode = SESS_STAT_ERR_CONNECT;
return SSH_AUTH_DENIED;
}
if (sess_info.auth_mode == TS_AUTH_MODE_PASSWORD) {
rc = ssh_userauth_password(_this->m_srv_session, NULL, sess_info.user_auth.c_str());
if (_this->m_auth_mode == TS_AUTH_MODE_PASSWORD) {
rc = ssh_userauth_password(_this->m_srv_session, NULL, _this->m_user_auth.c_str());
if (rc != SSH_OK) {
EXLOGE("[ssh] can not use user/name login to real SSH server %s:%d.\n", sess_info.host_ip.c_str(),
sess_info.host_port);
EXLOGE("[ssh] can not use user/name login to real SSH server %s:%d.\n", _this->m_server_ip.c_str(), _this->m_server_port);
_this->m_have_error = true;
_this->m_retcode = SESS_STAT_ERR_AUTH_DENIED;
return SSH_AUTH_DENIED;
}
}
else if (sess_info.auth_mode == TS_AUTH_MODE_PRIVATE_KEY) {
else if (_this->m_auth_mode == TS_AUTH_MODE_PRIVATE_KEY) {
ssh_key key = NULL;
if (SSH_OK != ssh_pki_import_privkey_base64(sess_info.user_auth.c_str(), NULL, NULL, NULL, &key)) {
if (SSH_OK != ssh_pki_import_privkey_base64(_this->m_user_auth.c_str(), NULL, NULL, NULL, &key)) {
EXLOGE("[ssh] can not import private-key for auth.\n");
_this->m_have_error = true;
_this->m_retcode = SESS_STAT_ERR_BAD_SSH_KEY;
@ -326,8 +331,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
rc = ssh_userauth_publickey(_this->m_srv_session, NULL, key);
if (rc != SSH_OK) {
ssh_key_free(key);
EXLOGE("[ssh] can not use private-key login to real SSH server %s:%d.\n", sess_info.host_ip.c_str(),
sess_info.host_port);
EXLOGE("[ssh] can not use private-key login to real SSH server %s:%d.\n", _this->m_server_ip.c_str(), _this->m_server_port);
_this->m_have_error = true;
_this->m_retcode = SESS_STAT_ERR_AUTH_DENIED;
return SSH_AUTH_DENIED;
@ -335,7 +339,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
ssh_key_free(key);
}
else if (sess_info.auth_mode == TS_AUTH_MODE_NONE)
else if (_this->m_auth_mode == TS_AUTH_MODE_NONE)
{
// do nothing.
return SSH_AUTH_DENIED;

View File

@ -55,7 +55,7 @@ public:
protected:
// ¼Ì³Ð×Ô TppSessionBase
bool _on_session_begin(TS_SESSION_INFO& info);
bool _on_session_begin(const TPP_SESSION_INFO* info);
bool _on_session_end(void);
@ -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

@ -1,218 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FDA16D20-09B7-45AF-ADF1-DAF3EF2C0531}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tpssh</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>tpssh</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\common\libex\include;..\..\..\..\external\libssh-win-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\..\..\external\libssh-win-static\lib;..\..\..\..\external\openssl\out32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;TPSSH_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\common\libex\include;..\..\..\..\external\libssh-win-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\..\..\..\external\libssh-win-static\lib;..\..\..\..\external\openssl\out32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;TPSSH_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\common\libex\include\ex.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_const.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_ini.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_log.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_path.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_platform.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_str.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_thread.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_types.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_winsrv.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\callbacks.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\libssh.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\server.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\sftp.h" />
<ClInclude Include="..\..\common\base_env.h" />
<ClInclude Include="..\..\common\base_record.h" />
<ClInclude Include="..\..\common\protocol_interface.h" />
<ClInclude Include="..\..\common\ts_const.h" />
<ClInclude Include="..\..\common\ts_membuf.h" />
<ClInclude Include="ssh_proxy.h" />
<ClInclude Include="ssh_recorder.h" />
<ClInclude Include="ssh_session.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="tpp_env.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\common\libex\src\ex_ini.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_log.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_path.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_str.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_thread.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_util.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_winsrv.cpp" />
<ClCompile Include="..\..\common\base_env.cpp" />
<ClCompile Include="..\..\common\base_record.cpp" />
<ClCompile Include="..\..\common\ts_membuf.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ssh_proxy.cpp" />
<ClCompile Include="ssh_recorder.cpp" />
<ClCompile Include="ssh_session.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="tpp_env.cpp" />
<ClCompile Include="tpssh.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FDA16D20-09B7-45AF-ADF1-DAF3EF2C0531}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tpssh</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>tpssh</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>..\..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>..\..\..\..\out\server\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>..\..\..\..\out\_tmp_\$(ProjectName)\$(PlatformTarget)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\common\libex\include;..\..\..\..\external\libssh-win-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>Debug</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\..\..\external\libssh-win-static\lib;..\..\..\..\external\openssl\out32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TPP_EXPORTS;LIBSSH_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\common\libex\include;..\..\..\..\external\libssh-win-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\..\..\..\external\libssh-win-static\lib;..\..\..\..\external\openssl\out32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\common\libex\include\ex.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_const.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_ini.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_log.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_path.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_platform.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_str.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_thread.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_types.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_util.h" />
<ClInclude Include="..\..\..\..\common\libex\include\ex\ex_winsrv.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\callbacks.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\libssh.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\server.h" />
<ClInclude Include="..\..\..\..\external\libssh-win-static\include\libssh\sftp.h" />
<ClInclude Include="..\..\common\base_env.h" />
<ClInclude Include="..\..\common\base_record.h" />
<ClInclude Include="..\..\common\protocol_interface.h" />
<ClInclude Include="..\..\common\ts_const.h" />
<ClInclude Include="..\..\common\ts_membuf.h" />
<ClInclude Include="ssh_proxy.h" />
<ClInclude Include="ssh_recorder.h" />
<ClInclude Include="ssh_session.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="tpp_env.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\common\libex\src\ex_ini.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_log.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_path.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_str.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_thread.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_util.cpp" />
<ClCompile Include="..\..\..\..\common\libex\src\ex_winsrv.cpp" />
<ClCompile Include="..\..\common\base_env.cpp" />
<ClCompile Include="..\..\common\base_record.cpp" />
<ClCompile Include="..\..\common\ts_membuf.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ssh_proxy.cpp" />
<ClCompile Include="ssh_recorder.cpp" />
<ClCompile Include="ssh_session.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="tpp_env.cpp" />
<ClCompile Include="tpssh.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

Binary file not shown.

View File

@ -1,6 +1,6 @@
#ifndef __TS_SERVER_VER_H__
#define __TS_SERVER_VER_H__
#define TP_SERVER_VER L"2.1.2.1"
#define TP_SERVER_VER L"2.2.5.1"
#endif // __TS_SERVER_VER_H__

View File

@ -11,7 +11,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="py" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="py34" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">

View File

@ -57,7 +57,8 @@ class TPDatabase:
return False
# 看看数据库中是否存在指定的数据表(如果不存在,可能是一个空数据库文件),则可能是一个新安装的系统
ret = self.is_table_exists('{}group'.format(self._table_prefix))
# ret = self.query('SELECT COUNT(*) FROM `sqlite_master` WHERE `type`="table" AND `name`="{}account";'.format(self._table_prefix))
ret = self.is_table_exists('{}group'.format(self._table_prefix))
if ret is None or not ret:
log.w('database need create.\n')
self.need_create = True
@ -75,9 +76,9 @@ class TPDatabase:
self.need_upgrade = True
return True
# DO TEST
# self.alter_table('ts_account', [['account_id', 'id'], ['account_type', 'type']])
# DO TEST
# self.alter_table('ts_account', [['account_id', 'id'], ['account_type', 'type']])
return True
def is_table_exists(self, table_name):
@ -158,49 +159,49 @@ class TPDatabase:
log.w('nothing to do.\n')
return False
if isinstance(table_names, str):
old_table_name = table_names
new_table_name = table_names
elif isinstance(table_names, list) and len(table_names) == 2:
old_table_name = table_names[0]
new_table_name = table_names[1]
else:
log.w('invalid param.\n')
return False
if isinstance(field_names, list):
for i in field_names:
if not isinstance(i, list) or 2 != len(i):
log.w('invalid param.\n')
return False
if field_names is None:
# 仅数据表改名
return self.exec('ALTER TABLE `{}` RENAME TO `{}`;'.format(old_table_name, new_table_name))
else:
# sqlite不支持字段改名所以需要通过临时表中转一下
# 先获取数据表的字段名列表
ret = self.query('SELECT * FROM `sqlite_master` WHERE `type`="table" AND `name`="{}";'.format(old_table_name))
log.w('-----\n')
log.w(ret[0][4])
log.w('\n')
# 先将数据表改名,成为一个临时表
# tmp_table_name = '{}_sqlite_tmp'.format(old_table_name)
# ret = self.exec('ALTER TABLE `{}` RENAME TO `{}`;'.format(old_table_name, tmp_table_name))
# if ret is None or not ret:
# return ret
pass
elif self.db_source['type'] == self.DB_TYPE_MYSQL:
log.e('mysql not supported yet.\n')
return False
else:
log.e('Unknown database type.\n')
return False
if isinstance(table_names, str):
old_table_name = table_names
new_table_name = table_names
elif isinstance(table_names, list) and len(table_names) == 2:
old_table_name = table_names[0]
new_table_name = table_names[1]
else:
log.w('invalid param.\n')
return False
if isinstance(field_names, list):
for i in field_names:
if not isinstance(i, list) or 2 != len(i):
log.w('invalid param.\n')
return False
if field_names is None:
# 仅数据表改名
return self.exec('ALTER TABLE `{}` RENAME TO `{}`;'.format(old_table_name, new_table_name))
else:
# sqlite不支持字段改名所以需要通过临时表中转一下
# 先获取数据表的字段名列表
ret = self.query('SELECT * FROM `sqlite_master` WHERE `type`="table" AND `name`="{}";'.format(old_table_name))
log.w('-----\n')
log.w(ret[0][4])
log.w('\n')
# 先将数据表改名,成为一个临时表
# tmp_table_name = '{}_sqlite_tmp'.format(old_table_name)
# ret = self.exec('ALTER TABLE `{}` RENAME TO `{}`;'.format(old_table_name, tmp_table_name))
# if ret is None or not ret:
# return ret
pass
elif self.db_source['type'] == self.DB_TYPE_MYSQL:
log.e('mysql not supported yet.\n')
return False
else:
log.e('Unknown database type.\n')
return False
class TPDatabasePool:
def __init__(self):
self._locker = threading.RLock()

View File

@ -53,7 +53,8 @@ controllers = [
# add another path to static-path
# todo: 重放数据路径是动态从core服务的json-rpc接口获取的因此这里的数据获取方式需要改变
(r"/log/replay/(.*)", tornado.web.StaticFileHandler, {"path": os.path.join(cfg.data_path, 'replay')}),
#(r"/log/replay/(.*)", tornado.web.StaticFileHandler, {"path": os.path.join(cfg.data_path, 'replay')}),
(r"/log/replay/(.*)", record.ReplayStaticFileHandler, {"path": os.path.join(cfg.data_path, 'replay')}),
(r'/log/list', record.LogList),
(r'/log/record/(.*)/(.*)', record.RecordHandler),
@ -113,6 +114,8 @@ controllers = [
(r'/set/', set.IndexHandler),
(r'/set', set.IndexHandler),
# 通过访问一个特殊URL来停止WEB服务仅用于开发阶段生产系统中请删除下一行
(r'/EXIT-4E581FEFD7AB497D833D71A51C61D898', index.ExitHandler),
(r'/uidesign', index.UIDesignHandler),
(r'/uidesign/without-sidebar', index.UIDesignWithoutSidebarHandler),
(r'/uidesign/table', index.UIDesignTableHandler)
]

View File

@ -58,12 +58,14 @@ class VerifyUser(TPBaseJsonHandler):
return
try:
user_id, account_type, nickname = user.verify_user(username, userpwd)
user_id, account_type, nickname, locked = user.verify_user(username, userpwd)
if locked == 1:
return self.write_json(-1, '账号被锁定,请联系管理员!')
if user_id == 0:
if cfg.app_mode == APP_MODE_MAINTENANCE:
self.write_json(-2, '系统维护中,请稍候再试')
self.write_json(-2, '系统维护中,请稍候再试')
else:
self.write_json(-1, '用户名/密码错误')
self.write_json(-1, '用户名/密码错误')
return
_user = self.get_session('user')
@ -92,7 +94,7 @@ class VerifyUser(TPBaseJsonHandler):
except:
log.e('can not set session.')
self.write_json(-1, '无法记录用户登录状态')
self.write_json(-1, '无法记录用户登录状态')
class LogoutHandler(TPBaseUserAuthHandler):

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,30 @@
# -*- coding: utf-8 -*-
import sys
import tornado.ioloop
from .base import TPBaseHandler, TPBaseUserAuthHandler
class IndexHandler(TPBaseUserAuthHandler):
def get(self):
self.redirect('/host')
class ExitHandler(TPBaseHandler):
def get(self):
self.write('exit ok')
tornado.ioloop.IOLoop.instance().stop()
# -*- coding: utf-8 -*-
import sys
import tornado.ioloop
from .base import TPBaseHandler, TPBaseUserAuthHandler
class IndexHandler(TPBaseUserAuthHandler):
def get(self):
self.redirect('/host')
class ExitHandler(TPBaseHandler):
def get(self):
self.write('exit ok')
tornado.ioloop.IOLoop.instance().stop()
class UIDesignHandler(TPBaseHandler):
def get(self):
self.render('uidesign/index.mako')
class UIDesignWithoutSidebarHandler(TPBaseHandler):
def get(self):
self.render('uidesign/without-sidebar.mako')
class UIDesignTableHandler(TPBaseHandler):
def get(self):
self.render('uidesign/table.mako')

View File

@ -9,6 +9,7 @@ from eom_app.app.configs import app_cfg
from eom_app.module import record
from eom_app.module import user
from .base import TPBaseAdminAuthHandler, TPBaseAdminAuthJsonHandler
import tornado.web
def get_free_space_bytes(folder):
@ -61,6 +62,12 @@ class RecordHandler(TPBaseAdminAuthHandler):
# # pass
# filename = os.path.join(cfg.core.replay_path, 'replay', 'rdp', '{}'.format(record_id), 'tp-rdp.tpr')
class ReplayStaticFileHandler(tornado.web.StaticFileHandler):
def initialize(self, path, default_filename=None):
super().initialize(path, default_filename)
self.root = app_cfg().core.replay_path
# self.default_filename = default_filename
class ComandLogHandler(TPBaseAdminAuthHandler):
def get(self, protocol, record_id):

View File

@ -414,7 +414,7 @@ def add_cert(cert_pub, cert_pri, cert_name):
def delete_cert(cert_id):
db = get_db()
sql = 'DELETE FROM `{}key` WHERE `cert_id`={};'.format(int(cert_id))
sql = 'DELETE FROM `{}key` WHERE `cert_id`={};'.format(db.table_prefix, int(cert_id))
return db.exec(sql)

View File

@ -19,8 +19,12 @@ def read_record_head(record_id):
data = file.read()
offset = 0
magic, = struct.unpack_from('I', data, offset) # magic must be 1381126228, 'TPRR'
magic, = struct.unpack_from('I', data, offset) # magic must be 1381126228, 'TPPR'
offset += 4
ver, = struct.unpack_from('H', data, offset)
offset += 2
protocol, = struct.unpack_from('H', data, offset)
offset += 2
time_start, = struct.unpack_from('Q', data, offset)
offset += 8
pkg_count, = struct.unpack_from('I', data, offset)
@ -42,6 +46,11 @@ def read_record_head(record_id):
user_name, = struct.unpack_from('16s', data, offset)
user_name = user_name.decode()
offset += 16
ip, = struct.unpack_from('18s', data, offset)
ip = ip.decode()
offset += 18
port, = struct.unpack_from('H', data, offset)
offset += 2
except Exception as e:
return None
@ -50,81 +59,19 @@ def read_record_head(record_id):
file.close()
header = dict()
header['start'] = time_start
header['file_count'] = file_count
header['time_used'] = time_used
header['width'] = width
header['height'] = height
header['account'] = account
header['user_name'] = user_name
header['ip'] = ip
header['port'] = port
return header
# def read_record_term(record_id):
# record_path = os.path.join(cfg.core.replay_path, 'ssh', '{}'.format(record_id))
# term_file_path = os.path.join(record_path, 'term.init')
# # term_file_path = r"E:\GitWork\teleport\share\data\replay\ssh\103\term.init"
#
# file = None
# try:
# file = open(term_file_path, 'rb')
# data = file.read()
# x = len(data)
# offset = 0
# # data = data.decode()
# ID, = struct.unpack_from('16s', data, offset)
# ID = ID.decode()
# offset += 16
#
# Version, = struct.unpack_from('16s', data, offset)
# Version = Version.decode()
# offset += 16
#
# t_count, = struct.unpack_from('I', data, offset)
# offset += 4
# term_list = list()
# for i in range(t_count):
# # _term, = struct.unpack_from('16s', data, offset)
# # _term = _term.decode()
# # offset += 16
# _time, = struct.unpack_from('I', data, offset)
# offset += 4
#
# x, = struct.unpack_from('I', data, offset)
# offset += 4
#
# y, = struct.unpack_from('I', data, offset)
# offset += 4
#
# # px, = struct.unpack_from('I', data, offset)
# # offset += 4
# #
# # py, = struct.unpack_from('I', data, offset)
# # offset += 4
# #
# # _time, = struct.unpack_from('I', data, offset)
# # offset += 4
# temp = dict()
# # temp['term'] = _term
# temp['t'] = _time
# temp['w'] = x
# temp['h'] = y
# # temp['px'] = px
# # temp['py'] = py
#
# term_list.append(temp)
#
# except Exception as e:
# return None
# finally:
# if file is not None:
# file.close()
#
# header = dict()
# header['id'] = ID
# header['ver'] = Version
# header['count'] = t_count
# header['term_list'] = term_list
# return header
def read_record_info(record_id, file_id):
record_path = os.path.join(app_cfg().core.replay_path, 'ssh', '{:06d}'.format(int(record_id)))
file_info = os.path.join(record_path, 'tp-ssh.{:03d}'.format(int(file_id)))

View File

@ -12,7 +12,7 @@ def verify_user(name, password):
cfg = app_cfg()
db = get_db()
sql = 'SELECT `account_id`, `account_type`, `account_name`, `account_pwd` FROM `{}account` WHERE `account_name`="{}";'.format(db.table_prefix, name)
sql = 'SELECT `account_id`, `account_type`, `account_name`, `account_pwd`, `account_lock` FROM `{}account` WHERE `account_name`="{}";'.format(db.table_prefix, name)
db_ret = db.query(sql)
if db_ret is None:
# 特别地,如果无法取得数据库连接,有可能是新安装的系统,尚未建立数据库,此时应该处于维护模式
@ -20,25 +20,29 @@ def verify_user(name, password):
if cfg.app_mode == APP_MODE_MAINTENANCE:
if name == 'admin' and password == 'admin':
return 1, 100, 'admin'
return 0, 0, ''
return 0, 0, '', 0
if len(db_ret) != 1:
return 0, 0, ''
return 0, 0, '', 0
user_id = db_ret[0][0]
account_type = db_ret[0][1]
name = db_ret[0][2]
locked = db_ret[0][4]
if locked == 1:
return 0, 0, '', locked
if not sec_verify_password(password, db_ret[0][3]):
# 按新方法验证密码失败,可能是旧版本的密码散列格式,再尝试一下
if db_ret[0][3] != hashlib.sha256(password.encode()).hexdigest():
return 0, 0, ''
return 0, 0, '', locked
else:
# 发现此用户的密码散列格式还是旧的,更新成新的吧!
_new_sec_password = sec_generate_password(password)
sql = 'UPDATE `{}account` SET `account_pwd`="{}" WHERE `account_id`={}'.format(db.table_prefix, _new_sec_password, int(user_id))
db.exec(sql)
return user_id, account_type, name
return user_id, account_type, name, locked
def modify_pwd(old_pwd, new_pwd, user_id):

View File

@ -1,4 +1,4 @@
# -*- coding: utf8 -*-
TS_VER = "2.1.2.1"
TP_ASSIST_LAST_VER = "2.1.2.1"
TS_VER = "2.2.5.1"
TP_ASSIST_LAST_VER = "2.2.5.1"
TP_ASSIST_REQUIRE = "2.0.0.1"

View File

@ -1 +1 @@
@charset "utf-8";body{padding-top:70px;padding-bottom:24px;background-color:#ececed}#head nav.navbar{height:70px;line-height:70px;background-color:#333;color:#fff}#head .logo .desc{display:block;float:right;color:#ccc;margin-top:10px;font-size:18px}#foot nav.navbar{min-height:24px;height:24px;line-height:24px;background-color:#ddd;color:#fff;font-size:12px;border-top:1px solid #ccc}#foot nav.navbar .container{height:24px}#foot nav.navbar p{margin:0 auto;text-align:center;color:#333}#content{margin:10px 0 50px 0}.auth-box{margin-top:30px;min-height:120px;border:1px solid #ccc;border-radius:8px;background-color:rgba(255,255,255,0.6)}.auth-box .header{min-height:50px;height:50px;border:none;box-shadow:none;border-bottom:1px solid #ccc}.auth-box .header .title{display:inline-block;float:left;margin-left:60px;height:24px;margin-top:25px;line-height:16px;font-size:20px;color:#999}.auth-box .header .selected{border-bottom:1px solid #69c;color:#555}.auth-box .header .title:hover{border-bottom:1px solid #999}.auth-box .inputarea{margin:30px}.auth-box .inputarea .input-group-addon{padding:0 5px 0 5px}.auth-box .inputarea p.input-addon-desc{text-align:right;padding:0 5px 0 5px;color:#999}#leftside{width:560px;height:560px;padding-top:60px;background:url(../img/login/side-001.jpg) 0 0 no-repeat}#leftside h1{font-size:24px;color:#888}#leftside p{font-size:18px;color:#888;padding-left:24px}.auth-box .inputbox{margin-bottom:10px}.auth-box-lg .inputbox{margin-bottom:20px}.auth-box .op_box{display:block;padding:5px;border-radius:3px;text-align:center;margin:5px 20px 10px 20px}.auth-box .op_error{background:#fbb}.auth-box .op_wait{background:#ccc}.auth-box .quick-area{padding:80px 0 80px 0}.auth-box .quick-area .quick-disc{text-align:center;margin-bottom:20px}.auth-box .quick-area .quick-no{padding-top:80px;padding-bottom:100px}.auth-box .quick-area .quick-yes{text-align:center}.auth-box .quick-area .quick-yes .quick-account{display:inline-block;margin:auto;margin-bottom:20px}.auth-box .quick-area .quick-yes .quick-account:hover .quick-image{box-shadow:0 0 8px #00c2f6}.auth-box .quick-area .quick-yes .quick-image{display:block;width:82px;height:82px;line-height:80px;font-size:64px;margin:auto;border:1px solid #a4cdf6;box-shadow:0 0 6px #a7d1fb}.auth-box .quick-area .quick-yes .quick-name{display:block;margin-top:5px}
@charset "utf-8";body{padding-top:70px;padding-bottom:24px;background-color:#ececed}#head nav.navbar{height:70px;line-height:70px;background-color:#333;color:#fff}#head .logo .desc{display:block;float:right;color:#ccc;margin-top:10px;font-size:18px}#foot nav.navbar{min-height:24px;height:24px;line-height:24px;background-color:#ddd;color:#fff;font-size:12px;border-top:1px solid #ccc}#foot nav.navbar .container{height:24px}#foot nav.navbar p{margin:0 auto;text-align:center;color:#333}#content{margin:10px 0 50px 0}.auth-box{margin-top:30px;min-height:120px;border:1px solid #ccc;border-radius:8px;background-color:rgba(255,255,255,0.6)}.auth-box .header{min-height:50px;height:50px;border:none;box-shadow:none;border-bottom:1px solid #ccc}.auth-box .header .title{display:inline-block;float:left;margin-left:60px;height:24px;margin-top:25px;line-height:16px;font-size:20px;color:#999}.auth-box .header .selected{border-bottom:1px solid #69c;color:#555}.auth-box .header .title:hover{border-bottom:1px solid #999}.auth-box .inputarea{margin:30px}.auth-box .inputarea .input-group-addon{padding:0 5px 0 5px}.auth-box .inputarea p.input-addon-desc{text-align:right;padding:0 5px 0 5px;color:#999}#leftside{width:560px;height:560px;padding-top:60px;background:url(../img/login/side-001.jpg) 0 0 no-repeat}@media screen and (max-width:990px){#leftside{display:none}}#leftside h1{font-size:24px;color:#888}#leftside p{font-size:18px;color:#888;padding-left:24px}.auth-box .inputbox{margin-bottom:10px}.auth-box-lg .inputbox{margin-bottom:20px}.auth-box .op_box{display:block;padding:5px;border-radius:3px;text-align:center;margin:5px 20px 10px 20px}.auth-box .op_error{background:#fbb}.auth-box .op_wait{background:#ccc}.auth-box .quick-area{padding:80px 0 80px 0}.auth-box .quick-area .quick-disc{text-align:center;margin-bottom:20px}.auth-box .quick-area .quick-no{padding-top:80px;padding-bottom:100px}.auth-box .quick-area .quick-yes{text-align:center}.auth-box .quick-area .quick-yes .quick-account{display:inline-block;margin:auto;margin-bottom:20px}.auth-box .quick-area .quick-yes .quick-account:hover .quick-image{box-shadow:0 0 8px #00c2f6}.auth-box .quick-area .quick-yes .quick-image{display:block;width:82px;height:82px;line-height:80px;font-size:64px;margin:auto;border:1px solid #a4cdf6;box-shadow:0 0 6px #a7d1fb}.auth-box .quick-area .quick-yes .quick-name{display:block;margin-top:5px}

File diff suppressed because it is too large Load Diff

View File

@ -522,10 +522,10 @@ ywl.on_user_host_table_created = function (tbl) {
ywl.ajax_post_json('/user/delete-host', {host_list: host_list, user_name: ywl.page_options.user_name},
function (ret) {
tbl.remove_row(row_id);
ywl.notify_success('删除用户拥有主机成功');
ywl.notify_success('回收授权成功!');
},
function () {
ywl.notify_error('删除用户拥有主机失败');
ywl.notify_error('回收授权失败!');
}
);
};

View File

@ -25,23 +25,23 @@ ywl.create_app = function () {
$('#captcha_image').click(function () {
$(this).attr('src', '/auth/get-captcha?' + Math.random());
$('#captcha').focus();
$('#captcha').focus().val('');
});
$('#username_account').keydown(function (event) {
$('[data-toggle="popover"]').popover('hide');
if (event.which == 13) {
if (event.which === 13) {
$('#password_account').focus();
}
});
$('#password_account').keydown(function (event) {
$('[data-toggle="popover"]').popover('hide');
if (event.which == 13) {
if (event.which === 13) {
$('#captcha').focus();
}
});
$('#captcha').keydown(function (event) {
$('[data-toggle="popover"]').popover('hide');
if (event.which == 13) {
if (event.which === 13) {
_app.login_account();
}
});
@ -64,7 +64,6 @@ ywl.create_app = function () {
str_password = dom_password.val();
str_captcha = dom_captcha.val();
is_remember = dom_remember.is(':checked');
console.log('xxxx', is_remember);
if (str_username.length === 0) {
show_op_box('error', '缺少账号!');
@ -92,7 +91,7 @@ ywl.create_app = function () {
// 先判断一下captcha是否正确如果不正确拒绝登录
ywl.ajax_post_json('/auth/verify-captcha', {captcha: str_captcha},
function (ret) {
if (ret.code === 0) {
if (ret.code === TPE_OK) {
// 验证成功
hide_op_box();
show_op_box('wait', '<i class="fa fa-circle-o-notch fa-spin"></i> 正在登录TELEPORT请稍候...');
@ -116,14 +115,11 @@ ywl.create_app = function () {
};
_app.do_account_login = function (username, userpwd, captcha, is_remember) {
console.log('remember', is_remember);
ywl.ajax_post_json('/auth/verify-user', {username: username, userpwd: userpwd, captcha: captcha, remember: is_remember},
function (ret) {
if (ret.code == 0) {
// 验证成功
if (ret.code === TPE_OK) {
window.location.href = ywl.page_options.ref;
}
else {
} else {
hide_op_box();
show_op_box('error', '无法登录TELEPORT' + ret.message);
console.log(ret);
@ -137,31 +133,6 @@ ywl.create_app = function () {
$('#btn_login').removeAttr('disabled');
}
);
// $.ajax({
// type: 'GET',
// url: '/auth/verify-user',
// jsonp: "callback",
// data: {username: username, userpwd: userpwd, captcha: captcha},
// dataType: 'jsonp',
// success: function (data) {
// if (data.code == 0) {
// // 验证成功
// window.location.href = ywl.page_options.ref;
// }
// else {
// hide_op_box();
// show_op_box('error', '无法登录TELEPORT');
// }
//
// $('#btn_login').removeAttr('disabled');
// },
// error: function () {
// hide_op_box();
// show_op_box('error', '很抱歉,无法连接服务器!请稍后再试一次!');
// $('#btn_login').removeAttr('disabled');
// }
// });
};
return _app;

View File

@ -1,7 +1,7 @@
/**
* Created by mi on 2016/7/4.
*/
"use strict";
var g_cert_dlg_info = null;
ywl.on_init = function (cb_stack, cb_args) {
var dom_id = '#ywl_cert_list';
@ -71,7 +71,7 @@ ywl.on_init = function (cb_stack, cb_args) {
ywl.on_host_table_created = function (tbl) {
tbl.on_cell_created = function (row_id, col_key, cell_obj) {
if (col_key == 'action') {
if (col_key === 'action') {
var row_data = tbl.get_row(row_id);
//console.log('row_data', row_data);
$(cell_obj).find('[ywl-btn-edit]').click(function () {
@ -82,18 +82,18 @@ ywl.on_host_table_created = function (tbl) {
var _fn_sure = function (cb_stack, cb_args) {
ywl.ajax_post_json('/host/delete-cert', {cert_id: cert_id},
function (ret) {
if (ret.code == 0) {
if (ret.code === TPE_OK) {
tbl.remove_row(row_id);
ywl.notify_success('删除成功!');
} else if (ret.code == -2) {
} else if (ret.code === -2) {
ywl.notify_error('不能删除,有主机使用了此密钥!');
} else {
ywl.notify_error('删除失败!');
ywl.notify_error('删除失败!错误代码:'+ret.code);
}
},
function (ret) {
ywl.notify_error('删除失败');
function () {
ywl.notify_error('网络通讯失败!');
}
);
};
@ -189,7 +189,7 @@ ywl.create_cert_info_dlg = function (tbl) {
ywl.notify_error('必须填写公钥内容!');
return false;
}
if (cert_info_dlg.update == 0 && cert_info_dlg.cert_pri.length == 0) {
if (cert_info_dlg.update === 0 && cert_info_dlg.cert_pri.length === 0) {
ywl.notify_error('添加密钥时,必须填写私钥内容!');
return false;
}
@ -197,7 +197,7 @@ ywl.create_cert_info_dlg = function (tbl) {
};
cert_info_dlg.post = function () {
if (cert_info_dlg.update == 1) {
if (cert_info_dlg.update === 1) {
ywl.ajax_post_json('/host/update-cert', {cert_id: cert_info_dlg.cert_id, cert_name: cert_info_dlg.cert_name, cert_pub: cert_info_dlg.cert_pub, cert_pri: cert_info_dlg.cert_pri},
function (ret) {
var update_args = {cert_id: cert_info_dlg.cert_id, cert_name: cert_info_dlg.cert_name};
@ -205,19 +205,19 @@ ywl.create_cert_info_dlg = function (tbl) {
ywl.notify_success('密钥更新成功!');
cert_info_dlg.hide();
},
function (ret) {
function () {
ywl.notify_error('密钥更新失败!');
}
);
} else {
ywl.ajax_post_json('/host/add-cert', {cert_name: cert_info_dlg.cert_name, cert_pub: cert_info_dlg.cert_pub, cert_pri: cert_info_dlg.cert_pri},
function (ret) {
if(ret.code == 0){
if(ret.code === TPE_OK){
cert_info_dlg.tbl.reload();
ywl.notify_success('密钥添加成功!');
cert_info_dlg.hide();
}else if(ret.code == -2){
ywl.notify_error('错误,没有启动核心服务!');
}else if(ret.code === TPE_NO_CORE_SERVER){
ywl.notify_error('错误没有启动核心服务!');
}else{
ywl.notify_error('密钥添加失败code:' + ret.code);
}

View File

@ -68,9 +68,9 @@ function get_system_group_by_id(gid) {
}
function get_command_name_by_id(cmd_id) {
return ywl.assist.get_cache_by_id(CACHE_TYPE_COMMAND, cmd_id);
}
//function get_command_name_by_id(cmd_id) {
// return ywl.assist.get_cache_by_id(CACHE_TYPE_COMMAND, cmd_id);
//}
//function notify_error(message_, title_) {
// var _title = title_ || '';

View File

@ -1,13 +1,13 @@
"use strict";
var OS_TYPE_WINDOWS = 1;
var OS_TYPE_LINUX = 2;
var PROTOCOL_TYPE_RDP = 1;
var PROTOCOL_TYPE_SSH = 2;
var PROTOCOL_TYPE_TELNET = 3;
var AUTH_TYPE_PASSWORD = 1;
var AUTH_TYPE_SSHKEY = 2;
var AUTH_NONE = 0;
//var OS_TYPE_WINDOWS = 1;
//var OS_TYPE_LINUX = 2;
//var PROTOCOL_TYPE_RDP = 1;
//var PROTOCOL_TYPE_SSH = 2;
//var PROTOCOL_TYPE_TELNET = 3;
//var AUTH_TYPE_PASSWORD = 1;
//var AUTH_TYPE_SSHKEY = 2;
//var AUTH_NONE = 0;
var g_assist = null;

View File

@ -1003,20 +1003,20 @@ ywl.create_table_render = function (tbl, on_created) {
return ret;
};
_tbl_render.host_status = function (row_id, fields) {
if (fields.status == HOST_STAT_ACTIVE) {
switch (fields.online) {
case AGENT_STAT_ONLINE:
return '<span class="badge badge-success">在线</span>';
case AGENT_STAT_OFFLINE:
return '<span class="badge badge-danger">离线</span>';
default:
return '<span class="badge badge-warning">未知</span>';
}
} else {
return '<span class="badge badge-ignore">- 未使用 -</span>';
}
};
// _tbl_render.host_status = function (row_id, fields) {
// if (fields.status == HOST_STAT_ACTIVE) {
// switch (fields.online) {
// case AGENT_STAT_ONLINE:
// return '<span class="badge badge-success">在线</span>';
// case AGENT_STAT_OFFLINE:
// return '<span class="badge badge-danger">离线</span>';
// default:
// return '<span class="badge badge-warning">未知</span>';
// }
// } else {
// return '<span class="badge badge-ignore">- 未使用 -</span>';
// }
// };
_tbl_render.sys_type = function (row_id, fields) {
switch (fields.sys_type) {

View File

@ -173,9 +173,9 @@ 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 tail = 'log/replay/rdp/' + prefixInteger(row_data.id, 6);
var args = {};
args.id = parseInt(row_data.id);
args.host = ip;

View File

@ -41,7 +41,7 @@ var speed_offset = 0;
ywl.req_record_info = function (record_id, file_id, repeat) {
ywl.ajax_post_json_time_out('/log/get-record-file-info', {id: record_id, file_id: file_id}, 30 * 1000,
function (ret) {
if (ret.code == 0) {
if (ret.code === TPE_OK) {
g_data[file_id] = ret.data;
if ((g_down_play_file_id + 1) <= g_total_file_count) {
@ -49,9 +49,7 @@ ywl.req_record_info = function (record_id, file_id, repeat) {
ywl.req_record_info(record_id, g_down_play_file_id, true);
g_down_play_file_id++;
}
}
//console.log('req_record_info successful');
} else {
console.log('req_record_info error ', ret.code);
}
@ -77,11 +75,13 @@ ywl.on_init = function (cb_stack, cb_args) {
ywl.ajax_post_json('/log/get-record-header', {id: record_id},
function (ret) {
if (ret.code == 0) {
if (ret.code === TPE_OK) {
g_header = ret.data.header;
g_total_file_count = g_header.file_count;
g_total_time = g_header.time_used;
$('#recorder-info').html(g_header.account + ' 于 ' + format_datetime(g_header.start) + ' 访问 ' + g_header.user_name + '@' + g_header.ip + ':' + g_header.port);
// 请求第一个录像数据块
g_down_play_file_id = 0;
ywl.req_record_info(record_id, g_down_play_file_id, true);

View File

@ -7,19 +7,18 @@ var g_current_version = "";
var g_host_name = window.location.hostname;
var error_process = function (ret, func_success, func_error) {
// console.log("ret", ret);
var code = ret.code;
if (code == TPE_OK) {
if (code === TPE_OK) {
func_success(ret);
return;
}
if (code == TPE_START_CLIENT) {
if (code === TPE_START_CLIENT) {
func_error(TPE_START_CLIENT, '启动本地客户端进程失败,请检查命令行是否正确:' + ret.path);
console.log('启动本地进程失败,命令行:', ret.path);
} else if (code == TPE_JSON_FORMAT || code == TPE_PARAM) {
} else if (code === TPE_JSON_FORMAT || code === TPE_PARAM) {
func_error(TPE_START_CLIENT, "启动本地客户端进程失败:启动参数错误!");
} else if (code == TPE_OLD_ASSIST) {
} else if (code === TPE_OLD_ASSIST) {
func_error(TPE_OLD_ASSIST, '助手版本太低,请下载最新版本!');
}
else {
@ -47,7 +46,7 @@ var teleport_init = function (last_version, req_version, func_success, func_erro
func_error(ret, TPE_OLD_ASSIST, '助手版本太低,请<a style="color:#aaaaff;" target="_blank" href="http://teleport.eomsoft.net/download">下载最新版本</a>');
}
},
error: function (jqXhr) {
error: function () {
func_error({}, TPE_NO_ASSIST, '无法连接到teleport助手可能尚未启动');
}
});
@ -60,7 +59,6 @@ var version_compare = function () {
};
var to_teleport = function (url, args, func_success, func_error) {
var auth_id = args['auth_id'];
// 开始Ajax调用
var args_ = JSON.stringify({auth_id: auth_id});
@ -94,7 +92,7 @@ var to_teleport = function (url, args, func_success, func_error) {
success: function (ret) {
error_process(ret, func_success, func_error);
},
error: function (jqXhr) {
error: function () {
func_error(TPE_NO_ASSIST, '无法连接到teleport助手可能尚未启动');
}
});
@ -109,7 +107,6 @@ var to_teleport = function (url, args, func_success, func_error) {
};
var to_admin_teleport = function (url, args, func_success, func_error) {
var host_auth_id = args['host_auth_id'];
// 开始Ajax调用
var args_ = JSON.stringify({host_auth_id: host_auth_id});
@ -124,7 +121,7 @@ var to_admin_teleport = function (url, args, func_success, func_error) {
if (ret.code === 0) {
var session_id = ret.data.session_id;
var data = {
server_ip: g_host_name, // args.server_ip,
server_ip: g_host_name,
server_port: parseInt(args.server_port),
host_ip: args.host_ip,
size: parseInt(args.size),
@ -158,7 +155,6 @@ var to_admin_teleport = function (url, args, func_success, func_error) {
};
var to_admin_fast_teleport = function (url, args, func_success, func_error) {
// 开始Ajax调用
var args_ = JSON.stringify(args);
$.ajax({
@ -172,7 +168,7 @@ var to_admin_fast_teleport = function (url, args, func_success, func_error) {
if (ret.code === 0) {
var session_id = ret.data.session_id;
var data = {
server_ip: g_host_name, //args.server_ip,
server_ip: g_host_name,
server_port: parseInt(args.server_port),
host_ip: args.host_ip,
size: parseInt(args.size),
@ -210,7 +206,6 @@ var to_admin_fast_teleport = function (url, args, func_success, func_error) {
};
var start_rdp_replay = function (args, func_success, func_error) {
var args_ = encodeURIComponent(JSON.stringify(args));
$.ajax({
type: 'GET',
@ -227,7 +222,7 @@ var start_rdp_replay = function (args, func_success, func_error) {
console.log('ret', ret);
},
error: function () {
func_error(TPE_NETWORK, '远程网络通讯失败!');
func_error(TPE_NETWORK, '与助手的络通讯失败!');
}
});
};

View File

@ -121,6 +121,10 @@ function digital_precision(num, keep) {
return Math.round(num * Math.pow(10, keep)) / Math.pow(10, keep);
}
function prefixInteger(num, length) {
return (num / Math.pow(10, length)).toFixed(length).substr(2);
}
function size2str(size, precision) {
precision = precision || 0;
var s = 0;

View File

@ -1,12 +1,23 @@
"use strict";
var USER_TYPE_TEAM_MEMBER = 1;
var USER_TYPE_TEAM_LEADER = 9;
var USER_TYPE_SYS_ADMIN = 99;
var PROTOCOL_TYPE_RDP = 1;
var PROTOCOL_TYPE_SSH = 2;
var PROTOCOL_TYPE_TELNET = 3;
var AGENT_STAT_ONLINE = 1;
var AGENT_STAT_OFFLINE = 0;
// var AGENT_STAT_NOT_ACTIVE = 2;
var OS_TYPE_WINDOWS = 1;
var OS_TYPE_LINUX = 2;
var AUTH_TYPE_PASSWORD = 1;
var AUTH_TYPE_SSHKEY = 2;
var AUTH_NONE = 0;
//var USER_TYPE_TEAM_MEMBER = 1;
//var USER_TYPE_TEAM_LEADER = 9;
//var USER_TYPE_SYS_ADMIN = 99;
//var AGENT_STAT_ONLINE = 1;
//var AGENT_STAT_OFFLINE = 0;
//var AGENT_STAT_NOT_ACTIVE = 2;
var HOST_STAT_NOT_ACTIVE = 0;
var HOST_STAT_ACTIVE = 2;
@ -87,6 +98,7 @@ var TPE_DATA = 127; // 数据错误
// #define TPE_OPENFILE_ERROR 0x1007 // 无法打开文件
// #define TPE_GETTEMPPATH_ERROR 0x1007
var TPE_OPENFILE = 300; // 无法打开文件
//-------------------------------------------------------
@ -103,4 +115,52 @@ var TPE_START_CLIENT = 100002; // 无法启动客户端程序(无法创建进
var TPE_NO_CORE_SERVER = 200000; // 未能检测到核心服务
function tp_error_msg(error_code) {
switch (error_code) {
case TPE_FAILED:
return '内部错误';
case TPE_NETWORK:
return '网络错误';
//-------------------------------------------------------
// HTTP请求相关错误
//-------------------------------------------------------
case TPE_HTTP_METHOD:
return '无效/错误的请求方法';
case TPE_HTTP_URL_ENCODE:
return 'URL编码错误无法解码';
case TPE_UNKNOWN_CMD:
return '未知命令';
case TPE_JSON_FORMAT:
return '错误的JSON格式数据';
case TPE_PARAM:
return '参数错误';
case TPE_DATA:
return '数据错误';
case TPE_OPENFILE:
return '无法打开文件';
//-------------------------------------------------------
// 助手程序专用错误值
//-------------------------------------------------------
case TPE_NO_ASSIST:
return '未能检测到助手程序';
case TPE_OLD_ASSIST:
return '助手程序版本太低';
case TPE_START_CLIENT:
return '无法启动客户端程序(无法创建进程)';
//-------------------------------------------------------
// 核心服务专用错误值
//-------------------------------------------------------
case TPE_NO_CORE_SERVER:
return '未能检测到核心服务';
default:
return '未知错误';
}
}

View File

@ -128,6 +128,12 @@ body {
background: url(../img/login/side-001.jpg) 0 0 no-repeat;
}
@media screen and (max-width: 990px) {
#leftside {
display: none;
}
}
#leftside h1 {
font-size: 24px;
color: #888;

View File

@ -55,7 +55,7 @@
<div id="foot">
<nav class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
<p>触维软件旗下产品 | TELEPORT v${eom_ver.TS_VER} | &copy;2015 - 2016 <a href="http://www.eomsoft.net/" target="_blank">触维软件</a>,保留所有权利。</p>
<p>触维软件旗下产品 | TELEPORT v${eom_ver.TS_VER} | &copy;2015 - 2017 <a href="http://www.eomsoft.net/" target="_blank">触维软件</a>,保留所有权利。</p>
</div>
</nav>
</div>

View File

@ -12,7 +12,7 @@
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-server fa-fw"></i> ${self.attr.page_title_}</li>
<li><i class="fa fa-key fa-fw"></i> ${self.attr.page_title_}</li>
</ol>
</%block>

View File

@ -52,27 +52,28 @@
'name': '日志查询',
'icon': 'fa-database',
},
## {
## 'require_type': 1,
## 'id': 'pwd',
## 'link': '/pwd',
## 'name': '密码修改',
## 'icon': 'fa-pencil-square-o',
## },
## {
## 'require_type': 1,
## 'id': 'exit',
## 'link': '/exit',
## 'name': '安全退出',
## 'icon': 'fa-sign-out',
## },
{
'separator': true,
'require_type': 1,
'id': 'assist-config',
'link': 'http://127.0.0.1:50022/config',
'target': '_blank',
'name': '助手配置',
'icon': 'fa-pencil-square-o',
},
{
'require_type': 1,
'id': 'pwd',
'link': '/pwd',
'name': '密码修改',
'icon': 'fa-pencil-square-o',
},
{
'require_type': 1,
'id': 'exit',
'link': '/exit',
'name': '安全退出',
'icon': 'fa-sign-out',
'icon': 'fa-cog',
},
]
%>
@ -103,7 +104,8 @@
<i class="fa fa-caret-right"></i></span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="/auth/logout" id="btn-logout">退出</a></li>
<li><a href="/pwd" id="btn-logout">修改密码</a></li>
<li><a href="/auth/logout" id="btn-logout">安全退出</a></li>
</ul>
</div>
@ -119,6 +121,10 @@
%for menu in _sidebar:
%if menu['require_type'] <= current_user['type']:
%if 'separator' in menu:
<hr style="border:none;border-bottom:1px solid #636363;margin-bottom:0;margin-top:5px;"/>
%endif
%if 'sub' in menu and len(menu['sub']) > 0:
<li id="sidebar_menu_${menu['id']}"><a href="javascript:;"
onclick="ywl._sidebar_toggle_submenu('${menu['id']}');"><i
@ -150,7 +156,7 @@
<hr style="border:none;border-bottom:1px dotted #4a4a4a;margin-bottom:0;"/>
<div style="color:#717171;font-size:90%;margin-top:5px;"><span style="display:inline-block;width:100px;text-align: right">服务端:</span><span class="mono">v${eom_ver.TS_VER}</span></div>
<div style="color:#717171;font-size:90%;margin-top:5px;"><span style="display:inline-block;width:100px;text-align: right">助手:</span><span class="mono" id="tp-assist-version" req-version=${eom_ver.TP_ASSIST_REQUIRE}>v${eom_ver.TP_ASSIST_LAST_VER}</span></div>
<div style="color:#717171;font-size:90%;margin-top:5px;"><span style="display:inline-block;width:100px;text-align: right">当前助手:</span><span class="mono">v${eom_ver.TP_ASSIST_REQUIRE}</span></div>
<hr style="border:none;border-bottom:1px dotted #4a4a4a;margin-bottom:0;margin-top:5px;"/>
</div>
<!-- end sidebar scrollbar -->

View File

@ -12,7 +12,7 @@
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-server fa-fw"></i> ${self.attr.page_title_}</li>
<li><i class="fa fa-object-group fa-fw"></i> ${self.attr.page_title_}</li>
</ol>
</%block>

View File

@ -155,8 +155,8 @@
<label class="col-sm-3 control-label" for="auth-sys-type"><strong>操作系统:</strong></label>
<div class="col-sm-6">
<select id="auth-sys-type" class="form-control">
<option value="2">Linux</option>
<option value="1">Windows</option>
<option value=2>Linux</option>
<option value=1>Windows</option>
</select>
</div>
</div>
@ -173,7 +173,6 @@
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-3 control-label" for="dlg-edit-host-group"><strong>主机分组:</strong></label>
<div class="col-sm-6">
@ -200,110 +199,18 @@
</div>
</div>
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label"><strong>远程访问协议:</strong></label>
## <div class="col-sm-9">
##
## <div class="dlg-protocol-group">
## <ul>
## <li class="item-name"><label><input id="dlg-edit-host-allow-ssh" type="checkbox"> SSH</label></li>
## <li>端口号</li>
## <li class="item-input"><input id="dlg-edit-host-ssh-port" type="text" class="form-control" placeholder="默认端口 22" value="22"></li>
## </ul>
## </div>
##
## <div class="dlg-protocol-group">
## <ul>
## <li class="item-name"><label><input type="checkbox" id="dlg-edit-host-allow-rdp"> RDP</label></li>
## <li>端口号</li>
## <li class="item-input"><input id="dlg-edit-host-rdp-port" type="text" class="form-control" placeholder="默认端口 3389" value="3389"></li>
## </ul>
## </div>
##
## <div class="dlg-protocol-group">
## <ul>
## <li class="item-name"><label><input type="checkbox" id="dlg-edit-host-allow-telnet"> TELNET</label></li>
## <li>端口号</li>
## <li class="item-input"><input id="dlg-edit-host-telnet-port" type="text" class="form-control" placeholder="默认端口 23" value="23"></li>
## </ul>
## </div>
## </div>
## </div>
<hr class="small"/>
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label" for="auth-protocol-type"><strong>远程访问协议:</strong></label>
## <div class="col-sm-6">
## <select id="auth-protocol-type" class="form-control">
## <option value="2">SSH</option>
## <option value="1">RDP (远程桌面协议)</option>
## </select>
## </div>
## </div>
##
## <div class="form-group form-group-sm">
## <label for="auth-host-port" class="col-sm-3 control-label"><strong>远程主机端口:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-port" type="text" class="form-control" value="22"/>
## </div>
## </div>
##
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label" for="auth-auth-type"><strong>认证方式:</strong></label>
## <div class="col-sm-6">
## <select id="auth-auth-type" class="form-control">
## <option value="1">用户名/密码</option>
## <option value="2">SSH密钥</option>
## </select>
## </div>
## </div>
##
## <div class="form-group form-group-sm">
## <label for="auth-host-username" class="col-sm-3 control-label"><strong>用户名:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-username" type="text" class="form-control" value=""/>
## </div>
## </div>
##
## <div id="auth-block-pswd">
## <div class="form-group form-group-sm">
## <label for="auth-host-pswd" class="col-sm-3 control-label"><strong>密码:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-pswd" type="password" class="form-control" placeholder="不填写则使用已存储的密码"/>
## </div>
## </div>
## <div class="form-group form-group-sm">
## <label for="auth-host-pswd-confirm" class="col-sm-3 control-label"><strong>确认密码:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-pswd-confirm" type="password" class="form-control" placeholder="请再次输入密码"/>
## </div>
## </div>
## </div>
##
##
## <div id="auth-block-sshkey" style="display: none;">
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label" for="auth-sshkey-list"><strong>SSH密钥</strong></label>
## <div class="col-sm-6">
## <select id="auth-sshkey-list" class="form-control"></select>
## </div>
## </div>
## </div>
</div>
</div>
<div class="modal-footer">
## <button type="button" class="btn btn-sm btn-success" id="test-btn-connect"><i class="fa fa-check fa-fw"></i> 测试连接</button>
<button type="button" class="btn btn-sm btn-primary" id="host-btn-save"><i class="fa fa-check fa-fw"></i> 保存主机信息</button>
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal"><i class="fa fa-close fa-fw"></i> 取消</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="dialog-host-user-edit" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -314,133 +221,18 @@
<div class="form-horizontal">
<div class="form-group form-group">
<label class="col-sm-2 control-label" for="auth-protocol-type"><strong>登录账号:</strong></label>
<div class="col-sm-10" id="sys-user-list">
## <div class="remote-action-group">
## <ul>
## <li class="remote-action-name"></li>
## <li class="remote-action-protocol">Telnet</li>
## <li class="remote-action-noauth">无需认证</li>
## <li class="remote-action-btn">
## <button type="button" class="btn btn-sm btn-primary disabled" disabled data-action="remote" data-sub-protocol="1"><i class="fa fa-edit fa-fw"></i> 修改</button>
## </li>
## <li class="remote-action-btn">
## <button type="button" class="btn btn-sm btn-danger" data-action="remote" data-sub-protocol="2"><i class="fa fa-trash-o fa-fw"></i> 删除</button>
## </li>
## </ul>
## </div>
## <div class="remote-action-group">
## <ul>
## <li class="remote-action-name">root</li>
## <li class="remote-action-protocol">SSH</li>
## <li class="remote-action-sshkey">私钥认证</li>
## ## <li class="remote-action-btn"><button type="button" class="btn btn-sm btn-success" data-action="remote" data-sub-protocol="1"><i class="fa fa-flash fa-fw"></i> 测试</button></li>
##
## <li class="remote-action-btn">
## <button type="button" class="btn btn-sm btn-primary" data-action="remote" data-sub-protocol="1"><i class="fa fa-edit fa-fw"></i> 修改</button>
## </li>
## <li class="remote-action-btn">
## <button type="button" class="btn btn-sm btn-danger" data-action="remote" data-sub-protocol="2"><i class="fa fa-trash-o fa-fw"></i> 删除</button>
## </li>
## </ul>
## </div>
## <div class="remote-action-group">
## <ul>
## <li class="remote-action-name">tester</li>
## <li class="remote-action-protocol">SSH</li>
## <li class="remote-action-password">密码认证</li>
## ## <li class="remote-action-btn"><button type="button" class="btn btn-sm btn-success" data-action="remote" data-sub-protocol="1"><i class="fa fa-flash fa-fw"></i> 测试</button></li>
##
## <li class="remote-action-btn">
## <button type="button" class="btn btn-sm btn-primary" data-action="remote" data-sub-protocol="1"><i class="fa fa-edit fa-fw"></i> 修改</button>
## </li>
## <li class="remote-action-btn">
## <button type="button" class="btn btn-sm btn-danger" data-action="remote" data-sub-protocol="2"><i class="fa fa-trash-o fa-fw"></i> 删除</button>
## </li>
## </ul>
## </div>
## <button type="button" class="btn btn-sm btn-primary" id="btn-add-user"><i class="fa fa-plus fa-fw"></i> 添加登录账号</button>
</div>
<div class="col-sm-10" id="sys-user-list"></div>
</div>
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label" for="auth-protocol-type"><strong>远程访问协议:</strong></label>
## <div class="col-sm-6">
## <select id="auth-protocol-type" class="form-control">
## <option value="2">SSH</option>
## <option value="1">RDP (远程桌面协议)</option>
## </select>
## </div>
## </div>
##
## <div class="form-group form-group-sm">
## <label for="auth-host-port" class="col-sm-3 control-label"><strong>远程主机端口:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-port" type="text" class="form-control" value="22"/>
## </div>
## </div>
##
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label" for="auth-auth-type"><strong>认证方式:</strong></label>
## <div class="col-sm-6">
## <select id="auth-auth-type" class="form-control">
## <option value="1">用户名/密码</option>
## <option value="2">SSH密钥</option>
## </select>
## </div>
## </div>
##
## <div class="form-group form-group-sm">
## <label for="auth-host-username" class="col-sm-3 control-label"><strong>用户名:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-username" type="text" class="form-control" value=""/>
## </div>
## </div>
##
## <div id="auth-block-pswd">
## <div class="form-group form-group-sm">
## <label for="auth-host-pswd" class="col-sm-3 control-label"><strong>密码:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-pswd" type="password" class="form-control" placeholder="不填写则使用已存储的密码"/>
## </div>
## </div>
## <div class="form-group form-group-sm">
## <label for="auth-host-pswd-confirm" class="col-sm-3 control-label"><strong>确认密码:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-pswd-confirm" type="password" class="form-control" placeholder="请再次输入密码"/>
## </div>
## </div>
## </div>
##
##
## <div id="auth-block-sshkey" style="display: none;">
## <div class="form-group form-group-sm">
## <label class="col-sm-3 control-label" for="auth-sshkey-list"><strong>SSH密钥</strong></label>
## <div class="col-sm-6">
## <select id="auth-sshkey-list" class="form-control"></select>
## </div>
## </div>
## </div>
</div>
</div>
<div class="modal-footer">
## <button type="button" class="btn btn-sm btn-success" id="test-btn-connect"><i class="fa fa-check fa-fw"></i> 测试连接</button>
<button type="button" class="btn btn-sm btn-primary" id="host-user-btn-save"><i class="fa fa-check fa-fw"></i> 确定</button>
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal"><i class="fa fa-close fa-fw"></i> 取消</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="dialog_user" tabindex="-1" role="dialog">
<div class="modal-dialog" style="width:460px;top:80px;">
<div class="modal-content">
@ -464,13 +256,6 @@
</div>
</div>
## <div class="form-group form-group-sm">
## <label for="auth-host-port" class="col-sm-3 control-label"><strong>远程主机端口:</strong></label>
## <div class="col-sm-6">
## <input id="auth-host-port" type="text" class="form-control" value="22"/>
## </div>
## </div>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="auth-user-type"><strong>认证方式:</strong></label>
<div class="col-sm-6" id="auth-sys-user-type-combox">
@ -530,9 +315,7 @@
</div>
</div>
</div>
</div>
<div class="modal-footer">
@ -594,18 +377,8 @@
</%block>
<%block name="embed_js">
<script type="text/javascript">
## ywl.add_page_options({
## group_list: ${group_list},
## cert_list: ${cert_list},
## ts_server: ${ts_server}
## });
##
## $(document).ready(function () {
## });
ywl.add_page_options(${page_param});
</script>
</%block>

View File

@ -6,13 +6,13 @@
<%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>
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-server fa-fw"></i> ${self.attr.page_title_}</li>
<li><i class="fa fa-database fa-fw"></i> ${self.attr.page_title_}</li>
</ol>
</%block>

View File

@ -11,6 +11,7 @@
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-server"></i> ${self.attr.page_title_}</li>
<li><span id="recorder-info"></span></li>
</ol>
</%block>

View File

@ -1,124 +1,125 @@
<!DOCTYPE html>
<%!
page_title_ = ''
page_menu_ = []
%>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh_CN">
<!--<![endif]-->
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
<title>${self.attr.page_title_}::TELEPORT</title>
<link rel="shortcut icon" href="${ static_url('favicon.png') }">
<link href="${ static_url('plugins/google-cache/open-sans.css') }" rel="stylesheet">
<link href="${ static_url('plugins/bootstrap/css/bootstrap.min.css') }" rel="stylesheet" type="text/css"/>
<link href="${ static_url('plugins/font-awesome/css/font-awesome.min.css') }" rel="stylesheet">
<link href="${ static_url('plugins/gritter/css/jquery.gritter.css') }" rel="stylesheet">
<link href="${ static_url('css/main.css') }" rel="stylesheet" type="text/css"/>
<%block name="extend_css"/>
</head>
<body>
<!-- begin #page-container -->
<div id="page-container" class="page-header-fixed page-sidebar-fixed">
<!-- begin #header -->
<div id="header" class="header navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="brand"><a href="http://teleport.eomsoft.net" target="_blank"><span class="navbar-logo"></span></a></div>
<div class="breadcrumb-container">
<%block name="breadcrumb" />
</div>
## <div style="float:right;padding-top:14px;margin-right: 50px"><a href="/set" id="teleport-server-ip"></a></div>
</div>
</div>
<!-- end #header -->
<!-- begin #sidebar -->
<div id="sidebar" class="sidebar">
<%include file="common/_sidebar_nav_menu.mako" />
</div>
<!-- end #sidebar -->
<!-- begin #content -->
<div id="content" class="content">
${self.body()}
</div>
<!-- end #content -->
</div>
<!-- end #page-container -->
<div class="modal fade" ywl_message_box="dialog-ywl-message-box" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" ywl-title></h4>
</div>
<div class="modal-body" ywl-content style="font-size: 20px">
</div>
<div class="modal-footer">
<input type="hidden" ywl-record-id="" ywl-row-id="">
<button type="button" class="btn btn-success btn-sm" ywl-btn-ok="ok"><i class="glyphicon glyphicon-ok"></i></button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i></button>
</div>
</div>
</div>
</div>
<%block name="extend_content" />
## <script type="text/javascript" src="${ static_url('js/var.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/underscore/underscore.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/jquery/jquery.min.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/jquery/ajaxfileupload.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/bootstrap/js/bootstrap.min.js') }"></script>
<!--[if lt IE 9]>
<script src="${ static_url('plugins/html5shiv/html5shiv.min.js') }"></script>
<![endif]-->
<script type="text/javascript" src="${ static_url('js/json2.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/gritter/js/jquery.gritter.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl_const.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl_common.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl_assist.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ui/common.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ui/controls.js') }"></script>
<%block name="extend_js"/>
<script type="text/javascript">
ywl.add_page_options({
## 有些参数由后台python脚本生成到模板中无法直接生成到js文件中所以必须通过这种方式传递参数到js脚本中。
active_menu: ${self.attr.page_menu_}
});
$(document).ready(function () {
// once page ready, init ywl object.
## var teleport_ip_info = "请核对您的堡垒机IP地址当前为 " + teleport_ip;
## $("#teleport-server-ip").text(teleport_ip_info);
ywl.init();
});
</script>
<%block name="embed_js" />
</body>
<!DOCTYPE html>
<%!
page_title_ = ''
page_menu_ = []
%>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh_CN">
<!--<![endif]-->
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
<title>${self.attr.page_title_}::TELEPORT</title>
<link rel="shortcut icon" href="${ static_url('favicon.png') }">
<link href="${ static_url('plugins/google-cache/open-sans.css') }" rel="stylesheet">
<link href="${ static_url('plugins/bootstrap/css/bootstrap.min.css') }" rel="stylesheet" type="text/css"/>
<link href="${ static_url('plugins/font-awesome/css/font-awesome.min.css') }" rel="stylesheet">
<link href="${ static_url('plugins/gritter/css/jquery.gritter.css') }" rel="stylesheet">
<link href="${ static_url('css/main.css') }" rel="stylesheet" type="text/css"/>
<%block name="extend_css"/>
</head>
<body>
<!-- begin #page-container -->
<div id="page-container" class="page-header-fixed page-sidebar-fixed">
<!-- begin #header -->
<div id="header" class="header navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="brand"><a href="http://teleport.eomsoft.net" target="_blank"><span class="navbar-logo"></span></a></div>
<div class="breadcrumb-container">
<%block name="breadcrumb" />
</div>
</div>
</div>
<!-- end #header -->
<!-- begin #sidebar -->
<div id="sidebar" class="sidebar">
<%block name="sidebar_nav_menu">
<%include file="common/_sidebar_nav_menu.mako" />
</%block>
</div>
<!-- end #sidebar -->
<!-- begin #content -->
<div id="content" class="content">
${self.body()}
</div>
<!-- end #content -->
</div>
<!-- end #page-container -->
<div class="modal fade" ywl_message_box="dialog-ywl-message-box" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" ywl-title></h4>
</div>
<div class="modal-body" ywl-content style="font-size: 20px">
</div>
<div class="modal-footer">
<input type="hidden" ywl-record-id="" ywl-row-id="">
<button type="button" class="btn btn-success btn-sm" ywl-btn-ok="ok"><i class="glyphicon glyphicon-ok"></i></button>
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i></button>
</div>
</div>
</div>
</div>
<%block name="extend_content" />
## <script type="text/javascript" src="${ static_url('js/var.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/underscore/underscore.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/jquery/jquery.min.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/jquery/ajaxfileupload.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/bootstrap/js/bootstrap.min.js') }"></script>
<!--[if lt IE 9]>
<script src="${ static_url('plugins/html5shiv/html5shiv.min.js') }"></script>
<![endif]-->
<script type="text/javascript" src="${ static_url('js/json2.js') }"></script>
<script type="text/javascript" src="${ static_url('plugins/gritter/js/jquery.gritter.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl_const.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl_common.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ywl_assist.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ui/common.js') }"></script>
<script type="text/javascript" src="${ static_url('js/ui/controls.js') }"></script>
<%block name="extend_js"/>
<script type="text/javascript">
ywl.add_page_options({
## 有些参数由后台python脚本生成到模板中无法直接生成到js文件中所以必须通过这种方式传递参数到js脚本中。
active_menu: ${self.attr.page_menu_}
});
$(document).ready(function () {
// once page ready, init ywl object.
## var teleport_ip_info = "请核对您的堡垒机IP地址当前为 " + teleport_ip;
## $("#teleport-server-ip").text(teleport_ip_info);
ywl.init();
});
</script>
<%block name="embed_js" />
</body>
</html>

View File

@ -12,7 +12,7 @@
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-server fa-fw"></i> ${self.attr.page_title_}</li>
<li><i class="fa fa-pencil-square-o fa-fw"></i> ${self.attr.page_title_}</li>
</ol>
</%block>

View File

@ -12,7 +12,7 @@
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-server fa-fw"></i> ${self.attr.page_title_}</li>
<li><i class="fa fa-cogs fa-fw"></i> ${self.attr.page_title_}</li>
</ol>
</%block>

View File

@ -1,124 +0,0 @@
<%!
page_title_ = '页面部件测试'
page_menu_ = ['dashboard']
%>
<%inherit file="page_base.mako"/>
<%block name="extend_js">
</%block>
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-dashboard fa-fw"></i> ${self.attr.page_title_}</li>
</ol>
</%block>
<%block name="embed_js">
<script type="text/javascript">
$(document).ready(function () {
});
</script>
</%block>
<%block name="extend_css">
</%block>
<div class="page-content">
<div class="box">
<h1>这是一级标题This is H1.</h1>
<h2>这是二级标题This is H2.</h2>
<h3>这是三级标题This is H3.</h3>
<h4>这是四级标题This is H4.</h4>
<h5>这是五级标题This is H5.</h5>
<p>这是正文this is content.</p>
</div>
<div class="box">
<div>
<p>徽章默认:[badge] <span class="badge">1</span></p>
<p>徽章尺寸:[badge] <span class="badge">比较长的文字</span>[badge badge-sm] <span class="badge badge-sm">小尺寸</span></p>
<p>
徽章上标:[badge badge-sup] <span class="badge badge-sup">1</span>
[badge badge-sm badge-sup] <span class="badge badge-sm badge-sup">1</span>
[badge badge-sm badge-sup badge-danger] <span class="badge badge-sm badge-sup badge-danger">3</span>
徽章配合图标:<span class="fa fa-bell fa-fw" style="font-size:16px;"></span><span class="badge badge-sm badge-sup badge-danger">3</span>
</p>
<p>
徽章颜色:[badge] <span class="badge">默认</span>
[badge badge-info] <span class="badge badge-ignore">忽略</span>
[badge badge-info] <span class="badge badge-info">信息</span>
[badge badge-primary] <span class="badge badge-primary">重要</span>
[badge badge-success] <span class="badge badge-success">成功</span>
[badge badge-warning] <span class="badge badge-warning">警告</span>
[badge badge-danger] <span class="badge badge-danger">危险(错误)</span>
</p>
<p>
徽章颜色(正常):
<span class="badge">默认</span>
<span class="badge badge-ignore">忽略</span>
<span class="badge badge-info">信息</span>
<span class="badge badge-primary">重要</span>
<span class="badge badge-success">成功</span>
<span class="badge badge-warning">警告</span>
<span class="badge badge-danger">危险(错误)</span>
</p>
<p>
徽章颜色(小):
<span class="badge badge-sm">默认</span>
<span class="badge badge-sm badge-ignore">忽略</span>
<span class="badge badge-sm badge-info">信息</span>
<span class="badge badge-sm badge-primary">重要</span>
<span class="badge badge-sm badge-success">成功</span>
<span class="badge badge-sm badge-warning">警告</span>
<span class="badge badge-sm badge-danger">危险(错误)</span>
</p>
</div>
</div>
<div class="box">
<div>
<p>标签默认:[label] <span class="label">标签文字</span></p>
<p>标签尺寸:[label] <span class="label">比较长的文字</span>[label label-sm] <span class="label label-sm">小尺寸</span></p>
<p>
标签颜色:
[label] <span class="label">默认</span>
[label label-ignore] <span class="label label-ignore">忽略</span>
[label label-info] <span class="label label-info">信息</span>
[label label-primary] <span class="label label-primary">重要</span>
[label label-success] <span class="label label-success">成功</span>
[label label-warning] <span class="label label-warning">警告</span>
[label label-danger] <span class="label label-danger">危险(错误)</span>
</p>
<p>
标签颜色(正常):
<span class="label">默认</span>
<span class="label label-ignore">忽略</span>
<span class="label label-info">信息</span>
<span class="label label-primary">重要</span>
<span class="label label-success">成功</span>
<span class="label label-warning">警告</span>
<span class="label label-danger">危险(错误)</span>
</p>
<p>
标签颜色(小):
<span class="label label-sm">默认</span>
<span class="label label-sm label-ignore">忽略</span>
<span class="label label-sm label-info">信息</span>
<span class="label label-sm label-primary">重要</span>
<span class="label label-sm label-success">成功</span>
<span class="label label-sm label-warning">警告</span>
<span class="label label-sm label-danger">危险(错误)</span>
</p>
</div>
</div>
</div>

View File

@ -0,0 +1,110 @@
<%!
import eom_ver
%>
<%
_sidebar = [
{
'require_type': 0,
'id': 'with-sidebar',
'link': '',
'name': '左侧菜单',
'icon': 'fa-database',
'sub': [
{
'require_type': 0,
'id': 'normal',
'link': '/uidesign',
'name': '普通页面',
'icon': 'fa-server',
},
{
'require_type': 0,
'id': 'table',
'link': '/uidesign/table',
'name': '表格页面',
'icon': 'fa-user',
},
]
},
{
'require_type': 0,
'id': 'without-sidebar',
'link': '/uidesign/without-sidebar',
'name': '无侧边菜单',
'icon': 'fa-database'
}
]
%>
<!-- begin sidebar scrollbar -->
<div class="slimScrollDiv">
<!-- begin sidebar user -->
<div class="nav">
<ul class="nav nav-profile">
<li>
<div class="image">
<img src="/static/img/avatar/001.png" width="36"/>
</div>
<div class="dropdown">
<a class="title" href="#" id="user-profile" data-target="#" data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false">
<span class="name">${ current_user['nick_name'] }</span>
<span class="role">测试用户 <i class="fa fa-caret-right"></i></span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="/auth/logout" id="btn-logout">退出</a></li>
</ul>
</div>
</li>
</ul>
</div>
<!-- end sidebar user -->
<!-- begin sidebar nav -->
<div class="nav">
<ul class="nav nav-menu">
%for menu in _sidebar:
%if menu['require_type'] <= current_user['type']:
%if 'sub' in menu and len(menu['sub']) > 0:
<li id="sidebar_menu_${menu['id']}">
<a href="javascript:;" onclick="ywl._sidebar_toggle_submenu('${menu['id']}');">
<i class="fa ${menu['icon']} fa-fw icon"></i>
<span>${menu['name']}</span>
<i class="menu-caret"></i>
</a>
<ul class="sub-menu" id="sidebar_submenu_${menu['id']}" style="display:none;">
%for sub in menu['sub']:
%if menu['require_type'] <= current_user['type']:
<li id="sidebar_menu_${menu['id']}_${sub['id']}"><a href="${sub['link']}"><span>${sub['name']}</span></a></li>
%endif
%endfor
</ul>
</li>
%else:
<li id="sidebar_menu_${menu['id']}"><a href="${menu['link']}"
%if 'target' in menu:
target="${menu['target']}"
%endif
><i class="fa ${menu['icon']} fa-fw icon"></i><span>${menu['name']}</span></a></li>
%endif
%endif
%endfor
</ul>
</div>
<!-- end sidebar nav -->
<hr style="border:none;border-bottom:1px dotted #4a4a4a;margin-bottom:0;"/>
<div style="color:#717171;font-size:90%;margin-top:5px;"><span style="display:inline-block;width:100px;text-align: right">服务端:</span><span class="mono">v${eom_ver.TS_VER}</span></div>
<div style="color:#717171;font-size:90%;margin-top:5px;"><span style="display:inline-block;width:100px;text-align: right">助手:</span><span class="mono" id="tp-assist-version" req-version=${eom_ver.TP_ASSIST_REQUIRE}>v${eom_ver.TP_ASSIST_LAST_VER}</span></div>
<div style="color:#717171;font-size:90%;margin-top:5px;"><span style="display:inline-block;width:100px;text-align: right">当前助手:</span><span class="mono">v${eom_ver.TP_ASSIST_REQUIRE}</span></div>
</div>
<!-- end sidebar scrollbar -->

View File

@ -0,0 +1,126 @@
<%!
page_title_ = '页面部件测试'
page_menu_ = ['with-sidebar', 'normal']
%>
<%inherit file="../page_base.mako"/>
<%block name="extend_js">
</%block>
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-paint-brush fa-fw"></i> ${self.attr.page_title_}</li>
<li>普通页面</li>
</ol>
</%block>
<%block name="embed_js">
<script type="text/javascript">
$(document).ready(function () {
});
</script>
</%block>
<%block name="extend_css">
</%block>
<%block name="sidebar_nav_menu">
<%include file="_sidebar_nav_menu.mako" />
</%block>
<div class="page-content">
<div class="box">
<h1>这是一级标题This is H1.</h1>
<h2>这是二级标题This is H2.</h2>
<h3>这是三级标题This is H3.</h3>
<h4>这是四级标题This is H4.</h4>
<h5>这是五级标题This is H5.</h5>
<p>这是正文this is content.</p>
</div>
<div class="box">
<div>
<p>徽章默认:[badge] <span class="badge">1</span></p>
<p>徽章尺寸:[badge] <span class="badge">比较长的文字</span>[badge badge-sm] <span class="badge badge-sm">小尺寸</span></p>
<p>
徽章上标:[badge badge-sup] <span class="badge badge-sup">1</span>
[badge badge-sm badge-sup] <span class="badge badge-sm badge-sup">1</span>
[badge badge-sm badge-sup badge-danger] <span class="badge badge-sm badge-sup badge-danger">3</span>
徽章配合图标:<span class="fa fa-bell fa-fw" style="font-size:16px;"></span><span class="badge badge-sm badge-sup badge-danger">3</span>
</p>
<p>
徽章颜色:[badge] <span class="badge">默认</span>
[badge badge-info] <span class="badge badge-ignore">忽略</span>
[badge badge-info] <span class="badge badge-info">信息</span>
[badge badge-primary] <span class="badge badge-primary">重要</span>
[badge badge-success] <span class="badge badge-success">成功</span>
[badge badge-warning] <span class="badge badge-warning">警告</span>
[badge badge-danger] <span class="badge badge-danger">危险(错误)</span>
</p>
<p>
徽章颜色(正常):
<span class="badge">默认</span>
<span class="badge badge-ignore">忽略</span>
<span class="badge badge-info">信息</span>
<span class="badge badge-primary">重要</span>
<span class="badge badge-success">成功</span>
<span class="badge badge-warning">警告</span>
<span class="badge badge-danger">危险(错误)</span>
</p>
<p>
徽章颜色(小):
<span class="badge badge-sm">默认</span>
<span class="badge badge-sm badge-ignore">忽略</span>
<span class="badge badge-sm badge-info">信息</span>
<span class="badge badge-sm badge-primary">重要</span>
<span class="badge badge-sm badge-success">成功</span>
<span class="badge badge-sm badge-warning">警告</span>
<span class="badge badge-sm badge-danger">危险(错误)</span>
</p>
</div>
</div>
<div class="box">
<div>
<p>标签默认:[label] <span class="label">标签文字</span></p>
<p>标签尺寸:[label] <span class="label">比较长的文字</span>[label label-sm] <span class="label label-sm">小尺寸</span></p>
<p>
标签颜色:
[label] <span class="label">默认</span>
[label label-ignore] <span class="label label-ignore">忽略</span>
[label label-info] <span class="label label-info">信息</span>
[label label-primary] <span class="label label-primary">重要</span>
[label label-success] <span class="label label-success">成功</span>
[label label-warning] <span class="label label-warning">警告</span>
[label label-danger] <span class="label label-danger">危险(错误)</span>
</p>
<p>
标签颜色(正常):
<span class="label">默认</span>
<span class="label label-ignore">忽略</span>
<span class="label label-info">信息</span>
<span class="label label-primary">重要</span>
<span class="label label-success">成功</span>
<span class="label label-warning">警告</span>
<span class="label label-danger">危险(错误)</span>
</p>
<p>
标签颜色(小):
<span class="label label-sm">默认</span>
<span class="label label-sm label-ignore">忽略</span>
<span class="label label-sm label-info">信息</span>
<span class="label label-sm label-primary">重要</span>
<span class="label label-sm label-success">成功</span>
<span class="label label-sm label-warning">警告</span>
<span class="label label-sm label-danger">危险(错误)</span>
</p>
</div>
</div>
</div>

View File

@ -0,0 +1,126 @@
<%!
page_title_ = '页面部件测试'
page_menu_ = ['with-sidebar', 'table']
%>
<%inherit file="../page_base.mako"/>
<%block name="extend_js">
</%block>
<%block name="breadcrumb">
<ol class="breadcrumb">
<li><i class="fa fa-paint-brush fa-fw"></i> ${self.attr.page_title_}</li>
<li>表格</li>
</ol>
</%block>
<%block name="embed_js">
<script type="text/javascript">
$(document).ready(function () {
});
</script>
</%block>
<%block name="extend_css">
</%block>
<%block name="sidebar_nav_menu">
<%include file="_sidebar_nav_menu.mako" />
</%block>
<div class="page-content">
<div class="box">
<h1>这是一级标题This is H1.</h1>
<h2>这是二级标题This is H2.</h2>
<h3>这是三级标题This is H3.</h3>
<h4>这是四级标题This is H4.</h4>
<h5>这是五级标题This is H5.</h5>
<p>这是正文this is content.</p>
</div>
<div class="box">
<div>
<p>徽章默认:[badge] <span class="badge">1</span></p>
<p>徽章尺寸:[badge] <span class="badge">比较长的文字</span>[badge badge-sm] <span class="badge badge-sm">小尺寸</span></p>
<p>
徽章上标:[badge badge-sup] <span class="badge badge-sup">1</span>
[badge badge-sm badge-sup] <span class="badge badge-sm badge-sup">1</span>
[badge badge-sm badge-sup badge-danger] <span class="badge badge-sm badge-sup badge-danger">3</span>
徽章配合图标:<span class="fa fa-bell fa-fw" style="font-size:16px;"></span><span class="badge badge-sm badge-sup badge-danger">3</span>
</p>
<p>
徽章颜色:[badge] <span class="badge">默认</span>
[badge badge-info] <span class="badge badge-ignore">忽略</span>
[badge badge-info] <span class="badge badge-info">信息</span>
[badge badge-primary] <span class="badge badge-primary">重要</span>
[badge badge-success] <span class="badge badge-success">成功</span>
[badge badge-warning] <span class="badge badge-warning">警告</span>
[badge badge-danger] <span class="badge badge-danger">危险(错误)</span>
</p>
<p>
徽章颜色(正常):
<span class="badge">默认</span>
<span class="badge badge-ignore">忽略</span>
<span class="badge badge-info">信息</span>
<span class="badge badge-primary">重要</span>
<span class="badge badge-success">成功</span>
<span class="badge badge-warning">警告</span>
<span class="badge badge-danger">危险(错误)</span>
</p>
<p>
徽章颜色(小):
<span class="badge badge-sm">默认</span>
<span class="badge badge-sm badge-ignore">忽略</span>
<span class="badge badge-sm badge-info">信息</span>
<span class="badge badge-sm badge-primary">重要</span>
<span class="badge badge-sm badge-success">成功</span>
<span class="badge badge-sm badge-warning">警告</span>
<span class="badge badge-sm badge-danger">危险(错误)</span>
</p>
</div>
</div>
<div class="box">
<div>
<p>标签默认:[label] <span class="label">标签文字</span></p>
<p>标签尺寸:[label] <span class="label">比较长的文字</span>[label label-sm] <span class="label label-sm">小尺寸</span></p>
<p>
标签颜色:
[label] <span class="label">默认</span>
[label label-ignore] <span class="label label-ignore">忽略</span>
[label label-info] <span class="label label-info">信息</span>
[label label-primary] <span class="label label-primary">重要</span>
[label label-success] <span class="label label-success">成功</span>
[label label-warning] <span class="label label-warning">警告</span>
[label label-danger] <span class="label label-danger">危险(错误)</span>
</p>
<p>
标签颜色(正常):
<span class="label">默认</span>
<span class="label label-ignore">忽略</span>
<span class="label label-info">信息</span>
<span class="label label-primary">重要</span>
<span class="label label-success">成功</span>
<span class="label label-warning">警告</span>
<span class="label label-danger">危险(错误)</span>
</p>
<p>
标签颜色(小):
<span class="label label-sm">默认</span>
<span class="label label-sm label-ignore">忽略</span>
<span class="label label-sm label-info">信息</span>
<span class="label label-sm label-primary">重要</span>
<span class="label label-sm label-success">成功</span>
<span class="label label-sm label-warning">警告</span>
<span class="label label-sm label-danger">危险(错误)</span>
</p>
</div>
</div>
</div>

Some files were not shown because too many files have changed in this diff Show More