diff --git a/.gitignore b/.gitignore index 7677215..3218e92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,103 +1,104 @@ -# for Visual Studio -.vs -*.opensdf -*.sdf -*.user -*.ncb -*.vc.db -*.vc.opendb -*.aps -**/ipch - -# for CMake -CMakeFiles -cmake_install.cmake -Makefile -cmake-build -cmake-build-debug -client/tp_assist_macos/build - -# for Python -__pycache__ -*.pyc - - -# for pyCharm -**/.idea/workspace.xml -**/.idea/misc.xml -**/.idea/modules.xml -**/.idea/dictionaries -**/.idea/watcherTasks.xml -**/.idea/inspectionProfiles -**/.idea/vcs.xml -**/.idea/codeStyles - -*.css.map - -# for tmp folder or files. -/out -/external/_download_ -/external/linux -/external/macos -/external/jsoncpp -/external/mongoose -/external/openssl -/external/python -/external/libssh -/external/libssh-win-static/include/libssh -/external/libssh-win-static/src -/external/libssh-win-static/lib -/external/mbedtls -/external/sqlite -/external/libuv -/client/tools/putty -/client/tools/winscp -/client/tp_assist_macos/DerivedData - -# for dist folder -**/_tmp_ -/dist/server/data -/dist/client/windows/assist/apps -/dist/client/windows/assist/cfg - -/server/share/etc/core.ini -/server/share/etc/web.ini -/server/share/db -/server/share/log -/server/share/replay -/server/testssh - - -# for generated files. -/config.ini -/build.bat - -# for not finished code -/common/libex/test -/client/tp_rdp -/server/tp_core/protocol/rdp -/client/tools/tprdp -/server/tp_core/testssh -/client/tp_assist_win_it_doctor -/dist/client/windows/assist-it-doctor - -# for MacOS. -.DS_Store - -# Xcode -build/* -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -*.xcworkspace -!default.xcworkspace -xcuserdata -profile -*.moved-aside -/server/share/tmp -/build.sh +# for Visual Studio +.vs +*.opensdf +*.sdf +*.user +*.ncb +*.vc.db +*.vc.opendb +*.aps +**/ipch + +# for CMake +CMakeFiles +cmake_install.cmake +cmake-build +cmake-build-debug +client/tp_assist_macos/build +**/xcode_build +**/DerivedData + +# for Python +__pycache__ +*.pyc + + +# for JetBrains IDEs. +**/.idea/workspace.xml +**/.idea/misc.xml +**/.idea/dictionaries +**/.idea/watcherTasks.xml +**/.idea/inspectionProfiles +**/.idea/codeStyles +**/.idea/inspectionProfiles +**/.idea/vcs.xml +**/.idea/modules.xml + +*.css.map + +# for tmp folder or files. +/out +/external/_download_ +/external/linux +/external/macos +/external/jsoncpp +/external/mongoose +/external/openssl +/external/python +/external/libssh +/external/mbedtls +/external/sqlite +/external/libuv +/client/tools/putty +/client/tools/winscp +/server/**/test/ +/server/**/tests/ + +# for dist folder +**/_tmp_ +/dist/server/data +/dist/client/windows/assist/apps +/dist/client/windows/assist/cfg + +/server/share/etc/core.ini +/server/share/etc/web.ini +/server/share/db +/server/share/log +/server/share/replay +/server/testssh + + +# for generated files. +/config.ini +/build.bat +/build.sh + +# for not finished code +/common/libex/test +/client/tp_rdp +/server/tp_core/protocol/rdp +/client/tools/tprdp +/server/tp_core/testssh +/client/tp_assist_win_it_doctor +/dist/client/windows/assist-it-doctor + +# for MacOS. +.DS_Store + +# for Xcode +build/* +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +/server/share/tmp + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..f49c862 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/teleport.iml b/.idea/teleport.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/teleport.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/CMakeCfg.txt b/CMakeCfg.txt new file mode 100644 index 0000000..b4bbbc5 --- /dev/null +++ b/CMakeCfg.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.5) + +MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}") +MESSAGE(STATUS "root source directory is ${PROJECT_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) + +# Determine the platform. +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") + MESSAGE(STATUS "build on macOS...") + set(OS_MACOS 1) + set(OS_POSIX 1) + set(TP_EXTERNAL_RELEASE_DIR "${PROJECT_SOURCE_DIR}/external/macos/release") +elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set(OS_LINUX 1) + set(OS_POSIX 1) + MESSAGE(STATUS "build on Linux...") + # add_subdirectory(server/tp_web/src) + set(TP_EXTERNAL_RELEASE_DIR "${PROJECT_SOURCE_DIR}/external/linux/release") +elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") + # MESSAGE(FATAL_ERROR "unsupported platform: Windows") +else () + MESSAGE(FATAL_ERROR "unsupported platform: ${CMAKE_SYSTEM_NAME}") +endif () + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8b9daf5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.5) +project(teleport) + +include(CMakeCfg.txt) + +#MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}") +#MESSAGE(STATUS "current source directory is ${CMAKE_CURRENT_SOURCE_DIR}") +# +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/out/server/x64/bin") +#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/out/server/x64/bin") +# +#set(CMAKE_CONFIGURATION_TYPES Debug Release) +# +## Determine the platform. +#if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") +# MESSAGE(STATUS "build on macOS...") +# set(OS_MACOS 1) +# set(OS_POSIX 1) +# set(TP_EXTERNAL_RELEASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/macos/release") +#elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") +# set(OS_LINUX 1) +# set(OS_POSIX 1) +# MESSAGE(STATUS "build on Linux...") +# add_subdirectory(server/tp_web/src) +# set(TP_EXTERNAL_RELEASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/linux/release") +#elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") +# # MESSAGE(FATAL_ERROR "unsupported platform: Windows") +#else () +# MESSAGE(FATAL_ERROR "unsupported platform: ${CMAKE_SYSTEM_NAME}") +#endif () + +if (OS_LINUX) + add_subdirectory(server/tp_web/src) +endif() + +add_subdirectory(server/tp_core/core) +add_subdirectory(server/tp_core/protocol/ssh) +add_subdirectory(server/tp_core/protocol/telnet) +#add_subdirectory(server/testssh/testssh) + +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/server/tp_core/protocol/rdp") + add_subdirectory(server/tp_core/protocol/rdp) +endif () diff --git a/build.sh.in b/build.sh.in index 8dfc7c3..2ed2f3a 100755 --- a/build.sh.in +++ b/build.sh.in @@ -16,14 +16,32 @@ function on_error() function build_linux { + if [ `id -u` -eq 0 ]; then + on_error "Do not build as root." + fi + + if [ ! -f "/etc/centos-release" ] ; then + on_error "Sorry, build script works on CentOS 7 only." + fi + + X=$(yum list installed | grep "libffi-devel") + if [ "$X-x" = "-x" ] ; then + on_error "Need libffi-devel to build Python, try:\r\n sudo yum install libffi-devel" + fi + + X=$(yum list installed | grep "zlib-devel") + if [ "$X-x" = "-x" ] ; then + on_error "Need zlib-devel to build Python, try:\r\n sudo yum install zlib-devel" + fi + PYEXEC=${PATH_ROOT}/external/linux/release/bin/python3.7 PYSTATIC=${PATH_ROOT}/external/linux/release/lib/libpython3.7m.a - if [ ! -f "${PYSTATIC}" ]; then + if [ ! -f "${PYSTATIC}" ] ; then echo "python static not found, now build it..." "${PATH_ROOT}/build/build-py-static.sh" - if [ ! -f "${PYSTATIC}" ]; then + if [ ! -f "${PYSTATIC}" ] ; then on_error "can not build python static." fi fi diff --git a/build/.idea/build.iml b/build/.idea/build.iml index 14585d1..7cfc769 100644 --- a/build/.idea/build.iml +++ b/build/.idea/build.iml @@ -1,10 +1,8 @@ - - - - + + diff --git a/build/builder/build-assist.py b/build/builder/build-assist.py index a228b4e..da84c60 100644 --- a/build/builder/build-assist.py +++ b/build/builder/build-assist.py @@ -29,7 +29,7 @@ class BuilderWin(BuilderBase): def build_exe(self): cc.i('build tp_assist...') - sln_file = os.path.join(env.root_path, 'client', 'tp_assist_win', 'tp_assist.vs2015.sln') + sln_file = os.path.join(env.root_path, 'client', 'tp_assist_win', 'tp_assist.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'client', ctx.bits_path, ctx.target_path, 'tp_assist.exe') if os.path.exists(out_file): utils.remove(out_file) @@ -74,7 +74,11 @@ class BuilderWin(BuilderBase): 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_win', 'cfg'), tmp_cfg_path, ('tp-assist.default.json', 'tp-assist.json')) + utils.copy_file(os.path.join(env.root_path, 'client', 'cfg'), tmp_cfg_path, ('tp-assist.windows.json', 'tp-assist.json')) + + utils.copy_file(os.path.join(env.root_path, 'client', 'cfg'), tmp_cfg_path, 'cacert.cer') + utils.copy_file(os.path.join(env.root_path, 'client', 'cfg'), tmp_cfg_path, 'localhost.key') + utils.copy_file(os.path.join(env.root_path, 'client', 'cfg'), tmp_cfg_path, 'localhost.pem') utils.copy_ex(os.path.join(env.root_path, 'client', 'tp_assist_win'), tmp_app_path, 'site') @@ -106,28 +110,23 @@ class BuilderMacOS(BuilderBase): configuration = ctx.target_path.capitalize() - proj_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'tp_assist.xcodeproj') - out_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'build', ctx.target_path, 'tp_assist.app') + proj_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'TP-Assist.xcodeproj') + out_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'build', configuration, 'TP-Assist.app') if os.path.exists(out_file): utils.remove(out_file) - utils.xcode_build(proj_file, 'tp_assist', configuration, False) + utils.xcode_build(proj_file, 'TP-Assist', configuration, False) utils.ensure_file_exists(os.path.join(out_file, 'Contents', 'Info.plist')) def build_installer(self): - cc.e('assist for macOS does not need an installer, you should make an .DMG file for release...') + cc.i('make tp_assist dmg file...') - # name = 'teleport-assist-{}-{}'.format(ctx.dist, VER_TP_ASSIST) - # - # out_path = os.path.join(env.root_path, 'out', 'installer') - # utils.makedirs(out_path) - # - # out_file = os.path.join(out_path, '{}.exe'.format(name)) - # utils.remove(out_file) - # - # self._build_installer() - # - # utils.ensure_file_exists(out_file) + json_file = os.path.join(env.root_path, 'dist', 'client', 'macos', 'dmg.json') + dmg_file = os.path.join(env.root_path, 'out', 'client', 'macos', 'teleport-assist-macos-{}.dmg'.format(VER_TP_ASSIST)) + if os.path.exists(dmg_file): + utils.remove(dmg_file) + utils.make_dmg(json_file, dmg_file) + utils.ensure_file_exists(dmg_file) @staticmethod def _build_installer(): diff --git a/build/builder/build-external.py b/build/builder/build-external.py index efb4b1e..f79ab9a 100644 --- a/build/builder/build-external.py +++ b/build/builder/build-external.py @@ -48,12 +48,12 @@ class BuilderBase: self._build_openssl(file_name) def _build_openssl(self, file_name): - _alt_ver = '_'.join(env.ver_openssl.split('.')) + _alt_ver = '_'.join(env.ver_ossl.split('.')) if not utils.download_file('openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(_alt_ver), PATH_DOWNLOAD, file_name): + cc.e("can not download openssl source tarball.") return False else: return True - # cc.e("this is a pure-virtual function.") def build_libuv(self): file_name = 'libuv-{}.zip'.format(env.ver_libuv) @@ -88,15 +88,6 @@ class BuilderBase: def _prepare_python(self): cc.e("this is a pure-virtual function.") - # def build_sqlite(self): - # file_name = 'sqlite-autoconf-{}.tar.gz'.format(env.ver_sqlite) - # if not utils.download_file('sqlite source tarball', 'http://sqlite.org/2017/{}'.format(file_name), PATH_DOWNLOAD, file_name): - # return - # self._build_sqlite(file_name) - # - # def _build_sqlite(self, file_name): - # cc.e("this is a pure-virtual function.") - def fix_output(self): pass @@ -111,11 +102,8 @@ class BuilderWin(BuilderBase): 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.LIBSSH_PATH_SRC = os.path.join(PATH_EXTERNAL, 'libssh') - # self._prepare_python_header() - def _prepare_python(self): cc.n('prepare python header files ...', end='') @@ -124,12 +112,6 @@ class BuilderWin(BuilderBase): return cc.v('') - # if os.path.exists(os.path.join(env.path_py_inc, 'Python.h')): - # cc.e('can not locate python development include path, make sure miniconda installed.') - # return - # cc.v('') - # utils.copy_ex(env.path_py_inc, os.path.join(PATH_EXTERNAL, 'python', 'include')) - _header_path = None for p in sys.path: if os.path.exists(os.path.join(p, 'include', 'Python.h')): @@ -145,8 +127,7 @@ class BuilderWin(BuilderBase): def _build_openssl(self, file_name): cc.n('build openssl static library from source code... ') - _alt_ver = '_'.join(env.ver_ossl.split('.')) - if not utils.download_file('openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(_alt_ver), PATH_DOWNLOAD, file_name): + if not super()._build_openssl(file_name): return _chk_output = [ @@ -162,7 +143,7 @@ class BuilderWin(BuilderBase): break if not need_build: - cc.n('build openssl static library from source code... ', end='') + cc.n('build openssl static library from source code... ', end='') cc.w('already exists, skip.') return cc.v('') @@ -180,7 +161,10 @@ class BuilderWin(BuilderBase): os.chdir(self.OPENSSL_PATH_SRC) os.system('""{}" Configure VC-WIN32"'.format(env.perl)) os.system(r'ms\do_nasm') - os.system(r'"{}\VC\bin\vcvars32.bat" && nmake -f ms\nt.mak'.format(env.visual_studio_path)) + # for vs2015 + # utils.sys_exec(r'"{}\VC\bin\vcvars32.bat" && nmake -f ms\nt.mak'.format(env.visual_studio_path), direct_output=True) + # for vs2017 community + utils.sys_exec(r'"{}VC\Auxiliary\Build\vcvars32.bat" && nmake -f ms\nt.mak'.format(env.visual_studio_path), direct_output=True) for f in _chk_output: if not os.path.exists(f): @@ -194,24 +178,28 @@ class BuilderWin(BuilderBase): utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL) os.rename(os.path.join(PATH_EXTERNAL, 'libssh-{}'.format(env.ver_libssh)), self.LIBSSH_PATH_SRC) + # cc.n('fix libssh source code... ', end='') + # utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src', 'sftp.c')) + # utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'sftp.c') cc.n('fix libssh source code... ', end='') - utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src', 'sftp.c')) - utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'sftp.c') + s_name = 'libssh-{}'.format(env.ver_libssh) + utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'session.c')) + utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto.c')) + utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto-compat.c')) + utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'session.c') + utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto.c') + utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto-compat.c') out_file_lib = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.lib') out_file_dll = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.dll') - need_build = False - if not (os.path.exists(out_file_lib) and (os.path.exists(out_file_dll))): - need_build = True - - if not need_build: + if os.path.exists(out_file_lib) and os.path.exists(out_file_dll): cc.w('already exists, skip.') return cc.v('') cc.w('On Windows, when build libssh, need you use cmake-gui.exe to generate solution file') - cc.w('for Visual Studio 2015. 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 libssh.sln generated, press Enter to continue or Q to quit...', end='') try: x = env.input() @@ -275,10 +263,6 @@ class BuilderWin(BuilderBase): else: cc.w('already exists, skip.') - # def build_sqlite(self): - # cc.w('sqlite not need for Windows, skip.') - # pass - def fix_output(self): pass @@ -290,11 +274,9 @@ class BuilderLinux(BuilderBase): def _init_path(self): self.PATH_TMP = os.path.join(PATH_EXTERNAL, 'linux', 'tmp') self.PATH_RELEASE = os.path.join(PATH_EXTERNAL, 'linux', 'release') - # self.OPENSSL_PATH_SRC = os.path.join(self.PATH_TMP, 'openssl-{}'.format(env.ver_ossl)) self.LIBUV_PATH_SRC = os.path.join(self.PATH_TMP, 'libuv-{}'.format(env.ver_libuv)) self.MBEDTLS_PATH_SRC = os.path.join(self.PATH_TMP, 'mbedtls-mbedtls-{}'.format(env.ver_mbedtls)) self.LIBSSH_PATH_SRC = os.path.join(self.PATH_TMP, 'libssh-{}'.format(env.ver_libssh)) - # self.SQLITE_PATH_SRC = os.path.join(self.PATH_TMP, 'sqlite-autoconf-{}'.format(env.ver_sqlite)) self.JSONCPP_PATH_SRC = os.path.join(PATH_EXTERNAL, 'jsoncpp') self.MONGOOSE_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mongoose') @@ -309,8 +291,6 @@ class BuilderLinux(BuilderBase): cc.w(' - header file already exists, skip.') else: utils.ensure_file_exists(os.path.join(self.PATH_RELEASE, 'include', 'python{}m'.format(ctx.py_dot_ver), 'Python.h')) - # utils.makedirs(os.path.join(self.PATH_RELEASE, 'include')) - # utils.copy_ex(env.path_py_inc, os.path.join(self.PATH_RELEASE, 'include', 'python')) utils.sys_exec('ln -s "{}" "{}"'.format( os.path.join(self.PATH_RELEASE, 'include', 'python{}m'.format(ctx.py_dot_ver)), os.path.join(self.PATH_RELEASE, 'include', 'python') @@ -318,13 +298,6 @@ class BuilderLinux(BuilderBase): lib_file = 'libpython{}m.a'.format(env.py_ver_dot) utils.ensure_file_exists(os.path.join(self.PATH_RELEASE, 'lib', lib_file)) - # if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', lib_file)): - # cc.w(' - lib file already exists, skip.') - # else: - # utils.makedirs(os.path.join(self.PATH_RELEASE, 'lib')) - # utils.copy_file(env.path_py_lib, os.path.join(self.PATH_RELEASE, 'lib'), lib_file) - # utils.copy_file(env.path_py_lib, os.path.join(self.PATH_RELEASE, 'lib'), 'libcrypto.a') - # utils.copy_file(env.path_py_lib, os.path.join(self.PATH_RELEASE, 'lib'), 'libssl.a') def _build_jsoncpp(self, file_name): cc.n('prepare jsoncpp source code...', end='') @@ -349,7 +322,6 @@ class BuilderLinux(BuilderBase): def _build_libuv(self, file_name): if not os.path.exists(self.LIBUV_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build libuv...', end='') @@ -377,7 +349,6 @@ class BuilderLinux(BuilderBase): def _build_mbedtls(self, file_name): if not os.path.exists(self.MBEDTLS_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build mbedtls...', end='') @@ -408,45 +379,6 @@ 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 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') @@ -469,6 +401,15 @@ class BuilderLinux(BuilderBase): return cc.v('') + cc.n('fix libssh source code... ', end='') + s_name = 'libssh-{}'.format(env.ver_libssh) + utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'session.c')) + utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto.c')) + utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto-compat.c')) + utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'session.c') + utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto.c') + utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto-compat.c') + build_path = os.path.join(self.LIBSSH_PATH_SRC, 'build') cmake_define = ' -DCMAKE_INSTALL_PREFIX={path_release}' \ @@ -495,10 +436,6 @@ class BuilderLinux(BuilderBase): pass os.chdir(old_p) - # utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'libssh.a')) - # utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src'), os.path.join(self.PATH_RELEASE, 'lib'), 'libssh.a') - # utils.copy_ex(os.path.join(self.LIBSSH_PATH_SRC, 'include'), os.path.join(self.PATH_RELEASE, 'include'), 'libssh') - utils.ensure_file_exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh.a')) files = os.listdir(os.path.join(self.PATH_RELEASE, 'lib')) for i in files: @@ -506,32 +443,8 @@ class BuilderLinux(BuilderBase): # use os.unlink() because some file should be a link. os.unlink(os.path.join(self.PATH_RELEASE, 'lib', i)) - # def _build_sqlite(self, file_name): - # if not os.path.exists(self.SQLITE_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) - # - # cc.n('build sqlite static...', end='') - # if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libsqlite3.a')): - # cc.w('already exists, skip.') - # return - # cc.v('') - # - # old_p = os.getcwd() - # os.chdir(self.SQLITE_PATH_SRC) - # os.system('./configure --prefix={}'.format(self.PATH_RELEASE)) - # os.system('make') - # os.system('make install') - # os.chdir(old_p) - def fix_output(self): pass - # 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'] - # rm = ['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): - # utils.remove(_path) class BuilderMacOS(BuilderBase): @@ -541,11 +454,10 @@ class BuilderMacOS(BuilderBase): def _init_path(self): self.PATH_TMP = os.path.join(PATH_EXTERNAL, 'macos', 'tmp') self.PATH_RELEASE = os.path.join(PATH_EXTERNAL, 'macos', 'release') - # self.OPENSSL_PATH_SRC = os.path.join(self.PATH_TMP, 'openssl-OpenSSL_{}'.format(env.ver_openssl.replace('.', '_'))) + self.OPENSSL_PATH_SRC = os.path.join(self.PATH_TMP, 'openssl-OpenSSL_{}'.format(env.ver_ossl.replace('.', '_'))) self.LIBUV_PATH_SRC = os.path.join(self.PATH_TMP, 'libuv-{}'.format(env.ver_libuv)) self.MBEDTLS_PATH_SRC = os.path.join(self.PATH_TMP, 'mbedtls-mbedtls-{}'.format(env.ver_mbedtls)) self.LIBSSH_PATH_SRC = os.path.join(self.PATH_TMP, 'libssh-{}'.format(env.ver_libssh)) - # self.SQLITE_PATH_SRC = os.path.join(self.PATH_TMP, 'sqlite-autoconf-{}'.format(env.ver_sqlite)) self.JSONCPP_PATH_SRC = os.path.join(PATH_EXTERNAL, 'jsoncpp') self.MONGOOSE_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mongoose') @@ -572,30 +484,36 @@ class BuilderMacOS(BuilderBase): cc.w('already exists, skip.') def _build_openssl(self, file_name): - pass # we do not need build openssl anymore, because first time run build.sh we built Python, it include openssl. - # - # if not os.path.exists(self.OPENSSL_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) - # - # cc.n('build openssl static...', end='') - # if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssl.a')): - # cc.w('already exists, skip.') - # return - # - # old_p = os.getcwd() - # os.chdir(self.OPENSSL_PATH_SRC) - # # os.system('./config --prefix={} --openssldir={}/openssl no-zlib no-shared'.format(self.PATH_RELEASE, self.PATH_RELEASE)) - # # os.system('./Configure darwin64-x86_64-cc') - # os.system('./Configure darwin64-x86_64-cc --prefix={} --openssldir={}/openssl -fPIC no-zlib no-shared'.format(self.PATH_RELEASE, self.PATH_RELEASE)) - # os.system('make') - # os.system('make install') - # os.chdir(old_p) + if not super()._build_openssl(file_name): + return + + cc.n('prepare openssl source code...', end='') + if not os.path.exists(self.OPENSSL_PATH_SRC): + os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) + if not os.path.exists(self.OPENSSL_PATH_SRC): + raise RuntimeError('can not prepare openssl source code.') + else: + cc.w('already exists, skip.') + + cc.n('build openssl static...', end='') + out_file_lib = os.path.join(self.PATH_RELEASE, 'lib', 'libssl.a') + if os.path.exists(out_file_lib): + cc.w('already exists, skip.') + return + cc.v('') + + old_p = os.getcwd() + os.chdir(self.OPENSSL_PATH_SRC) + # os.system('./config --prefix={} --openssldir={}/openssl no-zlib no-shared'.format(self.PATH_RELEASE, self.PATH_RELEASE)) + # os.system('./Configure darwin64-x86_64-cc') + os.system('./Configure darwin64-x86_64-cc --prefix={} --openssldir={}/openssl -fPIC no-zlib no-shared'.format(self.PATH_RELEASE, self.PATH_RELEASE)) + os.system('make') + os.system('make install') + os.chdir(old_p) def _build_libuv(self, file_name): cc.n('prepare libuv source code...', end='') - # return if not os.path.exists(self.LIBUV_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build libuv...', end='') @@ -617,7 +535,6 @@ class BuilderMacOS(BuilderBase): def _build_mbedtls(self, file_name): if not os.path.exists(self.MBEDTLS_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) cc.n('build mbedtls...', end='') @@ -662,62 +579,31 @@ class BuilderMacOS(BuilderBase): def _build_libssh(self, file_name): if not os.path.exists(self.LIBSSH_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, PATH_TMP)) os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) - # os.rename(os.path.join(self.PATH_TMP, 'master'), os.path.join(self.PATH_TMP, 'libssh-{}'.format(LIBSSH_VER))) cc.n('build libssh...', end='') - if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh.a')) and os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh_threads.a')): + # if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh.a')) and os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh_threads.a')): + if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh.a')): cc.w('already exists, skip.') return cc.v('') build_path = os.path.join(self.LIBSSH_PATH_SRC, 'build') - # utils.makedirs(build_path) - # here is a bug in cmake v2.8.11 (default on ubuntu14), in FindOpenSSL.cmake, - # it parse opensslv.h, use regex like this: - # REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") - # but in openssl-1.0.2h, the version define line is: - # # define OPENSSL_VERSION_NUMBER 0x1000208fL - # notice there is a space char between # and define, so find openssl always fail. - - # old_p = os.getcwd() - # os.chdir(build_path) - # cmd = 'cmake' \ - # ' -DCMAKE_INSTALL_PREFIX={}' \ - # ' -D_OPENSSL_VERSION={}' \ - # ' -DOPENSSL_INCLUDE_DIR={}/include' \ - # ' -DOPENSSL_LIBRARIES={}/lib' \ - # ' -DCMAKE_BUILD_TYPE=Release' \ - # ' -DWITH_GSSAPI=OFF' \ - # ' -DWITH_ZLIB=OFF' \ - # ' -DWITH_STATIC_LIB=ON' \ - # ' -DWITH_PCAP=OFF' \ - # ' -DWITH_EXAMPLES=OFF' \ - # ' -DWITH_NACL=OFF' \ - # ' ..'.format(self.PATH_RELEASE, OPENSSL_VER, self.PATH_RELEASE, self.PATH_RELEASE) - # cc.n(cmd) - # os.system(cmd) - # # os.system('make ssh_static ssh_threads_static') - # os.system('make ssh_static') - # # os.system('make install') - # os.chdir(old_p) - - cmake_define = ' -DCMAKE_INSTALL_PREFIX={prefix}' \ - ' -D_OPENSSL_VERSION={oss_ver}' \ - ' -DOPENSSL_INCLUDE_DIR={ossl_inc}' \ - ' -DOPENSSL_LIBRARIES={ossl_lib}' \ + cmake_define = ' -DCMAKE_INSTALL_PREFIX={path_release}' \ + ' -DOPENSSL_INCLUDE_DIR={path_release}/include' \ + ' -DOPENSSL_LIBRARIES={path_release}/lib' \ + ' -DWITH_SFTP=ON' \ + ' -DWITH_SERVER=ON' \ + ' -DWITH_STATIC_LIB=ON' \ ' -DWITH_GSSAPI=OFF' \ ' -DWITH_ZLIB=OFF' \ - ' -DWITH_STATIC_LIB=ON' \ ' -DWITH_PCAP=OFF' \ - ' -DWITH_TESTING=OFF' \ - ' -DWITH_CLIENT_TESTING=OFF' \ + ' -DUNIT_TESTING=OFF' \ ' -DWITH_EXAMPLES=OFF' \ ' -DWITH_BENCHMARKS=OFF' \ ' -DWITH_NACL=OFF' \ - ''.format(prefix=self.PATH_RELEASE, oss_ver=env.ver_ossl_number, ossl_inc=env.path_ossl_inc, ossl_lib=env.path_ossl_lib) + ''.format(path_release=self.PATH_RELEASE) try: utils.cmake(build_path, 'Release', False, cmake_define) @@ -727,32 +613,18 @@ class BuilderMacOS(BuilderBase): # because make install will fail because we can not disable ssh_shared target, # so we copy necessary files ourselves. utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'libssh.a')) - utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'threads', 'libssh_threads.a')) + # utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'threads', 'libssh_threads.a')) utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src'), os.path.join(self.PATH_RELEASE, 'lib'), 'libssh.a') - utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'threads'), os.path.join(self.PATH_RELEASE, 'lib'), 'libssh_threads.a') + # utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'threads'), os.path.join(self.PATH_RELEASE, 'lib'), 'libssh_threads.a') utils.copy_ex(os.path.join(self.LIBSSH_PATH_SRC, 'include'), os.path.join(self.PATH_RELEASE, 'include'), 'libssh') - # def _build_sqlite(self, file_name): - # if not os.path.exists(self.SQLITE_PATH_SRC): - # os.system('tar -zxvf "{}/{}" -C "{}"'.format(PATH_DOWNLOAD, file_name, self.PATH_TMP)) - # - # cc.n('build sqlite static...', end='') - # if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libsqlite3.a')): - # cc.w('already exists, skip.') - # return - # cc.v('') - # - # old_p = os.getcwd() - # os.chdir(self.SQLITE_PATH_SRC) - # os.system('./configure --prefix={}'.format(self.PATH_RELEASE)) - # os.system('make') - # os.system('make install') - # os.chdir(old_p) + def _prepare_python(self): + pass def fix_output(self): # 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'] - rm = ['libuv.la', 'libuv.so.1', 'libuv.so', 'libuv.so.1.0.0'] + rm = ['libuv.la', 'libuv.dylib', '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): @@ -803,9 +675,6 @@ def main(): builder.build_mbedtls() builder.build_libssh() - # do not need sqlite any more. - # builder.build_sqlite() - builder.fix_output() diff --git a/build/builder/build-pysrt.py b/build/builder/build-pysrt.py index f56adc9..629c737 100644 --- a/build/builder/build-pysrt.py +++ b/build/builder/build-pysrt.py @@ -46,7 +46,7 @@ class PYSBase: utils.sys_exec('{} -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip --upgrade'.format(env.py_exec)) pip = self._get_pip() - pypi_modules = ['mako', 'pymysql', 'qrcode', 'tornado', 'wheezy.captcha', 'Pillow', 'psutil'] + pypi_modules = ['ldap3', 'mako', 'Pillow', 'psutil', 'pymysql', 'qrcode', 'tornado', 'wheezy.captcha'] for p in pypi_modules: cc.n('install {} ...'.format(p)) utils.sys_exec('{} install -i https://pypi.tuna.tsinghua.edu.cn/simple {}'.format(pip, p), direct_output=True) diff --git a/build/builder/build-server.py b/build/builder/build-server.py index 8605b25..85fd0ce 100644 --- a/build/builder/build-server.py +++ b/build/builder/build-server.py @@ -27,7 +27,7 @@ class BuilderWin(BuilderBase): 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') + sln_file = os.path.join(env.root_path, 'server', 'tp_web', 'src', 'tp_web.vs2017.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) @@ -35,7 +35,7 @@ class BuilderWin(BuilderBase): 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') + sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'core', 'tp_core.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_core.exe') if os.path.exists(out_file): utils.remove(out_file) @@ -43,7 +43,7 @@ class BuilderWin(BuilderBase): utils.ensure_file_exists(out_file) cc.n('build SSH protocol ...') - sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'ssh', 'tpssh.vs2015.sln') + sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'ssh', 'tpssh.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tpssh.dll') if os.path.exists(out_file): utils.remove(out_file) @@ -52,7 +52,7 @@ class BuilderWin(BuilderBase): utils.copy_file(os.path.join(env.root_path, 'external', 'libssh', 'lib', ctx.target_path), os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path), 'ssh.dll') cc.n('build TELNET protocol ...') - sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'telnet', 'tptelnet.vs2015.sln') + sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'telnet', 'tptelnet.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tptelnet.dll') if os.path.exists(out_file): utils.remove(out_file) @@ -61,7 +61,7 @@ class BuilderWin(BuilderBase): if with_rdp: cc.n('build RDP protocol ...') - sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'rdp', 'tprdp.vs2015.sln') + sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'rdp', 'tprdp.vs2017.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) @@ -91,7 +91,7 @@ class BuilderLinux(BuilderBase): utils.makedirs(out_path) - utils.cmake(os.path.join(env.root_path, 'server', 'cmake-build'), ctx.target_path, False) + utils.cmake(os.path.join(env.root_path, 'cmake-build'), ctx.target_path, False) # utils.strip(out_file) for f in out_files: @@ -121,7 +121,7 @@ class BuilderMacOS(BuilderBase): utils.makedirs(out_path) - utils.cmake(os.path.join(env.root_path, 'server', 'cmake-build'), ctx.target_path, False) + utils.cmake(os.path.join(env.root_path, 'cmake-build'), ctx.target_path, False) # utils.strip(out_file) for f in out_files: diff --git a/build/builder/build-version.py b/build/builder/build-version.py index fbcb419..e4933a0 100644 --- a/build/builder/build-version.py +++ b/build/builder/build-version.py @@ -141,7 +141,7 @@ class Builder: self._update_ver_nsi(nsi_file, self.VER_TP_ASSIST) def make_assist_macos_ver(self): - plist_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'src', 'tp_assist-Info.plist') + plist_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'src', 'TP-Assist-Info.plist') self._update_ver_plist(plist_file, self.VER_TP_ASSIST) ver_file = os.path.join(env.root_path, 'client', 'tp_assist_macos', 'src', 'csrc', 'ts_ver.h') @@ -299,10 +299,10 @@ class Builder: def _update_ver_nsi(self, nsiFilePath, ver): """ update nsis file version info """ t_ver = ver.split('.') - while len(t_ver) < 4: + while len(t_ver) < 3: t_ver.append('0') - if len(t_ver) > 4: + if len(t_ver) > 3: raise RuntimeError('Invalid version for nsis file.') bOK = False @@ -319,40 +319,23 @@ class Builder: if nsiline.find('\n') != -1: nsiline = nsiline[:-1] - if nsiline.find(" FILE_VER") != -1 or nsiline.find(" STR_FILE_VER") != -1: - # cc.v('[ver] old ver: %s' % nsiLines[x]) - pos1 = nsiline.find('"') - pos2 = nsiline.rfind('"') - _ver = nsiline[pos1 + 1: pos2] - - nsiSplitList = _ver.split(".") - if (len(nsiSplitList) != 4): - raise RuntimeError('Invalid .nsi file (1).') - if '.'.join(nsiSplitList) == ver: - continue - - # nsiline = '%s\"%d.%d.%d.%d\"\n' % (nsiline[0:pos1], self.major, self.minor, self.revision, self.build) - nsiline = '%s\"%s.%s.%s.%s\"\n' % (nsiline[0:pos1], t_ver[0], t_ver[1], t_ver[2], t_ver[3]) + if nsiline.startswith("!define FILE_VER"): + nsiline = '!define FILE_VER \"%s.%s.%s.0\"\n' % (t_ver[0], t_ver[1], t_ver[2]) nsiLines[x] = "" nsiLines[x] = nsiline # cc.v('[ver] new ver: %s' % nsiLines[x]) bOK = True - elif nsiline.find(" PRODUCT_VER") != -1: - # cc.v('[ver] old ver: %s' % nsiLines[x]) - pos1 = nsiline.find('"') - pos2 = nsiline.rfind('"') - _ver = nsiline[pos1 + 1: pos2] + elif nsiline.startswith("!define OUT_VER"): + nsiline = '!define OUT_VER \"%s.%s.%s\"\n' % (t_ver[0], t_ver[1], t_ver[2]) - nsiSplitList = _ver.split(".") - if (len(nsiSplitList) != 2): - raise RuntimeError('Invalid .nsi file (2).') - if '.'.join(nsiSplitList) == '%s.%s' % (t_ver[0], t_ver[1]): - continue - - # nsiline = '%s\"%d.%d\"\n' % (nsiline[0:pos1], self.major, self.minor) - nsiline = '%s\"%s.%s\"\n' % (nsiline[0:pos1], t_ver[0], t_ver[1]) + nsiLines[x] = "" + nsiLines[x] = nsiline + # cc.v('[ver] new ver: %s' % nsiLines[x]) + bOK = True + elif nsiline.startswith("!define PRODUCT_VER"): + nsiline = '!define PRODUCT_VER \"%s.%s\"\n' % (t_ver[0], t_ver[1]) nsiLines[x] = "" nsiLines[x] = nsiline @@ -396,24 +379,6 @@ class Builder: if l.find('CFBundleVersion') != -1: is_ver = True continue - # pos1 = rcline.find(' FILEVERSION ') - # pos2 = rcline.rfind('\\0"') - # _ver = rcline[pos1 + 13: pos2].strip() - # - # rcSplitList = _ver.split(",") - # if (len(rcSplitList) < 4): - # rcSplitList = _ver.split(".") - # if (len(rcSplitList) < 4): - # raise RuntimeError('Invalid .rc file.') - # if '.'.join(rcSplitList) == ver: - # continue - # - # rcline = '%s%s,%s,%s,%s\n' % (rcline[0:pos1 + 13], t_ver[0], t_ver[1], t_ver[2], t_ver[3]) - # - # rcLines[x] = "" - # rcLines[x] = rcline - # # cc.v('[ver] new ver: %s' % rcLines[x]) - # bOK = True if is_ver: is_ver = False diff --git a/build/builder/core/env.py b/build/builder/core/env.py index 4739f82..82a907e 100644 --- a/build/builder/core/env.py +++ b/build/builder/core/env.py @@ -111,7 +111,7 @@ class Env(object): if self.nasm is None or not os.path.exists(self.nasm): if warn_miss_tool: - cc.w(' - can not locate `nasm`, so I can build openssl.') + cc.w(' - can not locate `nasm`, so I can not build openssl.') else: _nasm_path = os.path.abspath(os.path.join(self.nasm, '..')) os.environ['path'] = os.environ['path'] + ';' + _nasm_path @@ -123,12 +123,12 @@ class Env(object): if self.perl is None or not os.path.exists(self.perl): if warn_miss_tool: - cc.w(' - can not locate `perl`, so I can build openssl.') + cc.w(' - can not locate `perl`, so I can not build openssl.') self.visual_studio_path = self._get_visual_studio_path() if self.visual_studio_path is None or not os.path.exists(self.visual_studio_path): if warn_miss_tool: - cc.w(' - can not locate Visual Studio installation, so I can build openssl.') + cc.w(' - can not locate Visual Studio installation, so I can build nothing.') if 'msbuild' in _tmp: self.msbuild = _tmp['msbuild'] @@ -190,30 +190,40 @@ class Env(object): return True - def _get_msbuild(self): - # 14.0 = VS2015 - # 12.0 = VS2012 - # 4.0 = VS2008 - chk = ['14.0', '12.0', '4.0'] + # def _get_msbuild(self): + # # 14.0 = VS2015 + # # 12.0 = VS2012 + # # 4.0 = VS2008 + # chk = ['14.0', '12.0', '4.0'] - p = None - for c in chk: - p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\{}'.format(c), r'MSBuildToolsPath') - if p is not None: - break + # p = None + # for c in chk: + # p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\{}'.format(c), r'MSBuildToolsPath') + # if p is not None: + # break - return os.path.join(p[0], 'MSBuild.exe') if p is not None else None + # return os.path.join(p[0], 'MSBuild.exe') if p is not None else None + + # def _get_visual_studio_path(self): + # chk = ['14.0', '12.0', '4.0'] + # p = None + # for c in chk: + # p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\VisualStudio\{}'.format(c), r'ShellFolder') + # if p is not None: + # break + + # return p[0] if p is not None else None def _get_visual_studio_path(self): - chk = ['14.0', '12.0', '4.0'] - p = None - for c in chk: - p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\VisualStudio\{}'.format(c), r'ShellFolder') - if p is not None: - break - + p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7', r'15.0') return p[0] if p is not None else None + def _get_msbuild(self): + vs2017 = self._get_visual_studio_path() + if vs2017 is None: + return None + return os.path.join(vs2017, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe') + def _get_perl(self): p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\perl', 'BinDir') return p[0] if p is not None else None diff --git a/build/builder/core/utils.py b/build/builder/core/utils.py index 74c4a8e..c6aa97f 100644 --- a/build/builder/core/utils.py +++ b/build/builder/core/utils.py @@ -50,29 +50,41 @@ def _check_download_file(file_name): def download_file(desc, url, target_path, file_name): cc.n('download {} ... '.format(desc), end='') - local_file_name = os.path.join(target_path, file_name) - if os.path.exists(local_file_name): - if not _check_download_file(local_file_name): - cc.w('already exists but broken, download it again...') - else: - cc.w('already exists, skip.') - return True + _temp_file = os.path.join(target_path, '_dl_{}'.format(file_name)) + _real_file = os.path.join(target_path, file_name) + + if os.path.exists(_temp_file): + cc.w('already exists but broken, download it again...') + remove(_temp_file) + remove(_real_file) + + # if not _check_download_file(local_file_name): + # cc.w('already exists but broken, download it again...') + # else: + # cc.w('already exists, skip.') + # return True + + if os.path.exists(_real_file): + cc.w('already exists, skip.') + return True cc.v('') # 因为下载过程会在命令行显示进度,所以不能使用subprocess.Popen()的方式捕获输出,会很难看! if env.is_win: - cmd = '""{}" --no-check-certificate {} -O "{}""'.format(env.wget, url, local_file_name) + cmd = '""{}" --no-check-certificate {} -O "{}""'.format(env.wget, url, _temp_file) os.system(cmd) elif env.is_linux or env.is_macos: - os.system('wget --no-check-certificate {} -O "{}"'.format(url, local_file_name)) + os.system('wget --no-check-certificate {} -O "{}"'.format(url, _temp_file)) else: cc.e('can not download, no download tool.') return False - if not os.path.exists(local_file_name) or not _check_download_file(local_file_name): + if not os.path.exists(_temp_file) or not _check_download_file(_temp_file): cc.e('downloading {} from {} failed.'.format(desc, url)) return False + os.rename(_temp_file, _real_file) + return True @@ -257,6 +269,7 @@ def ensure_file_exists(filename): def sys_exec(cmd, direct_output=False, output_codec=None): + print(cmd) if output_codec is None: if env.is_win: output_codec = 'gb2312' @@ -308,9 +321,6 @@ def msvc_build(sln_file, proj_name, target, platform, force_rebuild): def xcode_build(proj_file, proj_name, target, force_rebuild): - # if env.msbuild is None: - # raise RuntimeError('where is `msbuild`?') - if force_rebuild: cmd = 'xcodebuild -project "{}" -target {} -configuration {} clean'.format(proj_file, proj_name, target) ret, _ = sys_exec(cmd, direct_output=True) @@ -322,6 +332,19 @@ def xcode_build(proj_file, proj_name, target, force_rebuild): raise RuntimeError('build XCode project `{}` failed.'.format(proj_name)) +def make_dmg(json_file, dmg_file): + out_path = os.path.dirname(dmg_file) + cc.v(out_path) + + if not os.path.exists(out_path): + makedirs(out_path) + + cmd = 'appdmg "{}" "{}"'.format(json_file, dmg_file) + ret, _ = sys_exec(cmd, direct_output=True) + if ret != 0: + raise RuntimeError('make dmg failed.') + + def nsis_build(nsi_file, _define=''): if env.nsis is None: raise RuntimeError('where is `nsis`?') diff --git a/build/builder/core/ver.py b/build/builder/core/ver.py index 5b022cc..4bc5945 100644 --- a/build/builder/core/ver.py +++ b/build/builder/core/ver.py @@ -1,3 +1,3 @@ # -*- coding: utf8 -*- -VER_TP_SERVER = "3.1.0" -VER_TP_ASSIST = "3.1.0" +VER_TP_SERVER = "3.2.0" +VER_TP_ASSIST = "3.2.0" diff --git a/client/cfg/cacert.cer b/client/cfg/cacert.cer new file mode 100644 index 0000000..d8f5d0c --- /dev/null +++ b/client/cfg/cacert.cer @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID4TCCAsmgAwIBAgIBADANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJDTjEN +MAsGA1UECgwEVFA0QTEZMBcGA1UECwwQVFA0QSBUZWxlcG9ydCBDQTEZMBcGA1UE +AwwQVFA0QSBUZWxlcG9ydCBDQTAgFw0xODExMDgxNzMyMjJaGA8yMTE4MTAxNTE3 +MzIyMlowUjELMAkGA1UEBhMCQ04xDTALBgNVBAoMBFRQNEExGTAXBgNVBAsMEFRQ +NEEgVGVsZXBvcnQgQ0ExGTAXBgNVBAMMEFRQNEEgVGVsZXBvcnQgQ0EwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCml/ERetMxXh17Uf4IlLjDfgGwnpQZ +L0UoCO2vAHk0h4eRx5x4fMB/Ml1YHYghVKJ9rxWeb+v5wWz9a8CFtNu+s46nG9cw +XdneQ2UT4L5+7a+mOyNGAcascfLWfUYoMnF0ugIf3OfsUeAwinMnvKi2I2b8XdXH +cXRqToEYmcovPLKaXByXFLjcMHMRwR5Es0zIRx+4uuIvCICndLRX5IGy/HGEPZyV +Vtrrrvkngz54UHB3C3sKuHuHBOxvJ1grJV9fLFptsbPhMonXfYKJpf+ODwmkEDFS ++4vV61ctYvUiElCPeQte23v6lIujqoLoHzYoi8J5BxEwBggeCgAZ/YYFAgMBAAGj +gb8wgbwwHQYDVR0OBBYEFKHqO88fYp8ard6SKPi8X4Gpr+uiMHoGA1UdIwRzMHGA +FKHqO88fYp8ard6SKPi8X4Gpr+uioVakVDBSMQswCQYDVQQGEwJDTjENMAsGA1UE +CgwEVFA0QTEZMBcGA1UECwwQVFA0QSBUZWxlcG9ydCBDQTEZMBcGA1UEAwwQVFA0 +QSBUZWxlcG9ydCBDQYIBADAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB +BjANBgkqhkiG9w0BAQsFAAOCAQEAQWYR/WBsaWEwTE9IuoULsGs0G5CWwfIvezil +HUmtQQb2G3P0kxv43xU3PT3czfbd22h9diSHyyYXOShHIfNx7ZD4SUMGyukcfPst +oyLcnlMK2hxtu3s5hTc76D+m7ylLQgV52jwHOXXS9toRhIo76HY6Q5Qbz9koP/x+ +MOwmNJ+dLQj/qI1WZZI7FS7Idi2dB5KMp11a2kxgeBIxwkCreBm/MLfdLRyaMdGX +1L05AI0d7lCu+N+Fu2QX9wToBZ4rRQFrdakgCXqXCdM1O4Akf1KvCDXHUJKgMQUE +Hav+XOE7nrtxIwfH4VjmCZYRE+8ZTYbG8xSHDwIRMxhsLnb63w== +-----END CERTIFICATE----- diff --git a/client/cfg/localhost.key b/client/cfg/localhost.key new file mode 100644 index 0000000..852ff91 --- /dev/null +++ b/client/cfg/localhost.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDxI1ZDRvuNnkVB +JgTZmnwF97d7Ace+R0gSSkWi2l2oezakLSdUUkiysr1wx45u2Du36FNqMGg7LiCZ +SX1e2Zba96PI6vwNGnlprCfXTe2eV3W8kMPKA6c9X8BTktMZINNHO3K591jGx+uM +fyrl6/CFVPHNkl73Ium9u91JXIX9BOata4RTlphmHADc+hPXuC6oeN8qayZvV2rV +Jfx1wMlWCMiGJM36JJO5pywteBCKQkVJuJ7y29XF2wT690o+i6ugk+yI2/2OpiET +2E5SYdvyhlbcU+iBERsnY3X7IvFY8/m00YIjIc3reGSEwt9M5WTPRCjgonnpQGAx +9xWXwqkzAgMBAAECggEAT9b2YdInye0EWxy+cFoBBGzPeE/PlcW+LCghRFlutzEM +l3FH21hfL6OUq7m3BCZeJ3cp3zfl2upb6sT1WKlMlHV36jc7ew8v8fgJPPVVXp7w +oZ2A5estvVltsX4knOZMbgJV6xLldvOMnvkf9/6VpV/Jq9nxzXvmzmZcT0TuLCaF +uPk/g/yD5qQ8LkWXDVJeBiDrrOZYo5F+T8bveYKKIEZV0ZAlXwJqVOUFnhffIaDF +fZVDOv4K3+q0aRDLTY2hxptHZiKzpLXgU634nBN3fiy0Fj88upNIus22gjaz+Jfx +2pYv22iGNXAMFQwGaeuT7d4+qhgxze8C7YlLJsJWCQKBgQD8kkXbgYG+8NoKmovz +ki9nuK1R6On5pNjZ344SJm6t/s4FaxQhE/4oHvODwgolqKyT2Sq1K8/5NInRGA29 +xPqqkkhwWk3Zf9VTXgmuXsOikPhbCOuiehO+6/ZthmHYy1jBMqkAIWYaL9Ytn2qb +dKMHwzNdnppQNdQnwmXI2ZdRBQKBgQD0aVTSOmKfKdIxH9qFLdbi2CoyJMzjAjm9 +Ss5M0OhI9wZnCXyjPBx4hOs+M/BKx4lQ296u2Dh+gSK3L8K3x8lVqqx8gd614qaC +EWzXZpAbd1S835o2vVYEWXU0iI9s0jkj+VnILEWBMRPYManRUATB2phwRPulimdu +o+BWN0GG1wKBgCYBxO1hMasQB1+tHf5LM0MCcWJwEDV27wLqNzDYA7O/MjVyhZbs +sURMVAyxuGEuXrno5hpZO3SeyVZjrj2uVKIyXSA7FpfyOqHO9tn8fKgL9LOORhcv +E6WZUH3uyO6cuwBnpTLV082BAVPgN2SpSpcycppV8Za8Yu6QvExbIgAZAoGBALcq +ANETxDj3hHggIQlRkwqpaOXvQkSVtGOxne1fWdTkmz24lFlYgRWotwsErX29D6Ez +RSzPCXd0m2mhN1G3PaEfqOgeA6NXWeV73Y+HY1PSGAT7pXyEY+QajoVyGdo5qWzW +P3yOAQCSoQaSIWulhgspILhyWgxzLpRx53t1KXw9AoGBAOxsrIrx/S6onTz58ncZ +m99OWwJX4WmY5KKhc5dWrfgHrNfldSbhjRhjALy6hSPzkaVy01wXKeeIZl64rUbd +S/r58yALQ5wuIHAi53BLStxgqEdHQHLg16GqL3b/+Waaf+Fy9y5eoUQ976HPr33G +uDJ1AAnWjX3KvcyZeWLFTU2/ +-----END PRIVATE KEY----- diff --git a/client/cfg/localhost.pem b/client/cfg/localhost.pem new file mode 100644 index 0000000..b91d7e1 --- /dev/null +++ b/client/cfg/localhost.pem @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEGTCCAwGgAwIBAgIEASUKPDANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJD +TjENMAsGA1UECgwEVFA0QTEZMBcGA1UECwwQVFA0QSBUZWxlcG9ydCBDQTEZMBcG +A1UEAwwQVFA0QSBUZWxlcG9ydCBDQTAgFw0xODExMDgxNzMyMjdaGA8yMTE4MTAx +NTE3MzIyN1owXzELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkJKMQswCQYDVQQHDAJ0 +cDERMA8GA1UECgwIVGVsZXBvcnQxDzANBgNVBAsMBkFzc2lzdDESMBAGA1UEAwwJ +bG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8SNWQ0b7 +jZ5FQSYE2Zp8Bfe3ewHHvkdIEkpFotpdqHs2pC0nVFJIsrK9cMeObtg7t+hTajBo +Oy4gmUl9XtmW2vejyOr8DRp5aawn103tnld1vJDDygOnPV/AU5LTGSDTRztyufdY +xsfrjH8q5evwhVTxzZJe9yLpvbvdSVyF/QTmrWuEU5aYZhwA3PoT17guqHjfKmsm +b1dq1SX8dcDJVgjIhiTN+iSTuacsLXgQikJFSbie8tvVxdsE+vdKPouroJPsiNv9 +jqYhE9hOUmHb8oZW3FPogREbJ2N1+yLxWPP5tNGCIyHN63hkhMLfTOVkz0Qo4KJ5 +6UBgMfcVl8KpMwIDAQABo4HnMIHkMB0GA1UdDgQWBBRc5d0h39QISTM55kCqPyy1 +dohEHTB6BgNVHSMEczBxgBSh6jvPH2KfGq3ekij4vF+Bqa/roqFWpFQwUjELMAkG +A1UEBhMCQ04xDTALBgNVBAoMBFRQNEExGTAXBgNVBAsMEFRQNEEgVGVsZXBvcnQg +Q0ExGTAXBgNVBAMMEFRQNEEgVGVsZXBvcnQgQ0GCAQAwDAYDVR0TAQH/BAIwADAO +BgNVHQ8BAf8EBAMCA4gwEwYDVR0lBAwwCgYIKwYBBQUHAwEwFAYDVR0RBA0wC4IJ +bG9jYWxob3N0MA0GCSqGSIb3DQEBCwUAA4IBAQAfj/CpFDhv5CrnN2kxhtRAmesJ +q6/KxxkBaimjbS/BpfvqfC9RxGH7MIqGUkbC4/ADkEt2OmVU4+f2R3+rCl+x+r1t +9+3r/JSYYVBxFnF1GbDhiY9sKahgb4HoFjE2Fj8eVODcEzdApLr198p5IIIyfBys +WHV4CYFMvq5qCKbSR/JMfrm9GArAh1J+B+JMIfm8xwerFi0tfK2YT+N4QkvbidjG +sd+RKlR51GHo9m4iEQ7mDd9H8joVrVs2MVLGf2EoVU5y/Ahee4g7k3SKrn3GI/Ec +6BRCht+INCLI3bnC3MtJHJRzv5Vmu4pSh3cwnVHfe+VWLGvGlp2+KeC02xZ2 +-----END CERTIFICATE----- diff --git a/client/cfg/tp-assist.macos.json b/client/cfg/tp-assist.macos.json new file mode 100644 index 0000000..93ff8bc --- /dev/null +++ b/client/cfg/tp-assist.macos.json @@ -0,0 +1,113 @@ +{ + "file_version": 3, + "ssh": { + "selected": "terminal", + "available": [ + { + "name":"terminal", + "display": "终端(系统自带)", + "app": "", + "cmdline": "Basic", + "desc": ["命令参数为终端偏好设置中描述文件的名称"] + }, + { + "name": "iterm2", + "display": "iTerm2", + "app": "", + "cmdline": "Default", + "desc": ["命令参数为iTerm偏好设置中描述文件的名称"] + }, + { + "name": "securecrt", + "display": "SecureCRT", + "app": "/Applications/SecureCRT.app/Contents/MacOS/SecureCRT", + "cmdline": "/T /N \"TP#ssh://{real_ip}\" /SSH2 /L {user_name} /PASSWORD **** {host_ip}:{host_port}", + "desc": [] + }, + { + "name": "other", + "display": "自定义", + "app": "", + "cmdline": "", + "desc": [] + } + ] + }, + + "sftp": { + "selected": "securefx", + "available": [ + { + "name": "securefx", + "display": "SecureFX", + "app": "/Applications/SecureFX.app/Contents/MacOS/SecureFX", + "cmdline": "sftp://{user_name}:****@{host_ip}:{host_port}", + "desc": [] + }, + { + "name": "filezilla", + "display": "FileZilla", + "app": "/Applications/FileZilla.app/Contents/MacOS/filezilla", + "cmdline": "sftp://{user_name}:****@{host_ip}:{host_port}", + "desc": [] + }, + { + "name": "other", + "display": "自定义", + "app": "", + "cmdline": "", + "desc": [] + } + ] + }, + + "telnet": { + "selected": "terminal", + "available": [ + { + "name":"terminal", + "display": "终端(系统自带)", + "app": "Terminal.app", + "cmdline": "Basic", + "desc": ["命令参数为终端偏好设置中描述文件的名称"] + }, + { + "name": "iterm2", + "display": "iTerm2", + "app": "iTerm2.app", + "cmdline": "Default", + "desc": ["命令参数为iTerm偏好设置中描述文件的名称"] + }, + { + "name": "securecrt", + "display": "SecureCRT", + "app": "SecureCRT.app", + "cmdline": "/T /N \"TP#telnet://{real_ip}\" /TELNET {user_name}@{host_ip} {host_port}", + "desc": [] + }, + { + "name": "other", + "display": "自定义", + "app": "", + "cmdline": "", + "desc": [] + } + ] + }, + + "rdp": { + "selected": "freerdp", + "available": [ + { + "name": "FreeRDP", + "display": "FreeRDP", + "app": "", + "cmdline": "", + "desc": [ + "建议使用homebrew安装freerdp,安装后freerdp默认路径在:/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp", + "首次安装freerdp后需要重新启动计算机" + ] + } + ] + } +} diff --git a/client/tp_assist_win/cfg/tp-assist.default.json b/client/cfg/tp-assist.windows.json old mode 100644 new mode 100755 similarity index 100% rename from client/tp_assist_win/cfg/tp-assist.default.json rename to client/cfg/tp-assist.windows.json diff --git a/client/tp_assist_macos/tp_assist.xcodeproj/project.pbxproj b/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj similarity index 64% rename from client/tp_assist_macos/tp_assist.xcodeproj/project.pbxproj rename to client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj index 66d8b03..f40084d 100644 --- a/client/tp_assist_macos/tp_assist.xcodeproj/project.pbxproj +++ b/client/tp_assist_macos/TP-Assist.xcodeproj/project.pbxproj @@ -3,19 +3,26 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ 0ADB3B0C178EF8DB004E9BB9 /* StatusIconAlt.png in Resources */ = {isa = PBXBuildFile; fileRef = 0ADB3B08178EF8DB004E9BB9 /* StatusIconAlt.png */; }; 0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 0ADB3B09178EF8DB004E9BB9 /* StatusIcon.png */; }; - 0ADB3B0E178EF8DB004E9BB9 /* StatusIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0ADB3B0A178EF8DB004E9BB9 /* StatusIcon@2x.png */; }; - 0ADB3B0F178EF8DB004E9BB9 /* StatusIconAlt@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0ADB3B0B178EF8DB004E9BB9 /* StatusIconAlt@2x.png */; }; 7A0C94AA1F68BD2900E04C3E /* AboutWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6FC541A51D45CF7F00A896E3 /* AboutWindowController.xib */; }; 7A18188F1F7D5D7F00F3C882 /* AppDelegate-C-Interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A18188E1F7D5D7F00F3C882 /* AppDelegate-C-Interface.cpp */; }; - 7A1818911F7FBBC200F3C882 /* tp-assist.default.json in Resources */ = {isa = PBXBuildFile; fileRef = 7A1818901F7FBBC200F3C882 /* tp-assist.default.json */; }; - 7A1818931F815B8A00F3C882 /* Terminal.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A1818921F815B8A00F3C882 /* Terminal.scpt */; }; + 7A1F87B1215D5A1600B69F88 /* StatusIconAlt@2X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A1F87AF215D5A1600B69F88 /* StatusIconAlt@2X.png */; }; + 7A1F87B2215D5A1600B69F88 /* StatusIcon@2X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A1F87B0215D5A1600B69F88 /* StatusIcon@2X.png */; }; 7A27E4A91F6A8EEC004FDE5D /* ts_env.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */; }; + 7A7C6C9121973C24006869D9 /* StatusIconAlt@3X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */; }; + 7A7C6C9221973C24006869D9 /* StatusIcon@3X.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */; }; + 7A7C6C9621973C69006869D9 /* tpassist.png in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9521973C69006869D9 /* tpassist.png */; }; + 7A7C6C9C21974094006869D9 /* cacert.cer in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9921974094006869D9 /* cacert.cer */; }; + 7A7C6C9D21974094006869D9 /* localhost.key in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9A21974094006869D9 /* localhost.key */; }; + 7A7C6C9E21974094006869D9 /* localhost.pem in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9B21974094006869D9 /* localhost.pem */; }; + 7A7C6CA02197410B006869D9 /* tp-assist.macos.json in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6C9F2197410B006869D9 /* tp-assist.macos.json */; }; + 7A7C6CAA21977F07006869D9 /* iterm2.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6CA821977F07006869D9 /* iterm2.scpt */; }; + 7A7C6CAB21977F07006869D9 /* terminal.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7A7C6CA921977F07006869D9 /* terminal.scpt */; }; 7AA2CD381F6A92620074C92B /* ts_http_rpc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD371F6A92620074C92B /* ts_http_rpc.cpp */; }; 7AA2CD3B1F6A955A0074C92B /* ts_cfg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD391F6A955A0074C92B /* ts_cfg.cpp */; }; 7AA2CD441F6AB9750074C92B /* ex_ini.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD3D1F6AB9750074C92B /* ex_ini.cpp */; }; @@ -30,7 +37,8 @@ 7AA2CD541F6AB9F10074C92B /* json_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD501F6AB9F10074C92B /* json_writer.cpp */; }; 7AA2CD571F6ABA2E0074C92B /* mongoose.c in Sources */ = {isa = PBXBuildFile; fileRef = 7AA2CD561F6ABA2E0074C92B /* mongoose.c */; }; 7AA2CD591F6AC0DA0074C92B /* site in Resources */ = {isa = PBXBuildFile; fileRef = 7AA2CD581F6AC0DA0074C92B /* site */; }; - 7AD1F1D31F7A55EA0048A496 /* iTerm2.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 7AD1F1D11F7A55EA0048A496 /* iTerm2.scpt */; }; + 7AF9BF272199E3DE00BE5DBC /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF9BF1F2199E31A00BE5DBC /* libssl.a */; }; + 7AF9BF292199E3DF00BE5DBC /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AF9BF282199E3DF00BE5DBC /* libcrypto.a */; }; A1B7B9DD1DB53ED200809327 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A1B7B9DF1DB53ED200809327 /* Localizable.strings */; }; A1D700071A5DCE8D003563E4 /* AboutWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A1D700061A5DCE8D003563E4 /* AboutWindowController.m */; }; C149EBFE15D5214600B1F558 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C149EBFD15D5214600B1F558 /* Cocoa.framework */; }; @@ -44,17 +52,44 @@ /* Begin PBXFileReference section */ 0ADB3B08178EF8DB004E9BB9 /* StatusIconAlt.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = StatusIconAlt.png; sourceTree = ""; }; 0ADB3B09178EF8DB004E9BB9 /* StatusIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = StatusIcon.png; sourceTree = ""; }; - 0ADB3B0A178EF8DB004E9BB9 /* StatusIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@2x.png"; sourceTree = ""; }; - 0ADB3B0B178EF8DB004E9BB9 /* StatusIconAlt@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@2x.png"; sourceTree = ""; }; 7A18188E1F7D5D7F00F3C882 /* AppDelegate-C-Interface.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "AppDelegate-C-Interface.cpp"; sourceTree = ""; }; - 7A1818901F7FBBC200F3C882 /* tp-assist.default.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "tp-assist.default.json"; sourceTree = ""; }; - 7A1818921F815B8A00F3C882 /* Terminal.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = Terminal.scpt; sourceTree = ""; }; 7A1818951F8242E900F3C882 /* apple-scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "apple-scripts"; sourceTree = ""; }; + 7A1F8797215D565600B69F88 /* ex_util.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_util.h; path = ../../../../common/libex/include/ex/ex_util.h; sourceTree = ""; }; + 7A1F8798215D565600B69F88 /* ex_ini.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_ini.h; path = ../../../../common/libex/include/ex/ex_ini.h; sourceTree = ""; }; + 7A1F8799215D565600B69F88 /* ex_const.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_const.h; path = ../../../../common/libex/include/ex/ex_const.h; sourceTree = ""; }; + 7A1F879B215D565600B69F88 /* ex_log.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_log.h; path = ../../../../common/libex/include/ex/ex_log.h; sourceTree = ""; }; + 7A1F879C215D565600B69F88 /* ex_platform.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_platform.h; path = ../../../../common/libex/include/ex/ex_platform.h; sourceTree = ""; }; + 7A1F879D215D565600B69F88 /* ex_types.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_types.h; path = ../../../../common/libex/include/ex/ex_types.h; sourceTree = ""; }; + 7A1F879E215D565700B69F88 /* ex_str.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_str.h; path = ../../../../common/libex/include/ex/ex_str.h; sourceTree = ""; }; + 7A1F879F215D565700B69F88 /* ex_path.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = ex_path.h; path = ../../../../common/libex/include/ex/ex_path.h; sourceTree = ""; }; + 7A1F87A0215D565700B69F88 /* ex_thread.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 2147486000; name = ex_thread.h; path = ../../../../common/libex/include/ex/ex_thread.h; sourceTree = ""; }; + 7A1F87A1215D56B500B69F88 /* writer.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = writer.h; path = ../../../../external/jsoncpp/include/json/writer.h; sourceTree = ""; }; + 7A1F87A2215D570000B69F88 /* value.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = value.h; path = ../../../../external/jsoncpp/include/json/value.h; sourceTree = ""; }; + 7A1F87A3215D570000B69F88 /* reader.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = reader.h; path = ../../../../external/jsoncpp/include/json/reader.h; sourceTree = ""; }; + 7A1F87A4215D570000B69F88 /* json.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = json.h; path = ../../../../external/jsoncpp/include/json/json.h; sourceTree = ""; }; + 7A1F87A5215D574400B69F88 /* config.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = config.h; path = ../../../../external/jsoncpp/include/json/config.h; sourceTree = ""; }; + 7A1F87A6215D574500B69F88 /* features.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = features.h; path = ../../../../external/jsoncpp/include/json/features.h; sourceTree = ""; }; + 7A1F87A7215D574500B69F88 /* forwards.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = forwards.h; path = ../../../../external/jsoncpp/include/json/forwards.h; sourceTree = ""; }; + 7A1F87A8215D574500B69F88 /* assertions.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = assertions.h; path = ../../../../external/jsoncpp/include/json/assertions.h; sourceTree = ""; }; + 7A1F87A9215D574500B69F88 /* autolink.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = autolink.h; path = ../../../../external/jsoncpp/include/json/autolink.h; sourceTree = ""; }; + 7A1F87AA215D574500B69F88 /* version.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = version.h; path = ../../../../external/jsoncpp/include/json/version.h; sourceTree = ""; }; + 7A1F87AF215D5A1600B69F88 /* StatusIconAlt@2X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@2X.png"; sourceTree = ""; }; + 7A1F87B0215D5A1600B69F88 /* StatusIcon@2X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@2X.png"; sourceTree = ""; }; 7A27E4A61F6A899B004FDE5D /* ts_const.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_const.h; sourceTree = ""; }; 7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_env.cpp; sourceTree = ""; }; 7A27E4A81F6A8EEC004FDE5D /* ts_env.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_env.h; sourceTree = ""; }; 7A40FFE21F7B2A4500F11697 /* AppDelegate-C-Interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate-C-Interface.h"; sourceTree = ""; }; - 7AA2CD361F6A92380074C92B /* ts_http_rpc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_http_rpc.h; sourceTree = ""; }; + 7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIconAlt@3X.png"; sourceTree = ""; }; + 7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "StatusIcon@3X.png"; sourceTree = ""; }; + 7A7C6C9521973C69006869D9 /* tpassist.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tpassist.png; sourceTree = ""; }; + 7A7C6C9921974094006869D9 /* cacert.cer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = cacert.cer; path = ../cfg/cacert.cer; sourceTree = SOURCE_ROOT; }; + 7A7C6C9A21974094006869D9 /* localhost.key */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = localhost.key; path = ../cfg/localhost.key; sourceTree = SOURCE_ROOT; }; + 7A7C6C9B21974094006869D9 /* localhost.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = localhost.pem; path = ../cfg/localhost.pem; sourceTree = SOURCE_ROOT; }; + 7A7C6C9F2197410B006869D9 /* tp-assist.macos.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "tp-assist.macos.json"; path = "../cfg/tp-assist.macos.json"; sourceTree = SOURCE_ROOT; }; + 7A7C6CA12197786B006869D9 /* ts_ver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ts_ver.h; sourceTree = ""; }; + 7A7C6CA821977F07006869D9 /* iterm2.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = iterm2.scpt; sourceTree = ""; }; + 7A7C6CA921977F07006869D9 /* terminal.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = terminal.scpt; sourceTree = ""; }; + 7AA2CD361F6A92380074C92B /* ts_http_rpc.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 2147486000; path = ts_http_rpc.h; sourceTree = ""; }; 7AA2CD371F6A92620074C92B /* ts_http_rpc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_http_rpc.cpp; sourceTree = ""; }; 7AA2CD391F6A955A0074C92B /* ts_cfg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ts_cfg.cpp; sourceTree = ""; }; 7AA2CD3A1F6A955A0074C92B /* ts_cfg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ts_cfg.h; sourceTree = ""; }; @@ -66,13 +101,17 @@ 7AA2CD421F6AB9750074C92B /* ex_util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ex_util.cpp; path = ../../../../common/libex/src/ex_util.cpp; sourceTree = ""; }; 7AA2CD431F6AB9750074C92B /* ex_winsrv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ex_winsrv.cpp; path = ../../../../common/libex/src/ex_winsrv.cpp; sourceTree = ""; }; 7AA2CD4C1F6AB9F10074C92B /* json_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = json_reader.cpp; path = ../../../../external/jsoncpp/src/lib_json/json_reader.cpp; sourceTree = ""; }; - 7AA2CD4D1F6AB9F10074C92B /* json_tool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = json_tool.h; path = ../../../../external/jsoncpp/src/lib_json/json_tool.h; sourceTree = ""; }; + 7AA2CD4D1F6AB9F10074C92B /* json_tool.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; name = json_tool.h; path = ../../../../external/jsoncpp/src/lib_json/json_tool.h; sourceTree = ""; }; 7AA2CD4E1F6AB9F10074C92B /* json_value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = json_value.cpp; path = ../../../../external/jsoncpp/src/lib_json/json_value.cpp; sourceTree = ""; }; 7AA2CD4F1F6AB9F10074C92B /* json_valueiterator.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = json_valueiterator.inl; path = ../../../../external/jsoncpp/src/lib_json/json_valueiterator.inl; sourceTree = ""; }; 7AA2CD501F6AB9F10074C92B /* json_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = json_writer.cpp; path = ../../../../external/jsoncpp/src/lib_json/json_writer.cpp; sourceTree = ""; }; 7AA2CD561F6ABA2E0074C92B /* mongoose.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mongoose.c; path = ../../../../external/mongoose/mongoose.c; sourceTree = ""; }; 7AA2CD581F6AC0DA0074C92B /* site */ = {isa = PBXFileReference; lastKnownFileType = folder; path = site; sourceTree = ""; }; - 7AD1F1D11F7A55EA0048A496 /* iTerm2.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = iTerm2.scpt; sourceTree = ""; }; + 7AF9BF1F2199E31A00BE5DBC /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = ../../external/macos/release/lib/libssl.a; sourceTree = ""; }; + 7AF9BF212199E32B00BE5DBC /* libmbedx509.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedx509.a; path = ../../external/macos/release/lib/libmbedx509.a; sourceTree = ""; }; + 7AF9BF222199E32B00BE5DBC /* libmbedtls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedtls.a; path = ../../external/macos/release/lib/libmbedtls.a; sourceTree = ""; }; + 7AF9BF232199E32B00BE5DBC /* libmbedcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedcrypto.a; path = ../../external/macos/release/lib/libmbedcrypto.a; sourceTree = ""; }; + 7AF9BF282199E3DF00BE5DBC /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = ../../external/macos/release/lib/libcrypto.a; sourceTree = ""; }; A1B7B9D31DB5361700809327 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; A1B7B9DE1DB53ED200809327 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; A1B7B9E01DB53ED700809327 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; @@ -84,18 +123,18 @@ A1B7B9F11DB54D8C00809327 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/AboutWindowController.strings"; sourceTree = ""; }; A1D700051A5DCDF4003563E4 /* AboutWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutWindowController.h; sourceTree = ""; }; A1D700061A5DCE8D003563E4 /* AboutWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AboutWindowController.m; sourceTree = ""; }; - C149EBF915D5214600B1F558 /* tp_assist.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tp_assist.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C149EBF915D5214600B1F558 /* TP-Assist.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TP-Assist.app"; sourceTree = BUILT_PRODUCTS_DIR; }; C149EBFD15D5214600B1F558 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; C149EC0015D5214600B1F558 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; C149EC0115D5214600B1F558 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; C149EC0215D5214600B1F558 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - C149EC0515D5214600B1F558 /* tp_assist-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "tp_assist-Info.plist"; sourceTree = ""; }; + C149EC0515D5214600B1F558 /* TP-Assist-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TP-Assist-Info.plist"; sourceTree = ""; }; C149EC0715D5214600B1F558 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; C149EC0915D5214600B1F558 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - C149EC0B15D5214600B1F558 /* tp_assist-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "tp_assist-Prefix.pch"; sourceTree = ""; }; + C149EC0B15D5214600B1F558 /* TP-Assist-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TP-Assist-Prefix.pch"; sourceTree = ""; }; C149EC0F15D5214600B1F558 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; C149EC1015D5214600B1F558 /* AppDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AppDelegate.mm; sourceTree = ""; }; - C159DC2715D5DE7F00F5DE24 /* teleport.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = teleport.icns; path = ../teleport.icns; sourceTree = ""; }; + C159DC2715D5DE7F00F5DE24 /* teleport.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = teleport.icns; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -104,6 +143,8 @@ buildActionMask = 2147483647; files = ( C149EBFE15D5214600B1F558 /* Cocoa.framework in Frameworks */, + 7AF9BF292199E3DF00BE5DBC /* libcrypto.a in Frameworks */, + 7AF9BF272199E3DE00BE5DBC /* libssl.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -113,17 +154,41 @@ 0ADB3B10178EF8E2004E9BB9 /* Images */ = { isa = PBXGroup; children = ( + 7A7C6C9021973C24006869D9 /* StatusIcon@3X.png */, + 7A7C6C8F21973C24006869D9 /* StatusIconAlt@3X.png */, + 7A7C6C9521973C69006869D9 /* tpassist.png */, + 7A1F87B0215D5A1600B69F88 /* StatusIcon@2X.png */, + 7A1F87AF215D5A1600B69F88 /* StatusIconAlt@2X.png */, 0ADB3B09178EF8DB004E9BB9 /* StatusIcon.png */, - 0ADB3B0A178EF8DB004E9BB9 /* StatusIcon@2x.png */, 0ADB3B08178EF8DB004E9BB9 /* StatusIconAlt.png */, - 0ADB3B0B178EF8DB004E9BB9 /* StatusIconAlt@2x.png */, ); name = Images; sourceTree = ""; }; + 7A45423D2196E32800FEB5B4 /* cfg */ = { + isa = PBXGroup; + children = ( + 7A7C6C9921974094006869D9 /* cacert.cer */, + 7A7C6C9A21974094006869D9 /* localhost.key */, + 7A7C6C9B21974094006869D9 /* localhost.pem */, + 7A7C6C9F2197410B006869D9 /* tp-assist.macos.json */, + ); + name = cfg; + path = ../cfg; + sourceTree = SOURCE_ROOT; + }; 7AA2CD3C1F6AB9560074C92B /* libex */ = { isa = PBXGroup; children = ( + 7A1F8799215D565600B69F88 /* ex_const.h */, + 7A1F8798215D565600B69F88 /* ex_ini.h */, + 7A1F879B215D565600B69F88 /* ex_log.h */, + 7A1F879F215D565700B69F88 /* ex_path.h */, + 7A1F879C215D565600B69F88 /* ex_platform.h */, + 7A1F879E215D565700B69F88 /* ex_str.h */, + 7A1F87A0215D565700B69F88 /* ex_thread.h */, + 7A1F879D215D565600B69F88 /* ex_types.h */, + 7A1F8797215D565600B69F88 /* ex_util.h */, 7AA2CD3D1F6AB9750074C92B /* ex_ini.cpp */, 7AA2CD3E1F6AB9750074C92B /* ex_log.cpp */, 7AA2CD3F1F6AB9750074C92B /* ex_path.cpp */, @@ -138,6 +203,16 @@ 7AA2CD4B1F6AB9880074C92B /* jsoncpp */ = { isa = PBXGroup; children = ( + 7A1F87A8215D574500B69F88 /* assertions.h */, + 7A1F87A9215D574500B69F88 /* autolink.h */, + 7A1F87A5215D574400B69F88 /* config.h */, + 7A1F87A6215D574500B69F88 /* features.h */, + 7A1F87A7215D574500B69F88 /* forwards.h */, + 7A1F87AA215D574500B69F88 /* version.h */, + 7A1F87A4215D570000B69F88 /* json.h */, + 7A1F87A3215D570000B69F88 /* reader.h */, + 7A1F87A2215D570000B69F88 /* value.h */, + 7A1F87A1215D56B500B69F88 /* writer.h */, 7AA2CD4C1F6AB9F10074C92B /* json_reader.cpp */, 7AA2CD4D1F6AB9F10074C92B /* json_tool.h */, 7AA2CD4E1F6AB9F10074C92B /* json_value.cpp */, @@ -168,15 +243,23 @@ 7A27E4A71F6A8EEC004FDE5D /* ts_env.cpp */, 7A27E4A81F6A8EEC004FDE5D /* ts_env.h */, 7A27E4A61F6A899B004FDE5D /* ts_const.h */, + 7A7C6CA12197786B006869D9 /* ts_ver.h */, ); path = csrc; sourceTree = ""; }; + 7AF9BF1E2199E0DD00BE5DBC /* mbedtls */ = { + isa = PBXGroup; + children = ( + ); + name = mbedtls; + sourceTree = ""; + }; A12D9BE61BCF2C72004F52A6 /* apple-scpt */ = { isa = PBXGroup; children = ( - 7A1818921F815B8A00F3C882 /* Terminal.scpt */, - 7AD1F1D11F7A55EA0048A496 /* iTerm2.scpt */, + 7A7C6CA821977F07006869D9 /* iterm2.scpt */, + 7A7C6CA921977F07006869D9 /* terminal.scpt */, ); path = "apple-scpt"; sourceTree = ""; @@ -186,16 +269,16 @@ children = ( 7A1818951F8242E900F3C882 /* apple-scripts */, 7AA2CD581F6AC0DA0074C92B /* site */, - C149EC0315D5214600B1F558 /* src */, C149EBFC15D5214600B1F558 /* Frameworks */, C149EBFA15D5214600B1F558 /* Products */, + C149EC0315D5214600B1F558 /* src */, ); sourceTree = ""; }; C149EBFA15D5214600B1F558 /* Products */ = { isa = PBXGroup; children = ( - C149EBF915D5214600B1F558 /* tp_assist.app */, + C149EBF915D5214600B1F558 /* TP-Assist.app */, ); name = Products; sourceTree = ""; @@ -203,6 +286,11 @@ C149EBFC15D5214600B1F558 /* Frameworks */ = { isa = PBXGroup; children = ( + 7AF9BF282199E3DF00BE5DBC /* libcrypto.a */, + 7AF9BF232199E32B00BE5DBC /* libmbedcrypto.a */, + 7AF9BF222199E32B00BE5DBC /* libmbedtls.a */, + 7AF9BF212199E32B00BE5DBC /* libmbedx509.a */, + 7AF9BF1F2199E31A00BE5DBC /* libssl.a */, C149EBFD15D5214600B1F558 /* Cocoa.framework */, C149EBFF15D5214600B1F558 /* Other Frameworks */, ); @@ -222,10 +310,11 @@ C149EC0315D5214600B1F558 /* src */ = { isa = PBXGroup; children = ( - 7A1818901F7FBBC200F3C882 /* tp-assist.default.json */, + 7AF9BF1E2199E0DD00BE5DBC /* mbedtls */, + 7A45423D2196E32800FEB5B4 /* cfg */, 7AD3E8741F6A7CC600D2EB48 /* csrc */, A12D9BE61BCF2C72004F52A6 /* apple-scpt */, - C159DC2715D5DE7F00F5DE24 /* teleport.icns */, + C149EC0915D5214600B1F558 /* main.m */, C149EC0F15D5214600B1F558 /* AppDelegate.h */, C149EC1015D5214600B1F558 /* AppDelegate.mm */, C149EC1215D5214600B1F558 /* MainMenu.xib */, @@ -243,10 +332,10 @@ C149EC0415D5214600B1F558 /* Supporting Files */ = { isa = PBXGroup; children = ( - C149EC0515D5214600B1F558 /* tp_assist-Info.plist */, + C159DC2715D5DE7F00F5DE24 /* teleport.icns */, + C149EC0515D5214600B1F558 /* TP-Assist-Info.plist */, C149EC0615D5214600B1F558 /* InfoPlist.strings */, - C149EC0915D5214600B1F558 /* main.m */, - C149EC0B15D5214600B1F558 /* tp_assist-Prefix.pch */, + C149EC0B15D5214600B1F558 /* TP-Assist-Prefix.pch */, A1B7B9DF1DB53ED200809327 /* Localizable.strings */, ); name = "Supporting Files"; @@ -255,9 +344,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - C149EBF815D5214600B1F558 /* tp_assist */ = { + C149EBF815D5214600B1F558 /* TP-Assist */ = { isa = PBXNativeTarget; - buildConfigurationList = C149EC1715D5214600B1F558 /* Build configuration list for PBXNativeTarget "tp_assist" */; + buildConfigurationList = C149EC1715D5214600B1F558 /* Build configuration list for PBXNativeTarget "TP-Assist" */; buildPhases = ( C149EBF515D5214600B1F558 /* Sources */, C149EBF615D5214600B1F558 /* Frameworks */, @@ -267,9 +356,9 @@ ); dependencies = ( ); - name = tp_assist; + name = "TP-Assist"; productName = Shuttle; - productReference = C149EBF915D5214600B1F558 /* tp_assist.app */; + productReference = C149EBF915D5214600B1F558 /* TP-Assist.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -279,10 +368,19 @@ isa = PBXProject; attributes = { LastUpgradeCheck = 0930; - ORGANIZATIONNAME = eomsoft; + ORGANIZATIONNAME = TP4A; + TargetAttributes = { + C149EBF815D5214600B1F558 = { + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 0; + }; + }; + }; + }; }; - buildConfigurationList = C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "tp_assist" */; - compatibilityVersion = "Xcode 3.2"; + buildConfigurationList = C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "TP-Assist" */; + compatibilityVersion = "Xcode 10.0"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( @@ -295,7 +393,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - C149EBF815D5214600B1F558 /* tp_assist */, + C149EBF815D5214600B1F558 /* TP-Assist */, ); }; /* End PBXProject section */ @@ -307,17 +405,23 @@ files = ( 7AA2CD591F6AC0DA0074C92B /* site in Resources */, A1B7B9DD1DB53ED200809327 /* Localizable.strings in Resources */, - 0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */, - 0ADB3B0C178EF8DB004E9BB9 /* StatusIconAlt.png in Resources */, C149EC0815D5214600B1F558 /* InfoPlist.strings in Resources */, - 0ADB3B0F178EF8DB004E9BB9 /* StatusIconAlt@2x.png in Resources */, - 7AD1F1D31F7A55EA0048A496 /* iTerm2.scpt in Resources */, - 0ADB3B0E178EF8DB004E9BB9 /* StatusIcon@2x.png in Resources */, + 7A7C6CA02197410B006869D9 /* tp-assist.macos.json in Resources */, + 7A7C6C9E21974094006869D9 /* localhost.pem in Resources */, + 7A7C6C9621973C69006869D9 /* tpassist.png in Resources */, + 7A7C6C9C21974094006869D9 /* cacert.cer in Resources */, C149EC1415D5214600B1F558 /* MainMenu.xib in Resources */, + 7A7C6C9D21974094006869D9 /* localhost.key in Resources */, C159DC2815D5DE8000F5DE24 /* teleport.icns in Resources */, 7A0C94AA1F68BD2900E04C3E /* AboutWindowController.xib in Resources */, - 7A1818911F7FBBC200F3C882 /* tp-assist.default.json in Resources */, - 7A1818931F815B8A00F3C882 /* Terminal.scpt in Resources */, + 0ADB3B0D178EF8DB004E9BB9 /* StatusIcon.png in Resources */, + 7A1F87B2215D5A1600B69F88 /* StatusIcon@2X.png in Resources */, + 7A7C6C9221973C24006869D9 /* StatusIcon@3X.png in Resources */, + 0ADB3B0C178EF8DB004E9BB9 /* StatusIconAlt.png in Resources */, + 7A1F87B1215D5A1600B69F88 /* StatusIconAlt@2X.png in Resources */, + 7A7C6C9121973C24006869D9 /* StatusIconAlt@3X.png in Resources */, + 7A7C6CAA21977F07006869D9 /* iterm2.scpt in Resources */, + 7A7C6CAB21977F07006869D9 /* terminal.scpt in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -399,6 +503,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -442,9 +547,10 @@ ../../external/mongoose, ../../external/jsoncpp/include, ); - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; + VALID_ARCHS = x86_64; }; name = Debug; }; @@ -454,6 +560,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -490,8 +597,9 @@ ../../external/mongoose, ../../external/jsoncpp/include, ); - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; SDKROOT = macosx; + VALID_ARCHS = x86_64; }; name = Release; }; @@ -501,11 +609,24 @@ CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch"; - INFOPLIST_FILE = "src/tp_assist-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; + GCC_PREFIX_HEADER = "src/TP-Assist-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + MG_ENABLE_SSL, + ); + HEADER_SEARCH_PATHS = ( + ../../common/teleport, + ../../common/libex/include, + ../../external/mongoose, + ../../external/jsoncpp/include, + ../../external/macos/release/include, + ); + INFOPLIST_FILE = "src/TP-Assist-Info.plist"; + LIBRARY_SEARCH_PATHS = ../../external/macos/release/lib; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + VALID_ARCHS = x86_64; WRAPPER_EXTENSION = app; }; name = Debug; @@ -516,11 +637,21 @@ CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "src/tp_assist-Prefix.pch"; - INFOPLIST_FILE = "src/tp_assist-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.8; + GCC_PREFIX_HEADER = "src/TP-Assist-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = MG_ENABLE_SSL; + HEADER_SEARCH_PATHS = ( + ../../common/teleport, + ../../common/libex/include, + ../../external/mongoose, + ../../external/jsoncpp/include, + ../../external/macos/release/include, + ); + INFOPLIST_FILE = "src/TP-Assist-Info.plist"; + LIBRARY_SEARCH_PATHS = ../../external/macos/release/lib; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "teleport.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + VALID_ARCHS = x86_64; WRAPPER_EXTENSION = app; }; name = Release; @@ -528,7 +659,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "tp_assist" */ = { + C149EBF315D5214600B1F558 /* Build configuration list for PBXProject "TP-Assist" */ = { isa = XCConfigurationList; buildConfigurations = ( C149EC1515D5214600B1F558 /* Debug */, @@ -537,7 +668,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - C149EC1715D5214600B1F558 /* Build configuration list for PBXNativeTarget "tp_assist" */ = { + C149EC1715D5214600B1F558 /* Build configuration list for PBXNativeTarget "TP-Assist" */ = { isa = XCConfigurationList; buildConfigurations = ( C149EC1815D5214600B1F558 /* Debug */, diff --git a/client/tp_assist_macos/apple-scripts/compile.sh b/client/tp_assist_macos/apple-scripts/compile.sh old mode 100644 new mode 100755 index 97b2bc1..7503566 --- a/client/tp_assist_macos/apple-scripts/compile.sh +++ b/client/tp_assist_macos/apple-scripts/compile.sh @@ -4,8 +4,8 @@ PATH_ROOT=$(cd "$(dirname "$0")/.."; pwd) echo "compiling applescripts for OS X terminal..." -rm ${PATH_ROOT}/src/apple-scpt/Terminal.scpt -rm ${PATH_ROOT}/src/apple-scpt/iTerm2.scpt +rm ${PATH_ROOT}/src/apple-scpt/terminal.scpt +rm ${PATH_ROOT}/src/apple-scpt/iterm2.scpt -osacompile -o ${PATH_ROOT}/src/apple-scpt/Terminal.scpt -x ${PATH_ROOT}/apple-scripts/scripts/Terminal.applescript -osacompile -o ${PATH_ROOT}/src/apple-scpt/iTerm2.scpt -x ${PATH_ROOT}/apple-scripts/scripts/iTerm2.applescript +osacompile -o ${PATH_ROOT}/src/apple-scpt/terminal.scpt -x ${PATH_ROOT}/apple-scripts/scripts/terminal.applescript +osacompile -o ${PATH_ROOT}/src/apple-scpt/iterm2.scpt -x ${PATH_ROOT}/apple-scripts/scripts/iterm2.applescript diff --git a/client/tp_assist_macos/apple-scripts/scripts/Terminal.applescript b/client/tp_assist_macos/apple-scripts/scripts/Terminal.applescript deleted file mode 100644 index 3b78a92..0000000 --- a/client/tp_assist_macos/apple-scripts/scripts/Terminal.applescript +++ /dev/null @@ -1,44 +0,0 @@ -on scriptRun(argsCmd, argsProfile, argsTitle) - set theCmd to (argsCmd) - set theProfile to (argsProfile) - set theTitle to (argsTitle) - CommandRun(theCmd, theProfile, theTitle) -end scriptRun - -on CommandRun(theCmd, theProfile, theTitle) - tell application "Terminal" - if it is not running then - --if this is the first time Terminal is running you have specify window 1 - --if you dont do this you will get two windows and the title wont be set - activate - set newTerm to do script theCmd in window 1 - set newTerm's current settings to settings set theProfile - set custom title of front window to theTitle - else - --Terminal is running get the window count - set windowCount to (count every window) - if windowCount = 0 then - --Terminal is running but no windows are open - --run our script in a new window - reopen - activate - do script theCmd in window 1 - else - --Terminal is running and we have a window run in a new tab - reopen - activate - tell application "System Events" - tell process "Terminal" - delay 0.2 - keystroke "t" using {command down} - end tell - end tell - activate - do script theCmd in front window - end if - set current settings of selected tab of front window to settings set theProfile - set title displays custom title of front window to true - set custom title of selected tab of front window to theTitle - end if - end tell -end CommandRun diff --git a/client/tp_assist_macos/apple-scripts/scripts/iTerm2.applescript b/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript similarity index 81% rename from client/tp_assist_macos/apple-scripts/scripts/iTerm2.applescript rename to client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript index b767862..1caf314 100644 --- a/client/tp_assist_macos/apple-scripts/scripts/iTerm2.applescript +++ b/client/tp_assist_macos/apple-scripts/scripts/iterm2.applescript @@ -10,7 +10,7 @@ on CommandRun(theCmd, theProfile, theTitle) if it is not running then tell application "iTerm" activate - delay 0.2 + delay 0.5 try close first window end try @@ -24,9 +24,12 @@ on CommandRun(theCmd, theProfile, theTitle) end try tell the current window tell the current session + delay 0.5 set name to theTitle set profile to theProfile write text theCmd + delay 0.5 + write text "" end tell end tell end tell @@ -43,14 +46,18 @@ on CommandRun(theCmd, theProfile, theTitle) end try tell the current tab tell the current session + delay 0.5 set name to theTitle write text theCmd + delay 0.5 + write text "" end tell end tell end tell end tell on error msg - --if all iTerm windows are closed the app stays open. In this scenario iTerm has no "current window" and will give an error when trying to create the new tab. + -- if all iTerm windows are closed the app stays open. In this scenario iTerm has + -- no "current window" and will give an error when trying to create the new tab. tell application "iTerm" try create window with profile theProfile @@ -59,8 +66,11 @@ on CommandRun(theCmd, theProfile, theTitle) end try tell the current window tell the current session + delay 0.5 set name to theTitle write text theCmd + delay 0.5 + write text "" end tell end tell end tell diff --git a/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript b/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript new file mode 100644 index 0000000..a61e3ab --- /dev/null +++ b/client/tp_assist_macos/apple-scripts/scripts/terminal.applescript @@ -0,0 +1,76 @@ +on scriptRun(argsCmd, argsProfile, argsTitle) + set theCmd to (argsCmd) + set theProfile to (argsProfile) + set theTitle to (argsTitle) + CommandRun(theCmd, theProfile, theTitle) +end scriptRun + +on CommandRun(theCmd, theProfile, theTitle) + tell application "Terminal" + if it is not running then + --if this is the first time Terminal is running you have specify window 1 + --if you dont do this you will get two windows and the title wont be set + activate + delay 1.0 + set newTerm to do script theCmd in window 1 + set newTerm's current settings to settings set theProfile + set custom title of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + else + --Terminal is running get the window count + set windowCount to (count every window) + if windowCount = 0 then + --Terminal is running but no windows are open + --run our script in a new window + reopen + activate + + do script theCmd in window 1 + + set current settings of selected tab of front window to settings set theProfile + set title displays custom title of front window to true + set custom title of selected tab of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + + else + --Terminal is running and we have a window run in a new tab + reopen + activate + + tell application "System Events" + tell process "Terminal" + delay 0.5 + keystroke "t" using {command down} + end tell + end tell + + reopen + activate + do script theCmd in front window + + set current settings of selected tab of front window to settings set theProfile + set title displays custom title of front window to true + set custom title of selected tab of front window to theTitle + + delay 1.0 + reopen + activate + tell application "System Events" to key code 36 + + end if + +# set current settings of selected tab of front window to settings set theProfile +# set title displays custom title of front window to true +# set custom title of selected tab of front window to theTitle + end if + + end tell +end CommandRun diff --git a/client/tp_assist_macos/site/css/style.css b/client/tp_assist_macos/site/css/style.css index 82956e3..414f387 100644 --- a/client/tp_assist_macos/site/css/style.css +++ b/client/tp_assist_macos/site/css/style.css @@ -1 +1 @@ -@charset "utf-8";body{font-family:"Microsoft YaHei","微软雅黑",Helvetica,Arial,sans-serif;font-size:13px;background-color:#fff;color:#333}html,body{height:100%}.header{width:100%;height:48px;position:fixed;top:0;line-height:48px;font-size:80%;background-color:#3b3b3b;color:#fff;z-index:999}.header .title{font-size:16px}.header .sub-title{margin-left:30px;color:#acacac}.header-fix{height:48px}.footer{width:100%;height:24px;position:fixed;bottom:0;text-align:center;line-height:24px;background-color:#d5d5d5;border-top:1px solid #a2a2a2;font-size:80%;z-index:999}.content{margin:20px 0 50px 0}.content .cfg-title{font-size:16px;font-weight:bold}.content .form-group{margin-bottom:5px}.content .col-sm-1,.content .col-sm-2,.content .col-sm-3,.content .col-sm-4,.content .col-sm-5,.content .col-sm-6,.content .col-sm-7,.content .col-sm-8,.content .col-sm-9,.content .col-sm-10,.content .col-sm-11,.content .col-sm-12{padding-left:3px;padding-right:3px}.content .arg-detail{font-size:11px}.content .arg-detail ol,.content .arg-detail ul{margin-bottom:0}.content .desc{display:inline-block;margin-top:5px;color:#6b6b6b}.content .arg-detail-common{background-color:#dbffbe;border-radius:5px;padding:15px}.content .input-args{font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace}.arg-varb{color:#0a6aa1;font-weight:bold;font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace;display:inline-block;width:128px}#gritter-notice-wrapper{z-index:9999}.gritter-bottom,.gritter-item,.gritter-top{background:rgba(0,0,0,0.8) !important}.gritter-top{border-top-left-radius:3px;border-top-right-radius:3px}.gritter-bottom{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.gritter-close,.gritter-light .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%}.gritter-close:before,.gritter-light .gritter-close:before{content:'\f00d' !important;font-family:FontAwesome !important;font-size:9px !important;width:16px !important;height:16px !important;line-height:16px !important;color:#fff !important;text-indent:0 !important;position:absolute !important;text-align:center !important;right:0 !important;top:0 !important}.gritter-title{font-size:13px !important;line-height:16px !important;padding-bottom:5px !important;font-weight:400 !important;color:#fff !important;text-shadow:none !important}.gritter-item{color:#aaa !important;font-size:13px !important;padding:2px 15px 5px !important}.gritter-error .gritter-bottom,.gritter-error .gritter-item,.gritter-error .gritter-top{background:rgba(123,32,32,0.9) !important}.gritter-error .gritter-title{color:#fff !important}.gritter-error .gritter-item{color:#ddd !important}.gritter-error .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%;background:#e33b3b !important}.gritter-success .gritter-bottom,.gritter-success .gritter-item,.gritter-success .gritter-top{background:rgba(1,65,16,0.9) !important}.gritter-success .gritter-title{color:#ddd !important}.gritter-success .gritter-item{color:#ccc !important}.gritter-success .gritter-close{background:#0eb320 !important}#gritter-notice-wrapper{width:320px;max-width:480px}/*# sourceMappingURL=style.css.map */ \ No newline at end of file +@charset "utf-8";body{font-family:"Microsoft YaHei","微软雅黑",Helvetica,Arial,sans-serif;font-size:13px;background-color:#fff;color:#333}html,body{height:100%}.header{width:100%;height:48px;position:fixed;top:0;line-height:48px;background-color:#3b3b3b;color:#fff;z-index:999}.header .title{font-size:16px}.header .sub-title{margin-left:30px;color:#acacac}.header-fix{height:48px}.footer{width:100%;height:24px;position:fixed;bottom:0;text-align:center;line-height:24px;background-color:#d5d5d5;border-top:1px solid #a2a2a2;z-index:999}.content{margin:20px 0 50px 0}.content .cfg-title{font-size:16px;font-weight:bold}.content .form-group{margin-bottom:5px}.content .col-sm-1,.content .col-sm-2,.content .col-sm-3,.content .col-sm-4,.content .col-sm-5,.content .col-sm-6,.content .col-sm-7,.content .col-sm-8,.content .col-sm-9,.content .col-sm-10,.content .col-sm-11{padding-left:3px;padding-right:3px}.content .arg-detail ol,.content .arg-detail ul{margin-bottom:0}.content .arg-detail-common{background-color:#dbffbe;border-radius:5px;padding:15px}.content .input-args{font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace}.content .desc{margin-top:5px;color:#6b6b6b}.arg-varb{color:#0a6aa1;font-weight:bold;font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace;display:inline-block;width:164px}#gritter-notice-wrapper{z-index:9999}.gritter-bottom,.gritter-item,.gritter-top{background:rgba(0,0,0,0.8) !important}.gritter-top{border-top-left-radius:3px;border-top-right-radius:3px}.gritter-bottom{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.gritter-close,.gritter-light .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%}.gritter-close:before,.gritter-light .gritter-close:before{content:'\f00d' !important;font-family:FontAwesome !important;font-size:9px !important;width:16px !important;height:16px !important;line-height:16px !important;color:#fff !important;text-indent:0 !important;position:absolute !important;text-align:center !important;right:0 !important;top:0 !important}.gritter-title{font-size:13px !important;line-height:16px !important;padding-bottom:5px !important;font-weight:400 !important;color:#fff !important;text-shadow:none !important}.gritter-item{color:#aaa !important;font-size:13px !important;padding:2px 15px 5px !important}.gritter-error .gritter-bottom,.gritter-error .gritter-item,.gritter-error .gritter-top{background:rgba(123,32,32,0.9) !important}.gritter-error .gritter-title{color:#fff !important}.gritter-error .gritter-item{color:#ddd !important}.gritter-error .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%;background:#e33b3b !important}.gritter-success .gritter-bottom,.gritter-success .gritter-item,.gritter-success .gritter-top{background:rgba(1,65,16,0.9) !important}.gritter-success .gritter-title{color:#ddd !important}.gritter-success .gritter-item{color:#ccc !important}.gritter-success .gritter-close{background:#0eb320 !important}#gritter-notice-wrapper{width:320px;max-width:480px} \ No newline at end of file diff --git a/client/tp_assist_macos/site/css/style.css.map b/client/tp_assist_macos/site/css/style.css.map deleted file mode 100644 index f0bfed4..0000000 --- a/client/tp_assist_macos/site/css/style.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["style.less"],"names":[],"mappings":"AAAA,SAAS,QAaT,KACE,YAJmB,kBAAmB,iCAItC,CACA,cAAA,CACA,qBAAA,CACA,WAGF,KAAM,KACJ,YAGF,QACE,UAAA,CACA,WAAA,CACA,cAAA,CACA,KAAA,CAEA,gBAAA,CAEA,aAAA,CAEA,wBAAA,CACA,UAAA,CACA,YAZF,OAcE,QACE,eAfJ,OAiBE,YACE,gBAAA,CACA,cAIJ,YACE,YAGF,QACE,UAAA,CACA,WAAA,CACA,cAAA,CACA,QAAA,CACA,iBAAA,CACA,gBAAA,CACA,wBAAA,CACA,4BAAA,CACA,aAAA,CACA,YAGF,SACE,qBADF,QAGE,YACE,cAAA,CACA,iBALJ,QAQE,aACE,kBATJ,QAYE,WAZF,QAYa,WAZb,QAYwB,WAZxB,QAYmC,WAZnC,QAY8C,WAZ9C,QAYyD,WAZzD,QAYoE,WAZpE,QAY+E,WAZ/E,QAY0F,WAZ1F,QAYqG,YAZrG,QAYiH,YAZjH,QAY6H,YACzH,gBAAA,CACA,kBAdJ,QAiBE,aACE,eAlBJ,QAiBE,YAEE,IAnBJ,QAiBE,YAEM,IACF,gBApBN,QAwBE,OACE,oBAAA,CACA,cAAA,CACA,cA3BJ,QA8BE,oBAEE,wBAAA,CAEA,iBAAA,CACA,aAnCJ,QAuCE,aACE,mDA7F0D,wBAiG9D,UACE,aAAA,CACA,gBAAA,CACA,mDApG4D,uBAoG5D,CACA,oBAAA,CACA,YAiBF,wBAKE,aAGF,gBAAiB,cAAe,aAE9B,0BAAA,YAGF,aACE,0BAAA,CACA,4BAGF,gBACE,6BAAA,CACA,+BAGF,eAAgB,cAAe,gBAU7B,SAAA,YACA,SAAA,YACA,OAAA,YACA,UAAA,YACA,WAAA,YACA,gBAAA,YACA,aAAA,YACA,kBAGF,cAAc,QAAS,cAAe,eAAc,QAClD,QAAS,OAAT,YACA,uBAAA,YACA,aAAA,YACA,UAAA,YACA,WAAA,YACA,gBAAA,YACA,UAAA,YACA,aAAA,YACA,iBAAA,YACA,iBAAA,YACA,OAAA,YACA,KAAA,YAcF,eACE,cAAA,YACA,gBAAA,YACA,kBAAA,YACA,eAAA,YACA,UAAA,YACA,gBAAA,YAQF,cAEE,UAAA,YACA,cAAA,YACA,oBAAA,YAGF,cACE,iBADF,cACmB,eADnB,cACkC,cAC9B,8BAAA,YAFJ,cAKE,gBACE,UAAA,YANJ,cASE,eACE,UAAA,YAVJ,cAaE,gBACE,SAAA,YACA,SAAA,YACA,OAAA,YACA,UAAA,YACA,WAAA,YACA,gBAAA,YACA,aAAA,YACA,iBAAA,CACA,kBAAA,YAIJ,gBACE,iBADF,gBACmB,eADnB,gBACkC,cAE9B,4BAAA,YAHJ,gBAME,gBAEE,UAAA,YARJ,gBAWE,eAEE,UAAA,YAbJ,gBAgBE,gBACE,kBAAA,YAKJ,wBACE,WAAA,CAEA","file":"style.css","sourceRoot":"../less"} \ No newline at end of file diff --git a/client/tp_assist_macos/site/favicon.ico b/client/tp_assist_macos/site/favicon.ico index 2b25ba4..f0c4fe0 100644 Binary files a/client/tp_assist_macos/site/favicon.ico and b/client/tp_assist_macos/site/favicon.ico differ diff --git a/client/tp_assist_macos/site/favicon.png b/client/tp_assist_macos/site/favicon.png index 515eec1..65f752b 100644 Binary files a/client/tp_assist_macos/site/favicon.png and b/client/tp_assist_macos/site/favicon.png differ diff --git a/client/tp_assist_macos/site/index.html b/client/tp_assist_macos/site/index.html index 72d61da..35292c5 100644 --- a/client/tp_assist_macos/site/index.html +++ b/client/tp_assist_macos/site/index.html @@ -1,105 +1,207 @@ - - - - - - TELEPORT助手配置 - - - - - - - - - - - -
-
- Teleport助手本地配置 - 此处配置保存到本地计算机上,如果更换计算机,需要重新配置! -
-
-
- - - - -
- -
- -
-

本地终端配置(用于SSH)

- -
-
- -
- -
-
- -
- -
- -
-
-
- - -
-

本地RDP配置

- -
-
- -
- -
-
-
- -
- - 建议使用homebrew安装freerdp,安装后freerdp默认路径在:/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp -
-
-
- - -
-
-
-
- -
-
- - -
- -
- - - - - - - - - - - - - - + + + + + + + + + + + TELEPORT助手配置 + + + + + + + + + + + + +
+
+ Teleport 助手本地配置 + +
+
+
+ + + + +
+ +
+ +
+

此处配置保存到本地计算机上,如果更换计算机,需要重新配置!

+ 注意:命令行参数设置中,可以用以下变量替换(注意大小写!): +
    +
  • {host_ip} 替换主机IP地址
  • +
  • {host_port} 替换主机端口号
  • +
  • {user_name} 替换用户名
  • +
  • {real_ip} 替换为远程主机真实IP(仅用于显示,例如客户端的窗口标题或标签页标题等)
  • +
  • {assist_tools_path} 替换为助手工具所在的tools目录的绝对路径
  • +
+
+ + +
+

本地 SSH 客户端配置

+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ + +
+

本地 SFTP 客户端配置

+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

本地 RDP 客户端配置

+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + +
+
+
+ + +
+
+
+
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + diff --git a/client/tp_assist_macos/site/js/config.js b/client/tp_assist_macos/site/js/config.js index 66900e9..e01122a 100644 --- a/client/tp_assist_macos/site/js/config.js +++ b/client/tp_assist_macos/site/js/config.js @@ -5,16 +5,54 @@ var g_url_base = 'http://127.0.0.1:50022'; var g_cfg = null; var dom = { - term_type: $('#term-type'), - term_profile: $('#term-profile'), + version: $('#version'), + + ssh_type: $('#ssh-type'), + ssh_app: $('#ssh-app'), + ssh_cmdline: $('#ssh-cmdline'), + ssh_desc: $('#ssh-desc'), + + sftp_type: $('#sftp-type'), + sftp_app: $('#sftp-app'), + sftp_cmdline: $('#sftp-cmdline'), + sftp_desc: $('#sftp-desc'), + + + telnet_type: $('#telnet-type'), + telnet_app: $('#telnet-app'), + telnet_cmdline: $('#telnet-cmdline'), + telnet_desc: $('#telnet-desc'), + rdp_type: $('#rdp-type'), rdp_app: $('#rdp-app'), + rdp_cmdline: $('#rdp-cmdline'), + rdp_desc: $('#rdp-desc'), btn_save: $('#btn-save') }; +function get_version() { + $.ajax({ + type: 'GET', + timeout: 5000, + url: g_url_base + '/api/get_version', + jsonp: 'callback', + dataType: 'json', + success: function (ret) { + if (ret.code == 0) { + dom.version.text('v' + ret.version); + } else { + alert("获取助手版本信息失败!"); + } + }, + error: function (jqXhr, _error, _e) { + console.log('state:', jqXhr.state()); + alert("获取助手版本信息失败!"); + } + }); +} -var get_config = function () { +function get_config() { $.ajax({ type: 'GET', timeout: 5000, @@ -24,51 +62,128 @@ var get_config = function () { success: function (ret) { if (ret.code == 0) { g_cfg = ret.data; + console.log(g_cfg); update_dom(); } else { - notify_error("获取配置信息失败!"); + alert("获取配置信息失败!"); } }, error: function (jqXhr, _error, _e) { console.log('state:', jqXhr.state()); - notify_error("获取配置信息失败!"); + alert("获取配置信息失败!"); } }); } function update_dom() { - console.log('---', g_cfg); + if (_.isNull(g_cfg)) + return; - dom.term_type.html(''); - - if (!_.isUndefined(g_cfg.term)) { - if (_.isUndefined(g_cfg.term.selected)) { - g_cfg.term.selected = ''; + dom.ssh_type.html(''); + if (!_.isUndefined(g_cfg.ssh)) { + if (_.isUndefined(g_cfg.ssh.selected)) { + g_cfg.ssh.selected = ''; } - if (!_.isUndefined(g_cfg.term.available) && g_cfg.term.available.length > 0) { + if (!_.isUndefined(g_cfg.ssh.available) && g_cfg.ssh.available.length > 0) { var selected = ''; - var profile = ''; + var app = ''; + var cmdline = ''; var html = []; - for (var i = 0; i < g_cfg.term.available.length; i++) { - var item = g_cfg.term.available[i]; + for (var i = 0; i < g_cfg.ssh.available.length; i++) { + var item = g_cfg.ssh.available[i]; - if (selected === '' || item.name === g_cfg.term.selected) { + if (selected === '' || item.name === g_cfg.ssh.selected) { selected = item.name; - profile = item.profile; + app = item.app; + cmdline = item.cmdline; } - html.push(''); + html.push(''); } - dom.term_type.html(html.join('')); + dom.ssh_type.html(html.join('')); - dom.term_type.val(selected); - dom.term_profile.val(profile); + dom.ssh_type.val(selected); + dom.ssh_app.val(app); + dom.ssh_cmdline.val(cmdline); + + $(dom.ssh_type).trigger('change'); } } + dom.sftp_type.html(''); + if (!_.isUndefined(g_cfg.sftp)) { + if (_.isUndefined(g_cfg.sftp.selected)) { + g_cfg.sftp.selected = ''; + } + + if (!_.isUndefined(g_cfg.sftp.available) && g_cfg.sftp.available.length > 0) { + var selected = ''; + var app = ''; + var cmdline = ''; + + var html = []; + for (var i = 0; i < g_cfg.sftp.available.length; i++) { + var item = g_cfg.sftp.available[i]; + + if (selected === '' || item.name === g_cfg.sftp.selected) { + selected = item.name; + app = item.app; + cmdline = item.cmdline; + } + + html.push(''); + } + + dom.sftp_type.html(html.join('')); + + dom.sftp_type.val(selected); + dom.sftp_app.val(app); + dom.sftp_cmdline.val(cmdline); + + $(dom.sftp_type).trigger('change'); + } + } + + + dom.telnet_type.html(''); + if (!_.isUndefined(g_cfg.telnet)) { + if (_.isUndefined(g_cfg.telnet.selected)) { + g_cfg.telnet.selected = ''; + } + + if (!_.isUndefined(g_cfg.telnet.available) && g_cfg.telnet.available.length > 0) { + var selected = ''; + var app = ''; + var cmdline = ''; + + var html = []; + for (var i = 0; i < g_cfg.telnet.available.length; i++) { + var item = g_cfg.telnet.available[i]; + + if (selected === '' || item.name === g_cfg.telnet.selected) { + selected = item.name; + app = item.app; + cmdline = item.cmdline; + } + + html.push(''); + } + + dom.telnet_type.html(html.join('')); + + dom.telnet_type.val(selected); + dom.telnet_app.val(app); + dom.telnet_cmdline.val(cmdline); + + $(dom.telnet_type).trigger('change'); + } + } + + + dom.rdp_type.html(''); if (!_.isUndefined(g_cfg.rdp)) { if (_.isUndefined(g_cfg.rdp.selected)) { g_cfg.rdp.selected = ''; @@ -77,6 +192,7 @@ function update_dom() { if (!_.isUndefined(g_cfg.rdp.available) && g_cfg.rdp.available.length > 0) { var selected = ''; var app = ''; + var cmdline = ''; var html = []; for (var i = 0; i < g_cfg.rdp.available.length; i++) { @@ -85,60 +201,57 @@ function update_dom() { if (selected === '' || item.name === g_cfg.rdp.selected) { selected = item.name; app = item.app; + cmdline = item.cmdline; } - html.push(''); + html.push(''); } dom.rdp_type.html(html.join('')); dom.rdp_type.val(selected); dom.rdp_app.val(app); + dom.rdp_cmdline.val(cmdline); + + $(dom.rdp_type).trigger('change'); } } } -function on_term_change() { - g_cfg.term.selected = dom.term_type.val(); - - for (var i = 0; i < g_cfg.term.available.length; i++) { - var item = g_cfg.term.available[i]; - if (item.name === g_cfg.term.selected) { - dom.term_profile.val(item.profile); - return; - } - } - notify_error('所选的终端配置项并不存在!'); -} - -function on_rdp_change() { - g_cfg.rdp.selected = dom.rdp_type.val(); - - for (var i = 0; i < g_cfg.rdp.available.length; i++) { - var item = g_cfg.rdp.available[i]; - if (item.name === g_cfg.rdp.selected) { - dom.rdp_app.val(item.app); - return; - } - } - notify_error('所选的RDP配置项并不存在!'); -} - function on_save() { if (g_cfg === null) return; - for (var i = 0; i < g_cfg.term.available.length; i++) { - var item = g_cfg.term.available[i]; - if (item.name === g_cfg.term.selected) { - item.profile = dom.term_profile.val(); + var i = 0; + for (i = 0; i < g_cfg.ssh.available.length; i++) { + var item = g_cfg.ssh.available[i]; + if (item.name === g_cfg.ssh.selected) { + item.app = dom.ssh_app.val(); + item.cmdline = dom.ssh_cmdline.val(); break; } } - for (var i = 0; i < g_cfg.rdp.available.length; i++) { + for (i = 0; i < g_cfg.sftp.available.length; i++) { + var item = g_cfg.sftp.available[i]; + if (item.name === g_cfg.sftp.selected) { + item.app = dom.sftp_app.val(); + item.cmdline = dom.sftp_cmdline.val(); + break; + } + } +// for (i = 0; i < g_cfg.telnet.available.length; i++) { +// var item = g_cfg.telnet.available[i]; +// if (item.name === g_cfg.telnet.selected) { +// item.app = dom.telnet_app.val(); +// item.cmdline = dom.telnet_cmdline.val(); +// break; +// } +// } + for (i = 0; i < g_cfg.rdp.available.length; i++) { var item = g_cfg.rdp.available[i]; if (item.name === g_cfg.rdp.selected) { item.app = dom.rdp_app.val(); + item.cmdline = dom.rdp_cmdline.val(); break; } } @@ -165,6 +278,30 @@ function on_save() { }); } +var select_local_file = function (callback) { + var data = { + action: 1 + }; + var args_ = encodeURIComponent(JSON.stringify(data)); + + $.ajax({ + type: 'GET', + timeout: -1, + url: g_url_base + '/api/file_action/' + args_, + jsonp: 'callback', + dataType: 'json', + success: function (ret) { + if(ret.code === 0) + callback(0, ret.path); + }, + error: function (jqXhr, _error, _e) { + console.log('state:', jqXhr.state()); + callback(-1, ""); + } + }); +} + + function notify_error(message_, title_) { var _title = title_ || ''; $.gritter.add({ @@ -188,16 +325,91 @@ function notify_success(message_, title_) { }); }; - $(document).ready(function () { + get_version(); + + dom.ssh_type.change(function () { + g_cfg.ssh.selected = dom.ssh_type.val(); + for (var i = 0; i < g_cfg.ssh.available.length; i++) { + var item = g_cfg.ssh.available[i]; + if (item.name === g_cfg.ssh.selected) { + dom.ssh_app.val(item.app); + dom.ssh_cmdline.val(item.cmdline); + + var html = []; + for(var j = 0; j < item.desc.length; j++) { + html.push('
' + item.desc[j] + '
'); + } + dom.ssh_desc.html(html.join('')); + return; + } + } + notify_error('所选的配置项不存在!'); + }); + + + dom.sftp_type.change(function () { + g_cfg.sftp.selected = dom.sftp_type.val(); + for (var i = 0; i < g_cfg.sftp.available.length; i++) { + var item = g_cfg.sftp.available[i]; + if (item.name === g_cfg.sftp.selected) { + dom.sftp_app.val(item.app); + dom.sftp_cmdline.val(item.cmdline); + + var html = []; + for(var j = 0; j < item.desc.length; j++) { + html.push('
' + item.desc[j] + '
'); + } + dom.sftp_desc.html(html.join('')); + return; + } + } + notify_error('所选的配置项不存在!'); + }); + + + dom.telnet_type.change(function () { + g_cfg.telnet.selected = dom.telnet_type.val(); + for (var i = 0; i < g_cfg.telnet.available.length; i++) { + var item = g_cfg.telnet.available[i]; + if (item.name === g_cfg.telnet.selected) { + dom.telnet_app.val(item.app); + dom.telnet_cmdline.val(item.cmdline); + + var html = []; + for(var j = 0; j < item.desc.length; j++) { + html.push('
' + item.desc[j] + '
'); + } + dom.telnet_desc.html(html.join('')); + return; + } + } + notify_error('所选的配置项不存在!'); + }); + + + dom.rdp_type.change(function () { + g_cfg.rdp.selected = dom.rdp_type.val(); + for (var i = 0; i < g_cfg.rdp.available.length; i++) { + var item = g_cfg.rdp.available[i]; + if (item.name === g_cfg.rdp.selected) { + dom.rdp_app.val(item.app); + dom.rdp_cmdline.val(item.cmdline); + + var html = []; + for(var j = 0; j < item.desc.length; j++) { + html.push('
' + item.desc[j] + '
'); + } + dom.rdp_desc.html(html.join('')); + return; + } + } + notify_error('所选的配置项不存在!'); + }); + + get_config(); - dom.term_type.change(function () { - on_term_change(); - }); - dom.rdp_type.change(function () { - on_rdp_change(); - }); dom.btn_save.click(function () { on_save(); diff --git a/client/tp_assist_macos/site/less/style.less b/client/tp_assist_macos/site/less/style.less index 964264a..b85be3d 100644 --- a/client/tp_assist_macos/site/less/style.less +++ b/client/tp_assist_macos/site/less/style.less @@ -30,7 +30,7 @@ html, body { //text-align: center; line-height: @header-height; //border-bottom: 1px solid darken(@toolbar-bg, 20%); - font-size: 80%; + //font-size: 80%; background-color: #3b3b3b; color: #fff; @@ -58,7 +58,7 @@ html, body { line-height: @footer-height; background-color: @toolbar-bg; border-top: 1px solid darken(@toolbar-bg, 20%); - font-size: 80%; + //font-size: 80%; z-index: 999; } @@ -74,24 +74,18 @@ html, body { margin-bottom: 5px; } - .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { + .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11 { padding-left: 3px; padding-right: 3px; } .arg-detail { - font-size: 11px; + //font-size: 13px; ol, ul { margin-bottom: 0; } } - .desc { - display:inline-block; - margin-top:5px; - color:rgb(107, 107, 107); - } - .arg-detail-common { //border:1px solid #f33; background-color: #dbffbe; @@ -104,6 +98,12 @@ html, body { .input-args { font-family: @font-family-mono; } + + .desc { + // display:inline-block; + margin-top:5px; + color:rgb(107, 107, 107); + } } .arg-varb { @@ -111,7 +111,7 @@ html, body { font-weight: bold; font-family: @font-family-mono; display: inline-block; - width: 128px; + width: 164px; //margin-right:20px; } diff --git a/client/tp_assist_macos/src/AboutWindowController.m b/client/tp_assist_macos/src/AboutWindowController.m index d7d2d98..32d17b6 100644 --- a/client/tp_assist_macos/src/AboutWindowController.m +++ b/client/tp_assist_macos/src/AboutWindowController.m @@ -38,28 +38,29 @@ NSDictionary *plistDict; plistDict = [[NSBundle mainBundle] infoDictionary]; //Get the application name. - id applicationName = [plistDict objectForKey:@"CFBundleName"]; +// id applicationName = [plistDict objectForKey:@"CFBundleName"]; //Get the build version. id applicationVersion = [plistDict objectForKey:@"CFBundleVersion"]; //Get the copyright. - id applicationCopyright = [plistDict objectForKey:@"NSHumanReadableCopyright"]; +// id applicationCopyright = [plistDict objectForKey:@"NSHumanReadableCopyright"]; //Build the string for the windows title. - NSString *aboutTitle = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"About ",nil), applicationName]; - [aboutWindow.window setTitle:aboutTitle]; + // NSString *aboutTitle = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"About ",nil), applicationName]; + NSString *strTitle = [NSString stringWithFormat:@"%@%@", + NSLocalizedString(@"about ",nil), + NSLocalizedString(@"app_name",nil)]; + [aboutWindow.window setTitle:strTitle]; //Build the string for the application name. appName - tagline - NSString *progName = [NSString stringWithFormat:@"%@", NSLocalizedString(@"Teleport Assist",nil)]; - [appName setStringValue:progName]; + NSString *strProgName = [NSString stringWithFormat:@"%@", NSLocalizedString(@"app_full_name", nil)]; + [appName setStringValue:strProgName]; //Build the string for the version. Version: $build - NSString *progVersion = [NSString stringWithFormat:@"%@", applicationVersion]; - [appVersion setStringValue:progVersion]; - - //Make the copyright font smaller. -// [appCopyright setFont:[NSFont systemFontOfSize:10]]; - [appCopyright setStringValue:applicationCopyright]; - + NSString *strVersion = [NSString stringWithFormat:@"%@%@", NSLocalizedString(@"version", nil), applicationVersion]; + [appVersion setStringValue:strVersion]; + + NSString *strCopyright = [NSString stringWithFormat:@"%@", NSLocalizedString(@"copyright", nil)]; + [appCopyright setStringValue:strCopyright]; } - (IBAction)btnHomepage:(id)sender { diff --git a/client/tp_assist_macos/src/AppDelegate-C-Interface.cpp b/client/tp_assist_macos/src/AppDelegate-C-Interface.cpp index a49cbc4..bc942ba 100644 --- a/client/tp_assist_macos/src/AppDelegate-C-Interface.cpp +++ b/client/tp_assist_macos/src/AppDelegate-C-Interface.cpp @@ -3,7 +3,6 @@ // tp_assist // // Created by ApexLiu on 2017/9/29. -// Copyright © 2017年 eomsoft. All rights reserved. // #include "AppDelegate-C-Interface.h" diff --git a/client/tp_assist_macos/src/AppDelegate-C-Interface.h b/client/tp_assist_macos/src/AppDelegate-C-Interface.h index f102bba..d7b455e 100644 --- a/client/tp_assist_macos/src/AppDelegate-C-Interface.h +++ b/client/tp_assist_macos/src/AppDelegate-C-Interface.h @@ -3,13 +3,13 @@ // tp_assist // // Created by ApexLiu on 2017/9/27. -// Copyright © 2017年 eomsoft. All rights reserved. // #ifndef wrap_c_objc_h #define wrap_c_objc_h int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* term_type, const char* term_theme, const char* term_title); +int AppDelegate_select_app (void *_self); // for cpp global object initialize. int cpp_main(void* _self, const char* cfg_file, const char* res_path); diff --git a/client/tp_assist_macos/src/AppDelegate.h b/client/tp_assist_macos/src/AppDelegate.h index 9fc4a07..8f845a6 100644 --- a/client/tp_assist_macos/src/AppDelegate.h +++ b/client/tp_assist_macos/src/AppDelegate.h @@ -16,5 +16,6 @@ } - (int) start_ssh_client:(NSString*)cmd_line termType:(NSString*)term_type termTheme:(NSString*)term_theme termTitle:(NSString*)term_title; +- (int) select_app:(NSString*)ignore; @end diff --git a/client/tp_assist_macos/src/AppDelegate.mm b/client/tp_assist_macos/src/AppDelegate.mm index 9953ade..e01461f 100644 --- a/client/tp_assist_macos/src/AppDelegate.mm +++ b/client/tp_assist_macos/src/AppDelegate.mm @@ -37,6 +37,11 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* return [(__bridge id)_self start_ssh_client:cmdLine termType:termType termTheme:termTheme termTitle:termTitle]; } +int AppDelegate_select_app (void *_self) { + NSString* strIgnore = @""; + return [(__bridge id)_self select_app:strIgnore]; +} + - (void) awakeFromNib { // The path for the configuration file (by default: ~/.tp_assist.ini) @@ -44,32 +49,26 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* // if the config file does not exist, create a default one if ( ![[NSFileManager defaultManager] fileExistsAtPath:cfgFile] ) { - NSString *cfgFileInResource = [[NSBundle mainBundle] pathForResource:@"tp-assist.default" ofType:@"json"]; + NSString *cfgFileInResource = [[NSBundle mainBundle] pathForResource:@"tp-assist.macos" ofType:@"json"]; [[NSFileManager defaultManager] copyItemAtPath:cfgFileInResource toPath:cfgFile error:nil]; } // Define Icons //only regular icon is needed for 10.10 and higher. OS X changes the icon for us. regularIcon = [NSImage imageNamed:@"StatusIcon"]; + [regularIcon setTemplate:YES]; + altIcon = [NSImage imageNamed:@"StatusIconAlt"]; - // TODO: 现在statusIcon有两个问题: - // 1. 不会响应系统设置“暗色菜单栏和Dock”的事件 - // 2. 即使是设置为暗色系,启动本程序也会使用黑色图标,导致在菜单栏中看不到图标。 - // 因此,应该响应系统的设置菜单栏颜色的事件,同时启动前先获取菜单栏的色系。 - // Create the status bar item statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; [statusItem setMenu:menu]; [statusItem setImage: regularIcon]; [statusItem setHighlightMode:YES]; - [statusItem setAlternateImage: altIcon]; + [statusItem setAlternateImage: altIcon]; // Needed to trigger the menuWillOpen event [menu setDelegate:self]; - - - //http_rpc_start((__bridge void*)self); NSString *resPath = [[NSBundle mainBundle] resourcePath]; std::string cpp_res_path = [resPath cStringUsingEncoding:NSUTF8StringEncoding]; @@ -77,26 +76,28 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* int ret = cpp_main((__bridge void*)self, cpp_cfg_file.c_str(), cpp_res_path.c_str()); if(ret != 0) { - // TODO: show error message and exit. - NSString *msg = Nil; + http_rpc_stop(); + + NSString *msg = Nil; if(ret == -1) msg = @"初始化运行环境失败!"; else if(ret == -2) - msg = @"加载配置文件失败!"; + msg = @"加载配置文件失败!\n\n请删除 ~/.tp-assist.json 后重试!"; else if(ret == -3) - msg = @"启动本地通讯端口失败!请检查本地50022端口是否被占用!"; - - NSAlert *alert = [NSAlert alertWithMessageText:@"无法启动Teleport助手" - defaultButton:@"确定" - alternateButton:Nil - otherButton:Nil - informativeTextWithFormat:msg]; - [alert runModal]; - - http_rpc_stop(); + msg = @"启动本地通讯端口失败!\n\n请检查本地50022和50023端口是否被占用!"; + else + msg = @"发生未知错误!"; + NSAlert *alert = [[NSAlert alloc] init]; + alert.icon = [NSImage imageNamed:@"tpassist"]; + [alert addButtonWithTitle:@"确定"]; + [alert setMessageText:@"无法启动Teleport助手"]; + [alert setInformativeText:msg]; + [alert runModal]; + [[NSStatusBar systemStatusBar] removeStatusItem:statusItem]; - [NSApp terminate:NSApp]; } + [NSApp terminate:NSApp]; + } } - (int) start_ssh_client:(NSString*)cmd_line termType:(NSString*)term_type termTheme:(NSString*)term_theme termTitle:(NSString*)term_title { @@ -122,8 +123,8 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* if (handlerName && [handlerName length]) { - /* If we have a handlerName (and potentially parameters), we build - * an NSAppleEvent to execute the script. */ + // If we have a handlerName (and potentially parameters), we build + // an NSAppleEvent to execute the script. //Get a descriptor int pid = [[NSProcessInfo processInfo] processIdentifier]; @@ -133,7 +134,8 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* //Create the container event - //We need these constants from the Carbon OpenScripting framework, but we don't actually need Carbon.framework... + // We need these constants from the Carbon OpenScripting framework, + // but we don't actually need Carbon.framework... #define kASAppleScriptSuite 'ascr' #define kASSubroutineEvent 'psbr' #define keyASSubroutineName 'snam' @@ -165,9 +167,30 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char* } } +- (int) select_app:(NSString*)strIgnore { + // NOT WORK NOW + // this function called by ts_http_rpc.c but it run in worker thread. + // once we call select_app from worker thread, the NSOpenPanel alloc crash. + // so we have had to show UI like "post a event and call callback" stuff. + + NSOpenPanel *mySelectPanel = [[NSOpenPanel alloc] init]; + [mySelectPanel setCanChooseDirectories:YES]; + [mySelectPanel setCanChooseFiles:YES]; + [mySelectPanel setCanCreateDirectories:YES]; + [mySelectPanel setAllowsMultipleSelection:NO]; + [mySelectPanel setResolvesAliases:YES]; + + if([mySelectPanel runModal] == NSModalResponseOK) { + NSURL *ret = [mySelectPanel URL]; + NSLog(@"%@", ret.absoluteString); + } + + return 0; +} + - (IBAction)visitWebsite:(id)sender { - NSURL *url = [NSURL URLWithString:@"http://www.tp4a.com/"]; + NSURL *url = [NSURL URLWithString:@"https://www.tp4a.com/"]; [[NSWorkspace sharedWorkspace] openURL:url]; } diff --git a/client/tp_assist_macos/src/Base.lproj/AboutWindowController.xib b/client/tp_assist_macos/src/Base.lproj/AboutWindowController.xib index c2bd698..f9946ed 100644 --- a/client/tp_assist_macos/src/Base.lproj/AboutWindowController.xib +++ b/client/tp_assist_macos/src/Base.lproj/AboutWindowController.xib @@ -1,8 +1,8 @@ - + - + @@ -16,11 +16,11 @@ - + - + @@ -53,7 +53,7 @@ - + @@ -73,7 +73,7 @@ - + diff --git a/client/tp_assist_macos/src/Base.lproj/Localizable.strings b/client/tp_assist_macos/src/Base.lproj/Localizable.strings index fc24123..e10f545 100644 --- a/client/tp_assist_macos/src/Base.lproj/Localizable.strings +++ b/client/tp_assist_macos/src/Base.lproj/Localizable.strings @@ -2,3 +2,13 @@ Localizable.strings TPAssist */ + +"app_name" = "Teleport助手"; + +//============================================= +// for About Window +//============================================= +"version" = "Version: "; +"app_full_name" = "Teleport Assist for macOS"; +"copyright" = "Copyright © 2017~2018 TP4A. All rights reserved."; +"visit_tp4a_website" = "Visit Teleport Website" diff --git a/client/tp_assist_macos/src/Base.lproj/MainMenu.xib b/client/tp_assist_macos/src/Base.lproj/MainMenu.xib index a93d3c7..d0fe852 100644 --- a/client/tp_assist_macos/src/Base.lproj/MainMenu.xib +++ b/client/tp_assist_macos/src/Base.lproj/MainMenu.xib @@ -1,8 +1,9 @@ - + - + + diff --git a/client/tp_assist_macos/src/StatusIcon.png b/client/tp_assist_macos/src/StatusIcon.png old mode 100644 new mode 100755 index 5be5df8..a746326 Binary files a/client/tp_assist_macos/src/StatusIcon.png and b/client/tp_assist_macos/src/StatusIcon.png differ diff --git a/client/tp_assist_macos/src/StatusIcon@2X.png b/client/tp_assist_macos/src/StatusIcon@2X.png old mode 100644 new mode 100755 index 0194cb2..b763496 Binary files a/client/tp_assist_macos/src/StatusIcon@2X.png and b/client/tp_assist_macos/src/StatusIcon@2X.png differ diff --git a/client/tp_assist_macos/src/StatusIcon@3X.png b/client/tp_assist_macos/src/StatusIcon@3X.png new file mode 100755 index 0000000..e1bc53d Binary files /dev/null and b/client/tp_assist_macos/src/StatusIcon@3X.png differ diff --git a/client/tp_assist_macos/src/StatusIconAlt.png b/client/tp_assist_macos/src/StatusIconAlt.png old mode 100644 new mode 100755 index 73e9c67..30ae8c6 Binary files a/client/tp_assist_macos/src/StatusIconAlt.png and b/client/tp_assist_macos/src/StatusIconAlt.png differ diff --git a/client/tp_assist_macos/src/StatusIconAlt@2X.png b/client/tp_assist_macos/src/StatusIconAlt@2X.png old mode 100644 new mode 100755 index d3e0da2..b8f515b Binary files a/client/tp_assist_macos/src/StatusIconAlt@2X.png and b/client/tp_assist_macos/src/StatusIconAlt@2X.png differ diff --git a/client/tp_assist_macos/src/StatusIconAlt@3X.png b/client/tp_assist_macos/src/StatusIconAlt@3X.png new file mode 100755 index 0000000..5a62c11 Binary files /dev/null and b/client/tp_assist_macos/src/StatusIconAlt@3X.png differ diff --git a/client/tp_assist_macos/src/tp_assist-Info.plist b/client/tp_assist_macos/src/TP-Assist-Info.plist similarity index 87% rename from client/tp_assist_macos/src/tp_assist-Info.plist rename to client/tp_assist_macos/src/TP-Assist-Info.plist index 5e0d218..63fffbc 100644 --- a/client/tp_assist_macos/src/tp_assist-Info.plist +++ b/client/tp_assist_macos/src/TP-Assist-Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.1.0 + 3.2.0 CFBundleSignature ???? CFBundleVersion - 3.1.0 + 3.2.0 LSApplicationCategoryType public.app-category.productivity LSMinimumSystemVersion @@ -29,12 +29,12 @@ LSUIElement NSHumanReadableCopyright - Copyright © 2017~2018 EOMSOFT. All rights reserved. + Copyright © 2017~2018 TP4A. All rights reserved. NSMainNibFile MainMenu NSPrincipalClass NSApplication Product Homepage - http://teleport.eomsoft.net/ + https://www.tp4a.com/ diff --git a/client/tp_assist_macos/src/tp_assist-Prefix.pch b/client/tp_assist_macos/src/TP-Assist-Prefix.pch similarity index 100% rename from client/tp_assist_macos/src/tp_assist-Prefix.pch rename to client/tp_assist_macos/src/TP-Assist-Prefix.pch diff --git a/client/tp_assist_macos/src/apple-scpt/iterm2.scpt b/client/tp_assist_macos/src/apple-scpt/iterm2.scpt new file mode 100644 index 0000000..431c2bf Binary files /dev/null and b/client/tp_assist_macos/src/apple-scpt/iterm2.scpt differ diff --git a/client/tp_assist_macos/src/apple-scpt/terminal.scpt b/client/tp_assist_macos/src/apple-scpt/terminal.scpt new file mode 100644 index 0000000..abda883 Binary files /dev/null and b/client/tp_assist_macos/src/apple-scpt/terminal.scpt differ diff --git a/client/tp_assist_macos/src/csrc/ts_cfg.cpp b/client/tp_assist_macos/src/csrc/ts_cfg.cpp index c90ed0d..7e3daf5 100644 --- a/client/tp_assist_macos/src/csrc/ts_cfg.cpp +++ b/client/tp_assist_macos/src/csrc/ts_cfg.cpp @@ -19,6 +19,20 @@ bool TsCfg::init(void) { if(!_load(file_content)) return false; + if(!m_root.isObject()) { + EXLOGE("invalid config file, not in json format?\n"); + return false; + } + + if(m_root["file_version"].isNull()) { + EXLOGE("invalid config file, maybe need create new one?\n"); + return false; + } + + if(!m_root["file_version"].isInt()) { + + } + return true; } @@ -38,6 +52,76 @@ bool TsCfg::save(const ex_astr& new_value) return true; } +bool TsCfg::_parse_app(const Json::Value& m_root, const ex_astr& str_app, APP_CONFIG& cfg) { + const Json::Value& jApp = m_root[str_app.c_str()]; + if(!jApp.isObject()) + return false; + + if (!jApp["selected"].isString()) { + EXLOGE("invalid config, error 2.\n"); + return false; + } + ex_astr _selected = jApp["selected"].asCString();; + + if (!jApp["available"].isArray() || jApp["available"].size() == 0) { + EXLOGE("invalid config, error 3.\n"); + return false; + } + const Json::Value& jAppList = jApp["available"]; + + int i = 0; + for (i = 0; i < jAppList.size(); ++i) { + if ( + !jAppList[i]["name"].isString() + || !jAppList[i]["app"].isString() + || !jAppList[i]["cmdline"].isString() + || !jAppList[i]["desc"].isArray() + ) { + EXLOGE("invalid config, error 4.\n"); + return false; + } + + if(jAppList[i]["name"].asString().empty()) { + EXLOGE("invalid config, need name.\n"); + return false; + } + + if (jAppList[i]["display"].isNull() || jAppList[i]["display"].asString().empty()) { + cfg.display = jAppList[i]["name"].asCString(); + } else + cfg.display = jAppList[i]["display"].asCString(); + + if (jAppList[i]["name"].asCString() != _selected) + continue; + + cfg.name = jAppList[i]["name"].asCString(); + cfg.display = jAppList[i]["display"].asCString(); + cfg.application = jAppList[i]["app"].asCString(); + cfg.cmdline = jAppList[i]["cmdline"].asCString(); + + if(jAppList[i]["desc"].size() > 0) { + const Json::Value& jAppDescList = jAppList[i]["desc"]; + + int j = 0; + for(j = 0; j < jAppDescList.size(); ++j) { + if(!jAppDescList[j].isString()) + return false; + cfg.description.push_back(jAppDescList[j].asCString()); + } + } + + break; + } + +// if (cfg.application.empty() || cfg.cmdline.empty()) { +// EXLOGE("invalid config, error 6.\n"); +// return false; +// } + + return true; +} + + bool TsCfg::_load(const ex_astr& str_json) { Json::Reader jreader; @@ -46,6 +130,233 @@ bool TsCfg::_load(const ex_astr& str_json) { return false; } + //=================================== + // check ssh config + //=================================== + if(!_parse_app(m_root, "ssh", ssh)) + return false; + if(!_parse_app(m_root, "sftp", sftp)) + return false; +// if(!_parse_app(m_root, "telnet", telnet)) +// return false; + if(!_parse_app(m_root, "rdp", rdp)) + return false; + +#if 0 + if (!m_root["ssh"].isObject()) { + EXLOGE("invalid config, error 1.\n"); + return false; + } + + if (!m_root["ssh"]["selected"].isString()) { + EXLOGE("invalid config, error 2.\n"); + return false; + } + + sel_name = m_root["ssh"]["selected"].asCString(); + + if (!m_root["ssh"]["available"].isArray() || m_root["ssh"]["available"].size() == 0) { + EXLOGE("invalid config, error 3.\n"); + return false; + } + + for (i = 0; i < m_root["ssh"]["available"].size(); ++i) { + + if ( + !m_root["ssh"]["available"][i]["name"].isString() + || !m_root["ssh"]["available"][i]["app"].isString() + || !m_root["ssh"]["available"][i]["cmdline"].isString() + ) { + EXLOGE("invalid config, error 4.\n"); + return false; + } + + if (m_root["ssh"]["available"][i]["display"].isNull()) { + m_root["ssh"]["available"][i]["display"] = m_root["ssh"]["available"][i]["name"]; + } + + if (m_root["ssh"]["available"][i]["name"].asCString() != sel_name) + continue; + + ssh_app = m_root["ssh"]["available"][i]["app"].asCString(); + ssh_cmdline = m_root["ssh"]["available"][i]["cmdline"].asCString(); + + break; + } + + if (ssh_app.length() == 0 || ssh_cmdline.length() == 0) { + EXLOGE("invalid config, error 6.\n"); + return false; + } + + + //=================================== + // check sftp config + //=================================== + + if (!m_root["scp"].isObject()) { + EXLOGE("invalid config, error 1.\n"); + return false; + } + + if (!m_root["scp"]["selected"].isString()) { + EXLOGE("invalid config, error 2.\n"); + return false; + } + + sel_name = m_root["scp"]["selected"].asCString(); + + if (!m_root["scp"]["available"].isArray() || m_root["scp"]["available"].size() == 0) { + EXLOGE("invalid config, error 3.\n"); + return false; + } + + for (i = 0; i < m_root["sftp"]["available"].size(); ++i) { + + if ( + !m_root["sftp"]["available"][i]["name"].isString() + || !m_root["sftp"]["available"][i]["app"].isString() + || !m_root["sftp"]["available"][i]["cmdline"].isString() + ) { + EXLOGE("invalid config, error 4.\n"); + return false; + } + + if (m_root["scp"]["available"][i]["display"].isNull()) { + m_root["scp"]["available"][i]["display"] = m_root["scp"]["available"][i]["name"]; + } + + if (m_root["scp"]["available"][i]["name"].asCString() != sel_name) + continue; + +// tmp = m_root["scp"]["available"][i]["app"].asCString(); +// ex_astr2wstr(tmp, scp_app, EX_CODEPAGE_UTF8); + scp_app = m_root["scp"]["available"][i]["app"].asCString(); +// tmp = m_root["scp"]["available"][i]["cmdline"].asCString(); +// ex_astr2wstr(tmp, scp_cmdline, EX_CODEPAGE_UTF8); + scp_cmdline = m_root["scp"]["available"][i]["cmdline"].asCString(); + + break; + } + + if (scp_app.length() == 0 || scp_cmdline.length() == 0) { + EXLOGE("invalid config, error 6.\n"); + return false; + } + + //=================================== + // check telnet config + //=================================== + + if (!m_root["telnet"].isObject()) { + EXLOGE("invalid config, error 1.\n"); + return false; + } + + if (!m_root["telnet"]["selected"].isString()) { + EXLOGE("invalid config, error 2.\n"); + return false; + } + + sel_name = m_root["telnet"]["selected"].asCString(); + + if (!m_root["telnet"]["available"].isArray() || m_root["telnet"]["available"].size() == 0) { + EXLOGE("invalid config, error 3.\n"); + return false; + } + + for (i = 0; i < m_root["telnet"]["available"].size(); ++i) { + + if ( + !m_root["telnet"]["available"][i]["name"].isString() + || !m_root["telnet"]["available"][i]["app"].isString() + || !m_root["telnet"]["available"][i]["cmdline"].isString() + ) { + EXLOGE("invalid config, error 4.\n"); + return false; + } + + if (m_root["telnet"]["available"][i]["display"].isNull()) { + m_root["telnet"]["available"][i]["display"] = m_root["telnet"]["available"][i]["name"]; + } + + if (m_root["telnet"]["available"][i]["name"].asCString() != sel_name) + continue; + +// tmp = m_root["telnet"]["available"][i]["app"].asCString(); +// ex_astr2wstr(tmp, telnet_app, EX_CODEPAGE_UTF8); +// tmp = m_root["telnet"]["available"][i]["cmdline"].asCString(); +// ex_astr2wstr(tmp, telnet_cmdline, EX_CODEPAGE_UTF8); + telnet_app = m_root["telnet"]["available"][i]["app"].asCString(); + telnet_cmdline = m_root["telnet"]["available"][i]["cmdline"].asCString(); + + break; + } + + if (telnet_app.length() == 0 || telnet_cmdline.length() == 0) { + EXLOGE("invalid config, error 6.\n"); + return false; + } + + //=================================== + // check rdp config + //=================================== + + if (!m_root["rdp"].isObject()) { + EXLOGE("invalid config, error 1.\n"); + return false; + } + + if (!m_root["rdp"]["selected"].isString()) { + EXLOGE("invalid config, error 2.\n"); + return false; + } + + sel_name = m_root["rdp"]["selected"].asCString(); + + if (!m_root["rdp"]["available"].isArray() || m_root["rdp"]["available"].size() == 0) { + EXLOGE("invalid config, error 3.\n"); + return false; + } + + for (i = 0; i < m_root["rdp"]["available"].size(); ++i) { + + if ( + !m_root["rdp"]["available"][i]["name"].isString() + || !m_root["rdp"]["available"][i]["app"].isString() + || !m_root["rdp"]["available"][i]["cmdline"].isString() + ) { + EXLOGE("invalid config, error 4.\n"); + return false; + } + + if (m_root["rdp"]["available"][i]["display"].isNull()) { + m_root["rdp"]["available"][i]["display"] = m_root["rdp"]["available"][i]["name"]; + } + + if (m_root["rdp"]["available"][i]["name"].asCString() != sel_name) + continue; + +// tmp = m_root["rdp"]["available"][i]["app"].asCString(); +// ex_astr2wstr(tmp, rdp_app, EX_CODEPAGE_UTF8); +// tmp = m_root["rdp"]["available"][i]["cmdline"].asCString(); +// ex_astr2wstr(tmp, rdp_cmdline, EX_CODEPAGE_UTF8); +// tmp = m_root["rdp"]["available"][i]["name"].asCString(); +// ex_astr2wstr(tmp, rdp_name, EX_CODEPAGE_UTF8); + rdp_app = m_root["rdp"]["available"][i]["app"].asCString(); + rdp_cmdline = m_root["rdp"]["available"][i]["cmdline"].asCString(); + rdp_name = m_root["rdp"]["available"][i]["name"].asCString(); + + break; + } + + if (rdp_app.length() == 0 || rdp_cmdline.length() == 0 || rdp_name.length() == 0) { + EXLOGE("invalid config, error 6.\n"); + return false; + } +#endif + +#if 0 // ------------ term --------------------- if (!m_root["term"].isObject()) { @@ -154,6 +465,7 @@ bool TsCfg::_load(const ex_astr& str_json) { EXLOGE("invalid config, error 6.\n"); return false; } +#endif return true; } diff --git a/client/tp_assist_macos/src/csrc/ts_cfg.h b/client/tp_assist_macos/src/csrc/ts_cfg.h index f37003d..741b5d9 100644 --- a/client/tp_assist_macos/src/csrc/ts_cfg.h +++ b/client/tp_assist_macos/src/csrc/ts_cfg.h @@ -6,6 +6,14 @@ #include +typedef struct APP_CONFIG { + ex_astr name; + ex_astr display; + ex_astr application; + ex_astr cmdline; + ex_astrs description; +}APP_CONFIG; + class TsCfg { public: @@ -17,18 +25,14 @@ public: Json::Value& get_root() {return m_root;} - ex_astr term_name; - ex_astr term_display; - ex_astr term_app; - ex_astr term_profile; - - ex_astr rdp_name; - ex_astr rdp_display; - ex_astr rdp_app; - //ex_astr rdp_cmdline; - + APP_CONFIG ssh; + APP_CONFIG sftp; + APP_CONFIG telnet; + APP_CONFIG rdp; + protected: bool _load(const ex_astr& str_json); + bool _parse_app(const Json::Value& m_root, const ex_astr& str_app, APP_CONFIG& cfg); protected: Json::Value m_root; diff --git a/client/tp_assist_macos/src/csrc/ts_const.h b/client/tp_assist_macos/src/csrc/ts_const.h index 87d50d9..43f96e9 100644 --- a/client/tp_assist_macos/src/csrc/ts_const.h +++ b/client/tp_assist_macos/src/csrc/ts_const.h @@ -1,12 +1,7 @@ #ifndef __TS_CONST_H__ #define __TS_CONST_H__ -//#define TS_WEB_URL L"http://teleport.eomsoft.net/" -//#define TS_BBS_URL L"http://bbs.eomsoft.net/" -//#define TS_TRAY_MSG L"Teleport" - -#define TS_HTTP_RPC_PORT 50022 -//#define TS_HTTP_RPC_HOST "127.0.0.1" -#define TS_HTTP_RPC_HOST "localhost" +#define TS_HTTP_RPC_PORT 50022 +#define TS_HTTPS_RPC_PORT 50023 #endif // __TS_CONST_H__ diff --git a/client/tp_assist_macos/src/csrc/ts_env.cpp b/client/tp_assist_macos/src/csrc/ts_env.cpp index 388cdad..fc196d9 100644 --- a/client/tp_assist_macos/src/csrc/ts_env.cpp +++ b/client/tp_assist_macos/src/csrc/ts_env.cpp @@ -1,4 +1,3 @@ -//#include "stdafx.h" #include "ts_env.h" #include @@ -24,12 +23,12 @@ bool TsEnv::init(const char* cfg_file, const char* res_path) ex_astr2wstr(cfg_file, m_cfg_file); ex_astr2wstr(res_path, m_res_path); -//#ifdef EX_DEBUG -// m_site_path = L"/Users/apex/work/eomsoft/teleport-dev/client/tp_assist_macos/site"; -//#else +#ifdef EX_DEBUG + m_site_path = L"/Users/apex/work/tp4a/teleport/client/tp_assist_macos/site"; +#else m_site_path = m_res_path; ex_path_join(m_site_path, false, L"site", NULL); -//#endif +#endif return true; } diff --git a/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp b/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp index d697b93..f74a9a7 100644 --- a/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp +++ b/client/tp_assist_macos/src/csrc/ts_http_rpc.cpp @@ -1,9 +1,3 @@ -//#include "stdafx.h" - -//#pragma warning(disable:4091) - -//#include -//#include #include #include @@ -15,7 +9,6 @@ #include "../AppDelegate-C-Interface.h" #include "ts_http_rpc.h" -//#include "dlg_main.h" #include "ts_ver.h" #include "ts_env.h" #include "ts_cfg.h" @@ -25,33 +18,44 @@ #define RDP_CLIENT_FREERDP TsHttpRpc g_http_interface; +TsHttpRpc g_https_interface; void* g_app = NULL; int http_rpc_start(void* app) { g_app = app; - -// if(!g_env.init()) -// return; - if (!g_http_interface.init(TS_HTTP_RPC_HOST, TS_HTTP_RPC_PORT)) + EXLOGW("======================================================\n"); + + if (!g_http_interface.init_http()) { EXLOGE("[ERROR] can not start HTTP-RPC listener, maybe port %d is already in use.\n", TS_HTTP_RPC_PORT); return -1; } - EXLOGW("======================================================\n"); - EXLOGW("[rpc] TeleportAssist-HTTP-RPC ready on %s:%d\n", TS_HTTP_RPC_HOST, TS_HTTP_RPC_PORT); + EXLOGW("[rpc] TeleportAssist-HTTP-RPC ready on localhost:%d\n", TS_HTTP_RPC_PORT); if(!g_http_interface.start()) return -2; - return 0; + if (!g_https_interface.init_https()) + { + EXLOGE("[ERROR] can not start HTTPS-RPC listener, maybe port %d is already in use.\n", TS_HTTPS_RPC_PORT); + return -1; + } + + EXLOGW("[rpc] TeleportAssist-HTTPS-RPC ready on localhost:%d\n", TS_HTTPS_RPC_PORT); + + if(!g_https_interface.start()) + return -2; + + return 0; } void http_rpc_stop(void) { - g_http_interface.stop(); + g_http_interface.stop(); + g_https_interface.stop(); } #define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W') @@ -102,45 +106,79 @@ TsHttpRpc::~TsHttpRpc() mg_mgr_free(&m_mg_mgr); } -bool TsHttpRpc::init(const char* ip, int port) +bool TsHttpRpc::init_http() { - struct mg_connection* nc = NULL; + + char addr[128] = { 0 }; + ex_strformat(addr, 128, "tcp://localhost:%d", TS_HTTP_RPC_PORT); + + struct mg_connection* nc = NULL; + nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler); + if (nc == NULL) { + EXLOGE("[rpc] TsHttpRpc::init_http() localhost:%d\n", TS_HTTP_RPC_PORT); + return false; + } + nc->user_data = this; + + mg_set_protocol_http_websocket(nc); + + return _on_init(); +} - char addr[128] = { 0 }; - if (0 == strcmp(ip, "127.0.0.1") || 0 == strcmp(ip, "localhost")) - ex_strformat(addr, 128, "tcp://127.0.0.1:%d", port); - else - ex_strformat(addr, 128, "tcp://%s:%d", ip, port); +bool TsHttpRpc::init_https() +{ + ex_wstr file_ssl_cert = g_env.m_res_path; + ex_path_join(file_ssl_cert, false, L"localhost.pem", NULL); + ex_wstr file_ssl_key = g_env.m_res_path; + ex_path_join(file_ssl_key, false, L"localhost.key", NULL); + ex_astr _ssl_cert; + ex_wstr2astr(file_ssl_cert, _ssl_cert); + ex_astr _ssl_key; + ex_wstr2astr(file_ssl_key, _ssl_key); + + const char *err = NULL; + struct mg_bind_opts bind_opts; + memset(&bind_opts, 0, sizeof(bind_opts)); + bind_opts.ssl_cert = _ssl_cert.c_str(); + bind_opts.ssl_key = _ssl_key.c_str(); + bind_opts.error_string = &err; + + char addr[128] = { 0 }; + ex_strformat(addr, 128, "tcp://localhost:%d", TS_HTTPS_RPC_PORT); - nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler); - if (nc == NULL) - { - EXLOGE("[rpc] TsHttpRpc::init %s:%d\n", ip, port); - return false; - } - nc->user_data = this; + struct mg_connection* nc = NULL; + nc = mg_bind_opt(&m_mg_mgr, addr, _mg_event_handler, bind_opts); + if (nc == NULL) { + EXLOGE("[rpc] TsHttpRpc::init_https() localhost:%d\n", TS_HTTPS_RPC_PORT); + return false; + } + nc->user_data = this; + + mg_set_protocol_http_websocket(nc); + + return _on_init(); +} - mg_set_protocol_http_websocket(nc); +bool TsHttpRpc::_on_init() { + m_content_type_map[".js"] = "application/javascript"; + m_content_type_map[".png"] = "image/png"; + m_content_type_map[".jpeg"] = "image/jpeg"; + m_content_type_map[".jpg"] = "image/jpeg"; + m_content_type_map[".gif"] = "image/gif"; + m_content_type_map[".ico"] = "image/x-icon"; + m_content_type_map[".json"] = "image/json"; + m_content_type_map[".html"] = "text/html"; + m_content_type_map[".css"] = "text/css"; + m_content_type_map[".tif"] = "image/tiff"; + m_content_type_map[".tiff"] = "image/tiff"; + m_content_type_map[".svg"] = "text/html"; - m_content_type_map[".js"] = "application/javascript"; - m_content_type_map[".png"] = "image/png"; - m_content_type_map[".jpeg"] = "image/jpeg"; - m_content_type_map[".jpg"] = "image/jpeg"; - m_content_type_map[".gif"] = "image/gif"; - m_content_type_map[".ico"] = "image/x-icon"; - m_content_type_map[".json"] = "image/json"; - m_content_type_map[".html"] = "text/html"; - m_content_type_map[".css"] = "text/css"; - m_content_type_map[".tif"] = "image/tiff"; - m_content_type_map[".tiff"] = "image/tiff"; - m_content_type_map[".svg"] = "text/html"; - - return true; + return true; } void TsHttpRpc::_thread_loop(void) { - while (!m_stop_flag) + while (!m_need_stop) { mg_mgr_poll(&m_mg_mgr, 500); } @@ -148,10 +186,10 @@ void TsHttpRpc::_thread_loop(void) EXLOGV("[core] rpc main loop end.\n"); } -void TsHttpRpc::_set_stop_flag(void) -{ - m_stop_flag = true; -} +//void TsHttpRpc::_set_stop_flag(void) +//{ +// m_stop_flag = true; +//} void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_data) { @@ -464,11 +502,15 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) ex_astr teleport_ip = jsRoot["teleport_ip"].asCString(); int teleport_port = jsRoot["teleport_port"].asUInt(); + char _port[64] = {0}; + ex_strformat(_port, 64, "%d", teleport_port); + ex_astr str_teleport_port = _port; ex_astr real_host_ip = jsRoot["remote_host_ip"].asCString(); ex_astr sid = jsRoot["session_id"].asCString(); ex_astr s_exec; + ex_astr s_arg; ex_astrs s_argv; @@ -478,7 +520,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) // RDP //============================================== - if(g_cfg.rdp_app.length() == 0) { + if(g_cfg.rdp.application.length() == 0) { _create_json_ret(buf, TPE_NOT_EXISTS); return; } @@ -546,7 +588,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) //w_exe_path = _T("/usr/local/Cellar/freerdp/1.0.2_1/bin/xfreerdp -u {user_name} {size} {console} "); //w_exe_path = _T("xfreerdp -u {user_name} {size} {console} "); //s_exec = "/usr/local/Cellar/freerdp/1.0.2_1/bin/xfreerdp"; - s_exec = g_cfg.rdp_app; + s_exec = g_cfg.rdp.application; s_argv.push_back(s_exec.c_str()); { @@ -594,25 +636,49 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) if (pro_sub == TP_PROTOCOL_TYPE_SSH_SHELL) { - char szCmd[1024] = {0}; - ex_strformat(szCmd, 1023, "ssh %s@%s -p %d", sid.c_str(), teleport_ip.c_str(), teleport_port); - - char szTitle[128] = {0}; - ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str()); - - int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.term_name.c_str(), g_cfg.term_profile.c_str(), szTitle); - if(ret == 0) - _create_json_ret(buf, TPE_OK); - else - _create_json_ret(buf, TPE_FAILED); - return; + if(g_cfg.ssh.name == "terminal" || g_cfg.ssh.name == "iterm2") { + char szCmd[1024] = {0}; + ex_strformat(szCmd, 1023, "ssh %s@%s -p %d", sid.c_str(), teleport_ip.c_str(), teleport_port); + + char szTitle[128] = {0}; + ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str()); + + int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.ssh.name.c_str(), g_cfg.ssh.cmdline.c_str(), szTitle); + if(ret == 0) + _create_json_ret(buf, TPE_OK); + else + _create_json_ret(buf, TPE_FAILED); + return; + } + + if(g_cfg.ssh.application.length() == 0) { + _create_json_ret(buf, TPE_NOT_EXISTS); + return; + } + + s_exec = g_cfg.ssh.application; + s_argv.push_back(s_exec.c_str()); + + s_arg = g_cfg.ssh.cmdline; } else { + // sorry, SFTP not supported yet for macOS. - _create_json_ret(buf, TPE_NOT_IMPLEMENT); - return; - } +// _create_json_ret(buf, TPE_NOT_IMPLEMENT); +// return; + + if(g_cfg.sftp.application.length() == 0) { + _create_json_ret(buf, TPE_NOT_EXISTS); + return; + } + + s_exec = g_cfg.sftp.application; + s_argv.push_back(s_exec.c_str()); + + s_arg = g_cfg.sftp.cmdline; + + } } else if (pro_type == TP_PROTOCOL_TYPE_TELNET) { @@ -621,74 +687,96 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) //============================================== // sorry, TELNET not supported yet for macOS. - _create_json_ret(buf, TPE_NOT_IMPLEMENT); - return; - } + _create_json_ret(buf, TPE_NOT_IMPLEMENT); + return; -// ex_replace_all(w_exe_path, _T("{host_port}"), w_port); -// ex_replace_all(w_exe_path, _T("{host_ip}"), w_teleport_ip.c_str()); -// ex_replace_all(w_exe_path, _T("{user_name}"), w_sid.c_str()); -// ex_replace_all(w_exe_path, _T("{real_ip}"), w_real_host_ip.c_str()); - //ex_replace_all(w_exe_path, _T("{assist_tools_path}"), g_env.m_tools_path.c_str()); +// if(g_cfg.telnet.name == "terminal" || 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); +// +// char szTitle[128] = {0}; +// ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str()); +// +// int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.telnet.name.c_str(), g_cfg.telnet.cmdline.c_str(), szTitle); +// if(ret == 0) +// _create_json_ret(buf, TPE_OK); +// else +// _create_json_ret(buf, TPE_FAILED); +// 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_arg = g_cfg.telnet.cmdline; + } + + //---- split s_arg and push to s_argv --- + ex_astr::size_type p1 = 0; + ex_astr::size_type p2 = 0; + ex_astr tmp = s_arg; + for(;;) { + ex_remove_white_space(tmp, EX_RSC_BEGIN); + if(tmp.empty()) { + break; + } + if(tmp[0] == '"') { + p1 = 1; + p2 = tmp.find('"', p1); + + if(p2 == ex_astr::npos) { + _create_json_ret(buf, TPE_PARAM); + return; + } + + ex_astr _t; + _t.assign(tmp, p1, p2 - p1); + tmp.erase(0, p2 + 2); + + s_argv.push_back(_t); + } else { + p1 = 0; + p2 = tmp.find(' ', p1); + + if(p2 == ex_astr::npos) { + s_argv.push_back(tmp); + tmp.clear(); + break; + } + + ex_astr _t; + _t.assign(tmp, p1, p2 - p1); + tmp.erase(0, p2 + 1); + + s_argv.push_back(_t); + } + } + + Json::Value root_ret; ex_astr utf8_path = s_exec; - //ex_wstr2astr(w_exe_path, utf8_path, EX_CODEPAGE_UTF8); ex_astrs::iterator it = s_argv.begin(); for(; it != s_argv.end(); ++it) { - utf8_path += " "; - utf8_path += (*it); - } + ex_replace_all((*it), "{host_port}", str_teleport_port); + ex_replace_all((*it), "{host_ip}", teleport_ip); + ex_replace_all((*it), "{user_name}", sid); + ex_replace_all((*it), "{real_ip}", real_host_ip); + //ex_replace_all(utf8_path, _T("{assist_tools_path}"), g_env.m_tools_path.c_str()); + utf8_path += " "; + utf8_path += (*it); + } + root_ret["path"] = utf8_path; - // if (!CreateProcess(NULL, (wchar_t *)w_exe_path.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) - // { - // EXLOGE(_T("CreateProcess() failed. Error=0x%08X.\n %s\n"), GetLastError(), w_exe_path.c_str()); - // root_ret["code"] = TPE_START_CLIENT; - // _create_json_ret(buf, root_ret); - // return; - // } - - //system(utf8_path.c_str()); - //ex_astr __sid; - //ex_wstr2astr(w_sid, __sid); - //execlp("xfreerdp", "-u", __sid.c_str(), "-g", "800x600", "127.0.0.1:52089", NULL); -// FILE *f = popen(utf8_path.c_str(), "r"); -// if(f == NULL) { -// root_ret["code"] = TPE_FAILED; -// } else { -// root_ret["code"] = TPE_OK; -// pclose(f); -// } - -// { -// int i = 0; -// char** _argv = (char**)calloc(s_argv.size()+1, sizeof(char*)); -// if (!_argv) -// return; -// -// for (i = 0; i < s_argv.size(); ++i) -// { -// _argv[i] = ex_strdup(s_argv[i].c_str()); -// } -// _argv[i] = NULL; -// -// execv(s_exec.c_str(), _argv); -// -// for(i = 0; i < s_argv.size(); ++i) { -// if(_argv[i] != NULL) { -// free(_argv[i]); -// } -// } -// free(_argv); -// -// } - - - // for macOS, Create Process should be fork()/exec()... pid_t processId; if ((processId = fork()) == 0) { @@ -704,8 +792,8 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) } _argv[i] = NULL; - execv(s_exec.c_str(), _argv); - + execv(s_exec.c_str(), _argv); + for(i = 0; i < s_argv.size(); ++i) { if(_argv[i] != NULL) { free(_argv[i]); @@ -756,8 +844,44 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf) } void TsHttpRpc::_rpc_func_file_action(const ex_astr& func_args, ex_astr& buf) { - _create_json_ret(buf, TPE_NOT_IMPLEMENT); + _create_json_ret(buf, TPE_FAILED); +#if 0 + Json::Reader jreader; + Json::Value jsRoot; + + if (!jreader.parse(func_args.c_str(), jsRoot)) { + _create_json_ret(buf, TPE_JSON_FORMAT); + return; + } +// if (!jsRoot["action"].isNumeric()) { +// _create_json_ret(buf, TPE_PARAM); +// return; +// } +// int action = jsRoot["action"].asUInt(); + + AppDelegate_select_app(g_app); + _create_json_ret(buf, TPE_FAILED); + +// if (ret) { +// if (action == 1 || action == 2 || action == 3) { +// ex_astr utf8_path; +// ex_wstr2astr(wszReturnPath, utf8_path, EX_CODEPAGE_UTF8); +// Json::Value root; +// root["code"] = TPE_OK; +// root["path"] = utf8_path; +// _create_json_ret(buf, root); +// +// return; +// } else { +// _create_json_ret(buf, TPE_OK); +// return; +// } +// } else { +// _create_json_ret(buf, TPE_DATA); +// return; +// } +#endif } void TsHttpRpc::_rpc_func_get_version(const ex_astr& func_args, ex_astr& buf) diff --git a/client/tp_assist_macos/src/csrc/ts_http_rpc.h b/client/tp_assist_macos/src/csrc/ts_http_rpc.h index 9f5786b..b24217b 100644 --- a/client/tp_assist_macos/src/csrc/ts_http_rpc.h +++ b/client/tp_assist_macos/src/csrc/ts_http_rpc.h @@ -14,29 +14,38 @@ /* //================================================================= -ӿʹ˵ -󣬼 127.0.0.1:50022httpʽҪ£ + # HTTP-RPC-INTERFACE: + + listen on http://localhost:50022 and https://localhost:50023. + + ---------------- + GET method: + http://127.0.0.1:50022/method/json_param + + here `json_param` is string in json format and encoded by url_encode(). -GET ʽ -http://127.0.0.1:50022/method/json_param -json_paramʹurl_encodeбjsonʽַ + ---------------- + POST method + http://127.0.0.1:50022/method -POST ʽ -http://127.0.0.1:50022/method -postjson_param + here the data field of POST should be json_param. + + + ## URI detail: + + - method the method to request to execute. + - json_param param of the method and it is optional. -УURIΪ֣ -method ִе񷽷 -json_param 񷽷ĸӲûиӲⲿֿʡԡ + ## RESULT -ظʽִн󣬷һjsonʽַߣʽ£ - -{"code":0,"data":varb} - -УcodeDZеģֵһ룬0ʾɹʧܣûdata򡣲ɹʱdata -ķݣʽݾִе񷽷ͬͬ + A string in json format should returned with following format: + + {"code":0,"data":varb} + `code` field always exists and 0 means success. + `data` field is optional. + */ int http_rpc_start(void* app); @@ -50,7 +59,8 @@ public: TsHttpRpc(); ~TsHttpRpc(); - bool init(const char* ip, int port); + bool init_http(); + bool init_https(); ex_astr get_content_type(ex_astr file_suffix) { @@ -67,7 +77,10 @@ public: protected: void _thread_loop(void); - void _set_stop_flag(void); +// void _set_stop_flag(void); +// void _on_stop(); + + bool _on_init(); private: int _parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args); diff --git a/client/tp_assist_macos/src/csrc/ts_ver.h b/client/tp_assist_macos/src/csrc/ts_ver.h index b2b4e76..a296cc3 100644 --- a/client/tp_assist_macos/src/csrc/ts_ver.h +++ b/client/tp_assist_macos/src/csrc/ts_ver.h @@ -1,6 +1,6 @@ #ifndef __TS_ASSIST_VER_H__ #define __TS_ASSIST_VER_H__ -#define TP_ASSIST_VER L"3.1.0" +#define TP_ASSIST_VER L"3.2.0" #endif // __TS_ASSIST_VER_H__ diff --git a/client/tp_assist_macos/src/en.lproj/AboutWindowController.strings b/client/tp_assist_macos/src/en.lproj/AboutWindowController.strings index 5aa3681..f4d60d1 100644 --- a/client/tp_assist_macos/src/en.lproj/AboutWindowController.strings +++ b/client/tp_assist_macos/src/en.lproj/AboutWindowController.strings @@ -1,15 +1,2 @@ - -/* Class = "NSTextFieldCell"; title = "Version"; ObjectID = "6fl-Xm-UPS"; */ -"6fl-Xm-UPS.title" = "Version"; - -/* Class = "NSTextFieldCell"; title = "Copyright"; ObjectID = "Cmu-CQ-3V9"; */ -"Cmu-CQ-3V9.title" = "Copyright"; - -/* Class = "NSWindow"; title = "Window"; ObjectID = "F0z-JX-Cv5"; */ -"F0z-JX-Cv5.title" = "Window"; - -/* Class = "NSTextFieldCell"; title = "Program Name and Tag Line"; ObjectID = "tb3-eK-HAT"; */ -"tb3-eK-HAT.title" = "Teleport Assistor for MacOS"; - /* Class = "NSButtonCell"; title = "Homepage"; ObjectID = "uUM-88-32s"; */ -"uUM-88-32s.title" = "Visit TELEPORT Website"; +"uUM-88-32s.title" = "Visit Teleport Website"; diff --git a/client/tp_assist_macos/src/en.lproj/MainMenu.strings b/client/tp_assist_macos/src/en.lproj/MainMenu.strings index 136cf79..cb217cb 100644 --- a/client/tp_assist_macos/src/en.lproj/MainMenu.strings +++ b/client/tp_assist_macos/src/en.lproj/MainMenu.strings @@ -15,7 +15,7 @@ "136.title" = "Quit TPAssist"; /* Class = "NSMenuItem"; title = "About"; ObjectID = "638"; */ -"638.title" = "About"; +"638.title" = "About Teleport Assist"; /* Class = "NSMenuItem"; title = "Quit"; ObjectID = "644"; */ "644.title" = "Quit"; @@ -23,11 +23,4 @@ /* Class = "NSMenuItem"; title = "Settings"; ObjectID = "646"; */ "646.title" = "Settings"; -/* Class = "NSMenu"; title = "Settings"; ObjectID = "647"; */ -"647.title" = "Settings"; - -/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "648"; */ -"648.title" = "Edit"; - -/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "649"; */ -"649.title" = "Quit"; +"pkv-BD-W9b.title" = "Visit Teleport Website"; diff --git a/client/tp_assist_macos/src/teleport.icns b/client/tp_assist_macos/src/teleport.icns new file mode 100644 index 0000000..95a2d7d Binary files /dev/null and b/client/tp_assist_macos/src/teleport.icns differ diff --git a/client/tp_assist_macos/src/tp-assist.default.json b/client/tp_assist_macos/src/tp-assist.default.json deleted file mode 100644 index 7428afb..0000000 --- a/client/tp_assist_macos/src/tp-assist.default.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "term": { - "selected": "Terminal", - "available": [ - { - "name":"Terminal", - "display": "终端(系统自带)", - "app": "Terminal.app", - "profile": "Basic" - }, - { - "name": "iTerm2", - "display": "iTerm2", - "app": "iTerm2.app", - "profile": "Default" - } - ] - }, - - "rdp": { - "selected": "FreeRDP", - "available": [ - { - "name": "FreeRDP", - "display": "FreeRDP", - "app": "" - } - ] - } -} diff --git a/client/tp_assist_macos/src/tpassist.png b/client/tp_assist_macos/src/tpassist.png new file mode 100755 index 0000000..ac7d3ac Binary files /dev/null and b/client/tp_assist_macos/src/tpassist.png differ diff --git a/client/tp_assist_macos/src/zh-Hans.lproj/AboutWindowController.strings b/client/tp_assist_macos/src/zh-Hans.lproj/AboutWindowController.strings index dae265c..2c620e8 100644 --- a/client/tp_assist_macos/src/zh-Hans.lproj/AboutWindowController.strings +++ b/client/tp_assist_macos/src/zh-Hans.lproj/AboutWindowController.strings @@ -1,15 +1,2 @@ - -/* Class = "NSTextFieldCell"; title = "Version"; ObjectID = "6fl-Xm-UPS"; */ -"6fl-Xm-UPS.title" = "Version"; - -/* Class = "NSTextFieldCell"; title = "Copyright"; ObjectID = "Cmu-CQ-3V9"; */ -"Cmu-CQ-3V9.title" = "Copyright"; - -/* Class = "NSWindow"; title = "Window"; ObjectID = "F0z-JX-Cv5"; */ -"F0z-JX-Cv5.title" = "Window"; - -/* Class = "NSTextFieldCell"; title = "Program Name and Tag Line"; ObjectID = "tb3-eK-HAT"; */ -"tb3-eK-HAT.title" = "Teleport助手 for MacOS"; - /* Class = "NSButtonCell"; title = "官方网站"; ObjectID = "uUM-88-32s"; */ -"uUM-88-32s.title" = "访问TELEPORT官方网站"; +"uUM-88-32s.title" = "访问 Teleport 网站"; diff --git a/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings b/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings index 7ec6657..1c1fec3 100644 --- a/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings +++ b/client/tp_assist_macos/src/zh-Hans.lproj/Localizable.strings @@ -7,9 +7,13 @@ /* NSLocalizedString(@"",nil)*/ -"About " = "关于 "; -//"Version: " = "版本:"; -"Teleport Assist" = "Teleport 助手 - macOS"; +"app_name" = "Teleport助手"; -"Quit" = "退出"; -//"Continue" = "继续"; +//============================================= +// for About Window +//============================================= +"about " = "关于 "; +"version" = "版本:"; +"app_full_name" = "Teleport助手 - macOS"; +"copyright" = "© 2017~2018 TP4A,保留所有权利。"; +"visit_tp4a_website" = "访问 Teleport 网站"; diff --git a/client/tp_assist_macos/src/zh-Hans.lproj/MainMenu.strings b/client/tp_assist_macos/src/zh-Hans.lproj/MainMenu.strings index 2613abc..986704e 100644 --- a/client/tp_assist_macos/src/zh-Hans.lproj/MainMenu.strings +++ b/client/tp_assist_macos/src/zh-Hans.lproj/MainMenu.strings @@ -15,7 +15,7 @@ "136.title" = "退出 TPAssist"; /* Class = "NSMenuItem"; title = "关于"; ObjectID = "638"; */ -"638.title" = "关于"; +"638.title" = "关于Teleport助手"; /* Class = "NSMenuItem"; title = "退出"; ObjectID = "644"; */ "644.title" = "退出"; @@ -23,11 +23,4 @@ /* Class = "NSMenuItem"; title = "设置"; ObjectID = "646"; */ "646.title" = "设置"; -/* Class = "NSMenu"; title = "设置"; ObjectID = "647"; */ -"647.title" = "设置"; - -/* Class = "NSMenuItem"; title = "编辑"; ObjectID = "648"; */ -"648.title" = "编辑"; - -/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "649"; */ -"649.title" = "Quit"; +"pkv-BD-W9b.title" = "访问Teleport网站"; diff --git a/client/tp_assist_macos/teleport.icns b/client/tp_assist_macos/teleport.icns deleted file mode 100644 index 91271bf..0000000 Binary files a/client/tp_assist_macos/teleport.icns and /dev/null differ diff --git a/client/tp_assist_win/cfg/scp.ini b/client/tp_assist_win/cfg/scp.ini deleted file mode 100644 index c5483a9..0000000 --- a/client/tp_assist_win/cfg/scp.ini +++ /dev/null @@ -1,9 +0,0 @@ -[common] -client_list=other -current_client=winscp -[other] -alias_name=自定义 -command_line= -desc=desc -name=other -path= diff --git a/client/tp_assist_win/cfg/ssh.ini b/client/tp_assist_win/cfg/ssh.ini deleted file mode 100644 index e9e07f2..0000000 --- a/client/tp_assist_win/cfg/ssh.ini +++ /dev/null @@ -1,21 +0,0 @@ -[common] -client_list=securecrt,xshell,other -current_client=putty -[other] -alias_name=自定义 -command_line= -desc=desc -name=other -path= -[securecrt] -alias_name=SecureCRT -command_line=/T /N "TP#ssh://{real_ip}" /SSH2 /P {host_port} /PASSWORD **** {user_name}@{host_ip} -desc=SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单地说是Windows下登录UNIX或Linux服务器主机的软件。 -name=securecrt -path= -[xshell] -alias_name=Xshell -command_line=-newtab "TP#ssh://{real_ip}" -url ssh://{user_name}:****@{host_ip}:{host_port} -desc=Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 协议。 -name=xshell -path= diff --git a/client/tp_assist_win/cfg/telnet.ini b/client/tp_assist_win/cfg/telnet.ini deleted file mode 100644 index 8ccf885..0000000 --- a/client/tp_assist_win/cfg/telnet.ini +++ /dev/null @@ -1,15 +0,0 @@ -[common] -client_list=securecrt,other -current_client=putty -[other] -alias_name=自定义 -command_line= -desc= -name=other -path= -[securecrt] -alias_name=SecureCRT -command_line=/T /N "TP#telnet://{real_ip}" /ARG {user_name} /SCRIPT "{assist_tools_path}\securecrt-telnet.vbs" /TELNET {host_ip} {host_port} -desc=SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单地说是Windows下登录UNIX或Linux服务器主机的软件。 -name=securecrt -path= diff --git a/client/tp_assist_win/dlg_main.cpp b/client/tp_assist_win/dlg_main.cpp index eb255da..c2171cc 100644 --- a/client/tp_assist_win/dlg_main.cpp +++ b/client/tp_assist_win/dlg_main.cpp @@ -18,7 +18,7 @@ extern HINSTANCE g_hInstance; -HWND g_hDlgMain = NULL; +HWND g_hDlgMain = nullptr; static DWORD g_dwTaskbarRecreateMessage = 0; static BOOL g_IsTrayIconShowed = FALSE; @@ -90,19 +90,13 @@ INT_PTR CALLBACK eomDlgMainProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARA case IDM_OPEN_WEB: { - ShellExecute(NULL, _T("open"), TS_WEB_URL, NULL, NULL, SW_SHOW); - return TRUE; - }break; - - case IDM_OPEN_BBS: - { - ShellExecute(NULL, _T("open"), TS_BBS_URL, NULL, NULL, SW_SHOW); + ShellExecute(nullptr, _T("open"), TS_WEB_URL, nullptr, nullptr, SW_SHOW); return TRUE; }break; case IDM_OPEN_CONFIG: { - ShellExecute(NULL, _T("open"), _T("http://127.0.0.1:50022/config"), NULL, NULL, SW_SHOW); + ShellExecute(nullptr, _T("open"), _T("http://localhost:50022/config"), nullptr, nullptr, SW_SHOW); return TRUE; }break; @@ -129,7 +123,7 @@ INT_PTR CALLBACK eomDlgMainProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARA HMENU hPopup = GetSubMenu(hMenu, 0); SetMenuDefaultItem(hPopup, IDM_ABOUT, FALSE); - TrackPopupMenu(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndDlg, NULL); + TrackPopupMenu(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndDlg, nullptr); DestroyMenu(hMenu); } @@ -216,7 +210,7 @@ void center_window(HWND hwndDlg) rc.top = (cyScreen - (rc.bottom - rc.top)) / 3; } - SetWindowPos(hwndDlg, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE); + SetWindowPos(hwndDlg, nullptr, rc.left, rc.top, 0, 0, SWP_NOSIZE); return; } diff --git a/client/tp_assist_win/res/tp.ico b/client/tp_assist_win/res/tp.ico index 2b25ba4..1ec99be 100644 Binary files a/client/tp_assist_win/res/tp.ico and b/client/tp_assist_win/res/tp.ico differ diff --git a/client/tp_assist_win/res/tp_small.ico b/client/tp_assist_win/res/tp_small.ico index ef68da1..4ef9018 100644 Binary files a/client/tp_assist_win/res/tp_small.ico and b/client/tp_assist_win/res/tp_small.ico differ diff --git a/client/tp_assist_win/res/tray_normal.ico b/client/tp_assist_win/res/tray_normal.ico index ef68da1..4e4a969 100644 Binary files a/client/tp_assist_win/res/tray_normal.ico and b/client/tp_assist_win/res/tray_normal.ico differ diff --git a/client/tp_assist_win/resource.h b/client/tp_assist_win/resource.h index cc46f88..10cca66 100644 Binary files a/client/tp_assist_win/resource.h and b/client/tp_assist_win/resource.h differ diff --git a/client/tp_assist_win/site/favicon.ico b/client/tp_assist_win/site/favicon.ico index 2b25ba4..f0c4fe0 100644 Binary files a/client/tp_assist_win/site/favicon.ico and b/client/tp_assist_win/site/favicon.ico differ diff --git a/client/tp_assist_win/site/favicon.png b/client/tp_assist_win/site/favicon.png index 515eec1..65f752b 100644 Binary files a/client/tp_assist_win/site/favicon.png and b/client/tp_assist_win/site/favicon.png differ diff --git a/client/tp_assist_win/site/index.html b/client/tp_assist_win/site/index.html index 229a185..60e67a2 100644 --- a/client/tp_assist_win/site/index.html +++ b/client/tp_assist_win/site/index.html @@ -4,220 +4,223 @@ + - - - + + + TELEPORT助手配置 - + - + + -
-
- Teleport 助手本地配置 - +
+
+ Teleport 助手本地配置 + +
-
-
+
-