Fixed on Linux, but some SQL must update to fit MySQL(can not use field named desc, must use `desc`, because desc is a keywork of MySQL).

pull/105/head
Apex Lu 2017-11-25 16:18:56 +08:00
parent b5c86b94fa
commit f84eeb9a61
10 changed files with 120 additions and 134 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/builder" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="py34" jdkType="Python SDK" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="TestRunnerService"> <component name="TestRunnerService">

View File

@ -25,13 +25,13 @@ class InstallerBase:
self._def_install_path = '' self._def_install_path = ''
ver_file = os.path.join(env.root_path, 'data', 'www', 'teleport', 'app', 'eom_ver.py') ver_file = os.path.join(env.root_path, 'data', 'www', 'teleport', 'webroot', 'app', 'app_ver.py')
try: try:
with open(ver_file, 'r') as f: with open(ver_file, 'r') as f:
x = f.readlines() x = f.readlines()
for i in x: for i in x:
s = i.split('=', 1) s = i.split('=', 1)
if 'TS_VER' == s[0].strip(): if 'TP_SERVER_VER' == s[0].strip():
self._current_ver = s[1].strip()[1:-1] self._current_ver = s[1].strip()[1:-1]
break break
except FileNotFoundError: except FileNotFoundError:
@ -46,7 +46,7 @@ class InstallerBase:
cc.v(' |{}|'.format('=' * (_width - 4))) cc.v(' |{}|'.format('=' * (_width - 4)))
cc.o((cc.CR_VERBOSE, ' | ver: '), (cc.CR_NORMAL, self._current_ver), cc.o((cc.CR_VERBOSE, ' | ver: '), (cc.CR_NORMAL, self._current_ver),
(cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 13 - len(self._current_ver))))) (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 13 - len(self._current_ver)))))
_str = 'author: apexliu@eomsoft.net' _str = 'author: apex.liu@qq.com'
cc.v(' | {}{}|'.format(_str, ' ' * (_width - 5 - len(_str)))) cc.v(' | {}{}|'.format(_str, ' ' * (_width - 5 - len(_str))))
cc.v('[]{}[]'.format('=' * (_width - 4))) cc.v('[]{}[]'.format('=' * (_width - 4)))
cc.v('') cc.v('')
@ -54,7 +54,8 @@ class InstallerBase:
cc.v('') cc.v('')
# cc.v(' NOTICE: if you want to use the default settings, just press `Enter`...') # cc.v(' NOTICE: if you want to use the default settings, just press `Enter`...')
cc.o((cc.CR_VERBOSE, cc.o((cc.CR_VERBOSE,
'NOTICE: There are a few steps need you enter information or make choice,\n if you want to use the '), 'NOTICE: There are a few steps need you enter information or make choice,\n'
' if you want to use the '),
(cc.CR_WARN, 'default settings'), (cc.CR_VERBOSE, ', just press `Enter` key.')) (cc.CR_WARN, 'default settings'), (cc.CR_VERBOSE, ', just press `Enter` key.'))
cc.o((cc.CR_VERBOSE, ' Otherwise you need enter the '), (cc.CR_NORMAL, 'highlight character'), cc.o((cc.CR_VERBOSE, ' Otherwise you need enter the '), (cc.CR_NORMAL, 'highlight character'),
(cc.CR_VERBOSE, ' to make choice.')) (cc.CR_VERBOSE, ' to make choice.'))
@ -77,13 +78,12 @@ class InstallerBase:
while True: while True:
x = self._prompt_choice('What are you wanna to do?', x = self._prompt_choice('What are you wanna to do?',
[('upgrade', 2, True), ('uninstall', 0, False), ('quit', 0, False)]) [('upgrade', 2, True), ('uninstall', 0, False), ('quit', 0, False)])
x = x.lower() if x in ['q', 'quit']:
if 'q' == x:
break break
elif 'u' == x: elif x in ['u', 'uninstall']:
self._do_uninstall() self._do_uninstall()
break break
elif 'g' == x: elif x in ['g', 'upgrade']:
self._do_upgrade() self._do_upgrade()
break break
@ -98,11 +98,10 @@ class InstallerBase:
x = self._prompt_choice( x = self._prompt_choice(
'The target path `{}` has already exists,\ndo you want to use it anyway?'.format( 'The target path `{}` has already exists,\ndo you want to use it anyway?'.format(
self._install_path), [('Yes', 0, True), ('No', 0, False)]) self._install_path), [('Yes', 0, True), ('No', 0, False)])
x = x.lower() if x in ['y', 'yes']:
if 'y' == x:
_use_anyway = True _use_anyway = True
break break
elif 'n' == x: elif x in ['n', 'no']:
break break
if _use_anyway: if _use_anyway:
@ -128,10 +127,9 @@ class InstallerBase:
cc.v('') cc.v('')
x = self._prompt_choice('Do you want to keep your database and settings?', x = self._prompt_choice('Do you want to keep your database and settings?',
[('Yes', 0, True), ('No', 0, False)]) [('Yes', 0, True), ('No', 0, False)])
x = x.lower() if x in ['y', 'yes']:
if 'y' == x:
break break
elif 'n' == x: elif x in ['n', 'no']:
_del_settings = True _del_settings = True
break break
@ -140,10 +138,9 @@ class InstallerBase:
cc.v('') cc.v('')
x = self._prompt_choice('Seriously!! Are you sure to remove all data and settings?', x = self._prompt_choice('Seriously!! Are you sure to remove all data and settings?',
[('Yes', 0, False), ('No', 0, True)]) [('Yes', 0, False), ('No', 0, True)])
x = x.lower() if x in ['y', 'yes']:
if 'y' == x:
break break
elif 'n' == x: elif x in ['n', 'no']:
_del_settings = False _del_settings = False
break break
@ -160,10 +157,9 @@ class InstallerBase:
x = self._prompt_choice( x = self._prompt_choice(
'The same version `{}` installed, are you sure to overwrite?'.format(self._current_ver), 'The same version `{}` installed, are you sure to overwrite?'.format(self._current_ver),
[('Yes', 0, False), ('No', 0, True)]) [('Yes', 0, False), ('No', 0, True)])
x = x.lower() if x in ['y', 'yes']:
if 'y' == x:
break break
elif 'n' == x: elif x in ['n', 'no']:
return return
elif x < 0: elif x < 0:
while True: while True:
@ -171,10 +167,9 @@ class InstallerBase:
x = self._prompt_choice( x = self._prompt_choice(
'A new version `{}` installed, rollback to old version `{}` may cause Teleport Server not functionally.\nAre you sure to rollback to old version?'.format( 'A new version `{}` installed, rollback to old version `{}` may cause Teleport Server not functionally.\nAre you sure to rollback to old version?'.format(
self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)]) self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)])
x = x.lower() if x in ['y', 'yes']:
if 'y' == x:
break break
elif 'n' == x: elif x in ['n', 'no']:
return return
else: else:
while True: while True:
@ -182,10 +177,9 @@ class InstallerBase:
x = self._prompt_choice( x = self._prompt_choice(
'Now upgrade from version `{}` to `{}`, \nAre you sure to upgrade to new version?'.format( 'Now upgrade from version `{}` to `{}`, \nAre you sure to upgrade to new version?'.format(
self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)]) self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)])
x = x.lower() if x in ['y', 'yes']:
if 'y' == x:
break break
elif 'n' == x: elif x in ['n', 'no']:
return return
while True: while True:
@ -193,9 +187,9 @@ class InstallerBase:
x = self._prompt_choice('Make sure you have backup your database and settings.\nAre you sure to continue?', x = self._prompt_choice('Make sure you have backup your database and settings.\nAre you sure to continue?',
[('Yes', 0, False), ('No', 0, True)]) [('Yes', 0, False), ('No', 0, True)])
x = x.lower() x = x.lower()
if 'y' == x: if x in ['y', 'yes']:
break break
elif 'n' == x: elif x in ['n', 'yes']:
return return
self._stop_service() self._stop_service()
@ -222,7 +216,7 @@ class InstallerBase:
idx = choices[i][1] idx = choices[i][1]
if choices[i][2]: if choices[i][2]:
msg = msg.upper() msg = msg.upper()
def_choice = msg[idx].lower() def_choice = msg[idx]
cc.w(msg[:idx], end='') cc.w(msg[:idx], end='')
cc.n(msg[idx], end='') cc.n(msg[idx], end='')
cc.w(msg[idx + 1:], end='') cc.w(msg[idx + 1:], end='')
@ -240,7 +234,7 @@ class InstallerBase:
except EOFError: except EOFError:
x = def_choice x = def_choice
return x return x.lower()
@staticmethod @staticmethod
def _prompt_input(message, def_value): def _prompt_input(message, def_value):
@ -289,14 +283,14 @@ class InstallerBase:
return return
# try to get the installed version from www/teleport/app/eom_ver.py # try to get the installed version from www/teleport/app/eom_ver.py
cc.v(' - check installed version ... ', end='') cc.o(' - check installed version ... ', end='')
ver_file = os.path.join(self._install_path, 'www', 'teleport', 'app', 'eom_ver.py') ver_file = os.path.join(self._install_path, 'www', 'teleport', 'webroot', 'app', 'app_ver.py')
try: try:
with open(ver_file) as f: with open(ver_file) as f:
x = f.readlines() x = f.readlines()
for i in x: for i in x:
s = i.split('=', 1) s = i.split('=', 1)
if 'TS_VER' == s[0].strip(): if 'TP_SERVER_VER' == s[0].strip():
self._installed_ver_str = s[1].strip()[1:-1] self._installed_ver_str = s[1].strip()[1:-1]
cc.i('[{}]'.format(self._installed_ver_str)) cc.i('[{}]'.format(self._installed_ver_str))
# self._installed_ver = self._ver_str_to_ver(self._installed_ver_str) # self._installed_ver = self._ver_str_to_ver(self._installed_ver_str)

View File

@ -13,6 +13,6 @@ PATH_TARGET=/usr/local/eom
"${PATH_ROOT}/data/bin/tp_web" --py "${PATH_ROOT}/script/main.py" "${PATH_ROOT}/data/bin/tp_web" --py "${PATH_ROOT}/script/main.py"
echo "" # echo ""
echo -e "\e[32mInstallation done.\033[0m" # echo -e "\e[32mInstallation done.\033[0m"
echo "" # echo ""

View File

@ -1,30 +1,36 @@
; codec: utf-8 ; codec: utf-8
[common] [common]
; 'log-file' define the log file location. if not set, default location ; 'log-file' define the log file location. if not set, default locate
; to $INSTDIR%/log/tpcore.log ; to $INSTDIR%/log/tpcore.log
;log-file=/var/log/teleport/tpcore.log ;log-file=/var/log/teleport/tpcore.log
# log-level can be 0 ~ 4, default value is 2. ; log-level can be 0 ~ 4, default value is 2.
# LOG_LEVEL_DEBUG 0 log every-thing. ; LOG_LEVEL_DEBUG 0 log every-thing.
# LOG_LEVEL_VERBOSE 1 log every-thing but without debug message. ; LOG_LEVEL_VERBOSE 1 log every-thing but without debug message.
# LOG_LEVEL_INFO 2 log infomation/warning/error message. ; LOG_LEVEL_INFO 2 log infomation/warning/error message.
# LOG_LEVEL_WARN 3 log warning and error message. ; LOG_LEVEL_WARN 3 log warning and error message.
# LOG_LEVEL_ERROR 4 log error message only. ; LOG_LEVEL_ERROR 4 log error message only.
log-level=2 log-level=2
; 0/1. default to 0.
; in debug mode, `log-level` force to 0 and display more message for debug purpose.
debug-mode=0 debug-mode=0
; 'replay-path' define the replay file location. if not set, default location ; 'replay-path' define the replay file location. if not set, default locate
; to $INSTDIR%/data/replay/ ; to $INSTDIR%/data/replay/
;replay-path=/var/lib/teleport/replay ;replay-path=/var/lib/teleport/replay
; `web-server-rpc` is the rpc interface of web server.
; default to `http://127.0.0.1:7190/rpc`.
; DO NOT FORGET update this setting if you modified common::port in web.ini.
web-server-rpc=http://127.0.0.1:7190/rpc web-server-rpc=http://127.0.0.1:7190/rpc
[rpc] [rpc]
; Request by web server. `bind-ip` should be the ip of core server. If web server and ; Request by web server. `bind-ip` should be the ip of core server. If web server and
; core server running at the same machine, it should be 127.0.0.1. ; core server running at the same machine, it should be 127.0.0.1.
bind-ip=127.0.0.1 bind-ip=127.0.0.1
; DO NOT FORGET update `common::core-server-rpc` in web.ini if you modified this setting.
bind-port=52080 bind-port=52080
[protocol-ssh] [protocol-ssh]
@ -34,7 +40,7 @@ bind-ip=0.0.0.0
bind-port=52189 bind-port=52189
[protocol-rdp] [protocol-rdp]
enabled=true enabled=false
lib=tprdp lib=tprdp
bind-ip=0.0.0.0 bind-ip=0.0.0.0
bind-port=52089 bind-port=52089

View File

@ -5,8 +5,7 @@
; ip=0.0.0.0 ; ip=0.0.0.0
; port listen by web server, default to 7190. ; port listen by web server, default to 7190.
; DO NOT FORGET update common::web-server-rpc in core.ini if you modified this setting. ; DO NOT FORGET update `common::web-server-rpc` in core.ini if you modified this setting.
; port=7190
port=7190 port=7190
; log file of web server, default to /var/log/teleport/tpweb.log ; log file of web server, default to /var/log/teleport/tpweb.log
@ -18,16 +17,15 @@ port=7190
; LOG_LEVEL_INFO 2 log information/warning/error message. ; LOG_LEVEL_INFO 2 log information/warning/error message.
; LOG_LEVEL_WARN 3 log warning and error message. ; LOG_LEVEL_WARN 3 log warning and error message.
; LOG_LEVEL_ERROR 4 log error message only. ; LOG_LEVEL_ERROR 4 log error message only.
; log-level=2 log-level=2
; 0/1. default to 0. ; 0/1. default to 0.
; in debug mode, `log-level` force to 0 and trace call stack when exception raised. ; in debug mode, `log-level` force to 0 and display more message for debug purpose.
; debug-mode=0
debug-mode=0 debug-mode=0
; `core-server-rpc` is the rpc interface of core server. ; `core-server-rpc` is the rpc interface of core server.
; default to `http://127.0.0.1:52080/rpc`.
; DO NOT FORGET update this setting if you modified rpc::bind-port in core.ini. ; DO NOT FORGET update this setting if you modified rpc::bind-port in core.ini.
; core-server-rpc=http://127.0.0.1:52080/rpc
core-server-rpc=http://127.0.0.1:52080/rpc core-server-rpc=http://127.0.0.1:52080/rpc

View File

@ -184,7 +184,7 @@ static int _main_loop(void)
{ {
sf_path = g_env.m_www_path; sf_path = g_env.m_www_path;
if (!ex_path_join(sf_path, false, L"teleport", L"app", L"eom_main.py", NULL)) if (!ex_path_join(sf_path, false, L"teleport", L"app_bootstrap.py", NULL))
{ {
EXLOGE(L"[tpweb] invalid path [%ls].\n", sf_path.c_str()); EXLOGE(L"[tpweb] invalid path [%ls].\n", sf_path.c_str());
return 1; return 1;

View File

@ -100,19 +100,18 @@ bool TsEnv::init(bool load_config)
int log_level = EX_LOG_LEVEL_INFO; int log_level = EX_LOG_LEVEL_INFO;
if (ps->GetInt(L"log-level", log_level)) if (ps->GetInt(L"log-level", log_level))
{ {
EXLOGV("[tpweb] log-level: %d\n", log_level); // EXLOGV("[tpweb] log-level: %d\n", log_level);
EXLOG_LEVEL(log_level); EXLOG_LEVEL(log_level);
} }
int debug_mode = 0; int debug_mode = 0;
if (ps->GetInt(L"debug-mode", debug_mode)) if (ps->GetInt(L"debug-mode", debug_mode))
{ {
EXLOGV("[tpweb] debug-mode: %d\n", debug_mode); // EXLOGV("[tpweb] debug-mode: %d\n", debug_mode);
// EXLOG_LEVEL(log_level); // EXLOG_LEVEL(log_level);
} if (1 == debug_mode) {
EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG);
if (1 == debug_mode) { }
EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG);
} }
return true; return true;

View File

@ -1,21 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../packages/packages-common" /> <content url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$"> <orderEntry type="inheritedJdk" />
<sourceFolder url="file://$MODULE_DIR$/webroot" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="py34" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Mako" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/view" />
</list>
</option>
</component>
<component name="TestRunnerService"> <component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" /> <option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component> </component>

View File

@ -50,7 +50,7 @@
## Begin Main Body. ## Begin Main Body.
<div class="content-box"> <div class="content-box">
<p class="welcome-message"><i class="fa fa-heart"></i> <span>欢迎安装使用 TELEPORT v${app_ver.TP_SRV_WWW_VER} 社区版!</span></p> <p class="welcome-message"><i class="fa fa-heart"></i> <span>欢迎安装使用 TELEPORT v${app_ver.TP_SERVER_VER} 社区版!</span></p>
<hr/> <hr/>
<h2><i class="fa fa-chevron-right"></i> 确定数据库类型</h2> <h2><i class="fa fa-chevron-right"></i> 确定数据库类型</h2>
@ -74,15 +74,15 @@
</tr> </tr>
<tr> <tr>
<td class="key"><label for="sysadmin-email">电子邮件地址:</label></td> <td class="key"><label for="sysadmin-email">电子邮件地址:</label></td>
<td><input type="text" class="form-control" id="sysadmin-email" value=""></td> <td><input type="text" class="form-control" id="sysadmin-email"></td>
</tr> </tr>
<tr> <tr>
<td class="key"><label for="password">密码:</label></td> <td class="key"><label for="password">密码:</label></td>
<td><input type="password" class="form-control" id="password" value="admin"></td> <td><input type="password" class="form-control" id="password"></td>
</tr> </tr>
<tr> <tr>
<td class="key"><label for="password-again">再次确认密码:</label></td> <td class="key"><label for="password-again">再次确认密码:</label></td>
<td><input type="password" class="form-control" id="password-again" value="admin"></td> <td><input type="password" class="form-control" id="password-again"></td>
</tr> </tr>
</table> </table>

View File

@ -89,7 +89,7 @@ class DatabaseInit:
# name: 角色名称 # name: 角色名称
f.append('name varchar(128) NOT NULL') f.append('name varchar(128) NOT NULL')
# desc: 角色描述 # desc: 角色描述
f.append('desc varchar(255) DEFAULT ""') f.append('desc varchar(255) DEFAULT NULL')
# privilege: 权限,可按位异或组合,请参考 TP_PRIVILEGE_XXXX 定义 # privilege: 权限,可按位异或组合,请参考 TP_PRIVILEGE_XXXX 定义
f.append('privilege int(11) DEFAULT 0') f.append('privilege int(11) DEFAULT 0')
@ -118,15 +118,15 @@ class DatabaseInit:
# username: teleport系统登录名 # username: teleport系统登录名
f.append('username varchar(32) NOT NULL') f.append('username varchar(32) NOT NULL')
# surname: 真实姓名 # surname: 真实姓名
f.append('surname varchar(64) DEFAULT ""') f.append('surname varchar(64) DEFAULT NULL')
# type 1=本地账号2=LDAP待扩展 # type 1=本地账号2=LDAP待扩展
f.append('type int(11) DEFAULT 1') f.append('type int(11) DEFAULT 1')
# auth_type: 0=使用全局设置,其他参考 TP_LOGIN_AUTH_XXX 系列值 # auth_type: 0=使用全局设置,其他参考 TP_LOGIN_AUTH_XXX 系列值
f.append('auth_type int(11) DEFAULT 0') f.append('auth_type int(11) DEFAULT 0')
# password: 登录密码如果是LDAP账号则忽略此字段 # password: 登录密码如果是LDAP账号则忽略此字段
f.append('password varchar(128) DEFAULT ""') f.append('password varchar(128) DEFAULT NULL')
# oath_secret: 身份验证器密钥(使用核心服务加密存储) # oath_secret: 身份验证器密钥(使用核心服务加密存储)
f.append('oath_secret varchar(64) DEFAULT ""') f.append('oath_secret varchar(64) DEFAULT NULL')
# state: 状态1=正常2=禁用3=临时锁定 # state: 状态1=正常2=禁用3=临时锁定
f.append('state int(3) DEFAULT 1') f.append('state int(3) DEFAULT 1')
# fail_count: 连续登录失败的次数(根据设置,超过一定数量时将临时锁定) # fail_count: 连续登录失败的次数(根据设置,超过一定数量时将临时锁定)
@ -136,20 +136,20 @@ class DatabaseInit:
# last_chpass: 最近一次修改密码时间(根据设置,密码可能有有效期限制) # last_chpass: 最近一次修改密码时间(根据设置,密码可能有有效期限制)
f.append('last_chpass int(11) DEFAULT 0') f.append('last_chpass int(11) DEFAULT 0')
# email: 用户邮箱 # email: 用户邮箱
f.append('email varchar(64) DEFAULT ""') f.append('email varchar(64) DEFAULT NULL')
f.append('mobile varchar(24) DEFAULT ""') f.append('mobile varchar(24) DEFAULT NULL')
f.append('qq varchar(24) DEFAULT ""') f.append('qq varchar(24) DEFAULT NULL')
f.append('wechat varchar(32) DEFAULT ""') f.append('wechat varchar(32) DEFAULT NULL')
f.append('desc varchar(255) DEFAULT ""') f.append('desc varchar(255) DEFAULT NULL')
# login_time: 本次成功登录时间 # login_time: 本次成功登录时间
f.append('login_time int(11) DEFAULT 0') f.append('login_time int(11) DEFAULT 0')
# last_login: 最近一次成功登录时间 # last_login: 最近一次成功登录时间
f.append('last_login int(11) DEFAULT 0') f.append('last_login int(11) DEFAULT 0')
# login_ip: 本次成功登录IP # login_ip: 本次成功登录IP
f.append('login_ip varchar(40) DEFAULT ""') f.append('login_ip varchar(40) DEFAULT NULL')
# last_ip: 最近一次成功登录IP # last_ip: 最近一次成功登录IP
f.append('last_ip varchar(40) DEFAULT ""') f.append('last_ip varchar(40) DEFAULT NULL')
# creator_id: 创建者的用户id0=系统默认创建 # creator_id: 创建者的用户id0=系统默认创建
f.append('creator_id int(11) DEFAULT 0') f.append('creator_id int(11) DEFAULT 0')
@ -171,7 +171,7 @@ class DatabaseInit:
# user_id: user's id # user_id: user's id
f.append('user_id int(11) DEFAULT 0') f.append('user_id int(11) DEFAULT 0')
# token: token # token: token
f.append('token varchar(48) DEFAULT ""') f.append('token varchar(48) DEFAULT NULL')
# create_time: 创建时间 # create_time: 创建时间
f.append('create_time int(11) DEFAULT 0') f.append('create_time int(11) DEFAULT 0')
@ -190,9 +190,9 @@ class DatabaseInit:
# type 1=用户组2=主机组3=账号组 # type 1=用户组2=主机组3=账号组
f.append('type int(11) DEFAULT 1') f.append('type int(11) DEFAULT 1')
# name: 组名称 # name: 组名称
f.append('name varchar(128) DEFAULT ""') f.append('name varchar(128) DEFAULT NULL')
# desc: 详细描述 # desc: 详细描述
f.append('desc varchar(255) DEFAULT ""') f.append('desc varchar(255) DEFAULT NULL')
# state: 状态1=正常2=禁用 # state: 状态1=正常2=禁用
f.append('state int(3) DEFAULT 1') f.append('state int(3) DEFAULT 1')
@ -241,14 +241,14 @@ class DatabaseInit:
# os_type: 操作系统类型1=win101=win2003srv102=win2008srvetc...2=linux201=ubuntu202=centosetc...3=others. # os_type: 操作系统类型1=win101=win2003srv102=win2008srvetc...2=linux201=ubuntu202=centosetc...3=others.
f.append('os_type int(11) DEFAULT 1') f.append('os_type int(11) DEFAULT 1')
# os_ver: 操作系统具体名称和版本,可选(手工填写,将来可以通过自动发现功能自动获取) # os_ver: 操作系统具体名称和版本,可选(手工填写,将来可以通过自动发现功能自动获取)
f.append('os_ver varchar(128) DEFAULT ""') f.append('os_ver varchar(128) DEFAULT NULL')
# name: 名称,用于快速区分 # name: 名称,用于快速区分
f.append('name varchar(64) DEFAULT ""') f.append('name varchar(64) DEFAULT NULL')
# ip: IP地址长度40是为了将来的ipv6准备的IPV6=X:X:X:X:X:X:X:X每个X为最长4字节总计39字节 # ip: IP地址长度40是为了将来的ipv6准备的IPV6=X:X:X:X:X:X:X:X每个X为最长4字节总计39字节
f.append('ip varchar(40) NOT NULL') f.append('ip varchar(40) NOT NULL')
# router_ip: 路由IP仅用于路由连接模式teleport与远程主机之间有路由网关该路由网关通过端口映射不同的远程主机 # router_ip: 路由IP仅用于路由连接模式teleport与远程主机之间有路由网关该路由网关通过端口映射不同的远程主机
f.append('router_ip varchar(40) DEFAULT ""') f.append('router_ip varchar(40) DEFAULT NULL')
# router_port: 路由端口,仅用于路由连接模式 # router_port: 路由端口,仅用于路由连接模式
f.append('router_port int(11) DEFAULT 0') f.append('router_port int(11) DEFAULT 0')
@ -257,10 +257,10 @@ class DatabaseInit:
# acc_count: 远程账号数量(注意创建/删除远程账号时更新此数据) # acc_count: 远程账号数量(注意创建/删除远程账号时更新此数据)
f.append('acc_count int(11) DEFAULT 0') f.append('acc_count int(11) DEFAULT 0')
# cid: 公司内部用,资产统一编号 # cid: 公司内部用,资产统一编号
f.append('cid varchar(64) DEFAULT ""') f.append('cid varchar(64) DEFAULT NULL')
# desc: 对此资产的详细描述 # desc: 对此资产的详细描述
f.append('desc varchar(255) DEFAULT ""') f.append('desc varchar(255) DEFAULT NULL')
# creator_id: 账号创建者的id0=系统默认创建 # creator_id: 账号创建者的id0=系统默认创建
f.append('creator_id int(11) DEFAULT 0') f.append('creator_id int(11) DEFAULT 0')
@ -288,7 +288,7 @@ class DatabaseInit:
# host_ip: 主机IP地址 # host_ip: 主机IP地址
f.append('host_ip varchar(40) NOT NULL') f.append('host_ip varchar(40) NOT NULL')
# router_ip: 路由IP # router_ip: 路由IP
f.append('router_ip varchar(40) DEFAULT ""') f.append('router_ip varchar(40) DEFAULT NULL')
# router_port: 路由端口 # router_port: 路由端口
f.append('router_port int(11) DEFAULT 0') f.append('router_port int(11) DEFAULT 0')
@ -308,15 +308,15 @@ class DatabaseInit:
# auth_type: 登录认证类型0=无认证1=password2=public-key # auth_type: 登录认证类型0=无认证1=password2=public-key
f.append('auth_type int(11) DEFAULT 0') f.append('auth_type int(11) DEFAULT 0')
# username: 登录账号 # username: 登录账号
f.append('username varchar(128) DEFAULT ""') f.append('username varchar(128) DEFAULT NULL')
# username_prompt: 输入用户名的提示仅用于telnet协议 # username_prompt: 输入用户名的提示仅用于telnet协议
f.append('username_prompt varchar(128) DEFAULT ""') f.append('username_prompt varchar(128) DEFAULT NULL')
# password_prompt: 输入密码的提示仅用于telnet协议 # password_prompt: 输入密码的提示仅用于telnet协议
f.append('password_prompt varchar(128) DEFAULT ""') f.append('password_prompt varchar(128) DEFAULT NULL')
# password: 登录密码仅当auth=1时有效 # password: 登录密码仅当auth=1时有效
f.append('password varchar(255) DEFAULT ""') f.append('password varchar(255) DEFAULT NULL')
# pri_key: 私钥仅当auth=2时有效 # pri_key: 私钥仅当auth=2时有效
f.append('pri_key varchar(4096) DEFAULT ""') f.append('pri_key varchar(4096) DEFAULT NULL')
# creator_id: 账号创建者的id0=系统默认创建 # creator_id: 账号创建者的id0=系统默认创建
f.append('creator_id int(11) DEFAULT 0') f.append('creator_id int(11) DEFAULT 0')
@ -337,20 +337,20 @@ class DatabaseInit:
# id: 自增主键 # id: 自增主键
f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment)) f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment))
# name: 此条账号认证信息的名称,用于显示 # name: 此条账号认证信息的名称,用于显示
f.append('name varchar(128) DEFAULT ""') f.append('name varchar(128) DEFAULT NULL')
# auth_type: 登录认证类型0=无认证1=password2=public-key # auth_type: 登录认证类型0=无认证1=password2=public-key
f.append('auth_type int(11) DEFAULT 0') f.append('auth_type int(11) DEFAULT 0')
# username: 登录账号 # username: 登录账号
f.append('username varchar(128) DEFAULT ""') f.append('username varchar(128) DEFAULT NULL')
# username_prompt: 输入用户名的提示仅用于telnet协议 # username_prompt: 输入用户名的提示仅用于telnet协议
f.append('username_prompt varchar(128) DEFAULT ""') f.append('username_prompt varchar(128) DEFAULT NULL')
# password_prompt: 输入密码的提示仅用于telnet协议 # password_prompt: 输入密码的提示仅用于telnet协议
f.append('password_prompt varchar(128) DEFAULT ""') f.append('password_prompt varchar(128) DEFAULT NULL')
# password: 登录密码仅当auth=1时有效 # password: 登录密码仅当auth=1时有效
f.append('password varchar(255) DEFAULT ""') f.append('password varchar(255) DEFAULT NULL')
# pri_key: 私钥仅当auth=2时有效 # pri_key: 私钥仅当auth=2时有效
f.append('pri_key varchar(4096) DEFAULT ""') f.append('pri_key varchar(4096) DEFAULT NULL')
# creator_id: 创建者的id0=系统默认创建 # creator_id: 创建者的id0=系统默认创建
f.append('creator_id int(11) DEFAULT 0') f.append('creator_id int(11) DEFAULT 0')
@ -373,9 +373,9 @@ class DatabaseInit:
f.append('rank int(11) DEFAULT 0') f.append('rank int(11) DEFAULT 0')
# name: 策略名称 # name: 策略名称
f.append('name varchar(128) DEFAULT ""') f.append('name varchar(128) DEFAULT NULL')
# desc: 策略描述 # desc: 策略描述
f.append('desc varchar(255) DEFAULT ""') f.append('desc varchar(255) DEFAULT NULL')
# start_time: 策略有效期起始时间(为0则忽略) # start_time: 策略有效期起始时间(为0则忽略)
f.append('start_time int(11) DEFAULT 0') f.append('start_time int(11) DEFAULT 0')
# end_time: 策略有效期结束时间(为0则忽略) # end_time: 策略有效期结束时间(为0则忽略)
@ -387,7 +387,7 @@ class DatabaseInit:
# limit_ip: 是否启用来源限制0=不限制1=白名单2=黑名单(尚未实现) # limit_ip: 是否启用来源限制0=不限制1=白名单2=黑名单(尚未实现)
f.append('limit_ip int(3) DEFAULT 0') f.append('limit_ip int(3) DEFAULT 0')
# ip_list: 限制IP列表白名单或者黑名单 # ip_list: 限制IP列表白名单或者黑名单
f.append('ip_list TEXT DEFAULT ""') f.append('ip_list TEXT DEFAULT NULL')
# limit_time: 是否启用限时连接0=不限制1=限制(尚未实现) # limit_time: 是否启用限时连接0=不限制1=限制(尚未实现)
f.append('limit_time int(3) DEFAULT 0') f.append('limit_time int(3) DEFAULT 0')
@ -452,7 +452,7 @@ class DatabaseInit:
# rid: 外链对象的ID # rid: 外链对象的ID
f.append('rid int(11) DEFAULT 0') f.append('rid int(11) DEFAULT 0')
# name: 外链对象的名称 # name: 外链对象的名称
f.append('name varchar(64) DEFAULT ""') f.append('name varchar(64) DEFAULT NULL')
# state: 状态1=正常2=禁用3=临时锁定 # state: 状态1=正常2=禁用3=临时锁定
f.append('state int(3) DEFAULT 1') f.append('state int(3) DEFAULT 1')
@ -518,21 +518,21 @@ class DatabaseInit:
# 后续字段仅用于显示 # 后续字段仅用于显示
# u_name: 用户登录名 # u_name: 用户登录名
f.append('u_name varchar(32) DEFAULT ""') f.append('u_name varchar(32) DEFAULT NULL')
# u_surname: 用户姓名 # u_surname: 用户姓名
f.append('u_surname varchar(64) DEFAULT ""') f.append('u_surname varchar(64) DEFAULT NULL')
# h_name: 主机名称 # h_name: 主机名称
f.append('h_name varchar(64) DEFAULT ""') f.append('h_name varchar(64) DEFAULT NULL')
# ip: IP地址 # ip: IP地址
f.append('ip varchar(40) NOT NULL') f.append('ip varchar(40) NOT NULL')
# router_ip: 路由IP # router_ip: 路由IP
f.append('router_ip varchar(40) DEFAULT ""') f.append('router_ip varchar(40) DEFAULT NULL')
# router_port: 路由端口 # router_port: 路由端口
f.append('router_port int(11) DEFAULT 0') f.append('router_port int(11) DEFAULT 0')
# a_name: 登录账号 # a_name: 登录账号
f.append('a_name varchar(128) DEFAULT ""') f.append('a_name varchar(128) DEFAULT NULL')
# protocol_type: 协议类型0=1=SSH2=RDP3=TELNET # protocol_type: 协议类型0=1=SSH2=RDP3=TELNET
f.append('protocol_type int(11) DEFAULT 0') f.append('protocol_type int(11) DEFAULT 0')
# protocol_port: 协议端口 # protocol_port: 协议端口
@ -551,9 +551,9 @@ class DatabaseInit:
f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment)) f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment))
# name: 策略名称 # name: 策略名称
f.append('name varchar(128) DEFAULT ""') f.append('name varchar(128) DEFAULT NULL')
# desc: 策略描述 # desc: 策略描述
f.append('desc varchar(255) DEFAULT ""') f.append('desc varchar(255) DEFAULT NULL')
# start_time: 策略有效期起始时间(为0则忽略) # start_time: 策略有效期起始时间(为0则忽略)
f.append('start_time int(11) DEFAULT 0') f.append('start_time int(11) DEFAULT 0')
# end_time: 策略有效期结束时间(为0则忽略) # end_time: 策略有效期结束时间(为0则忽略)
@ -621,11 +621,11 @@ class DatabaseInit:
# 后续字段仅用于显示 # 后续字段仅用于显示
# host_name: 主机名称 # host_name: 主机名称
f.append('host_name varchar(64) DEFAULT ""') f.append('host_name varchar(64) DEFAULT NULL')
# ip: IP地址 # ip: IP地址
f.append('ip varchar(40) NOT NULL') f.append('ip varchar(40) NOT NULL')
# router_ip: 路由IP # router_ip: 路由IP
f.append('router_ip varchar(40) DEFAULT ""') f.append('router_ip varchar(40) DEFAULT NULL')
# router_port: 路由端口 # router_port: 路由端口
f.append('router_port int(11) DEFAULT 0') f.append('router_port int(11) DEFAULT 0')
@ -642,20 +642,20 @@ class DatabaseInit:
f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment)) f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment))
# user_name: 用户名 # user_name: 用户名
f.append('user_name varchar(32) DEFAULT ""') f.append('user_name varchar(32) DEFAULT NULL')
# user_surname: 用户真实姓名 # user_surname: 用户真实姓名
f.append('user_surname varchar(64) DEFAULT ""') f.append('user_surname varchar(64) DEFAULT NULL')
# client_ip: 操作发起的IP地址 # client_ip: 操作发起的IP地址
f.append('client_ip varchar(40) DEFAULT ""') f.append('client_ip varchar(40) DEFAULT NULL')
# code: 操作结果(成功还是失败 TPE_XXXX # code: 操作结果(成功还是失败 TPE_XXXX
f.append('code int(11) DEFAULT 0') f.append('code int(11) DEFAULT 0')
# time: 日志发生时间 # time: 日志发生时间
f.append('log_time int(11) DEFAULT 0') f.append('log_time int(11) DEFAULT 0')
# message: 说明 # message: 说明
f.append('message varchar(255) DEFAULT ""') f.append('message varchar(255) DEFAULT NULL')
# detail: 详细描述 # detail: 详细描述
f.append('detail TEXT DEFAULT ""') f.append('detail TEXT DEFAULT NULL')
self._db_exec( self._db_exec(
'创建系统日志表...', '创建系统日志表...',
@ -670,7 +670,7 @@ class DatabaseInit:
f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment)) f.append('id integer PRIMARY KEY {}'.format(self.db.auto_increment))
# sid: 会话ID # sid: 会话ID
f.append('sid varchar(32) DEFAULT ""') f.append('sid varchar(32) DEFAULT NULL')
# 下列三个ID主要用于在线会话管理强行终止会话 # 下列三个ID主要用于在线会话管理强行终止会话
# user_id: 操作的用户 # user_id: 操作的用户
@ -684,20 +684,20 @@ class DatabaseInit:
f.append('state int(11) DEFAULT 0') f.append('state int(11) DEFAULT 0')
# user_name: 用户名 # user_name: 用户名
f.append('user_username varchar(32) DEFAULT ""') f.append('user_username varchar(32) DEFAULT NULL')
# user_surname: 用户姓名 # user_surname: 用户姓名
f.append('user_surname varchar(64) DEFAULT ""') f.append('user_surname varchar(64) DEFAULT NULL')
# host_ip: 目标主机IP # host_ip: 目标主机IP
f.append('host_ip varchar(40) DEFAULT ""') f.append('host_ip varchar(40) DEFAULT NULL')
# conn_ip: 端口转发模式=路由主机IP直连模式=目标主机IP # conn_ip: 端口转发模式=路由主机IP直连模式=目标主机IP
f.append('conn_ip varchar(40) DEFAULT ""') f.append('conn_ip varchar(40) DEFAULT NULL')
f.append('conn_port int(11) DEFAULT 0') f.append('conn_port int(11) DEFAULT 0')
# client_ip: 操作发起的IP地址 # client_ip: 操作发起的IP地址
f.append('client_ip varchar(40) DEFAULT ""') f.append('client_ip varchar(40) DEFAULT NULL')
# acc_username: 账号(远程主机登录账号名称) # acc_username: 账号(远程主机登录账号名称)
f.append('acc_username varchar(128) DEFAULT ""') f.append('acc_username varchar(128) DEFAULT NULL')
# auth_type: 远程登录认证方式 # auth_type: 远程登录认证方式
f.append('auth_type int(11) DEFAULT 0') f.append('auth_type int(11) DEFAULT 0')