mirror of https://github.com/tp4a/teleport
pull/130/head
parent
2fa413d46b
commit
8672b46bd2
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<span class="title"><i class="fa fa-cog fa-fw"></i> Teleport助手本地配置</span>
|
<span class="title"><i class="fa fa-cog fa-fw"></i> Teleport助手本地配置</span>
|
||||||
|
<span class="sub-title" id="version"></span>
|
||||||
<span class="sub-title">此处配置保存到本地计算机上,如果更换计算机,需要重新配置!</span>
|
<span class="sub-title">此处配置保存到本地计算机上,如果更换计算机,需要重新配置!</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="header-fix"></div>
|
<div class="header-fix"></div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
|
@ -35,10 +35,19 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<div class="arg-detail arg-detail-common">
|
||||||
|
<p><strong>此处配置保存到本地计算机上,如果更换计算机,需要重新配置!</strong></p>
|
||||||
|
<span><strong>注意:</strong>命令行参数设置中,可以用以下变量替换(注意大小写!):</span>
|
||||||
|
<ul>
|
||||||
|
<li><span class="arg-varb">{host_ip}</span> 替换主机IP地址</li>
|
||||||
|
<li><span class="arg-varb">{host_port}</span> 替换主机端口号</li>
|
||||||
|
<li><span class="arg-varb">{user_name}</span> 替换用户名</li>
|
||||||
|
<li><span class="arg-varb">{real_ip}</span> 替换为远程主机真实IP(仅用于显示,例如客户端的窗口标题或标签页标题等)</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<p class="cfg-title">本地终端配置(用于SSH)</p>
|
<p class="cfg-title">本地 SSH 客户端配置</p>
|
||||||
|
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<div class="form-group form-group-sm">
|
<div class="form-group form-group-sm">
|
||||||
<label for="term-type" class="col-sm-1 control-label"><strong>终端:</strong></label>
|
<label for="term-type" class="col-sm-1 control-label"><strong>终端:</strong></label>
|
||||||
|
@ -55,6 +64,66 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<p class="cfg-title">本地 SFTP 客户端配置</p>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-horizontal">
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label for="scp-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<select id="scp-type" class="form-control"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label for="scp-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="scp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
|
||||||
|
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="scp-select-app">选择...</button></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label for="scp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="scp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<p class="cfg-title">本地 TELNET 客户端配置</p>
|
||||||
|
|
||||||
|
<div class="form-horizontal">
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label for="telnet-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<select id="telnet-type" class="form-control"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label for="telnet-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="telnet-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
|
||||||
|
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="telnet-select-app">选择...</button></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label for="telnet-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input id="telnet-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<p class="cfg-title">本地RDP配置</p>
|
<p class="cfg-title">本地RDP配置</p>
|
||||||
|
|
|
@ -77,7 +77,6 @@ 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());
|
int ret = cpp_main((__bridge void*)self, cpp_cfg_file.c_str(), cpp_res_path.c_str());
|
||||||
if(ret != 0) {
|
if(ret != 0) {
|
||||||
// TODO: show error message and exit.
|
|
||||||
NSString *msg = Nil;
|
NSString *msg = Nil;
|
||||||
if(ret == -1)
|
if(ret == -1)
|
||||||
msg = @"初始化运行环境失败!";
|
msg = @"初始化运行环境失败!";
|
||||||
|
@ -85,6 +84,8 @@ int AppDelegate_start_ssh_client (void *_self, const char* cmd_line, const char*
|
||||||
msg = @"加载配置文件失败!";
|
msg = @"加载配置文件失败!";
|
||||||
else if(ret == -3)
|
else if(ret == -3)
|
||||||
msg = @"启动本地通讯端口失败!请检查本地50022端口是否被占用!";
|
msg = @"启动本地通讯端口失败!请检查本地50022端口是否被占用!";
|
||||||
|
else
|
||||||
|
msg = @"发生未知错误!";
|
||||||
|
|
||||||
NSAlert *alert = [NSAlert alertWithMessageText:@"无法启动Teleport助手"
|
NSAlert *alert = [NSAlert alertWithMessageText:@"无法启动Teleport助手"
|
||||||
defaultButton:@"确定"
|
defaultButton:@"确定"
|
||||||
|
|
|
@ -46,6 +46,220 @@ bool TsCfg::_load(const ex_astr& str_json) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ex_astr sel_name;
|
||||||
|
size_t i = 0;
|
||||||
|
ex_astr tmp;
|
||||||
|
|
||||||
|
//===================================
|
||||||
|
// check ssh config
|
||||||
|
//===================================
|
||||||
|
|
||||||
|
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);
|
||||||
|
tmp = m_root["scp"]["available"][i]["cmdline"].asCString();
|
||||||
|
ex_astr2wstr(tmp, scp_cmdline, EX_CODEPAGE_UTF8);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rdp_app.length() == 0 || rdp_cmdline.length() == 0 || rdp_name.length() == 0) {
|
||||||
|
EXLOGE("invalid config, error 6.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// ------------ term ---------------------
|
// ------------ term ---------------------
|
||||||
|
|
||||||
if (!m_root["term"].isObject()) {
|
if (!m_root["term"].isObject()) {
|
||||||
|
@ -154,6 +368,7 @@ bool TsCfg::_load(const ex_astr& str_json) {
|
||||||
EXLOGE("invalid config, error 6.\n");
|
EXLOGE("invalid config, error 6.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,25 @@ public:
|
||||||
|
|
||||||
Json::Value& get_root() {return m_root;}
|
Json::Value& get_root() {return m_root;}
|
||||||
|
|
||||||
ex_astr term_name;
|
// ex_astr term_name;
|
||||||
ex_astr term_display;
|
// ex_astr term_display;
|
||||||
ex_astr term_app;
|
// ex_astr term_app;
|
||||||
ex_astr term_profile;
|
// ex_astr term_profile;
|
||||||
|
|
||||||
|
ex_astr ssh_app;
|
||||||
|
ex_astr ssh_cmdline;
|
||||||
|
ex_astr scp_app;
|
||||||
|
ex_astr scp_cmdline;
|
||||||
|
ex_astr telnet_app;
|
||||||
|
ex_astr telnet_cmdline;
|
||||||
ex_astr rdp_name;
|
ex_astr rdp_name;
|
||||||
ex_astr rdp_display;
|
|
||||||
ex_astr rdp_app;
|
ex_astr rdp_app;
|
||||||
|
ex_astr rdp_cmdline;
|
||||||
|
|
||||||
|
|
||||||
|
// ex_astr rdp_name;
|
||||||
|
// ex_astr rdp_display;
|
||||||
|
// ex_astr rdp_app;
|
||||||
//ex_astr rdp_cmdline;
|
//ex_astr rdp_cmdline;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -105,7 +105,7 @@ bool TsCfg::_load(const ex_astr& str_json) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//===================================
|
//===================================
|
||||||
// check scp config
|
// check sftp config
|
||||||
//===================================
|
//===================================
|
||||||
|
|
||||||
if (!m_root["scp"].isObject()) {
|
if (!m_root["scp"].isObject()) {
|
||||||
|
|
|
@ -182,9 +182,9 @@ EX_BOOL ex_copy_file(const wchar_t* from_file, const wchar_t* to_file) {
|
||||||
return EX_FALSE;
|
return EX_FALSE;
|
||||||
}
|
}
|
||||||
else if (S_ISREG(src_stat.st_mode)) {
|
else if (S_ISREG(src_stat.st_mode)) {
|
||||||
int src, dst;
|
int src = -1, dst = -1;
|
||||||
int rsize;
|
int rsize = 0;
|
||||||
char buf[1024];
|
char buf[1024] = {0};
|
||||||
if ((src = open(source.c_str(), O_RDONLY)) == -1) {
|
if ((src = open(source.c_str(), O_RDONLY)) == -1) {
|
||||||
close(dst);
|
close(dst);
|
||||||
return EX_FALSE;
|
return EX_FALSE;
|
||||||
|
|
Loading…
Reference in New Issue