diff --git a/build/.idea/build.iml b/build/.idea/build.iml index 8a94704..6711606 100644 --- a/build/.idea/build.iml +++ b/build/.idea/build.iml @@ -1,8 +1,8 @@ - - + + diff --git a/dist/server/script/main.py b/dist/server/script/main.py index 41fe594..441872a 100644 --- a/dist/server/script/main.py +++ b/dist/server/script/main.py @@ -25,13 +25,13 @@ class InstallerBase: 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: with open(ver_file, 'r') as f: x = f.readlines() for i in x: 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] break except FileNotFoundError: @@ -46,7 +46,7 @@ class InstallerBase: cc.v(' |{}|'.format('=' * (_width - 4))) cc.o((cc.CR_VERBOSE, ' | ver: '), (cc.CR_NORMAL, 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('=' * (_width - 4))) cc.v('') @@ -54,7 +54,8 @@ class InstallerBase: cc.v('') # cc.v(' NOTICE: if you want to use the default settings, just press `Enter`...') 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.o((cc.CR_VERBOSE, ' Otherwise you need enter the '), (cc.CR_NORMAL, 'highlight character'), (cc.CR_VERBOSE, ' to make choice.')) @@ -77,13 +78,12 @@ class InstallerBase: while True: x = self._prompt_choice('What are you wanna to do?', [('upgrade', 2, True), ('uninstall', 0, False), ('quit', 0, False)]) - x = x.lower() - if 'q' == x: + if x in ['q', 'quit']: break - elif 'u' == x: + elif x in ['u', 'uninstall']: self._do_uninstall() break - elif 'g' == x: + elif x in ['g', 'upgrade']: self._do_upgrade() break @@ -98,11 +98,10 @@ class InstallerBase: x = self._prompt_choice( 'The target path `{}` has already exists,\ndo you want to use it anyway?'.format( self._install_path), [('Yes', 0, True), ('No', 0, False)]) - x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: _use_anyway = True break - elif 'n' == x: + elif x in ['n', 'no']: break if _use_anyway: @@ -128,10 +127,9 @@ class InstallerBase: cc.v('') x = self._prompt_choice('Do you want to keep your database and settings?', [('Yes', 0, True), ('No', 0, False)]) - x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: break - elif 'n' == x: + elif x in ['n', 'no']: _del_settings = True break @@ -140,10 +138,9 @@ class InstallerBase: cc.v('') x = self._prompt_choice('Seriously!! Are you sure to remove all data and settings?', [('Yes', 0, False), ('No', 0, True)]) - x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: break - elif 'n' == x: + elif x in ['n', 'no']: _del_settings = False break @@ -160,10 +157,9 @@ class InstallerBase: x = self._prompt_choice( 'The same version `{}` installed, are you sure to overwrite?'.format(self._current_ver), [('Yes', 0, False), ('No', 0, True)]) - x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: break - elif 'n' == x: + elif x in ['n', 'no']: return elif x < 0: while True: @@ -171,10 +167,9 @@ class InstallerBase: 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( self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)]) - x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: break - elif 'n' == x: + elif x in ['n', 'no']: return else: while True: @@ -182,10 +177,9 @@ class InstallerBase: x = self._prompt_choice( '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)]) - x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: break - elif 'n' == x: + elif x in ['n', 'no']: return 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?', [('Yes', 0, False), ('No', 0, True)]) x = x.lower() - if 'y' == x: + if x in ['y', 'yes']: break - elif 'n' == x: + elif x in ['n', 'yes']: return self._stop_service() @@ -222,7 +216,7 @@ class InstallerBase: idx = choices[i][1] if choices[i][2]: msg = msg.upper() - def_choice = msg[idx].lower() + def_choice = msg[idx] cc.w(msg[:idx], end='') cc.n(msg[idx], end='') cc.w(msg[idx + 1:], end='') @@ -240,7 +234,7 @@ class InstallerBase: except EOFError: x = def_choice - return x + return x.lower() @staticmethod def _prompt_input(message, def_value): @@ -289,14 +283,14 @@ class InstallerBase: return # try to get the installed version from www/teleport/app/eom_ver.py - cc.v(' - check installed version ... ', end='') - ver_file = os.path.join(self._install_path, 'www', 'teleport', 'app', 'eom_ver.py') + cc.o(' - check installed version ... ', end='') + ver_file = os.path.join(self._install_path, 'www', 'teleport', 'webroot', 'app', 'app_ver.py') try: with open(ver_file) as f: x = f.readlines() for i in x: 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] cc.i('[{}]'.format(self._installed_ver_str)) # self._installed_ver = self._ver_str_to_ver(self._installed_ver_str) diff --git a/dist/server/setup.sh b/dist/server/setup.sh index 16d4c12..de317c5 100755 --- a/dist/server/setup.sh +++ b/dist/server/setup.sh @@ -13,6 +13,6 @@ PATH_TARGET=/usr/local/eom "${PATH_ROOT}/data/bin/tp_web" --py "${PATH_ROOT}/script/main.py" -echo "" -echo -e "\e[32mInstallation done.\033[0m" -echo "" +# echo "" +# echo -e "\e[32mInstallation done.\033[0m" +# echo "" diff --git a/server/share/etc/core.ini.in b/server/share/etc/core.ini.in index 8776071..ccbba2e 100644 --- a/server/share/etc/core.ini.in +++ b/server/share/etc/core.ini.in @@ -1,30 +1,36 @@ ; codec: utf-8 [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 ;log-file=/var/log/teleport/tpcore.log -# log-level can be 0 ~ 4, default value is 2. -# LOG_LEVEL_DEBUG 0 log every-thing. -# LOG_LEVEL_VERBOSE 1 log every-thing but without debug message. -# LOG_LEVEL_INFO 2 log infomation/warning/error message. -# LOG_LEVEL_WARN 3 log warning and error message. -# LOG_LEVEL_ERROR 4 log error message only. +; log-level can be 0 ~ 4, default value is 2. +; LOG_LEVEL_DEBUG 0 log every-thing. +; LOG_LEVEL_VERBOSE 1 log every-thing but without debug message. +; LOG_LEVEL_INFO 2 log infomation/warning/error message. +; LOG_LEVEL_WARN 3 log warning and error message. +; LOG_LEVEL_ERROR 4 log error message only. 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 -; '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/ ;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 [rpc] ; 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. -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 [protocol-ssh] @@ -34,7 +40,7 @@ bind-ip=0.0.0.0 bind-port=52189 [protocol-rdp] -enabled=true +enabled=false lib=tprdp bind-ip=0.0.0.0 bind-port=52089 diff --git a/server/share/etc/web.ini.in b/server/share/etc/web.ini.in index 6cb80b2..31255d6 100644 --- a/server/share/etc/web.ini.in +++ b/server/share/etc/web.ini.in @@ -5,8 +5,7 @@ ; ip=0.0.0.0 ; port listen by web server, default to 7190. -; DO NOT FORGET update common::web-server-rpc in core.ini if you modified this setting. -; port=7190 +; DO NOT FORGET update `common::web-server-rpc` in core.ini if you modified this setting. port=7190 ; 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_WARN 3 log warning and error message. ; 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 trace call stack when exception raised. -; debug-mode=0 +; in debug mode, `log-level` force to 0 and display more message for debug purpose. debug-mode=0 ; `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. -; core-server-rpc=http://127.0.0.1:52080/rpc core-server-rpc=http://127.0.0.1:52080/rpc diff --git a/server/tp_web/src/main.cpp b/server/tp_web/src/main.cpp index c8c9e64..c93662a 100644 --- a/server/tp_web/src/main.cpp +++ b/server/tp_web/src/main.cpp @@ -184,7 +184,7 @@ static int _main_loop(void) { 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()); return 1; diff --git a/server/tp_web/src/ts_env.cpp b/server/tp_web/src/ts_env.cpp index e86bf5b..b14378f 100644 --- a/server/tp_web/src/ts_env.cpp +++ b/server/tp_web/src/ts_env.cpp @@ -100,19 +100,18 @@ bool TsEnv::init(bool load_config) int log_level = EX_LOG_LEVEL_INFO; 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); } int debug_mode = 0; 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); - } - - if (1 == debug_mode) { - EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG); + if (1 == debug_mode) { + EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG); + } } return true; diff --git a/server/www/teleport/.idea/teleport.iml b/server/www/teleport/.idea/teleport.iml index 6253974..6711606 100644 --- a/server/www/teleport/.idea/teleport.iml +++ b/server/www/teleport/.idea/teleport.iml @@ -1,21 +1,10 @@ - - - - - + + - - - diff --git a/server/www/teleport/view/maintenance/install.mako b/server/www/teleport/view/maintenance/install.mako index c6caf9d..88d5d87 100644 --- a/server/www/teleport/view/maintenance/install.mako +++ b/server/www/teleport/view/maintenance/install.mako @@ -50,7 +50,7 @@ ## Begin Main Body.
-

欢迎安装使用 TELEPORT v${app_ver.TP_SRV_WWW_VER} 社区版!

+

欢迎安装使用 TELEPORT v${app_ver.TP_SERVER_VER} 社区版!


确定数据库类型

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