mirror of https://github.com/tp4a/teleport
.tmp.
parent
c240f94da5
commit
bffefe8965
|
@ -307,6 +307,7 @@ void TsWsClient::_create_response(ex_astr& buf, const AssistMessage& msg_ret, in
|
||||||
|
|
||||||
void TsWsClient::_on_message(const std::string& message, std::string& buf)
|
void TsWsClient::_on_message(const std::string& message, std::string& buf)
|
||||||
{
|
{
|
||||||
|
// e.g.:
|
||||||
// {
|
// {
|
||||||
// "type":0,
|
// "type":0,
|
||||||
// "method":"run",
|
// "method":"run",
|
||||||
|
@ -317,6 +318,8 @@ void TsWsClient::_on_message(const std::string& message, std::string& buf)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
EXLOGV("on_message: %s\n", message.c_str());
|
||||||
|
|
||||||
AssistMessage msg_req;
|
AssistMessage msg_req;
|
||||||
|
|
||||||
Json::CharReaderBuilder jrb;
|
Json::CharReaderBuilder jrb;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
; 'log-file' define the log file location. if not set, default locate
|
; 'log-file' define the log file location. if not set, default locate
|
||||||
; to $INSTDIR%/data/log/tpcore.log
|
; to $TELEPORT_INSTDIR%/data/log/tpcore.log
|
||||||
;log-file=/var/log/teleport/tpcore.log
|
;log-file=/usr/local/teleport/data/log/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.
|
||||||
|
@ -18,8 +18,8 @@ log-level=2
|
||||||
debug-mode=0
|
debug-mode=0
|
||||||
|
|
||||||
; 'replay-path' define the replay file location. if not set, default locate
|
; 'replay-path' define the replay file location. if not set, default locate
|
||||||
; to `$INSTDIR%/data/replay`
|
; to `$TELEPORT_INSTDIR/data/replay`
|
||||||
;replay-path=/var/lib/teleport/replay
|
;replay-path=/usr/local/teleport/data/replay
|
||||||
|
|
||||||
; `web-server-rpc` is the rpc interface of web server.
|
; `web-server-rpc` is the rpc interface of web server.
|
||||||
; default to `http://127.0.0.1:7190/rpc`.
|
; default to `http://127.0.0.1:7190/rpc`.
|
||||||
|
|
|
@ -38,14 +38,8 @@ def _export_table(db, table_name):
|
||||||
else:
|
else:
|
||||||
fields_count = len(fields)
|
fields_count = len(fields)
|
||||||
for i in range(len(d)):
|
for i in range(len(d)):
|
||||||
# x = []
|
|
||||||
# for j in range(fields_count):
|
|
||||||
# x.append(d[i][j].__str__())
|
|
||||||
# val = "','".join(x).replace('\n', '\\n')
|
|
||||||
x = list()
|
x = list()
|
||||||
for j in range(fields_count):
|
for j in range(fields_count):
|
||||||
# if j > 0:
|
|
||||||
# x.append(',')
|
|
||||||
if s[j]:
|
if s[j]:
|
||||||
if d[i][j] is None:
|
if d[i][j] is None:
|
||||||
x.append('NULL')
|
x.append('NULL')
|
||||||
|
@ -54,12 +48,11 @@ def _export_table(db, table_name):
|
||||||
else:
|
else:
|
||||||
x.append('{}'.format(d[i][j]))
|
x.append('{}'.format(d[i][j]))
|
||||||
val = ','.join(x)
|
val = ','.join(x)
|
||||||
print('VAL:', val, '\n')
|
|
||||||
|
|
||||||
sql = "INSERT INTO `{}` VALUES ({});".format(table_name, val)
|
sql = "INSERT INTO `{}` VALUES ({});".format(table_name, val)
|
||||||
ret.append(sql)
|
ret.append(sql)
|
||||||
|
|
||||||
return '\r\n'.join(ret)
|
return '\n'.join(ret)
|
||||||
|
|
||||||
|
|
||||||
def export_database(db):
|
def export_database(db):
|
||||||
|
@ -67,9 +60,9 @@ def export_database(db):
|
||||||
now = time.localtime(time.time())
|
now = time.localtime(time.time())
|
||||||
ret.append('-- {:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d} '.format(now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec))
|
ret.append('-- {:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d} '.format(now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec))
|
||||||
if db.db_type == db.DB_TYPE_SQLITE:
|
if db.db_type == db.DB_TYPE_SQLITE:
|
||||||
ret.append('-- export from SQLite Database')
|
ret.append('-- export from Teleport SQLite Database')
|
||||||
elif db.db_type == db.DB_TYPE_MYSQL:
|
elif db.db_type == db.DB_TYPE_MYSQL:
|
||||||
ret.append('-- export from MySQL Database')
|
ret.append('-- export from Teleport MySQL Database')
|
||||||
else:
|
else:
|
||||||
return '未知的数据库类型', False
|
return '未知的数据库类型', False
|
||||||
|
|
||||||
|
@ -77,24 +70,7 @@ def export_database(db):
|
||||||
if db_ret is None or 0 == len(db_ret):
|
if db_ret is None or 0 == len(db_ret):
|
||||||
return '无法获取数据库版本', False
|
return '无法获取数据库版本', False
|
||||||
else:
|
else:
|
||||||
ret.append('-- DATABASE VERSION {}'.format(db_ret[0][0]))
|
ret.append('-- TELEPORT DATABASE VERSION {}'.format(db_ret[0][0]))
|
||||||
|
|
||||||
# _fields = ['account_id', 'account_type', 'account_name', 'account_pwd', 'account_status', 'account_lock', 'account_desc', 'oath_secret']
|
|
||||||
# ret.append(_export_table(db, 'account', _fields))
|
|
||||||
# _fields = ['auth_id', 'account_name', 'host_id', 'host_auth_id']
|
|
||||||
# ret.append(_export_table(db, 'auth', _fields))
|
|
||||||
# _fields = ['cert_id', 'cert_name', 'cert_pub', 'cert_pri', 'cert_desc']
|
|
||||||
# ret.append(_export_table(db, 'key', _fields))
|
|
||||||
# _fields = ['name', 'value']
|
|
||||||
# ret.append(_export_table(db, 'config', _fields))
|
|
||||||
# _fields = ['group_id', 'group_name']
|
|
||||||
# ret.append(_export_table(db, 'group', _fields))
|
|
||||||
# _fields = ['host_id', 'group_id', 'host_sys_type', 'host_ip', 'host_port', 'protocol', 'host_lock', 'host_desc']
|
|
||||||
# ret.append(_export_table(db, 'host_info', _fields))
|
|
||||||
# _fields = ['id', 'host_id', 'auth_mode', 'user_name', 'user_pswd', 'user_param', 'cert_id', 'encrypt', 'log_time']
|
|
||||||
# ret.append(_export_table(db, 'auth_info', _fields))
|
|
||||||
# _fields = ['id', 'session_id', 'account_name', 'host_ip', 'host_port', 'sys_type', 'auth_type', 'protocol', 'user_name', 'ret_code', 'begin_time', 'end_time', 'log_time']
|
|
||||||
# ret.append(_export_table(db, 'log', _fields))
|
|
||||||
|
|
||||||
ret.append(_export_table(db, 'config'))
|
ret.append(_export_table(db, 'config'))
|
||||||
ret.append(_export_table(db, 'core_server'))
|
ret.append(_export_table(db, 'core_server'))
|
||||||
|
@ -116,4 +92,4 @@ def export_database(db):
|
||||||
ret.append(_export_table(db, 'record'))
|
ret.append(_export_table(db, 'record'))
|
||||||
ret.append(_export_table(db, 'record_audit'))
|
ret.append(_export_table(db, 'record_audit'))
|
||||||
|
|
||||||
return '\r\n'.join(ret), True
|
return '\n'.join(ret), True
|
||||||
|
|
Loading…
Reference in New Issue