macOS版助手可以配合FreeRDP 2.0.0-rc4版本使用了(与TP3.2.2服务端配合使用,测试连接Win10通过)。

pull/236/head
Apex Liu 2020-02-06 23:19:06 +08:00
parent b4014b5af6
commit da209cbea7
7 changed files with 92 additions and 56 deletions

View File

@ -152,6 +152,9 @@ class BuilderMacOS(BuilderBase):
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')) utils.ensure_file_exists(os.path.join(out_file, 'Contents', 'Info.plist'))
def build_player(self):
cc.o('skip build tp_player now...')
def build_installer(self): def build_installer(self):
cc.i('make tp_assist dmg file...') cc.i('make tp_assist dmg file...')

View File

@ -102,7 +102,7 @@
"name": "FreeRDP", "name": "FreeRDP",
"display": "FreeRDP", "display": "FreeRDP",
"app": "", "app": "",
"cmdline": "", "cmdline": "/u:{user_name} /v:{host_ip} /port:{host_port}",
"desc": [ "desc": [
"建议使用homebrew安装freerdp安装后freerdp默认路径在/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp", "建议使用homebrew安装freerdp安装后freerdp默认路径在/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp",
"首次安装freerdp后需要重新启动计算机" "首次安装freerdp后需要重新启动计算机"

View File

@ -631,7 +631,10 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "src/TP-Assist-Prefix.pch"; GCC_PREFIX_HEADER = "src/TP-Assist-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = MG_ENABLE_SSL; GCC_PREPROCESSOR_DEFINITIONS = (
MG_ENABLE_SSL,
"MG_SSL_IF=MG_SSL_IF_MBEDTLS",
);
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
../../common/teleport, ../../common/teleport,
../../common/libex/include, ../../common/libex/include,

View File

@ -41,8 +41,11 @@ bool TsCfg::save(const ex_astr& new_value)
if(!_load(new_value)) if(!_load(new_value))
return false; return false;
Json::StyledWriter jwriter; Json::StreamWriterBuilder jwb;
ex_astr val = jwriter.write(m_root); std::unique_ptr<Json::StreamWriter> jwriter(jwb.newStreamWriter());
ex_aoss os;
jwriter->write(m_root, &os);
ex_astr val = os.str();
if(!ex_write_text_file(g_env.m_cfg_file, val)) { if(!ex_write_text_file(g_env.m_cfg_file, val)) {
EXLOGE("can not save config file.\n"); EXLOGE("can not save config file.\n");
@ -123,10 +126,19 @@ bool TsCfg::_parse_app(const Json::Value& m_root, const ex_astr& str_app, APP_CO
bool TsCfg::_load(const ex_astr& str_json) { bool TsCfg::_load(const ex_astr& str_json) {
Json::Reader jreader; // Json::Reader jreader;
//
// if (!jreader.parse(str_json.c_str(), m_root)) {
// EXLOGE("can not parse new config data, not in json format?\n");
// return false;
// }
Json::CharReaderBuilder jcrb;
std::unique_ptr<Json::CharReader> const jreader(jcrb.newCharReader());
const char *str_json_begin = str_json.c_str();
if (!jreader.parse(str_json.c_str(), m_root)) { ex_astr err;
EXLOGE("can not parse new config data, not in json format?\n"); if (!jreader->parse(str_json_begin, str_json_begin + str_json.length(), &m_root, &err)) {
EXLOGE("can not parse new config data, not in json format? %s\n", err.c_str());
return false; return false;
} }

View File

@ -264,7 +264,7 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat
_this->_process_js_request(method, json_param, ret_buf); _this->_process_js_request(method, json_param, ret_buf);
} }
mg_printf(nc, "HTTP/1.0 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Length: %ld\r\nContent-Type: application/json\r\n\r\n%s", ret_buf.size() - 1, &ret_buf[0]); mg_printf(nc, "HTTP/1.0 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Length: %ld\r\nContent-Type: application/json\r\n\r\n%s", ret_buf.length(), ret_buf.c_str());
nc->flags |= MG_F_SEND_AND_CLOSE; nc->flags |= MG_F_SEND_AND_CLOSE;
return; return;
} }
@ -308,7 +308,7 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat
ex_wstr page = L"<html lang=\"zh_CN\"><html><head><title>404 Not Found</title></head><body bgcolor=\"white\"><center><h1>404 Not Found</h1></center><hr><center><p>Teleport Assistor configuration page not found.</p></center></body></html>"; ex_wstr page = L"<html lang=\"zh_CN\"><html><head><title>404 Not Found</title></head><body bgcolor=\"white\"><center><h1>404 Not Found</h1></center><hr><center><p>Teleport Assistor configuration page not found.</p></center></body></html>";
ex_wstr2astr(page, ret_buf, EX_CODEPAGE_UTF8); ex_wstr2astr(page, ret_buf, EX_CODEPAGE_UTF8);
mg_printf(nc, "HTTP/1.0 404 File Not Found\r\nAccess-Control-Allow-Origin: *\r\nContent-Length: %ld\r\nContent-Type: text/html\r\n\r\n%s", ret_buf.size() - 1, &ret_buf[0]); mg_printf(nc, "HTTP/1.0 404 File Not Found\r\nAccess-Control-Allow-Origin: *\r\nContent-Length: %ld\r\nContent-Type: text/html\r\n\r\n%s", ret_buf.length(), ret_buf.c_str());
nc->flags |= MG_F_SEND_AND_CLOSE; nc->flags |= MG_F_SEND_AND_CLOSE;
return; return;
} }
@ -449,32 +449,38 @@ void TsHttpRpc::_create_json_ret(ex_astr& buf, int errcode)
{ {
// return {"code":123} // return {"code":123}
Json::FastWriter jr_writer;
Json::Value jr_root; Json::Value jr_root;
jr_root["code"] = errcode; jr_root["code"] = errcode;
buf = jr_writer.write(jr_root); Json::StreamWriterBuilder jwb;
std::unique_ptr<Json::StreamWriter> jwriter(jwb.newStreamWriter());
ex_aoss os;
jwriter->write(jr_root, &os);
buf = os.str();
} }
void TsHttpRpc::_create_json_ret(ex_astr& buf, Json::Value& jr_root) void TsHttpRpc::_create_json_ret(ex_astr& buf, Json::Value& jr_root)
{ {
Json::FastWriter jr_writer; Json::StreamWriterBuilder jwb;
buf = jr_writer.write(jr_root); std::unique_ptr<Json::StreamWriter> jwriter(jwb.newStreamWriter());
ex_aoss os;
jwriter->write(jr_root, &os);
buf = os.str();
} }
void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf) {
{
// param: {"ip":"192.168.5.11","port":22,"uname":"root","uauth":"abcdefg","authmode":1,"protocol":2} // param: {"ip":"192.168.5.11","port":22,"uname":"root","uauth":"abcdefg","authmode":1,"protocol":2}
// authmode: 1=password, 2=private-key // authmode: 1=password, 2=private-key
// protocol: 1=rdp, 2=ssh // protocol: 1=rdp, 2=ssh
// SSH return {"code":0, "data":{"sid":"0123abcde"}} // SSH return {"code":0, "data":{"sid":"0123abcde"}}
// RDP return {"code":0, "data":{"sid":"0123abcde0A"}} // RDP return {"code":0, "data":{"sid":"0123abcde0A"}}
Json::Reader jreader; Json::CharReaderBuilder jcrb;
Json::Value jsRoot; std::unique_ptr<Json::CharReader> const jreader(jcrb.newCharReader());
const char *str_json_begin = func_args.c_str();
if (!jreader.parse(func_args.c_str(), jsRoot)) Json::Value jsRoot;
{ ex_astr err;
if (!jreader->parse(str_json_begin, str_json_begin + func_args.length(), &jsRoot, &err)) {
_create_json_ret(buf, TPE_JSON_FORMAT); _create_json_ret(buf, TPE_JSON_FORMAT);
return; return;
} }
@ -513,8 +519,7 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
ex_astrs s_argv; ex_astrs s_argv;
if (pro_type == TP_PROTOCOL_TYPE_RDP) if (pro_type == TP_PROTOCOL_TYPE_RDP) {
{
//============================================== //==============================================
// RDP // RDP
//============================================== //==============================================
@ -588,16 +593,27 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
//w_exe_path = _T("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 = "/usr/local/Cellar/freerdp/1.0.2_1/bin/xfreerdp";
s_exec = g_cfg.rdp.application; s_exec = g_cfg.rdp.application;
s_argv.push_back(s_exec.c_str()); s_arg = g_cfg.rdp.cmdline;
sid = "02" + real_sid;
s_argv.push_back("/f");
ex_astr _tmp_pass = "/p:";
_tmp_pass += szPwd;
s_argv.push_back(_tmp_pass);
#if 0
//s_argv.push_back(s_exec.c_str());
{ {
ex_astr username = "02" + real_sid; ex_astr username = "02" + real_sid;
s_argv.push_back("-u"); // s_argv.push_back("/u:");
s_argv.push_back(username.c_str()); // s_argv.push_back(username.c_str());
if (rdp_w == 0 || rdp_h == 0) { if (rdp_w == 0 || rdp_h == 0) {
s_argv.push_back("-f"); s_argv.push_back("/f");
} }
else { else {
char sz_size[64] = {0}; char sz_size[64] = {0};
@ -625,10 +641,9 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
s_argv.push_back(sz_temp); s_argv.push_back(sz_temp);
} }
} }
#endif
} }
else if (pro_type == TP_PROTOCOL_TYPE_SSH) else if (pro_type == TP_PROTOCOL_TYPE_SSH) {
{
//============================================== //==============================================
// SSH // SSH
//============================================== //==============================================
@ -676,11 +691,9 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
s_argv.push_back(s_exec.c_str()); s_argv.push_back(s_exec.c_str());
s_arg = g_cfg.sftp.cmdline; s_arg = g_cfg.sftp.cmdline;
} }
} }
else if (pro_type == TP_PROTOCOL_TYPE_TELNET) else if (pro_type == TP_PROTOCOL_TYPE_TELNET) {
{
//============================================== //==============================================
// TELNET // TELNET
//============================================== //==============================================
@ -811,27 +824,32 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
_create_json_ret(buf, root_ret); _create_json_ret(buf, root_ret);
} }
void TsHttpRpc::_rpc_func_rdp_play(const ex_astr& func_args, ex_astr& buf) {
void TsHttpRpc::_rpc_func_rdp_play(const ex_astr& func_args, ex_astr& buf)
{
_create_json_ret(buf, TPE_NOT_IMPLEMENT); _create_json_ret(buf, TPE_NOT_IMPLEMENT);
} }
void TsHttpRpc::_rpc_func_get_config(const ex_astr& func_args, ex_astr& buf) void TsHttpRpc::_rpc_func_get_config(const ex_astr& func_args, ex_astr& buf) {
{
Json::Value jr_root; Json::Value jr_root;
jr_root["code"] = 0; jr_root["code"] = 0;
jr_root["data"] = g_cfg.get_root(); jr_root["data"] = g_cfg.get_root();
_create_json_ret(buf, jr_root); _create_json_ret(buf, jr_root);
} }
void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf) void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf) {
{ // Json::Reader jreader;
Json::Reader jreader; // Json::Value jsRoot;
// if (!jreader.parse(func_args.c_str(), jsRoot))
// {
// _create_json_ret(buf, TPE_JSON_FORMAT);
// return;
// }
Json::CharReaderBuilder jcrb;
std::unique_ptr<Json::CharReader> const jreader(jcrb.newCharReader());
const char *str_json_begin = func_args.c_str();
Json::Value jsRoot; Json::Value jsRoot;
if (!jreader.parse(func_args.c_str(), jsRoot)) ex_astr err;
{ if (!jreader->parse(str_json_begin, str_json_begin + func_args.length(), &jsRoot, &err)) {
_create_json_ret(buf, TPE_JSON_FORMAT); _create_json_ret(buf, TPE_JSON_FORMAT);
return; return;
} }
@ -883,8 +901,7 @@ void TsHttpRpc::_rpc_func_file_action(const ex_astr& func_args, ex_astr& buf) {
#endif #endif
} }
void TsHttpRpc::_rpc_func_get_version(const ex_astr& func_args, ex_astr& buf) void TsHttpRpc::_rpc_func_get_version(const ex_astr& func_args, ex_astr& buf) {
{
Json::Value root_ret; Json::Value root_ret;
ex_wstr w_version = TP_ASSIST_VER; ex_wstr w_version = TP_ASSIST_VER;
ex_astr version; ex_astr version;

View File

@ -1,6 +1,7 @@
"use strict"; "use strict";
var g_url_base = 'http://localhost:50022'; //var g_url_base = 'http://localhost:50022';
var g_url_base = 'http://127.0.0.1:50022';
var g_cfg = null; var g_cfg = null;

Binary file not shown.