mirror of https://github.com/tp4a/teleport
temp.
parent
a49590705d
commit
65f2d1ceae
|
@ -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', 'tp_assist.vs2015.sln')
|
||||
sln_file = os.path.join(env.root_path, 'client', 'tp_assist_win', 'tp_assist.vs2015.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)
|
||||
|
|
|
@ -839,7 +839,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
|
|||
// SSH
|
||||
//==============================================
|
||||
|
||||
if (pro_sub == TP_PROTOCOL_SUB_TYPE_SSH)
|
||||
if (pro_sub == TP_PROTOCOL_TYPE_SSH_SHELL)
|
||||
{
|
||||
w_exe_path = _T("\"");
|
||||
w_exe_path += g_cfg.ssh_app + _T("\" ");
|
||||
|
|
|
@ -9,8 +9,6 @@ TppRecBase::TppRecBase()
|
|||
{
|
||||
m_cache.reserve(MAX_SIZE_PER_FILE);
|
||||
m_start_time = 0;
|
||||
m_last_time = 0;
|
||||
//m_protocol =
|
||||
}
|
||||
|
||||
TppRecBase::~TppRecBase()
|
||||
|
|
|
@ -92,13 +92,10 @@ protected:
|
|||
virtual bool _on_end() = 0;
|
||||
|
||||
protected:
|
||||
//int m_protocol;
|
||||
|
||||
ex_wstr m_base_path; // 录像文件基础路径,例如 /usr/local/eom/teleport/data/replay/ssh/123,数字编号是内部附加的,作为本次会话录像文件的目录名称
|
||||
ex_wstr m_base_fname; // 录像文件的文件名,不含扩展名部分,内部会以此为基础合成文件全名,并将录像文件存放在 m_base_path 指向的目录中
|
||||
|
||||
ex_u64 m_start_time;
|
||||
ex_u64 m_last_time;
|
||||
|
||||
MemBuffer m_cache;
|
||||
};
|
||||
|
|
|
@ -10,12 +10,13 @@ TppSshRec::TppSshRec()
|
|||
memset(&m_head, 0, sizeof(TS_RECORD_HEADER));
|
||||
memcpy((ex_u8*)(&m_head.info.magic), TPP_RECORD_MAGIC, sizeof(ex_u32));
|
||||
m_head.info.ver = 0x03;
|
||||
m_header_changed = false;
|
||||
m_save_full_header = false;
|
||||
|
||||
m_file_info = NULL;
|
||||
m_file_data = NULL;
|
||||
m_file_cmd = NULL;
|
||||
|
||||
m_save_full_header = false;
|
||||
}
|
||||
|
||||
TppSshRec::~TppSshRec()
|
||||
|
@ -44,29 +45,7 @@ bool TppSshRec::_on_begin(const TPP_CONNECT_INFO* info)
|
|||
bool TppSshRec::_on_end()
|
||||
{
|
||||
// 如果还有剩下未写入的数据,写入文件中。
|
||||
if (m_cache.size() > 0)
|
||||
_save_to_data_file();
|
||||
if (m_cmd_cache.size() > 0)
|
||||
_save_to_cmd_file();
|
||||
|
||||
// // ¸üÐÂÍ·ÐÅÏ¢
|
||||
// //m_head.timestamp = m_start_time;
|
||||
// m_head.info.time_ms = (ex_u32)(m_last_time - m_start_time);
|
||||
//
|
||||
// ex_wstr fname = m_base_path;
|
||||
// ex_path_join(fname, false, m_base_fname.c_str(), NULL);
|
||||
// fname += L".tpr";
|
||||
//
|
||||
// FILE* f = ex_fopen(fname, L"wb");
|
||||
// if (NULL == f)
|
||||
// {
|
||||
// EXLOGE("[ssh] can not open record file for write.\n");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// fwrite(&m_head, sizeof(TS_RECORD_HEADER), 1, f);
|
||||
// fflush(f);
|
||||
// fclose(f);
|
||||
save_record();
|
||||
|
||||
if(m_file_info != NULL)
|
||||
fclose(m_file_info);
|
||||
|
@ -79,10 +58,8 @@ bool TppSshRec::_on_end()
|
|||
}
|
||||
|
||||
void TppSshRec::save_record() {
|
||||
if (m_cache.size() > 0)
|
||||
_save_to_data_file();
|
||||
if (m_cmd_cache.size() > 0)
|
||||
_save_to_cmd_file();
|
||||
_save_to_data_file();
|
||||
_save_to_cmd_file();
|
||||
}
|
||||
|
||||
void TppSshRec::record(ex_u8 type, const ex_u8* data, size_t size)
|
||||
|
@ -90,7 +67,7 @@ void TppSshRec::record(ex_u8 type, const ex_u8* data, size_t size)
|
|||
if (data == NULL || 0 == size)
|
||||
return;
|
||||
|
||||
if (sizeof(TS_RECORD_PKG) + size + m_cache.size() > m_cache.buffer_size())
|
||||
if (sizeof(TS_RECORD_PKG) + size + m_cache.size() > MAX_SIZE_PER_FILE)
|
||||
_save_to_data_file();
|
||||
|
||||
TS_RECORD_PKG pkg = {0};
|
||||
|
@ -100,16 +77,15 @@ void TppSshRec::record(ex_u8 type, const ex_u8* data, size_t size)
|
|||
|
||||
if (m_start_time > 0)
|
||||
{
|
||||
m_last_time = ex_get_tick_count();
|
||||
pkg.time_ms = (ex_u32)(m_last_time - m_start_time);
|
||||
|
||||
pkg.time_ms = (ex_u32)(ex_get_tick_count() - m_start_time);
|
||||
m_head.info.time_ms = pkg.time_ms;
|
||||
}
|
||||
|
||||
m_head.info.packages++;
|
||||
|
||||
m_cache.append((ex_u8*)&pkg, sizeof(TS_RECORD_PKG));
|
||||
m_cache.append(data, size);
|
||||
|
||||
m_head.info.packages++;
|
||||
m_header_changed = true;
|
||||
}
|
||||
|
||||
void TppSshRec::record_win_size_startup(int width, int height)
|
||||
|
@ -146,15 +122,17 @@ void TppSshRec::record_command(const ex_astr& cmd)
|
|||
size_t lenTime = strlen(szTime);
|
||||
|
||||
|
||||
if (m_cmd_cache.size() + cmd.length() + lenTime > m_cache.buffer_size())
|
||||
if (m_cmd_cache.size() + cmd.length() + lenTime > MAX_SIZE_PER_FILE)
|
||||
_save_to_cmd_file();
|
||||
|
||||
m_cmd_cache.append((ex_u8*)szTime, lenTime);
|
||||
m_cmd_cache.append((ex_u8*)cmd.c_str(), cmd.length());
|
||||
}
|
||||
|
||||
bool TppSshRec::_save_to_data_file()
|
||||
{
|
||||
bool TppSshRec::_save_to_info_file() {
|
||||
if (!m_header_changed)
|
||||
return true;
|
||||
|
||||
if(m_file_info == NULL) {
|
||||
ex_wstr fname = m_base_path;
|
||||
ex_path_join(fname, false, m_base_fname.c_str(), NULL);
|
||||
|
@ -171,7 +149,26 @@ bool TppSshRec::_save_to_data_file()
|
|||
m_save_full_header = true;
|
||||
}
|
||||
|
||||
if(m_file_data == NULL) {
|
||||
fseek(m_file_info, 0L, SEEK_SET);
|
||||
if (m_save_full_header) {
|
||||
fwrite(&m_head, ts_record_header_size, 1, m_file_info);
|
||||
fflush(m_file_info);
|
||||
m_save_full_header = false;
|
||||
}
|
||||
else {
|
||||
fwrite(&m_head.info, ts_record_header_info_size, 1, m_file_info);
|
||||
fflush(m_file_info);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TppSshRec::_save_to_data_file()
|
||||
{
|
||||
if (m_cache.size() == 0)
|
||||
return true;
|
||||
|
||||
if(m_file_data == NULL) {
|
||||
ex_wstr fname = m_base_path;
|
||||
ex_path_join(fname, false, m_base_fname.c_str(), NULL);
|
||||
fname += L".dat";
|
||||
|
@ -182,47 +179,22 @@ bool TppSshRec::_save_to_data_file()
|
|||
EXLOGE("[ssh] can not open record data-file for write.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_header_changed = true;
|
||||
}
|
||||
|
||||
// wchar_t _str_file_id[24] = { 0 };
|
||||
// ex_wcsformat(_str_file_id, 24, L".%03d", 0);// m_head.file_count);
|
||||
//
|
||||
// ex_wstr fname = m_base_path;
|
||||
// ex_path_join(fname, false, m_base_fname.c_str(), NULL);
|
||||
// fname += _str_file_id;
|
||||
//
|
||||
// FILE* f = ex_fopen(fname, L"wb");
|
||||
//
|
||||
// if (NULL == f)
|
||||
// {
|
||||
// EXLOGE("[ssh] can not open record data-file for write.\n");
|
||||
// m_cache.empty();
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if(m_cache.size() > 0) {
|
||||
fwrite(m_cache.data(), m_cache.size(), 1, m_file_data);
|
||||
fflush(m_file_data);
|
||||
}
|
||||
|
||||
|
||||
fseek(m_file_info, 0L, SEEK_SET);
|
||||
if(m_save_full_header) {
|
||||
fwrite(&m_head, ts_record_header_size, 1, m_file_info);
|
||||
fflush(m_file_info);
|
||||
m_save_full_header = false;
|
||||
} else {
|
||||
fwrite(&m_head.info, ts_record_header_info_size, 1, m_file_info);
|
||||
fflush(m_file_info);
|
||||
}
|
||||
|
||||
fwrite(m_cache.data(), m_cache.size(), 1, m_file_data);
|
||||
fflush(m_file_data);
|
||||
m_cache.empty();
|
||||
return true;
|
||||
|
||||
return _save_to_info_file();
|
||||
}
|
||||
|
||||
bool TppSshRec::_save_to_cmd_file()
|
||||
{
|
||||
if (m_cmd_cache.size() == 0)
|
||||
return true;
|
||||
|
||||
if(NULL == m_file_cmd) {
|
||||
ex_wstr fname = m_base_path;
|
||||
ex_path_join(fname, false, m_base_fname.c_str(), NULL);
|
||||
|
@ -233,26 +205,13 @@ bool TppSshRec::_save_to_cmd_file()
|
|||
EXLOGE("[ssh] can not open record cmd-file for write.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ex_wstr fname = m_base_path;
|
||||
// ex_path_join(fname, false, m_base_fname.c_str(), NULL);
|
||||
// fname += L"-cmd.txt";
|
||||
//
|
||||
// FILE* f = ex_fopen(fname, L"ab");
|
||||
// if (NULL == f)
|
||||
// {
|
||||
// m_cmd_cache.empty();
|
||||
// return false;
|
||||
// }
|
||||
m_header_changed = true;
|
||||
}
|
||||
|
||||
fwrite(m_cmd_cache.data(), m_cmd_cache.size(), 1, m_file_cmd);
|
||||
fflush(m_file_cmd);
|
||||
// fclose(f);
|
||||
|
||||
m_cmd_cache.empty();
|
||||
|
||||
return true;
|
||||
return _save_to_info_file();
|
||||
}
|
||||
|
|
|
@ -8,34 +8,6 @@
|
|||
|
||||
#pragma pack(push,1)
|
||||
|
||||
// 录像文件头
|
||||
// typedef struct TS_RECORD_HEADER
|
||||
// {
|
||||
// ex_u32 magic; // "TPPR" 标志 TelePort Protocol Record
|
||||
// ex_u64 timestamp; // 本次录像的起始时间(UTC时间戳)
|
||||
// ex_u32 packages; // 总包数
|
||||
// ex_u32 time_ms; // 总耗时(毫秒)
|
||||
// ex_u16 width; // 初始屏幕尺寸:宽
|
||||
// ex_u16 height; // 初始屏幕尺寸:高
|
||||
// ex_u16 file_count; // 数据文件总数
|
||||
// ex_u32 file_size; // 所有数据文件的总大小(不包括每个数据文件的头,即4字节的每文件大小)
|
||||
// char account[16]; // teleport账号
|
||||
// char username[16]; // 远程主机用户名
|
||||
// char ip[18];
|
||||
// ex_u16 port;
|
||||
//
|
||||
// ex_u8 reserve[128 - 4 - 8 - 4 - 4 - 2 - 2 - 2 - 4 - 16 - 16 - 18 - 2]; // 保留
|
||||
// }TS_RECORD_HEADER;
|
||||
//
|
||||
// // 一个数据包的头
|
||||
// typedef struct TS_RECORD_PKG
|
||||
// {
|
||||
// ex_u8 type; // 包的数据类型
|
||||
// ex_u32 size; // 这个包的总大小(不含包头)
|
||||
// ex_u32 time_ms; // 这个包距起始时间的时间差(毫秒,意味着一个连接不能持续超过49天)
|
||||
// ex_u8 reserve[3]; // 保留
|
||||
// }TS_RECORD_PKG;
|
||||
|
||||
// 记录窗口大小改变的数据包
|
||||
typedef struct TS_RECORD_WIN_SIZE
|
||||
{
|
||||
|
@ -62,11 +34,13 @@ protected:
|
|||
bool _on_begin(const TPP_CONNECT_INFO* info);
|
||||
bool _on_end();
|
||||
|
||||
bool _save_to_info_file();
|
||||
bool _save_to_data_file();
|
||||
bool _save_to_cmd_file();
|
||||
|
||||
protected:
|
||||
TS_RECORD_HEADER m_head;
|
||||
bool m_header_changed;
|
||||
|
||||
MemBuffer m_cmd_cache;
|
||||
|
||||
|
|
|
@ -297,13 +297,9 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
|
|||
if (_this->m_auth_type != TP_AUTH_TYPE_NONE)
|
||||
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_USER, _this->m_acc_name.c_str());
|
||||
|
||||
//#ifdef EX_DEBUG
|
||||
// // int _timeout_us = 500000000; // 5 sec.
|
||||
// // ssh_options_set(_this->m_srv_session, SSH_OPTIONS_TIMEOUT_USEC, &_timeout_us);
|
||||
//#else
|
||||
// int _timeout_us = 10000000; // 10 sec.
|
||||
// ssh_options_set(_this->m_srv_session, SSH_OPTIONS_TIMEOUT_USEC, &_timeout_us);
|
||||
//#endif
|
||||
// default timeout is 10 seconds.
|
||||
int _timeout = 30; // 30 sec.
|
||||
ssh_options_set(_this->m_srv_session, SSH_OPTIONS_TIMEOUT, &_timeout);
|
||||
|
||||
int rc = 0;
|
||||
rc = ssh_connect(_this->m_srv_session);
|
||||
|
@ -321,6 +317,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
|
|||
}
|
||||
|
||||
// // 检查服务端支持的认证协议
|
||||
ssh_userauth_none(_this->m_srv_session, NULL);
|
||||
// rc = ssh_userauth_none(_this->m_srv_session, NULL);
|
||||
// if (rc == SSH_AUTH_ERROR) {
|
||||
// EXLOGE("[ssh] invalid password for password mode to login to real SSH server %s:%d.\n", _this->m_server_ip.c_str(), _this->m_server_port);
|
||||
|
@ -344,6 +341,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
|
|||
retry_count += 1;
|
||||
if (retry_count >= 5)
|
||||
break;
|
||||
ex_sleep_ms(500);
|
||||
rc = ssh_userauth_kbdint(_this->m_srv_session, NULL, NULL);
|
||||
continue;
|
||||
}
|
||||
|
@ -394,7 +392,7 @@ int SshSession::_on_auth_password_request(ssh_session session, const char *user,
|
|||
EXLOGD("[ssh] failed to login with password mode, got %d.\n", rc);
|
||||
}
|
||||
|
||||
EXLOGE("[ssh] can not use password mode or interactive mode ot login to real SSH server %s:%d.\n", _this->m_conn_ip.c_str(), _this->m_conn_port);
|
||||
EXLOGE("[ssh] can not use password mode or interactive mode to login to real SSH server %s:%d.\n", _this->m_conn_ip.c_str(), _this->m_conn_port);
|
||||
_this->m_have_error = true;
|
||||
_this->m_retcode = TP_SESS_STAT_ERR_AUTH_DENIED;
|
||||
return SSH_AUTH_ERROR;
|
||||
|
|
Loading…
Reference in New Issue