From 57f4518d6944e86e328f490233c3189a6f65cefd Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Fri, 23 Mar 2018 13:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E6=96=B9=E5=BC=8F=E8=AE=BF=E9=97=AETP?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=EF=BC=8C=E4=B9=9F=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E6=92=AD=E6=94=BERDP=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/tp_assist_win/ts_http_rpc.cpp | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/client/tp_assist_win/ts_http_rpc.cpp b/client/tp_assist_win/ts_http_rpc.cpp index a761691..b330ba5 100644 --- a/client/tp_assist_win/ts_http_rpc.cpp +++ b/client/tp_assist_win/ts_http_rpc.cpp @@ -899,6 +899,58 @@ void TsHttpRpc::_rpc_func_rdp_play(const ex_astr& func_args, ex_astr& buf) char cmd_args[1024] = { 0 }; ex_strformat(cmd_args, 1023, "%d \"%s\" \"%09d-%s-%s-%s-%s\"", rid, a_sid.c_str(), rid, a_user.c_str(), a_acc.c_str(), a_host.c_str(), a_start.c_str()); + { + unsigned int port_i = 0; + struct mg_str scheme, query, fragment, user_info, host, path; + + if (mg_parse_uri(mg_mk_str(a_url_base.c_str()), &scheme, &user_info, &host, &port_i, &path, &query, &fragment) != 0) { + EXLOGE(_T("parse url failed.\n")); + Json::Value root_ret; + root_ret["code"] = TPE_PARAM; + _create_json_ret(buf, root_ret); + return; + } + + ex_astr _scheme; + _scheme.assign(scheme.p, scheme.len); + + // 将host从域名转换为IP + ex_astr str_tp_host; + str_tp_host.assign(host.p, host.len); + struct hostent *tp_host = gethostbyname(str_tp_host.c_str()); + if (NULL == tp_host) { + EXLOGE(_T("resolve host name failed.\n")); + Json::Value root_ret; + root_ret["code"] = TPE_PARAM; + _create_json_ret(buf, root_ret); + return; + } + + int i = 0; + char* _ip = NULL; + if (tp_host->h_addrtype == AF_INET) + { + struct in_addr addr; + while (tp_host->h_addr_list[i] != 0) { + addr.s_addr = *(u_long *)tp_host->h_addr_list[i++]; + _ip = inet_ntoa(addr); + break; + } + } + + if (NULL == _ip) { + EXLOGE(_T("resolve host name failed.\n")); + Json::Value root_ret; + root_ret["code"] = TPE_PARAM; + _create_json_ret(buf, root_ret); + return; + } + + char _url_base[256]; + ex_strformat(_url_base, 255, "%s://%s:%d", _scheme.c_str(), _ip, port_i); + a_url_base = _url_base; + } + ex_wstr w_url_base; ex_astr2wstr(a_url_base, w_url_base); ex_wstr w_cmd_args;