mirror of https://github.com/tp4a/teleport
libtpssh.so now build on Linux.
parent
c5f1b9091a
commit
4cc96b0025
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -126,9 +126,9 @@ function step_prepare_source()
|
|||
# tar -zxvf "${PATH_DOWNLOAD}/psutil-${VER_PSUTIL}.tar.gz" -C "${PATH_TMP}"
|
||||
# fi
|
||||
|
||||
# cp -r "${PATH_TMP}/psutil-${VER_PSUTIL}/psutil" "${PATH_TMP}/Python-${VER_PYTHON}/Modules/."
|
||||
cp -r "${PATH_TMP}/sqlite-autoconf-${VER_SQLITE}" "${PATH_TMP}/Python-${VER_PYTHON}/Modules/_sqlite/sqlite3"
|
||||
cp -r "${PATH_FIX}/Python-${VER_PYTHON}" "${PATH_TMP}"
|
||||
# cp -r "${PATH_TMP}/psutil-${VER_PSUTIL}/psutil" "${PATH_TMP}/Python-${VER_PYTHON}/Modules/."
|
||||
cp -r "${PATH_TMP}/sqlite-autoconf-${VER_SQLITE}" "${PATH_TMP}/Python-${VER_PYTHON}/Modules/_sqlite/sqlite3"
|
||||
cp -r "${PATH_FIX}/Python-${VER_PYTHON}" "${PATH_TMP}"
|
||||
}
|
||||
|
||||
function step_build_openssl()
|
||||
|
@ -138,7 +138,7 @@ function step_build_openssl()
|
|||
if [ ! -f "${PATH_RELEASE}/lib/libssl.a" ] || [ ! -f "${PATH_RELEASE}/lib/libcrypto.a" ]; then
|
||||
echo ""
|
||||
cd "${OSSL_PATH_SRC}"
|
||||
./config --prefix=${PATH_RELEASE} --openssldir=${PATH_RELEASE}/openssl no-zlib no-shared
|
||||
./config -fPIC --prefix=${PATH_RELEASE} --openssldir=${PATH_RELEASE}/openssl no-zlib no-shared
|
||||
make
|
||||
make install
|
||||
cd "${PATH_ROOT}"
|
||||
|
@ -184,7 +184,7 @@ function step_finalize()
|
|||
fi
|
||||
|
||||
|
||||
# cp -r "${PATH_FIX}/psutil-${VER_PSUTIL}/psutil" "${PATH_RELEASE}/lib/python${VER_PYTHON_SHORT}/site-packages/psutil"
|
||||
# cp -r "${PATH_FIX}/psutil-${VER_PSUTIL}/psutil" "${PATH_RELEASE}/lib/python${VER_PYTHON_SHORT}/site-packages/psutil"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,10 +55,6 @@ def main():
|
|||
ctx.set_target(TARGET_DEBUG)
|
||||
elif 'release' == argv[i]:
|
||||
ctx.set_target(TARGET_RELEASE)
|
||||
# elif 'x86' == argv[i]:
|
||||
# ctx.set_bits(BITS_32)
|
||||
# elif 'x64' == argv[i]:
|
||||
# ctx.set_bits(BITS_64)
|
||||
elif argv[i] in ctx.dist_all:
|
||||
ctx.set_dist(argv[i])
|
||||
else:
|
||||
|
@ -122,11 +118,8 @@ def clean_all():
|
|||
|
||||
def do_opt(opt):
|
||||
cc.v(opt)
|
||||
# PY_EXEC = cfg[opt['bits']]['PY_EXEC']
|
||||
|
||||
arg = ''
|
||||
# if 'pysbase' == opt['name']:
|
||||
# script = 'build-pysbase.py'
|
||||
|
||||
if 'ver' == opt['name']:
|
||||
script = 'build-version.py'
|
||||
|
@ -137,9 +130,6 @@ def do_opt(opt):
|
|||
elif 'external' == opt['name']:
|
||||
script = 'build-external.py'
|
||||
|
||||
# elif 'agent-runtime' == opt['name']:
|
||||
# script = 'build-agent.py'
|
||||
# arg = '%s %s runtime' % (ctx.target_path, opt['bits'])
|
||||
elif 'server' == opt['name']:
|
||||
script = 'build-server.py'
|
||||
arg = '%s %s server' % (ctx.target_path, opt['bits'])
|
||||
|
@ -163,17 +153,10 @@ def do_opt(opt):
|
|||
script = 'build-assist.py'
|
||||
arg = '%s %s installer' % (ctx.dist, opt['bits'])
|
||||
|
||||
# elif 'server' == opt['name']:
|
||||
# script = 'build-server.py'
|
||||
# # arg = 'installer'
|
||||
# # arg = '%s %s' % (ctx.dist, ctx.bits_path)
|
||||
# arg = '%s' % (opt['bits'])
|
||||
|
||||
else:
|
||||
cc.e('unknown option: ', opt['name'])
|
||||
return
|
||||
|
||||
# cmd = '%s "%s" %s' % (PY_EXEC, arg, ex_arg)
|
||||
cmd = '"%s" -B "%s/%s" %s' % (utils.cfg.py_exec, BUILDER_PATH, script, arg)
|
||||
cc.i(cmd)
|
||||
cc.v('')
|
||||
|
@ -220,11 +203,8 @@ def add_split():
|
|||
def make_options():
|
||||
global options, options_idx, cfg
|
||||
|
||||
# options = [{'name': 'config', 'disp': 'Configure'}]
|
||||
|
||||
options = list()
|
||||
options_idx = 0
|
||||
# add_option(None, 'config', 'Configure')
|
||||
|
||||
if ctx.host_os == 'windows':
|
||||
add_option('x86', 'ver', 'Update version setting')
|
||||
|
@ -242,9 +222,9 @@ def make_options():
|
|||
add_option('x64', 'pysrt', 'Make Python-Runtime for python%s-x64' % (utils.cfg.py_ver_str))
|
||||
add_option('x64', 'external', 'Build external for Teleport-Server')
|
||||
add_split()
|
||||
add_option('x64', 'server', 'Teleport Server [%s]' % ctx.target_path)
|
||||
add_option('x64', 'server', 'Build server app [%s]' % ctx.target_path)
|
||||
add_split()
|
||||
add_option('x64', 'installer', 'Teleport Installer for %s' % ctx.host_os)
|
||||
add_option('x64', 'installer', 'Make server installer for %s' % ctx.host_os)
|
||||
|
||||
|
||||
def get_input(msg, log_func=cc.w):
|
||||
|
|
|
@ -134,7 +134,8 @@ class BuilderLinux(BuilderBase):
|
|||
|
||||
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('./config --prefix={} --openssldir={}/openssl no-zlib no-shared'.format(self.PATH_RELEASE, self.PATH_RELEASE))
|
||||
os.system('./config --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)
|
||||
|
@ -362,8 +363,8 @@ def main():
|
|||
if builder is None:
|
||||
builder = gen_builder(ctx.host_os)
|
||||
|
||||
builder.build_openssl()
|
||||
builder.build_libuv()
|
||||
# builder.build_openssl()
|
||||
####builder.build_libuv()
|
||||
builder.build_mbedtls()
|
||||
builder.build_libssh()
|
||||
builder.build_sqlite()
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
|
||||
protected:
|
||||
ex_u32 m_filesize;
|
||||
ex_u32 m_max_filesize;
|
||||
ex_u8 m_max_count;
|
||||
ex_u32 m_max_filesize;
|
||||
ex_u8 m_max_count;
|
||||
ex_wstr m_path;
|
||||
ex_wstr m_filename;
|
||||
ex_wstr m_fullname;
|
||||
|
@ -54,11 +54,11 @@ protected:
|
|||
#endif
|
||||
};
|
||||
|
||||
extern ExLogger g_ex_logger;
|
||||
//extern ExLogger g_ex_logger;
|
||||
|
||||
// extern void* ex_logger;
|
||||
|
||||
void EXLOG_USE_EXTERNAL_LOGGER(ExLogger* logger);
|
||||
void EXLOG_USE_LOGGER(ExLogger* logger);
|
||||
|
||||
void EXLOG_LEVEL(int min_level);
|
||||
|
||||
|
|
|
@ -6,41 +6,48 @@
|
|||
#include <algorithm>
|
||||
|
||||
#ifdef EX_OS_WIN32
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <direct.h>
|
||||
# include <io.h>
|
||||
# include <stdio.h>
|
||||
# include <direct.h>
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#include <sys/time.h>
|
||||
# include <dirent.h>
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define EX_LOG_CONTENT_MAX_LEN 2048
|
||||
|
||||
//typedef std::deque<unsigned long long> log_file_deque;
|
||||
|
||||
ExLogger g_ex_logger;
|
||||
static ExLogger* g_exlog = &g_ex_logger;
|
||||
//ExLogger g_ex_logger;
|
||||
static ExLogger* g_exlog = NULL;//&g_ex_logger;
|
||||
|
||||
void EXLOG_USE_EXTERNAL_LOGGER(ExLogger* logger)
|
||||
void EXLOG_USE_LOGGER(ExLogger* logger)
|
||||
{
|
||||
if (NULL == logger)
|
||||
g_exlog = &g_ex_logger;
|
||||
else
|
||||
g_exlog = logger;
|
||||
// if (NULL == logger)
|
||||
// g_exlog = &g_ex_logger;
|
||||
// else
|
||||
// g_exlog = logger;
|
||||
|
||||
g_exlog = logger;
|
||||
}
|
||||
|
||||
void EXLOG_LEVEL(int min_level)
|
||||
{
|
||||
g_exlog->min_level = min_level;
|
||||
if(NULL != g_exlog)
|
||||
g_exlog->min_level = min_level;
|
||||
}
|
||||
|
||||
void EXLOG_CONSOLE(bool output_to_console)
|
||||
{
|
||||
g_exlog->to_console = output_to_console;
|
||||
if(NULL != g_exlog)
|
||||
g_exlog->to_console = output_to_console;
|
||||
}
|
||||
|
||||
void EXLOG_FILE(const wchar_t* log_file, const wchar_t* log_path /*= NULL*/, ex_u32 max_filesize /*= EX_LOG_FILE_MAX_SIZE*/, ex_u8 max_filecount /*= EX_LOG_FILE_MAX_COUNT*/)
|
||||
{
|
||||
if(NULL == g_exlog)
|
||||
return;
|
||||
|
||||
ex_wstr _path;
|
||||
if (NULL == log_path)
|
||||
{
|
||||
|
@ -69,6 +76,7 @@ ExLogger::ExLogger()
|
|||
m_file = NULL;
|
||||
m_filesize = 0;
|
||||
}
|
||||
|
||||
ExLogger::~ExLogger()
|
||||
{
|
||||
if (NULL != m_file)
|
||||
|
@ -162,6 +170,8 @@ void ExLogger::log_w(int level, const wchar_t* fmt, va_list valist)
|
|||
#define EX_PRINTF_X(fn, level) \
|
||||
void fn(const char* fmt, ...) \
|
||||
{ \
|
||||
if(NULL == g_exlog) \
|
||||
return; \
|
||||
if (g_exlog->min_level > level) \
|
||||
return; \
|
||||
ExThreadSmartLock locker(g_exlog->lock); \
|
||||
|
@ -172,6 +182,8 @@ void fn(const char* fmt, ...) \
|
|||
} \
|
||||
void fn(const wchar_t* fmt, ...) \
|
||||
{ \
|
||||
if(NULL == g_exlog) \
|
||||
return; \
|
||||
if (g_exlog->min_level > level) \
|
||||
return; \
|
||||
ExThreadSmartLock locker(g_exlog->lock); \
|
||||
|
@ -236,6 +248,8 @@ void ex_printf_e_lasterror(const wchar_t* fmt, ...)
|
|||
|
||||
void ex_printf_bin(const ex_u8* bin_data, size_t bin_size, const char* fmt, ...)
|
||||
{
|
||||
if(NULL == g_exlog)
|
||||
return;
|
||||
if (!g_exlog->debug_mode)
|
||||
return;
|
||||
|
||||
|
@ -549,6 +563,7 @@ bool ExLogger::write(const char* buf)
|
|||
m_filesize += lenTime;
|
||||
fwrite(buf, len, 1, m_file);
|
||||
m_filesize += len;
|
||||
fflush(m_file);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -256,8 +256,14 @@ bool ex_abspath(ex_wstr& inout_path)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifndef EX_OS_WIN32
|
||||
// if(_tmp == _str)
|
||||
// paths.push_back(L"/");
|
||||
#endif
|
||||
|
||||
_tmp[0] = EX_NULL_END;
|
||||
paths.push_back(_str);
|
||||
// if(wcslen(_str) > 0)
|
||||
paths.push_back(_str);
|
||||
_str = _tmp + 1;
|
||||
}
|
||||
}
|
||||
|
@ -297,10 +303,11 @@ bool ex_abspath(ex_wstr& inout_path)
|
|||
{
|
||||
#ifdef EX_OS_WIN32
|
||||
if ((*it)[1] != L':')
|
||||
#else
|
||||
if ((*it)[0] != L'/')
|
||||
#endif
|
||||
return false;
|
||||
#else
|
||||
// if ((*it)[0] != L'/')
|
||||
#endif
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (!is_first)
|
||||
|
|
|
@ -10,8 +10,13 @@
|
|||
<file url="file://$PROJECT_DIR$/../common/libex/src/ex_util.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/main.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_db.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_env.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_http_rpc.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/core/ts_main.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_proxy.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_recorder.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_session.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_core/protocol/ssh/ssh_session.h" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_web/src/main.cpp" charset="GBK" />
|
||||
<file url="file://$PROJECT_DIR$/tp_web/src/ts_env.cpp" charset="GBK" />
|
||||
</component>
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_rpc.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_session.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.cpp" isTestSource="false" />
|
||||
|
@ -53,13 +54,28 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_db.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/CMakeLists.txt" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_env.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_db.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_session.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/ts_membuf.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_env.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_record.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_record.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/ts_membuf.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/tpp_env.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/CMakeLists.txt" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_recorder.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_session.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_proxy.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/tpssh.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_recorder.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/tpp_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_session.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_core/protocol/ssh/ssh_proxy.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_web/src/main.cpp" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_web/src/ts_env.h" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tp_web/src/CMakeLists.txt" isTestSource="false" />
|
||||
|
|
|
@ -9,4 +9,4 @@ cmake_minimum_required(VERSION 3.5)
|
|||
|
||||
add_subdirectory(tp_web/src)
|
||||
add_subdirectory(tp_core/core)
|
||||
#add_subdirectory(tp_core/protocol/ssh)
|
||||
add_subdirectory(tp_core/protocol/ssh)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
server_port = 7190
|
||||
|
||||
log_file = 'E:\work\eomsoft\teleport-github\server\share\log\web.log'
|
||||
|
||||
# log_level can be 0 ~ 4
|
||||
# LOG_LEVEL_DEBUG 0 log every-thing.
|
||||
# LOG_LEVEL_VERBOSE 1 log every-thing but without debug message.
|
||||
# LOG_LEVEL_INFO 2 log infomation/warning/error message.
|
||||
# LOG_LEVEL_WARN 3 log warning and error message.
|
||||
# LOG_LEVEL_ERROR 4 log error message only.
|
||||
log_level = 0
|
|
@ -14,7 +14,7 @@ bool TppEnvBase::init(TPP_INIT_ARGS* args)
|
|||
return false;
|
||||
}
|
||||
|
||||
EXLOG_USE_EXTERNAL_LOGGER(args->logger);
|
||||
EXLOG_USE_LOGGER(args->logger);
|
||||
|
||||
exec_path = args->exec_path;
|
||||
etc_path = args->etc_path;
|
||||
|
|
|
@ -146,17 +146,17 @@ void base_record::record(unsigned char* buf, int len, int cmd)
|
|||
bool bRet = cached_buffer(&replay_header, buf, len);
|
||||
if (!bRet)
|
||||
{
|
||||
//缓存已满,把缓存存文件,并且清空缓存
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD>
|
||||
save_buffer_to_file(int(internal_time));
|
||||
|
||||
//打开下个文件
|
||||
//<EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
open_next_file();
|
||||
|
||||
bRet = cached_buffer(&replay_header, buf, len);
|
||||
|
||||
if (!bRet)
|
||||
{
|
||||
//如果还是太大,不能缓存,直接存文件
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><EFBFBD>棬ֱ<EFBFBD>Ӵ<EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
save_to_file(ex_u32(internal_time), &replay_header, buf, len);
|
||||
open_next_file();
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ bool base_record::cached_buffer(ts_replay_data_header* header, unsigned char* bu
|
|||
return false;
|
||||
}
|
||||
|
||||
//长度够长直接存缓存
|
||||
//<EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵ滺<EFBFBD><EFBFBD>
|
||||
memcpy(m_buf + m_buf_offset, header, header_len);
|
||||
m_buf_offset += header_len;
|
||||
|
||||
|
@ -208,7 +208,7 @@ bool base_record::save_buffer_to_file(int internal_time)
|
|||
if(NULL == m_current_file)
|
||||
return false;
|
||||
|
||||
int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* 写的struct文件*/
|
||||
int ret = fwrite(m_buf, m_buf_offset, 1, m_current_file); /* д<EFBFBD><EFBFBD>struct<EFBFBD>ļ<EFBFBD>*/
|
||||
m_totol_size += m_buf_offset;
|
||||
|
||||
m_buf_offset = 0;
|
||||
|
|
|
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.5)
|
|||
project(tpcore)
|
||||
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${Project_SOURCE_DIR}/../out/server/x64/bin")
|
||||
|
||||
|
||||
|
@ -15,6 +16,8 @@ ADD_DEFINITIONS(
|
|||
-DDISABLE_MD5
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-export-dynamic")
|
||||
|
||||
aux_source_directory(. DIR_SRCS)
|
||||
aux_source_directory(../../../common/libex/src DIR_SRCS)
|
||||
aux_source_directory(../../../external/mongoose DIR_SRCS)
|
||||
|
@ -27,8 +30,6 @@ include_directories(
|
|||
../../../external/mongoose
|
||||
../../../external/jsoncpp/include
|
||||
../../../external/linux/release/include
|
||||
# ../../pyshell/pys/include
|
||||
# ../../py-static/release/include/python3.4m
|
||||
)
|
||||
|
||||
link_directories(../../../external/linux/release/lib)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// --version 打印版本号然后退出
|
||||
// start 以服务方式运行
|
||||
//
|
||||
ExLogger g_ex_logger;
|
||||
|
||||
bool g_is_debug = false;
|
||||
|
||||
|
@ -115,6 +116,8 @@ static int _main_loop(void)
|
|||
|
||||
int _app_main(int argc, wchar_t** argv)
|
||||
{
|
||||
EXLOG_USE_LOGGER(&g_ex_logger);
|
||||
|
||||
if (!_process_cmd_line(argc, argv))
|
||||
return 1;
|
||||
|
||||
|
@ -302,12 +305,10 @@ VOID WINAPI service_main(DWORD argc, wchar_t** argv)
|
|||
|
||||
#else
|
||||
// not EX_OS_WIN32
|
||||
//#include "ts_util.h"
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
static void _sig_handler(int signum, siginfo_t* info, void* ptr);
|
||||
//static int _daemon(int nochdir, int noclose);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -329,7 +330,7 @@ void _sig_handler(int signum, siginfo_t* info, void* ptr)
|
|||
{
|
||||
if (signum == SIGINT || signum == SIGTERM)
|
||||
{
|
||||
printf("[ts] received signal SIGINT, exit now.\n");
|
||||
EXLOGW("[core] received signal SIGINT, exit now.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +340,7 @@ static bool _run_daemon(void)
|
|||
pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
printf("[ERROR] can not fork daemon.\n");
|
||||
EXLOGE("[core] can not fork daemon.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (pid > 0)
|
||||
|
@ -350,7 +351,7 @@ static bool _run_daemon(void)
|
|||
// now I'm first children.
|
||||
if (setsid() == -1)
|
||||
{
|
||||
printf("setsid() failed.\n");
|
||||
EXLOGE("[core] setsid() failed.\n");
|
||||
assert(0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -360,7 +361,7 @@ static bool _run_daemon(void)
|
|||
pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
printf("[ERROR] can not fork daemon.\n");
|
||||
EXLOGE("[core] can not fork daemon.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (pid > 0)
|
||||
|
|
|
@ -9,16 +9,6 @@
|
|||
|
||||
//#include "../common/protocol_interface.h"
|
||||
|
||||
//#if defined(MBEDTLS_PLATFORM_C)
|
||||
//#include "mbedtls/platform.h"
|
||||
////#else
|
||||
////#include <stdio.h>
|
||||
////#include <stdlib.h>
|
||||
////#define mbedtls_time time
|
||||
////#define mbedtls_time_t time_t
|
||||
////#define mbedtls_fprintf fprintf
|
||||
////#define mbedtls_printf printf
|
||||
//#endif
|
||||
|
||||
#include <mbedtls/platform.h>
|
||||
#include <mbedtls/debug.h>
|
||||
|
@ -122,13 +112,16 @@ private:
|
|||
};
|
||||
|
||||
static TppManager g_tpp_mgr;
|
||||
extern ExLogger g_ex_logger;
|
||||
|
||||
bool TppManager::load_tpp(const ex_wstr& libname)
|
||||
{
|
||||
ex_wstr filename = libname;
|
||||
ex_wstr filename;
|
||||
#ifdef EX_OS_WIN32
|
||||
filename += L".dll";
|
||||
filename = libname + L".dll";
|
||||
#else
|
||||
filename = L"lib";
|
||||
filename += libname;
|
||||
filename += L".so";
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
project(tpssh)
|
||||
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${Project_SOURCE_DIR}/../out/server/x64/bin")
|
||||
|
||||
|
||||
aux_source_directory(. DIR_SRCS)
|
||||
aux_source_directory(../../common DIR_SRCS)
|
||||
aux_source_directory(../../../../common/libex/src DIR_SRCS)
|
||||
aux_source_directory(../../../../external/jsoncpp/src/lib_json DIR_SRCS)
|
||||
|
||||
list(REMOVE_ITEM DIR_SRCS "./dllmain.cpp")
|
||||
list(REMOVE_ITEM DIR_SRCS "./stdafx.cpp")
|
||||
|
||||
include_directories(
|
||||
../../../../common/libex/include
|
||||
../../../../external/jsoncpp/include
|
||||
../../../../external/linux/release/include
|
||||
)
|
||||
|
||||
link_directories(../../../../external/linux/release/lib)
|
||||
|
||||
add_library(tpssh SHARED ${DIR_SRCS})
|
||||
target_link_libraries(tpssh ssh ssl crypto mbedx509 mbedtls mbedcrypto dl pthread rt util)
|
||||
#target_link_libraries(tpssh ssh mbedx509 mbedtls mbedcrypto dl pthread rt util)
|
|
@ -26,8 +26,8 @@ SshProxy::~SshProxy()
|
|||
|
||||
bool SshProxy::init(void)
|
||||
{
|
||||
m_host_ip = g_env.bind_ip;
|
||||
m_host_port = g_env.bind_port;
|
||||
m_host_ip = g_ssh_env.bind_ip;
|
||||
m_host_port = g_ssh_env.bind_port;
|
||||
|
||||
|
||||
m_bind = ssh_bind_new();
|
||||
|
@ -48,15 +48,11 @@ bool SshProxy::init(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef EX_OS_WIN32
|
||||
ex_wstr _key_file = g_env.etc_path;
|
||||
ex_path_join(_key_file, false, _T("tp_ssh_server.key"), NULL);
|
||||
ex_wstr _key_file = g_ssh_env.etc_path;
|
||||
ex_path_join(_key_file, false, L"tp_ssh_server.key", NULL);
|
||||
ex_astr key_file;
|
||||
ex_wstr2astr(_key_file, key_file);
|
||||
#else
|
||||
ex_str key_file = g_env.m_etc_path;
|
||||
g_env.path_join(key_file, 0, _T("ts_ssh_server.key"), NULL);
|
||||
#endif
|
||||
|
||||
EXLOGV("[ssh] try to load ssh-server-key: %s\n", key_file.c_str());
|
||||
if (SSH_OK != ssh_bind_options_set(m_bind, SSH_BIND_OPTIONS_RSAKEY, key_file.c_str()))
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ void TppRec::record_command(const ex_astr cmd)
|
|||
time(&timep);
|
||||
p = localtime(&timep);
|
||||
if (p == NULL)
|
||||
return false;
|
||||
return;
|
||||
sprintf(szTime, "[%04d-%02d-%02d %02d:%02d:%02d] ", p->tm_year + 1900, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
||||
#endif
|
||||
int lenTime = strlen(szTime);
|
||||
|
|
|
@ -73,13 +73,13 @@ void SshSession::_set_stop_flag(void) {
|
|||
|
||||
bool SshSession::_on_session_begin(TS_SESSION_INFO& info)
|
||||
{
|
||||
if (!g_env.session_begin(info, m_db_id))
|
||||
if (!g_ssh_env.session_begin(info, m_db_id))
|
||||
{
|
||||
EXLOGD("[ssh] session_begin error. %d\n", m_db_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rec.begin(g_env.replay_path.c_str(), L"tp-ssh", m_db_id, info);
|
||||
m_rec.begin(g_ssh_env.replay_path.c_str(), L"tp-ssh", m_db_id, info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ bool SshSession::_on_session_end(void)
|
|||
if (m_retcode == SESS_STAT_RUNNING)
|
||||
m_retcode = SESS_STAT_END;
|
||||
|
||||
g_env.session_end(m_db_id, m_retcode);
|
||||
g_ssh_env.session_end(m_db_id, m_retcode);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -232,7 +232,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
|
|||
bool bRet = true;
|
||||
TS_SESSION_INFO sess_info;
|
||||
//bRet = _this->m_proxy->get_session_mgr()->take_session(_this->m_sid, sess_info);
|
||||
bRet = g_env.take_session(_this->m_sid, sess_info);
|
||||
bRet = g_ssh_env.take_session(_this->m_sid, sess_info);
|
||||
|
||||
if (!bRet) {
|
||||
EXLOGW("[ssh] try to get login-info from ssh-sftp-session.\n");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "tpp_env.h"
|
||||
|
||||
TppEnv g_env;
|
||||
TppEnv g_ssh_env;
|
||||
|
||||
TppEnv::TppEnv()
|
||||
{}
|
||||
|
|
|
@ -17,6 +17,6 @@ private:
|
|||
bool _on_init(TPP_INIT_ARGS* args);
|
||||
};
|
||||
|
||||
extern TppEnv g_env;
|
||||
extern TppEnv g_ssh_env;
|
||||
|
||||
#endif // __TPP_ENV_H__
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
TPP_API ex_rv tpp_init(TPP_INIT_ARGS* init_args)
|
||||
{
|
||||
if (!g_env.init(init_args))
|
||||
if (!g_ssh_env.init(init_args))
|
||||
return TSR_FAILED;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.5)
|
|||
project(tpweb)
|
||||
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${Project_SOURCE_DIR}/../out/server/x64/bin")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-export-dynamic")
|
||||
|
||||
aux_source_directory(. DIR_SRCS)
|
||||
aux_source_directory(../../../common/libex/src DIR_SRCS)
|
||||
aux_source_directory(../../../common/pyshell/src DIR_SRCS)
|
||||
|
@ -13,10 +16,9 @@ include_directories(
|
|||
../../../common/pyshell/include
|
||||
../../../external/linux/release/include
|
||||
../../../external/linux/release/include/python3.4m
|
||||
# ../external/common/jsoncpp/include
|
||||
# ../../pyshell/pys/include
|
||||
# ../../py-static/release/include/python3.4m
|
||||
)
|
||||
|
||||
link_directories(../../../external/linux/release/lib)
|
||||
|
||||
add_executable(tp_web ${DIR_SRCS})
|
||||
target_link_libraries(tp_web python3.4m ssl crypto dl pthread rt util)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// script-file.py 被执行的脚本文件
|
||||
// ... 剩余的所有参数均传递给Python脚本
|
||||
|
||||
|
||||
ExLogger g_ex_logger;
|
||||
bool g_is_debug = false;
|
||||
static ex_wstrs g_py_args;
|
||||
|
||||
|
@ -232,6 +232,8 @@ static int _main_loop(void)
|
|||
|
||||
int _app_main(int argc, wchar_t** argv)
|
||||
{
|
||||
EXLOG_USE_LOGGER(&g_ex_logger);
|
||||
|
||||
if (!_process_cmd_line(argc, argv))
|
||||
return 1;
|
||||
|
||||
|
@ -445,7 +447,7 @@ void _sig_handler(int signum, siginfo_t* info, void* ptr)
|
|||
{
|
||||
if (signum == SIGINT || signum == SIGTERM)
|
||||
{
|
||||
printf("[ts] received signal SIGINT, exit now.\n");
|
||||
EXLOGW("[tpweb] received signal SIGINT, exit now.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -455,7 +457,7 @@ static bool _run_daemon(void)
|
|||
pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
printf("[ERROR] can not fork daemon.\n");
|
||||
EXLOGE("[tpweb] can not fork daemon.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (pid > 0)
|
||||
|
@ -466,7 +468,7 @@ static bool _run_daemon(void)
|
|||
// now I'm first children.
|
||||
if (setsid() == -1)
|
||||
{
|
||||
printf("setsid() failed.\n");
|
||||
EXLOGE("[tpweb] setsid() failed.\n");
|
||||
assert(0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -476,7 +478,7 @@ static bool _run_daemon(void)
|
|||
pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
printf("[ERROR] can not fork daemon.\n");
|
||||
EXLOGE("[tpweb] can not fork daemon.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (pid > 0)
|
||||
|
|
Loading…
Reference in New Issue