修正:审计页面没有显示用户姓名,仅显示了用户登录账号名;

修正:telnet配置为无用户名密码登录时,总是提示参数错误;
其他:去掉构建脚本对python2的支持;
dev
Apex Liu 2020-12-05 01:33:47 +08:00
parent a50b540b95
commit 3a42600b73
11 changed files with 129 additions and 263 deletions

View File

@ -4,9 +4,6 @@ MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}")
MESSAGE(STATUS "root source directory is ${PROJECT_SOURCE_DIR}") MESSAGE(STATUS "root source directory is ${PROJECT_SOURCE_DIR}")
MESSAGE(STATUS "current source directory is ${CMAKE_CURRENT_SOURCE_DIR}") MESSAGE(STATUS "current source directory is ${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/server/x64/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/server/x64/bin")
set(CMAKE_CONFIGURATION_TYPES Debug Release) set(CMAKE_CONFIGURATION_TYPES Debug Release)
# Determine the platform. # Determine the platform.
@ -16,12 +13,16 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(OS_POSIX 1) set(OS_POSIX 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(TP_EXTERNAL_RELEASE_DIR "${PROJECT_SOURCE_DIR}/external/macos/release") set(TP_EXTERNAL_RELEASE_DIR "${PROJECT_SOURCE_DIR}/external/macos/release")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/server/macos/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/server/macos/bin")
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
MESSAGE(STATUS "build on Linux...") MESSAGE(STATUS "build on Linux...")
set(OS_LINUX 1) set(OS_LINUX 1)
set(OS_POSIX 1) set(OS_POSIX 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(TP_EXTERNAL_RELEASE_DIR "${PROJECT_SOURCE_DIR}/external/linux/release") set(TP_EXTERNAL_RELEASE_DIR "${PROJECT_SOURCE_DIR}/external/linux/release")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/server/linux/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/out/server/linux/bin")
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
MESSAGE(FATAL_ERROR "unsupported platform: Windows") MESSAGE(FATAL_ERROR "unsupported platform: Windows")
else () else ()

View File

@ -11,11 +11,6 @@ import builder.core.colorconsole as cc
import builder.core.utils as utils import builder.core.utils as utils
from builder.core.context import * from builder.core.context import *
if env.is_py2:
_input = raw_input
else:
_input = input
options = list() options = list()
options_idx = 0 options_idx = 0
ctx = BuildContext() ctx = BuildContext()
@ -27,9 +22,6 @@ def main():
if not env.init(warn_miss_tool=True): if not env.init(warn_miss_tool=True):
return return
# wget = os.environ.get('TP_TOOLCHAIN_WGET')
# cc.w(wget)
action = None action = None
argv = sys.argv[1:] argv = sys.argv[1:]
if len(argv) >= 1: if len(argv) >= 1:
@ -46,7 +38,21 @@ def main():
make_options() make_options()
if action is not None: if action is not None:
cc.v(action) if action == '-h' or action == '--help':
max_name_len = 0
for x in options:
if x['id'] != '--SPLIT-LINE--':
max_name_len = max(len(x['name']), max_name_len)
max_name_len += 4
for x in options:
if x['id'] != '--SPLIT-LINE--':
name_pad = max_name_len - len(x['name'])
cc.o((cc.CR_INFO, x['name']), (cc.CR_VERBOSE, ' ' * name_pad), (cc.CR_VERBOSE, x['disp']))
return
# cc.v(action)
opt = select_option_by_name(action) opt = select_option_by_name(action)
if opt is None: if opt is None:
cc.e('unknown config: ', action) cc.e('unknown config: ', action)
@ -61,16 +67,6 @@ def main():
if x == 'q': if x == 'q':
break break
# if x == 'c':
# clean_all()
# continue
# elif x == 'a':
# clean_everything()
# continue
# elif x == 'e':
# clean_external()
# continue
try: try:
x = int(x) x = int(x)
except: except:
@ -91,7 +87,7 @@ def main():
cc.w('\ntask finished, press Enter to continue or Q to quit...', end='') cc.w('\ntask finished, press Enter to continue or Q to quit...', end='')
try: try:
x = _input() x = input()
except EOFError: except EOFError:
x = 'q' x = 'q'
if x == 'q': if x == 'q':
@ -124,16 +120,16 @@ def clean_everything():
def clean_external(): def clean_external():
#utils.remove(os.path.join(env.root_path, 'out')) # utils.remove(os.path.join(env.root_path, 'out'))
utils.remove(os.path.join(env.root_path, 'external', 'jsoncpp')) utils.remove(os.path.join(env.root_path, 'external', 'jsoncpp'))
utils.remove(os.path.join(env.root_path, 'external', 'libuv')) utils.remove(os.path.join(env.root_path, 'external', 'libuv'))
utils.remove(os.path.join(env.root_path, 'external', 'mbedtls')) utils.remove(os.path.join(env.root_path, 'external', 'mbedtls'))
utils.remove(os.path.join(env.root_path, 'external', 'mongoose')) utils.remove(os.path.join(env.root_path, 'external', 'mongoose'))
#utils.remove(os.path.join(env.root_path, 'external', 'openssl')) # utils.remove(os.path.join(env.root_path, 'external', 'openssl'))
#utils.remove(os.path.join(env.root_path, 'external', 'python')) # utils.remove(os.path.join(env.root_path, 'external', 'python'))
#utils.remove(os.path.join(env.root_path, 'external', 'libssh-win-static', 'lib')) # utils.remove(os.path.join(env.root_path, 'external', 'libssh-win-static', 'lib'))
#utils.remove(os.path.join(env.root_path, 'external', 'libssh-win-static', 'src')) # utils.remove(os.path.join(env.root_path, 'external', 'libssh-win-static', 'src'))
#utils.remove(os.path.join(env.root_path, 'external', 'linux', 'tmp')) # utils.remove(os.path.join(env.root_path, 'external', 'linux', 'tmp'))
utils.remove(os.path.join(env.root_path, 'external', 'linux', 'release', 'lib', 'libmbedcrypto.a')) utils.remove(os.path.join(env.root_path, 'external', 'linux', 'release', 'lib', 'libmbedcrypto.a'))
utils.remove(os.path.join(env.root_path, 'external', 'linux', 'release', 'lib', 'libmbedtls.a')) utils.remove(os.path.join(env.root_path, 'external', 'linux', 'release', 'lib', 'libmbedtls.a'))
utils.remove(os.path.join(env.root_path, 'external', 'linux', 'release', 'lib', 'libmbedx509.a')) utils.remove(os.path.join(env.root_path, 'external', 'linux', 'release', 'lib', 'libmbedx509.a'))
@ -153,9 +149,6 @@ def do_opt(opt):
elif 'pysrt' == opt['name']: elif 'pysrt' == opt['name']:
script = 'build-pysrt.py' script = 'build-pysrt.py'
# elif 'external' == opt['name']:
# script = 'build-external.py'
# arg = '%s %s' % (ctx.target_path, opt['bits'])
elif opt['name'] in ['ext-client', 'ext-server', 'clear-ext-client', 'clear-ext-server']: elif opt['name'] in ['ext-client', 'ext-server', 'clear-ext-client', 'clear-ext-server']:
script = 'build-external.py' script = 'build-external.py'
arg = '%s %s %s' % (opt['name'], ctx.target_path, opt['bits']) arg = '%s %s %s' % (opt['name'], ctx.target_path, opt['bits'])
@ -166,15 +159,12 @@ def do_opt(opt):
elif 'server-installer' == opt['name']: elif 'server-installer' == opt['name']:
script = 'build-installer.py' script = 'build-installer.py'
# arg = 'installer'
arg = '%s %s server-installer' % (ctx.dist, opt['bits']) arg = '%s %s server-installer' % (ctx.dist, opt['bits'])
elif 'client' == opt['name']: elif 'client' == opt['name']:
script = 'build-assist.py' script = 'build-assist.py'
arg = '%s %s exe' % (ctx.target_path, opt['bits']) arg = '%s %s exe' % (ctx.target_path, opt['bits'])
# elif 'assist-rdp' == opt['name']:
# script = 'build-assist.py'
# arg = '%s rdp' % (opt['bits'])
elif 'client-installer' == opt['name']: elif 'client-installer' == opt['name']:
script = 'build-assist.py' script = 'build-assist.py'
arg = '%s %s installer' % (ctx.dist, opt['bits']) arg = '%s %s installer' % (ctx.dist, opt['bits'])
@ -183,47 +173,35 @@ def do_opt(opt):
cc.e('unknown option: ', opt['name']) cc.e('unknown option: ', opt['name'])
return return
# cmd = '"%s" -B "%s" %s' % (utils.cfg.py_exec, os.path.join(BUILDER_PATH, script), arg)
cmd = '%s -B %s %s' % (env.py_exec, os.path.join(env.builder_path, script), arg) cmd = '%s -B %s %s' % (env.py_exec, os.path.join(env.builder_path, script), arg)
print(cmd)
os.system(cmd) os.system(cmd)
def select_option_by_name(name): def select_option_by_name(name):
global options for x in options:
if x['id'] != '--SPLIT-LINE--':
for o in range(len(options)): if name == x['name']:
if options[o] is None: return x
continue
if name == options[o]['name']:
return options[o]
return None return None
def select_option_by_id(_id): def select_option_by_id(_id):
global options for x in options:
if x['id'] == _id:
return x
for o in range(len(options)):
if options[o] is None:
continue
if options[o]['id'] == _id:
return options[o]
return None return None
def add_option(bits, name, disp): def add_option(bits, name, disp):
global options, options_idx global options, options_idx
options_idx += 1 options_idx += 1
# if bits is not None:
# disp = '[%s] %s' % (bits, disp)
options.append({'id': options_idx, 'name': name, 'disp': disp, 'bits': bits}) options.append({'id': options_idx, 'name': name, 'disp': disp, 'bits': bits})
def add_split(title=None): def add_split(title=None):
global options global options
# options.append(None)
options.append({'id': '--SPLIT-LINE--', 'title': title}) options.append({'id': '--SPLIT-LINE--', 'title': title})
@ -258,8 +236,8 @@ def make_options():
add_option('x64', 'client', 'build client applications [%s]' % ctx.target_path) add_option('x64', 'client', 'build client applications [%s]' % ctx.target_path)
add_option('x64', 'client-installer', 'make client installer') add_option('x64', 'client-installer', 'make client installer')
add_split('server side') add_split('server side')
add_option('x64', 'ext-server', 'build external libraries for server') add_option('x64', 'ext-server', '(DEV-ONLY) build external libraries for server')
add_option('x64', 'server', '(DEV-ONLY) build server applications [%s]' % ctx.target_path) add_option('x64', 'server', '(DEV-ONLY) build server applications for MacOS [%s]' % ctx.target_path)
add_split('clear') add_split('clear')
add_option('x64', 'clear-ext-client', 'clear external libraries for client') add_option('x64', 'clear-ext-client', 'clear external libraries for client')
add_option('x64', 'clear-ext-server', 'clear external libraries for server') add_option('x64', 'clear-ext-server', 'clear external libraries for server')
@ -282,47 +260,36 @@ def make_options():
def get_input(msg, log_func=cc.w): def get_input(msg, log_func=cc.w):
log_func(msg, end=' ') log_func(msg, end=' ')
try: try:
return _input() return input()
except EOFError: except EOFError:
return '' return ''
def show_logo(): def show_logo():
cc.v('[]==========================================================[]') cc.v('[]==========================================================[]')
cc.o((cc.CR_VERBOSE, ' | '), (cc.CR_INFO, 'Teleport Projects Builder'), (cc.CR_VERBOSE, ' |')) cc.v(' | Teleport Projects Builder v2.0 |')
cc.v(' | auth: apex.liu@qq.com |') cc.v(' | auth: apex.liu@qq.com |')
cc.v('[]==========================================================[]') cc.v('[]==========================================================[]')
def show_menu(): def show_menu():
cc.v('\n=====================[ MENU ]===============================') cc.v('\n=====================[ MENU ]===============================')
for o in range(len(options)): for o in options:
if options[o]['id'] == '--SPLIT-LINE--': if o['id'] == '--SPLIT-LINE--':
if options[o]['title'] is not None: if o['title'] is not None:
# title = ' {}: '.format(options[o]['title']) cc.w('\n {}:'.format(o['title']))
# pad = '-' * (60 - len(title))
# cc.v('\n{}{}'.format(title, pad))
cc.w('\n {}:'.format(options[o]['title']))
else: else:
cc.v('\n ----------------------------------------------------------') cc.v('\n ----------------------------------------------------------')
continue continue
# if options[o] is None: cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, '%2d' % o['id']), (cc.CR_NORMAL, '] ', o['disp']))
# cc.v(' -------------------------------------------------------')
# continue
cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, '%2d' % options[o]['id']), (cc.CR_NORMAL, '] ', options[o]['disp']))
# cc.v(' -------------------------------------------------------')
# cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, ' E'), (cc.CR_NORMAL, '] clean external temp. files.'))
# cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, ' C'), (cc.CR_NORMAL, '] clean build and dist.'))
# cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, ' A'), (cc.CR_NORMAL, '] clean everything.'))
cc.v('\n ----------------------------------------------------------') cc.v('\n ----------------------------------------------------------')
cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, ' Q'), (cc.CR_NORMAL, '] exit')) cc.o((cc.CR_NORMAL, ' ['), (cc.CR_INFO, ' Q'), (cc.CR_NORMAL, '] exit'))
cc.w('\nselect action: ', end='') cc.w('\nselect action: ', end='')
try: try:
x = _input() x = input()
except EOFError: except EOFError:
x = 'q' x = 'q'
@ -338,4 +305,4 @@ if __name__ == '__main__':
except RuntimeError as e: except RuntimeError as e:
cc.e(e.__str__()) cc.e(e.__str__())
except: except:
cc.f('got exception.') cc.f('got an exception.')

View File

@ -166,7 +166,7 @@ class BuilderWin(BuilderBase):
cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC)) cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC))
cc.w('\nOnce the OpenSSL installed, press Enter to continue or Q to quit...', end='') cc.w('\nOnce the OpenSSL installed, press Enter to continue or Q to quit...', end='')
try: try:
x = env.input() x = input()
except EOFError: except EOFError:
x = 'q' x = 'q'
if x == 'q': if x == 'q':
@ -349,7 +349,7 @@ class BuilderWin(BuilderBase):
cc.w('for Visual Studio 2017. Visit https://docs.tp4a.com for more details.') cc.w('for Visual Studio 2017. Visit https://docs.tp4a.com for more details.')
cc.w('\nOnce the zlib.sln generated, press Enter to continue or Q to quit...', end='') cc.w('\nOnce the zlib.sln generated, press Enter to continue or Q to quit...', end='')
try: try:
x = env.input() x = input()
except EOFError: except EOFError:
x = 'q' x = 'q'
if x == 'q': if x == 'q':

View File

@ -129,7 +129,7 @@ class BuilderLinux(BuilderBase):
utils.fix_new_line_flag(os.path.join(self.path_tmp_data, 'tmp', 'etc', 'web.ini')) utils.fix_new_line_flag(os.path.join(self.path_tmp_data, 'tmp', 'etc', 'web.ini'))
utils.fix_new_line_flag(os.path.join(self.path_tmp_data, 'tmp', 'etc', 'core.ini')) utils.fix_new_line_flag(os.path.join(self.path_tmp_data, 'tmp', 'etc', 'core.ini'))
out_path = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, 'bin') out_path = os.path.join(env.root_path, 'out', 'server', 'linux', 'bin')
bin_path = os.path.join(self.path_tmp_data, 'bin') bin_path = os.path.join(self.path_tmp_data, 'bin')
utils.copy_ex(out_path, bin_path, 'tp_web') 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, 'tp_core')

View File

@ -206,85 +206,12 @@ class ColorConsole:
s = traceback.extract_stack() s = traceback.extract_stack()
c = len(s) c = len(s)
self._console_set_color(CR_RED) self._console_set_color(CR_RED)
for i in range(2, c): for i in range(1, c):
self._console_output(' ', os.path.abspath(s[c - i - 1][0]), '(', s[c - i - 1][1], '): ', s[c - i - 1][3], sep='') self._console_output(' ', os.path.abspath(s[c - i - 1][0]), '(', s[c - i - 1][1], '): ', s[c - i - 1][3], sep='')
self._console_restore_color() self._console_restore_color()
sys.stdout.flush() sys.stdout.flush()
# def _do_log(self, msg, color=None):
# self._log_console(msg, color)
#
# def _console_default(self, msg, color=None):
# if msg is None:
# return
#
# sys.stdout.writelines(msg)
# sys.stdout.flush()
#
# def _console_win(self, msg, color=None):
# if msg is None:
# return
#
# # 这里的问题很复杂,日常使用没有问题,但是当在工作机上使用时,部分内容是捕获另一个脚本执行的结果再输出
# # 如果结果中有中文,这里就会显示乱码。如果尝试编码转换,会抛出异常。目前暂时采用显示乱码的方式了。
#
# # if CONSOLE_WIN_CMD == self.console_type:
# # try:
# # _msg = unicode(msg, 'utf-8')
# # except:
# # _msg = msg
# # else:
# # _msg = msg
# # _msg = None
# # if isinstance(msg, unicode):
# # _msg = msg
# # else:
# # # _msg = unicode(msg, 'utf-8')
# # try:
# # _msg = unicode(msg, 'utf-8')
# # except:
# # _msg = unicode(msg, 'gb2312')
# # # _msg = msg
# #
# # # if CONSOLE_WIN_CMD == self.console_type:
# # # sys.stdout.writelines(msg.encode('gb2312'))
# # # else:
# # # sys.stdout.writelines(msg.encode('utf-8'))
# #
# #
# # # try:
# # # _msg = unicode(msg, 'utf-8')
# # # except:
# # _msg = msg
#
# if color is None:
# sys.stdout.writelines(msg)
# else:
# self._win_color.set_color(COLORS[color][1])
# sys.stdout.writelines(msg)
# sys.stdout.flush()
# self._win_color.set_color(COLORS[CR_RESTORE][1])
#
# sys.stdout.flush()
#
# def _console_linux(self, msg, cr=None):
# if msg is None:
# return
#
# if cr is None:
# sys.stdout.writelines(msg)
# else:
# sys.stdout.writelines('\x1B')
# sys.stdout.writelines(COLORS[cr][0])
# sys.stdout.writelines(msg)
# sys.stdout.writelines('\x1B[0m')
#
# sys.stdout.flush()
# def _console_set_color_default(self, cr=None):
# pass
def _console_set_color_win(self, cr=None): def _console_set_color_win(self, cr=None):
if cr is None: if cr is None:
return return
@ -325,55 +252,33 @@ class ColorConsole:
sys.stdout.writelines(end) sys.stdout.writelines(end)
sys.stdout.flush() sys.stdout.flush()
# def _test(self): def test(self):
# self.log('###################', CR_RESTORE) self.o((CR_RESTORE, '################### CR_RESTORE'))
# self.log(' CR_RESTORE\n') self.o((CR_BLACK, '################### CR_BLACK'))
# self.log('###################', CR_BLACK) self.o((CR_LIGHT_GRAY, '################### CR_LIGHT_GRAY'))
# self.log(' CR_BLACK\n') self.o((CR_GRAY, '################### CR_GRAY'))
# self.log('###################', CR_LIGHT_GRAY) self.o((CR_WHITE, '################### CR_WHITE'))
# self.log(' CR_LIGHT_GRAY\n') self.o((CR_RED, '################### CR_RED'))
# self.log('###################', CR_GRAY) self.o((CR_GREEN, '################### CR_GREEN'))
# self.log(' CR_GRAY\n') self.o((CR_YELLOW, '################### CR_YELLOW'))
# self.log('###################', CR_WHITE) self.o((CR_BLUE, '################### CR_BLUE'))
# self.log(' CR_WHITE\n') self.o((CR_MAGENTA, '################### CR_MAGENTA'))
# self.log('###################', CR_RED) self.o((CR_CYAN, '################### CR_CYAN'))
# self.log(' CR_RED\n') self.o((CR_LIGHT_RED, '################### CR_LIGHT_RED'))
# self.log('###################', CR_GREEN) self.o((CR_LIGHT_GREEN, '################### CR_LIGHT_GREEN'))
# self.log(' CR_GREEN\n') self.o((CR_LIGHT_YELLOW, '################### CR_LIGHT_YELLOW'))
# self.log('###################', CR_YELLOW) self.o((CR_LIGHT_BLUE, '################### CR_LIGHT_BLUE'))
# self.log(' CR_YELLOW\n') self.o((CR_LIGHT_MAGENTA, '################### CR_LIGHT_MAGENTA'))
# self.log('###################', CR_BLUE) self.o((CR_LIGHT_CYAN, '################### CR_LIGHT_CYAN'))
# self.log(' CR_BLUE\n')
# self.log('###################', CR_MAGENTA) self.v('This is VERBOSE message.')
# self.log(' CR_MAGENTA\n') self.n('This is NORMAL message.')
# self.log('###################', CR_CYAN) self.i('This is INFORMATION message.')
# self.log(' CR_CYAN\n') self.w('This is WARNING message.')
# self.log('###################', CR_LIGHT_RED) self.e('This is ERROR message.')
# self.log(' CR_LIGHT_RED\n') self.f('This is FAIL message, show backtrace also.')
# self.log('###################', CR_LIGHT_GREEN)
# self.log(' CR_LIGHT_GREEN\n') self.v('test auto\nsplit lines.\nYou should see\nmulti-lines.\n')
# self.log('###################', CR_LIGHT_YELLOW)
# self.log(' CR_LIGHT_YELLOW\n')
# self.log('###################', CR_LIGHT_BLUE)
# self.log(' CR_LIGHT_BLUE\n')
# self.log('###################', CR_LIGHT_MAGENTA)
# self.log(' CR_LIGHT_MAGENTA\n')
# self.log('###################', CR_LIGHT_CYAN)
# self.log(' CR_LIGHT_CYAN\n')
# # data = b'This is a test string and you can see binary format data here.'
# # self.bin('Binary Data:\n', data)
# # data = b''
# # self.bin('Empty binary\n', data)
# # self.bin('This is string\n\n', 'data')
#
# # self.d('This is DEBUG message.\n')
# self.v('This is VERBOSE message.\n')
# self.i('This is INFORMATION message.\n')
# self.w('This is WARNING message.\n')
# self.e('This is ERROR message.\n')
# self.f('This is FAIL message.\n')
#
# self.v('test auto\nsplit lines.\nYou should see\nmulti-lines.\n')
class Win32ColorConsole: class Win32ColorConsole:
@ -474,3 +379,7 @@ def e(*args, **kwargs):
def f(*args, **kwargs): def f(*args, **kwargs):
_cc.f(*args, **kwargs) _cc.f(*args, **kwargs)
if __name__ == '__main__':
_cc.test()

View File

@ -26,14 +26,6 @@ class Env(object):
self.build_path = os.path.abspath(os.path.join(_this_path, '..', '..')) self.build_path = os.path.abspath(os.path.join(_this_path, '..', '..'))
self.builder_path = os.path.join(self.build_path, 'builder') self.builder_path = os.path.join(self.build_path, 'builder')
self.is_py2 = sys.version_info[0] == 2
self.is_py3 = sys.version_info[0] == 3
if self.is_py2:
self.input = raw_input
else:
self.input = input
self.py_ver = platform.python_version_tuple() self.py_ver = platform.python_version_tuple()
self.py_ver_str = '%s%s' % (self.py_ver[0], self.py_ver[1]) self.py_ver_str = '%s%s' % (self.py_ver[0], self.py_ver[1])
self.py_ver_dot = '%s.%s' % (self.py_ver[0], self.py_ver[1]) self.py_ver_dot = '%s.%s' % (self.py_ver[0], self.py_ver[1])
@ -76,10 +68,8 @@ class Env(object):
def _load_config(self, warn_miss_tool): def _load_config(self, warn_miss_tool):
_cfg_file = 'config.{}.json'.format(self.plat) _cfg_file = 'config.{}.json'.format(self.plat)
# _cfg_file = os.path.join(self.root_path, 'config.ini')
_cfg_file = os.path.join(self.root_path, _cfg_file) _cfg_file = os.path.join(self.root_path, _cfg_file)
if not os.path.exists(_cfg_file): if not os.path.exists(_cfg_file):
# cc.e('can not load configuration.\n\nplease copy `config.ini.in` to `config.ini` and modify it to fit your condition and try again.')
cc.e('can not load configuration.\n\nplease copy `config.json.in` to `config.{}.json` and modify it to fit your condition and try again.'.format(self.plat)) cc.e('can not load configuration.\n\nplease copy `config.json.in` to `config.{}.json` and modify it to fit your condition and try again.'.format(self.plat))
return False return False
@ -90,12 +80,6 @@ class Env(object):
cc.e('can ot load configuration file, not in JSON format.') cc.e('can ot load configuration file, not in JSON format.')
return False return False
# _cfg = configparser.ConfigParser()
# _cfg.read(_cfg_file)
# if 'toolchain' not in _cfg.sections():
# cc.e('invalid configuration file: need `toolchain` section.')
# return False
if 'toolchain' not in _cfg: if 'toolchain' not in _cfg:
cc.e('invalid configuration file: need `toolchain` section.') cc.e('invalid configuration file: need `toolchain` section.')
return False return False

View File

@ -9,11 +9,8 @@ import time
from . import colorconsole as cc from . import colorconsole as cc
from .env import env from .env import env
if env.is_py2: import importlib
import imp import importlib.machinery
elif env.is_py3:
import importlib
import importlib.machinery
def _check_download_file(file_name): def _check_download_file(file_name):
@ -96,12 +93,6 @@ def extension_suffixes():
# type为文件类型, 1代表PY_SOURCE, 2代表PY_COMPILED, 3代表C_EXTENSION # type为文件类型, 1代表PY_SOURCE, 2代表PY_COMPILED, 3代表C_EXTENSION
EXTENSION_SUFFIXES = list() EXTENSION_SUFFIXES = list()
if env.is_py2:
suf = imp.get_suffixes()
for s in suf:
if s[2] == 3:
EXTENSION_SUFFIXES.append(s[0])
else:
EXTENSION_SUFFIXES = importlib.machinery.EXTENSION_SUFFIXES EXTENSION_SUFFIXES = importlib.machinery.EXTENSION_SUFFIXES
if env.is_win: if env.is_win:

View File

@ -713,33 +713,35 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) {
//============================================== //==============================================
// sorry, TELNET not supported yet for macOS. // sorry, TELNET not supported yet for macOS.
_create_json_ret(buf, TPE_NOT_IMPLEMENT); // _create_json_ret(buf, TPE_NOT_IMPLEMENT);
return; // return;
// if(g_cfg.telnet.name == "terminal" || g_cfg.telnet.name == "iterm2") { g_cfg.telnet.name = "iterm2";
// char szCmd[1024] = {0};
// ex_strformat(szCmd, 1023, "telnet -l %s %s %d", sid.c_str(), teleport_ip.c_str(), teleport_port); if(g_cfg.telnet.name == "terminal" || g_cfg.telnet.name == "iterm2") {
// char szCmd[1024] = {0};
// char szTitle[128] = {0}; ex_strformat(szCmd, 1023, "telnet -l %s %s %d", sid.c_str(), teleport_ip.c_str(), teleport_port);
// ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str());
// char szTitle[128] = {0};
// int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.telnet.name.c_str(), g_cfg.telnet.cmdline.c_str(), szTitle); ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str());
// if(ret == 0)
// _create_json_ret(buf, TPE_OK); int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.telnet.name.c_str(), g_cfg.telnet.cmdline.c_str(), szTitle);
// else if(ret == 0)
// _create_json_ret(buf, TPE_FAILED); _create_json_ret(buf, TPE_OK);
// return; else
// } _create_json_ret(buf, TPE_FAILED);
// return;
// if(g_cfg.telnet.application.length() == 0) { }
// _create_json_ret(buf, TPE_NOT_EXISTS);
// return; if(g_cfg.telnet.application.length() == 0) {
// } _create_json_ret(buf, TPE_NOT_EXISTS);
// return;
// s_exec = g_cfg.telnet.application; }
// s_argv.push_back(s_exec.c_str());
// s_exec = g_cfg.telnet.application;
// s_arg = g_cfg.telnet.cmdline; s_argv.push_back(s_exec.c_str());
s_arg = g_cfg.telnet.cmdline;
} }

View File

@ -194,7 +194,7 @@ int ts_web_rpc_get_conn_info(int conn_id, TS_CONNECT_INFO& info)
|| user_username.length() == 0 || user_username.length() == 0
|| host_ip.length() == 0 || conn_ip.length() == 0 || client_ip.length() == 0 || host_ip.length() == 0 || conn_ip.length() == 0 || client_ip.length() == 0
|| conn_port <= 0 || conn_port >= 65535 || conn_port <= 0 || conn_port >= 65535
|| acc_username.length() == 0 || acc_secret.length() == 0 || acc_username.length() == 0
|| !(protocol_type == TP_PROTOCOL_TYPE_RDP || protocol_type == TP_PROTOCOL_TYPE_SSH || protocol_type == TP_PROTOCOL_TYPE_TELNET) || !(protocol_type == TP_PROTOCOL_TYPE_RDP || protocol_type == TP_PROTOCOL_TYPE_SSH || protocol_type == TP_PROTOCOL_TYPE_TELNET)
|| !(auth_type == TP_AUTH_TYPE_NONE || auth_type == TP_AUTH_TYPE_PASSWORD || auth_type == TP_AUTH_TYPE_PRIVATE_KEY) || !(auth_type == TP_AUTH_TYPE_NONE || auth_type == TP_AUTH_TYPE_PASSWORD || auth_type == TP_AUTH_TYPE_PRIVATE_KEY)
) )
@ -202,7 +202,11 @@ int ts_web_rpc_get_conn_info(int conn_id, TS_CONNECT_INFO& info)
return TPE_PARAM; return TPE_PARAM;
} }
if (_enc) { if(auth_type != TP_AUTH_TYPE_NONE && acc_secret.length() == 0) {
return TPE_PARAM;
}
if (_enc && !acc_secret.empty()) {
ex_astr _auth; ex_astr _auth;
if (!ts_db_field_decrypt(acc_secret, _auth)) if (!ts_db_field_decrypt(acc_secret, _auth))
return TPE_FAILED; return TPE_FAILED;

View File

@ -493,10 +493,18 @@ def session_fix():
def session_begin(sid, user_id, host_id, acc_id, user_username, acc_username, host_ip, conn_ip, conn_port, client_ip, auth_type, protocol_type, protocol_sub_type): def session_begin(sid, user_id, host_id, acc_id, user_username, acc_username, host_ip, conn_ip, conn_port, client_ip, auth_type, protocol_type, protocol_sub_type):
db = get_db() db = get_db()
sql = 'INSERT INTO `{}record` (sid,user_id,host_id,acc_id,state,user_username,host_ip,conn_ip,conn_port,client_ip,acc_username,auth_type,protocol_type,protocol_sub_type,time_begin,time_end) ' \
'VALUES ("{sid}",{user_id},{host_id},{acc_id},0,"{user_username}","{host_ip}","{conn_ip}",{conn_port},"{client_ip}","{acc_username}",{auth_type},{protocol_type},{protocol_sub_type},{time_begin},0)' \ sql = 'SELECT surname FROM `{tp}user` WHERE id={ph};'.format(tp=db.table_prefix, ph=db.place_holder)
db_ret = db.query(sql, (user_id, ))
if db_ret is None or len(db_ret) == 0:
user_surname = user_username
else:
user_surname = db_ret[0][0]
sql = 'INSERT INTO `{}record` (sid,user_id,host_id,acc_id,state,user_username,user_surname,host_ip,conn_ip,conn_port,client_ip,acc_username,auth_type,protocol_type,protocol_sub_type,time_begin,time_end) ' \
'VALUES ("{sid}",{user_id},{host_id},{acc_id},0,"{user_username}","{user_surname}","{host_ip}","{conn_ip}",{conn_port},"{client_ip}","{acc_username}",{auth_type},{protocol_type},{protocol_sub_type},{time_begin},0)' \
';'.format(db.table_prefix, ';'.format(db.table_prefix,
sid=sid, user_id=user_id, host_id=host_id, acc_id=acc_id, user_username=user_username, host_ip=host_ip, conn_ip=conn_ip, conn_port=conn_port, sid=sid, user_id=user_id, host_id=host_id, acc_id=acc_id, user_username=user_username, user_surname=user_surname, host_ip=host_ip, conn_ip=conn_ip, conn_port=conn_port,
client_ip=client_ip, acc_username=acc_username, auth_type=auth_type, protocol_type=protocol_type, protocol_sub_type=protocol_sub_type, client_ip=client_ip, acc_username=acc_username, auth_type=auth_type, protocol_type=protocol_type, protocol_sub_type=protocol_sub_type,
time_begin=tp_timestamp_sec()) time_begin=tp_timestamp_sec())