1. 调整win平台助手安装包的输出文件名;2. 修正win平台助手在客户端软件路径中含有中文时出错的问题。

pull/105/head
Apex Liu 2017-11-26 19:40:17 +08:00
parent 4d5007e413
commit 03aade65d9
8 changed files with 35 additions and 489 deletions

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<content url="file://$MODULE_DIR$/builder">
<sourceFolder url="file://$MODULE_DIR$/builder" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="py34" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">

View File

@ -48,7 +48,7 @@ class BuilderWin(BuilderBase):
def build_installer(self):
cc.i('build assist installer...')
name = 'teleport-assist-{}'.format(VER_TP_ASSIST)
name = 'teleport-assist-{}-{}'.format(ctx.dist, VER_TP_ASSIST)
out_path = os.path.join(env.root_path, 'out', 'installer')
utils.makedirs(out_path)

View File

@ -49,7 +49,7 @@ bool TsCfg::_load(const ex_astr& str_json) {
}
ex_astr sel_name;
int i = 0;
size_t i = 0;
ex_astr tmp;
//===================================
@ -91,25 +91,10 @@ bool TsCfg::_load(const ex_astr& str_json) {
if (m_root["ssh"]["available"][i]["name"].asCString() != sel_name)
continue;
// if (m_root["ssh"]["available"][i]["disp"].isString()) {
// ssh_display = m_root["ssh"]["available"][i]["display"].asCString();
// }
// else if (m_root["ssh"]["available"][i]["disp"].isNull()) {
// m_root["ssh"]["available"][i]["disp"] = ssh_name;
// ssh_display = ssh_name;
// }
// else {
// EXLOGE("invalid config, error 5.\n");
// return false;
// }
tmp = m_root["ssh"]["available"][i]["app"].asCString();
ex_astr2wstr(tmp, ssh_app);
ex_astr2wstr(tmp, ssh_app, EX_CODEPAGE_UTF8);
tmp = m_root["ssh"]["available"][i]["cmdline"].asCString();
ex_astr2wstr(tmp, ssh_cmdline);
// ssh_app = m_root["ssh"]["available"][i]["app"].asCString();
// ssh_cmdline = m_root["ssh"]["available"][i]["cmdline"].asCString();
ex_astr2wstr(tmp, ssh_cmdline, EX_CODEPAGE_UTF8);
break;
}
@ -159,9 +144,9 @@ bool TsCfg::_load(const ex_astr& str_json) {
continue;
tmp = m_root["scp"]["available"][i]["app"].asCString();
ex_astr2wstr(tmp, scp_app);
ex_astr2wstr(tmp, scp_app, EX_CODEPAGE_UTF8);
tmp = m_root["scp"]["available"][i]["cmdline"].asCString();
ex_astr2wstr(tmp, scp_cmdline);
ex_astr2wstr(tmp, scp_cmdline, EX_CODEPAGE_UTF8);
break;
}
@ -211,9 +196,9 @@ bool TsCfg::_load(const ex_astr& str_json) {
continue;
tmp = m_root["telnet"]["available"][i]["app"].asCString();
ex_astr2wstr(tmp, telnet_app);
ex_astr2wstr(tmp, telnet_app, EX_CODEPAGE_UTF8);
tmp = m_root["telnet"]["available"][i]["cmdline"].asCString();
ex_astr2wstr(tmp, telnet_cmdline);
ex_astr2wstr(tmp, telnet_cmdline, EX_CODEPAGE_UTF8);
break;
}
@ -225,246 +210,3 @@ bool TsCfg::_load(const ex_astr& str_json) {
return true;
}
#if 0
TsCfgSSH g_cfgSSH;
TsCfgScp g_cfgScp;
TsCfgTelnet g_cfgTelnet;
void split_by_char(ex_wstr s, char ch, std::vector<ex_wstr>& ret)
{
int pos;
while (s.length() != 0)
{
pos = s.find_first_of(ch, 0);
if (-1 == pos)
{
ret.push_back(s);
s = s.erase(0, s.length());
}
else if (0 == pos)
{
s = s.erase(0, pos + 1);
}
else
{
ex_wstr temp;
temp.append(s, 0, pos);
ret.push_back(temp);
s = s.erase(0, pos + 1);
}
}
}
//=====================================================================
// Base Configuration Class
//=====================================================================
TsClientCfgBase::TsClientCfgBase()
{
m_clientsetmap.clear();
m_client_list.clear();
}
TsClientCfgBase::~TsClientCfgBase()
{}
bool TsClientCfgBase::_init(void)
{
client_set temp;
ExIniSection* cfg = NULL;
cfg = m_ini.GetSection(_T("common"));
if (NULL == cfg)
{
EXLOGE("[ERROR] Invalid configuration, [common] section not found.\n");
return false;
}
ex_wstr _wstr;
if (!cfg->GetStr(_T("current_client"), _wstr)) {
return false;
}
m_current_client = _wstr;
if (!cfg->GetStr(_T("client_list"), _wstr)) {
return false;
}
std::vector<ex_wstr> c_list;
split_by_char(_wstr, ',', c_list);
std::vector<ex_wstr>::iterator it;
for (it = c_list.begin(); it != c_list.end(); it++)
{
ex_wstr sec_name = it->c_str();
cfg = m_ini.GetSection(sec_name);
if (NULL == cfg)
{
EXLOGE("[ERROR] Invalid configuration, [common] section not found.\n");
return false;
}
if (!cfg->GetStr(_T("name"), _wstr)) {
continue;
}
temp.name = _wstr;
if (!cfg->GetStr(_T("path"), _wstr)) {
continue;
}
temp.path = _wstr;
if (!cfg->GetStr(_T("alias_name"), _wstr)) {
continue;
}
temp.alias_name = _wstr;
if (!cfg->GetStr(_T("command_line"), _wstr)) {
continue;
}
temp.commandline = _wstr;
if (!cfg->GetStr(_T("desc"), _wstr)) {
continue;
}
temp.desc = _wstr;
temp.is_default = false;
m_clientsetmap[temp.name] = temp;
m_client_list.push_back(temp.name);
}
return true;
}
void TsClientCfgBase::set(ex_wstr sec_name, ex_wstr key, ex_wstr value)
{
if (sec_name != _T("common"))
{
clientsetmap::iterator it = m_clientsetmap.find(sec_name);
if (it == m_clientsetmap.end())
return;
}
ExIniSection* cfg = NULL;
cfg = m_ini.GetSection(sec_name);
if (NULL == cfg)
{
EXLOGE("[ERROR] Invalid configuration, [common] section not found.\n");
return;
}
cfg->SetValue(key, value);
return;
}
void TsClientCfgBase::save()
{
m_ini.Save(EX_CODEPAGE_UTF8);
}
//=====================================================
TsCfgSSH::TsCfgSSH()
{}
TsCfgSSH::~TsCfgSSH()
{}
bool TsCfgSSH::init(void)
{
m_current_client = _T("putty");
client_set temp;
temp.name = _T("putty");
temp.alias_name = _T("PuTTY (内置)");
temp.path = g_env.m_tools_path;
temp.path += _T("\\putty\\putty.exe");
temp.commandline = _T("-ssh -pw **** -P {host_port} -l {user_name} {host_ip}");
temp.desc = _T("PuTTY为开放源代码软件主要由Simon Tatham维护使用MIT licence授权。");
temp.is_default = true;
m_clientsetmap[temp.name] = temp;
m_client_list.push_back(temp.name);
if (!m_ini.LoadFromFile(g_env.m_ssh_client_conf_file))
{
EXLOGE("can not load ssh config file.\n");
return false;
}
return _init();
}
//=====================================================
TsCfgScp::TsCfgScp()
{}
TsCfgScp::~TsCfgScp()
{}
bool TsCfgScp::init(void)
{
m_current_client = _T("winscp");
client_set temp;
temp.name = _T("winscp");
temp.alias_name = _T("WinSCP (内置)");
temp.path = g_env.m_tools_path;
temp.path += _T("\\winscp\\winscp.exe");
temp.commandline = _T("/sessionname=\"TP#{real_ip}\" {user_name}:****@{host_ip}:{host_port}");
temp.desc = _T("WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端。同时支持SCP协议。它的主要功能就是在本地与远程计算机间安全的复制文件。");
temp.is_default = true;
m_clientsetmap[temp.name] = temp;
m_client_list.push_back(temp.name);
if (!m_ini.LoadFromFile(g_env.m_scp_client_conf_file))
{
EXLOGE("can not load scp config file.\n");
return false;
}
return _init();
}
//=====================================================
TsCfgTelnet::TsCfgTelnet()
{}
TsCfgTelnet::~TsCfgTelnet()
{}
bool TsCfgTelnet::init(void)
{
m_current_client = _T("putty");
client_set temp;
temp.name = _T("putty");
temp.alias_name = _T("PuTTY (内置)");
temp.path = g_env.m_tools_path;
temp.path += _T("\\putty\\putty.exe");
//temp.commandline = _T("-telnet -P {host_port} -l {user_name} {host_ip}");
temp.commandline = _T("telnet://{user_name}@{host_ip}:{host_port}");
temp.desc = _T("PuTTY为开放源代码软件主要由Simon Tatham维护使用MIT licence授权。");
temp.is_default = true;
m_clientsetmap[temp.name] = temp;
m_client_list.push_back(temp.name);
if (!m_ini.LoadFromFile(g_env.m_telnet_client_conf_file))
{
EXLOGE("can not load telnet config file.\n");
return false;
}
return _init();
}
#endif

View File

@ -4,23 +4,18 @@
#include <ex.h>
#include <vector>
#include <json/json.h>
class TsCfg
{
public:
TsCfg();
virtual ~TsCfg();
bool init(void);
bool save(const ex_astr& new_value);
Json::Value& get_root() { return m_root; }
// ex_astr ssh_name;
// ex_astr ssh_display;
// ex_astr ssh_app;
// ex_astr ssh_cmdline;
#include <json/json.h>
class TsCfg
{
public:
TsCfg();
virtual ~TsCfg();
bool init(void);
bool save(const ex_astr& new_value);
Json::Value& get_root() { return m_root; }
ex_wstr ssh_app;
ex_wstr ssh_cmdline;
@ -28,79 +23,14 @@ public:
ex_wstr scp_cmdline;
ex_wstr telnet_app;
ex_wstr telnet_cmdline;
protected:
bool _load(const ex_astr& str_json);
protected:
Json::Value m_root;
};
extern TsCfg g_cfg;
//#include <map>
//
// typedef std::vector<ex_wstr> client_list;
// struct client_set
// {
// ex_wstr name;
// ex_wstr alias_name;
// ex_wstr path;
// ex_wstr commandline;
// ex_wstr desc;
// bool is_default;
// };
//
// typedef std::map<ex_wstr, client_set> clientsetmap;
//
// class TsClientCfgBase
// {
// public:
// TsClientCfgBase();
// virtual ~TsClientCfgBase();
//
// virtual bool init(void) = 0;
// void set(ex_wstr sec_name, ex_wstr key, ex_wstr value);
// void save();
// client_list m_client_list;
// clientsetmap m_clientsetmap;
// ex_wstr m_current_client;
//
// protected:
// bool _init(void);
//
// protected:
// ExIniFile m_ini;
// };
//
// class TsCfgSSH : public TsClientCfgBase
// {
// public:
// TsCfgSSH();
// ~TsCfgSSH();
//
// bool init(void);
// };
// extern TsCfgSSH g_cfgSSH;
//
// class TsCfgScp : public TsClientCfgBase
// {
// public:
// TsCfgScp();
// ~TsCfgScp();
//
// bool init(void);
// };
// extern TsCfgScp g_cfgScp;
//
// class TsCfgTelnet : public TsClientCfgBase
// {
// public:
// TsCfgTelnet();
// ~TsCfgTelnet();
//
// bool init(void);
// };
// extern TsCfgTelnet g_cfgTelnet;
protected:
bool _load(const ex_astr& str_json);
protected:
Json::Value m_root;
};
extern TsCfg g_cfg;
#endif // __TS_CFG_H__

View File

@ -31,34 +31,12 @@ bool TsEnv::init(void)
m_cfg_file = m_exec_path;
ex_path_join(m_cfg_file, false, L"cfg", L"tp-assist.json", NULL);
// m_ssh_client_conf_file = m_exec_path;
// ex_path_join(m_ssh_client_conf_file, false, L"cfg", L"ssh.ini", NULL);
//
// m_scp_client_conf_file = m_exec_path;
// ex_path_join(m_scp_client_conf_file, false, L"cfg", L"scp.ini", NULL);
//
// m_telnet_client_conf_file = m_exec_path;
// ex_path_join(m_telnet_client_conf_file, false, L"cfg", L"telnet.ini", NULL);
m_log_path = m_exec_path;
ex_path_join(m_log_path, false, L"log", NULL);
ex_wstr cfg_default;
#ifdef _DEBUG
// m_ssh_client_conf_file = m_exec_path;
// ex_path_join(m_ssh_client_conf_file, false, L"ssh.ini", NULL);
//
// m_scp_client_conf_file = m_exec_path;
// ex_path_join(m_scp_client_conf_file, false, L"scp.ini", NULL);
//
// m_telnet_client_conf_file = m_exec_path;
// ex_path_join(m_telnet_client_conf_file, false, L"telnet.ini", NULL);
//
// m_log_path = m_exec_path;
// ex_path_join(m_log_path, false, L"log", NULL);
m_site_path = m_exec_path;
ex_path_join(m_site_path, true, L"..", L"..", L"..", L"..", L"client", L"tp_assist_win", L"site", NULL);
@ -69,21 +47,6 @@ bool TsEnv::init(void)
ex_path_join(cfg_default, true, L"..", L"..", L"..", L"..", L"client", L"tp_assist_win", L"cfg", L"tp-assist.default.json", NULL);
#else
// TCHAR szBuf[PATH_MAX] = { 0 };
// SHGetSpecialFolderPathW(NULL, szBuf, CSIDL_APPDATA, FALSE);
//
// m_ssh_client_conf_file = szBuf;// m_exec_path;
// ex_path_join(m_ssh_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"ssh.ini", NULL);
//
// m_scp_client_conf_file = szBuf;// m_exec_path;
// ex_path_join(m_scp_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"scp.ini", NULL);
//
// m_telnet_client_conf_file = szBuf;// m_exec_path;
// ex_path_join(m_telnet_client_conf_file, false, L"eomsoft", L"teleport", L"assist", L"cfg", L"telnet.ini", NULL);
//
// m_log_path = szBuf;// m_exec_path;
// ex_path_join(m_log_path, false, L"eomsoft", L"teleport", L"assist", L"log", NULL);
m_site_path = m_exec_path;
ex_path_join(m_site_path, false, L"site", NULL);

View File

@ -354,9 +354,6 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat
FILE* file = ex_fopen(index_path.c_str(), "rb");
//
// FILE* file = NULL;
// file = fopen(index_path.c_str(), "rb");
if (file)
{
unsigned long file_size = 0;
@ -574,12 +571,6 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
return;
}
// int pro_sub = 0;
// if (!jsRoot["protocol_sub_type"].isNull()) {
// if (jsRoot["protocol_sub_type"].isNumeric()) {
// pro_sub = jsRoot["protocol_sub_type"].asInt();
// }
// }
int pro_sub = jsRoot["protocol_sub_type"].asInt();
ex_astr teleport_ip = jsRoot["teleport_ip"].asCString();
@ -844,41 +835,12 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
w_exe_path = _T("\"");
w_exe_path += g_cfg.ssh_app + _T("\" ");
w_exe_path += g_cfg.ssh_cmdline;
// clientsetmap::iterator it = g_cfgSSH.m_clientsetmap.find(g_cfgSSH.m_current_client);
// if (it == g_cfgSSH.m_clientsetmap.end())
// {
// w_exe_path = _T("\"");
// w_exe_path += g_env.m_tools_path;
// w_exe_path += _T("\\putty\\putty.exe\"");
// w_exe_path += _T(" -ssh -pw **** -P {host_port} -l {user_name} {host_ip}");
// }
// else
// {
// w_exe_path = _T("\"");
// w_exe_path += it->second.path + _T("\" ");
// w_exe_path += it->second.commandline;
// }
}
else
{
w_exe_path = _T("\"");
w_exe_path += g_cfg.scp_app + _T("\" ");
w_exe_path += g_cfg.scp_cmdline;
// clientsetmap::iterator it = g_cfgScp.m_clientsetmap.find(g_cfgScp.m_current_client);
// if (it == g_cfgScp.m_clientsetmap.end())
// {
// w_exe_path = _T("\"");
// w_exe_path += g_env.m_tools_path;
// w_exe_path += _T("\\winscp\\winscp.exe\"");
// w_exe_path += _T(" /sessionname=\"TP#{real_ip}\" {user_name}:****@{host_ip}:{host_port}");
// }
// else {
// w_exe_path = it->second.path + _T(" ");
// w_exe_path += it->second.commandline;
// }
}
}
else if (pro_type == TP_PROTOCOL_TYPE_TELNET)
@ -889,21 +851,6 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
w_exe_path = _T("\"");
w_exe_path += g_cfg.telnet_app + _T("\" ");
w_exe_path += g_cfg.telnet_cmdline;
// clientsetmap::iterator it = g_cfgTelnet.m_clientsetmap.find(g_cfgTelnet.m_current_client);
// if (it == g_cfgTelnet.m_clientsetmap.end())
// {
// w_exe_path = _T("\"");
// w_exe_path += g_env.m_tools_path;
// w_exe_path += _T("\\putty\\putty.exe\"");
// w_exe_path += _T(" telnet://{user_name}@{host_ip}:{host_port}");
// }
// else
// {
// w_exe_path = _T("\"");
// w_exe_path += it->second.path + _T("\" ");
// w_exe_path += it->second.commandline;
// }
}
ex_replace_all(w_exe_path, _T("{host_port}"), w_port);
@ -1026,26 +973,18 @@ void TsHttpRpc::_rpc_func_check(const ex_astr& func_args, ex_astr& buf)
{
//printf("gethostbyname error for host:%s/n", ptr);
_create_json_ret(buf, TPE_PARAM);
return; /* 如果调用gethostbyname发生错误返回1 */
return;
}
/* 将主机的规范名打出来 */
//printf("official hostname:%s/n", hptr->h_name);
// 主机可能有多个别名,将所有别名分别打出来
//for (pptr = hptr->h_aliases; *pptr != NULL; pptr++)
// printf(" alias:%s/n", *pptr);
/* 根据地址类型,将地址打出来 */
char szbuf[1204] = { 0 };
switch (hptr->h_addrtype)
{
case AF_INET:
case AF_INET6:
pptr = hptr->h_addr_list;
/* 将刚才得到的所有地址都打出来。其中调用了inet_ntop()函数 */
for (; *pptr != NULL; pptr++)
inet_ntop(hptr->h_addrtype, *pptr, IP, sizeof(IP));
server_ip = IP;
//printf(" address:%s/n", inet_ntop(hptr->h_addrtype, *pptr, str, sizeof(str)));
break;
default:
printf("unknown address type/n");
@ -1128,7 +1067,7 @@ void TsHttpRpc::_rpc_func_rdp_play(const ex_astr& func_args, ex_astr& buf)
}
/* 将主机的规范名打出来 */
//printf("official hostname:%s/n", hptr->h_name);
///* 主机可能有多个别名,将所有别名分别打出来 */
/* 主机可能有多个别名,将所有别名分别打出来 */
//for (pptr = hptr->h_aliases; *pptr != NULL; pptr++)
// printf(" alias:%s/n", *pptr);
/* 根据地址类型,将地址打出来 */
@ -1165,7 +1104,6 @@ void TsHttpRpc::_rpc_func_rdp_play(const ex_astr& func_args, ex_astr& buf)
ex_wstr w_exe_path;
w_exe_path = _T("\"");
w_exe_path += g_env.m_tools_path + _T("\\tprdp\\tprdp-replay.exe\"");
//swprintf_s(w_szCommandLine, _T(" -ssh -pw **** -P %d -l %s %s"), teleport_port, w_s_id.c_str(), w_teleport_ip.c_str());
w_exe_path += _T(" ");
w_exe_path += w_url;

View File

@ -12,27 +12,6 @@
#include "../../external/mongoose/mongoose.h"
// typedef ex_u32 ts_rv;
// #define TSR_OK 0x0000
// #define TSR_INVALID_DATA 0x0001
// #define TSR_SEND_ERROR 0x0002
// #define TSR_NEED_MORE_DATA 0x0005
// #define TSR_FAILED 0x0006
// #define TSR_PING_OK 0x0007
// #define TSR_PING_ERROR 0x0008
//
// #define TSR_INVALID_REQUEST 0x1000
// #define TSR_INVALID_URI 0x1001
// #define TSR_INVALID_URL_ENCODE 0x1002
// #define TSR_NO_SUCH_METHOD 0x1003
// #define TSR_INVALID_JSON_FORMAT 0x1004
// #define TSR_INVALID_JSON_PARAM 0x1005
// #define TSR_CREATE_PROCESS_ERROR 0x1006
// #define TSR_OPENFILE_ERROR 0x1007
// #define TSR_GETTEMPPATH_ERROR 0x1007
/*
//=================================================================
使
@ -65,14 +44,6 @@ void http_rpc_stop(void);
typedef std::map<ex_astr, ex_astr> content_type_map;
// struct sid_info
// {
// ex_astr host_ip;
// ex_astr s_id;
// bool update;
// };
// typedef std::map<DWORD, sid_info> PidSidMap;
class TsHttpRpc
{
public:

Binary file not shown.