diff --git a/client/tp_assist/tp_assist.vs2015.vcxproj b/client/tp_assist/tp_assist.vs2015.vcxproj
index 6d36e81..a7293a5 100644
--- a/client/tp_assist/tp_assist.vs2015.vcxproj
+++ b/client/tp_assist/tp_assist.vs2015.vcxproj
@@ -61,7 +61,7 @@
Disabled
WIN32;_DEBUG;_WINDOWS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)
true
- ..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32
+ ..\..\common\teleport;..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32
Windows
@@ -78,7 +78,7 @@
true
WIN32;NDEBUG;_WINDOWS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)
true
- ..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32
+ ..\..\common\teleport;..\..\common\libex\include;..\..\external\jsoncpp\include;..\..\external\openssl\inc32
MultiThreaded
@@ -100,6 +100,7 @@
+
diff --git a/client/tp_assist/tp_assist.vs2015.vcxproj.filters b/client/tp_assist/tp_assist.vs2015.vcxproj.filters
index 44d3832..c020865 100644
--- a/client/tp_assist/tp_assist.vs2015.vcxproj.filters
+++ b/client/tp_assist/tp_assist.vs2015.vcxproj.filters
@@ -126,6 +126,9 @@
libex\header
+
+ teleport
+
@@ -160,6 +163,9 @@
{d7d49fa4-5192-42c5-bc70-5584d9d646c6}
+
+ {1291a5cf-cb08-4ad6-8a86-8a0486297c63}
+
diff --git a/client/tp_assist/ts_http_rpc.cpp b/client/tp_assist/ts_http_rpc.cpp
index cad0cce..f7622dc 100644
--- a/client/tp_assist/ts_http_rpc.cpp
+++ b/client/tp_assist/ts_http_rpc.cpp
@@ -4,6 +4,9 @@
#include
#include
+
+#include
+
#include "ts_http_rpc.h"
#include "dlg_main.h"
#include "ts_ver.h"
@@ -335,7 +338,7 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat
ex_astr method;
ex_astr json_param;
- unsigned int rv = _this->_parse_request(hm, method, json_param);
+ int rv = _this->_parse_request(hm, method, json_param);
if (0 != rv)
{
EXLOGE("[ERROR] http-rpc got invalid request.\n");
@@ -355,10 +358,10 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat
}
}
-unsigned int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args)
+int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args)
{
if (NULL == req)
- return TSR_INVALID_REQUEST;
+ return TPE_FAILED;
bool is_get = true;
if (req->method.len == 3 && 0 == memcmp(req->method.p, "GET", req->method.len))
@@ -366,7 +369,7 @@ unsigned int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_c
else if (req->method.len == 4 && 0 == memcmp(req->method.p, "POST", req->method.len))
is_get = false;
else
- return TSR_INVALID_REQUEST;
+ return TPE_HTTP_METHOD;
ex_astrs strs;
@@ -394,7 +397,7 @@ unsigned int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_c
}
if (0 == strs.size())
- return TSR_INVALID_REQUEST;
+ return TPE_PARAM;
if (is_get)
{
@@ -409,7 +412,7 @@ unsigned int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_c
}
else
{
- return TSR_INVALID_REQUEST;
+ return TPE_PARAM;
}
}
else
@@ -420,7 +423,7 @@ unsigned int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_c
}
else
{
- return TSR_INVALID_REQUEST;
+ return TPE_PARAM;
}
if (req->body.len > 0)
@@ -437,14 +440,14 @@ unsigned int TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_c
sztmp.resize(len);
memset(&sztmp[0], 0, len);
if (-1 == ts_url_decode(func_args.c_str(), func_args.length(), &sztmp[0], len, 0))
- return TSR_INVALID_URL_ENCODE;
+ return TPE_HTTP_URL_ENCODE;
func_args = &sztmp[0];
}
EXLOGV("[rpc] method=%s, json_param=%s\n", func_cmd.c_str(), func_args.c_str());
- return TSR_OK;
+ return TPE_OK;
}
void TsHttpRpc::_process_js_request(const ex_astr& func_cmd, const ex_astr& func_args, ex_astr& buf)
@@ -480,7 +483,7 @@ void TsHttpRpc::_process_js_request(const ex_astr& func_cmd, const ex_astr& func
else
{
EXLOGE("[rpc] got unknown command: %s\n", func_cmd.c_str());
- _create_json_ret(buf, TSR_NO_SUCH_METHOD);
+ _create_json_ret(buf, TPE_UNKNOWN_CMD);
}
}
@@ -514,12 +517,12 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
if (!jreader.parse(func_args.c_str(), jsRoot))
{
- _create_json_ret(buf, TSR_INVALID_JSON_FORMAT);
+ _create_json_ret(buf, TPE_JSON_FORMAT);
return;
}
if (jsRoot.isArray())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
@@ -529,7 +532,7 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
|| !jsRoot["session_id"].isString() || !jsRoot["pro_type"].isNumeric()
)
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
@@ -862,12 +865,12 @@ void TsHttpRpc::_rpc_func_create_ts_client(const ex_astr& func_args, ex_astr& bu
if (!CreateProcess(NULL, (wchar_t *)w_exe_path.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
EXLOGE(_T("CreateProcess() failed. Error=0x%08X.\n %s\n"), GetLastError(), w_exe_path.c_str());
- root_ret["code"] = TSR_CREATE_PROCESS_ERROR;
+ root_ret["code"] = TPE_START_CLIENT;
_create_json_ret(buf, root_ret);
return;
}
- root_ret["code"] = TSR_OK;
+ root_ret["code"] = TPE_OK;
_create_json_ret(buf, root_ret);
}
@@ -919,12 +922,12 @@ void TsHttpRpc::_rpc_func_ts_check(const ex_astr& func_args, ex_astr& buf)
if (!jreader.parse(func_args.c_str(), jsRoot))
{
- _create_json_ret(buf, TSR_INVALID_JSON_FORMAT);
+ _create_json_ret(buf, TPE_JSON_FORMAT);
return;
}
if (jsRoot.isArray())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
int windows_size = 2;
@@ -936,7 +939,7 @@ void TsHttpRpc::_rpc_func_ts_check(const ex_astr& func_args, ex_astr& buf)
|| !jsRoot["rdp_port"].isNumeric()
)
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
@@ -959,7 +962,7 @@ void TsHttpRpc::_rpc_func_ts_check(const ex_astr& func_args, ex_astr& buf)
if ((hptr = gethostbyname(ptr)) == NULL)
{
//printf("gethostbyname error for host:%s/n", ptr);
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return; /* 如果调用gethostbyname发生错误,返回1 */
}
/* 将主机的规范名打出来 */
@@ -988,24 +991,24 @@ void TsHttpRpc::_rpc_func_ts_check(const ex_astr& func_args, ex_astr& buf)
}
if (!isIPAddress(server_ip.c_str()))
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
if (TestTCPPort(server_ip, rdp_port) && TestTCPPort(server_ip, ssh_port))
{
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
ICMPheaderRet temp = { 0 };
int b_ok = ICMPSendTo(&temp, (char*)server_ip.c_str(), 16, 8);
if (b_ok == 0)
{
- _create_json_ret(buf, TSR_PING_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
else
{
- _create_json_ret(buf, TSR_PING_ERROR);
+ _create_json_ret(buf, TPE_NETWORK);
}
return;
@@ -1018,24 +1021,24 @@ void TsHttpRpc::_rpc_func_ts_rdp_play(const ex_astr& func_args, ex_astr& buf)
if (!jreader.parse(func_args.c_str(), jsRoot))
{
- _create_json_ret(buf, TSR_INVALID_JSON_FORMAT);
+ _create_json_ret(buf, TPE_JSON_FORMAT);
return;
}
// 判断参数是否正确
if (!jsRoot["host"].isString())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
if (!jsRoot["port"].isInt())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
if (!jsRoot["tail"].isString())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
ex_astr a_host = jsRoot["host"].asCString();
@@ -1057,7 +1060,7 @@ void TsHttpRpc::_rpc_func_ts_rdp_play(const ex_astr& func_args, ex_astr& buf)
if ((hptr = gethostbyname(ptr)) == NULL)
{
//printf("gethostbyname error for host:%s/n", ptr);
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
/* 将主机的规范名打出来 */
@@ -1120,12 +1123,12 @@ void TsHttpRpc::_rpc_func_ts_rdp_play(const ex_astr& func_args, ex_astr& buf)
if (!CreateProcess(NULL, (wchar_t *)w_exe_path.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
EXLOGE(_T("CreateProcess() failed. Error=0x%08X.\n %s\n"), GetLastError(), w_exe_path.c_str());
- root_ret["code"] = TSR_CREATE_PROCESS_ERROR;
+ root_ret["code"] = TPE_START_CLIENT;
_create_json_ret(buf, root_ret);
return;
}
- root_ret["code"] = TSR_OK;
+ root_ret["code"] = TPE_OK;
_create_json_ret(buf, root_ret);
return;
}
@@ -1137,13 +1140,13 @@ void TsHttpRpc::_rpc_func_get_config(const ex_astr& func_args, ex_astr& buf)
if (!jreader.parse(func_args.c_str(), jsRoot))
{
- _create_json_ret(buf, TSR_INVALID_JSON_FORMAT);
+ _create_json_ret(buf, TPE_JSON_FORMAT);
return;
}
// 判断参数是否正确
if (!jsRoot["type"].isNumeric())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
int type = jsRoot["type"].asUInt();
@@ -1278,7 +1281,7 @@ void TsHttpRpc::_rpc_func_get_config(const ex_astr& func_args, ex_astr& buf)
}
else
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
}
@@ -1290,12 +1293,12 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
if (!jreader.parse(func_args.c_str(), jsRoot))
{
- _create_json_ret(buf, TSR_INVALID_JSON_FORMAT);
+ _create_json_ret(buf, TPE_JSON_FORMAT);
return;
}
if (jsRoot.isArray())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
@@ -1304,7 +1307,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
!jsRoot["commandline"].isString() ||
!jsRoot["type"].isNumeric())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
int type = jsRoot["type"].asUInt();
@@ -1325,7 +1328,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
clientsetmap::iterator it = g_cfgSSH.m_clientsetmap.find(w_name);
if (it == g_cfgSSH.m_clientsetmap.end()) {
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
if (it->second.is_default)
@@ -1333,7 +1336,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
g_cfgSSH.set(_T("common"), _T("current_client"), w_name);
g_cfgSSH.save();
g_cfgSSH.init();
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
g_cfgSSH.set(w_name, _T("path"), w_path);
@@ -1342,7 +1345,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
g_cfgSSH.save();
g_cfgSSH.init();
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
@@ -1350,7 +1353,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
{
clientsetmap::iterator it = g_cfgScp.m_clientsetmap.find(w_name);
if (it == g_cfgScp.m_clientsetmap.end()) {
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
if (it->second.is_default)
@@ -1358,7 +1361,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
g_cfgScp.set(_T("common"), _T("current_client"), w_name);
g_cfgScp.save();
g_cfgScp.init();
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
g_cfgScp.set(w_name, _T("path"), w_path);
@@ -1367,14 +1370,14 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
g_cfgScp.save();
g_cfgScp.init();
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
else if (type == 3)
{
clientsetmap::iterator it = g_cfgTelnet.m_clientsetmap.find(w_name);
if (it == g_cfgTelnet.m_clientsetmap.end()) {
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
if (it->second.is_default)
@@ -1382,7 +1385,7 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
g_cfgTelnet.set(_T("common"), _T("current_client"), w_name);
g_cfgTelnet.save();
g_cfgTelnet.init();
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
g_cfgTelnet.set(w_name, _T("path"), w_path);
@@ -1391,11 +1394,11 @@ void TsHttpRpc::_rpc_func_set_config(const ex_astr& func_args, ex_astr& buf)
g_cfgTelnet.save();
g_cfgTelnet.init();
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
else {
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
}
@@ -1407,13 +1410,13 @@ void TsHttpRpc::_rpc_func_file_action(const ex_astr& func_args, ex_astr& buf) {
if (!jreader.parse(func_args.c_str(), jsRoot))
{
- _create_json_ret(buf, TSR_INVALID_JSON_FORMAT);
+ _create_json_ret(buf, TPE_JSON_FORMAT);
return;
}
// 判断参数是否正确
if (!jsRoot["action"].isNumeric())
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
int action = jsRoot["action"].asUInt();
@@ -1483,7 +1486,7 @@ void TsHttpRpc::_rpc_func_file_action(const ex_astr& func_args, ex_astr& buf) {
if (wsDefaultPath.length() == 0)
{
- _create_json_ret(buf, TSR_INVALID_JSON_PARAM);
+ _create_json_ret(buf, TPE_PARAM);
return;
}
@@ -1518,13 +1521,13 @@ void TsHttpRpc::_rpc_func_file_action(const ex_astr& func_args, ex_astr& buf) {
}
else
{
- _create_json_ret(buf, TSR_OK);
+ _create_json_ret(buf, TPE_OK);
return;
}
}
else
{
- _create_json_ret(buf, TSR_INVALID_DATA);
+ _create_json_ret(buf, TPE_DATA);
return;
}
}
@@ -1536,7 +1539,7 @@ void TsHttpRpc::_rpc_func_get_version(const ex_astr& func_args, ex_astr& buf)
ex_astr version;
ex_wstr2astr(w_version, version, EX_CODEPAGE_UTF8);
root_ret["version"] = version;
- root_ret["code"] = TSR_OK;
+ root_ret["code"] = TPE_OK;
_create_json_ret(buf, root_ret);
return;
}
diff --git a/client/tp_assist/ts_http_rpc.h b/client/tp_assist/ts_http_rpc.h
index 13eb378..bd4037c 100644
--- a/client/tp_assist/ts_http_rpc.h
+++ b/client/tp_assist/ts_http_rpc.h
@@ -13,25 +13,25 @@
#include "../../external/mongoose/mongoose.h"
-typedef ex_u32 ts_rv;
+// 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
+// #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
/*
//=================================================================
@@ -97,7 +97,7 @@ public:
};
private:
- unsigned int _parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args);
+ int _parse_request(struct http_message* req, ex_astr& func_cmd, ex_astr& func_args);
void _process_js_request(const ex_astr& func_cmd, const ex_astr& func_args, ex_astr& buf);
void _create_json_ret(ex_astr& buf, int errcode);
void _create_json_ret(ex_astr& buf, Json::Value& jr_root);
diff --git a/common/teleport/teleport_const.h b/common/teleport/teleport_const.h
new file mode 100644
index 0000000..852d887
--- /dev/null
+++ b/common/teleport/teleport_const.h
@@ -0,0 +1,56 @@
+#ifndef __TELEPORT_CONST_H__
+#define __TELEPORT_CONST_H__
+
+// 本文件设定teleport各个模块之间通讯时的错误值(JSON数据),包括:
+// - WEB界面与助手
+// - WEB界面与WEB后台
+// - WEB后台与CORE核心服务
+
+// 成功
+#define TPE_OK 0
+
+//-------------------------------------------------------
+// 通用错误值
+//-------------------------------------------------------
+#define TPE_NEED_MORE_DATA 1 // 需要更多数据(不一定是错误)
+
+
+// 100~299是通用错误值
+
+#define TPE_FAILED 100 // 内部错误
+#define TPE_NETWORK 101 // 网络错误
+
+// HTTP请求相关错误
+#define TPE_HTTP_METHOD 120 // 无效的请求方法(不是GET/POST等),或者错误的请求方法(例如需要POST,却使用GET方式请求)
+#define TPE_HTTP_URL_ENCODE 121 // URL编码错误(无法解码)
+//#define TPE_HTTP_URI 122 // 无效的URI
+
+#define TPE_UNKNOWN_CMD 124 // 未知的命令
+#define TPE_JSON_FORMAT 125 // 错误的JSON格式(需要JSON格式数据,但是却无法按JSON格式解码)
+#define TPE_PARAM 126 // 参数错误
+#define TPE_DATA 127 // 数据错误
+
+
+
+
+// #define TPE_OPENFILE_ERROR 0x1007 // 无法打开文件
+// #define TPE_GETTEMPPATH_ERROR 0x1007
+
+
+//-------------------------------------------------------
+// 助手程序专用错误值
+//-------------------------------------------------------
+#define TPE_NO_ASSIST 100000 // 未能检测到助手程序
+#define TPE_OLD_ASSIST 100001 // 助手程序版本太低
+#define TPE_START_CLIENT 100002 // 无法启动客户端程序(无法创建进程)
+
+
+
+//-------------------------------------------------------
+// 核心服务专用错误值
+//-------------------------------------------------------
+#define TPE_NO_CORE_SERVER 200000 // 未能检测到核心服务
+
+
+
+#endif // __TELEPORT_CONST_H__
diff --git a/server/www/teleport/static/js/ui/admin_host.js b/server/www/teleport/static/js/ui/admin_host.js
index ba3441c..46111ac 100644
--- a/server/www/teleport/static/js/ui/admin_host.js
+++ b/server/www/teleport/static/js/ui/admin_host.js
@@ -1,4 +1,3 @@
-/*! ywl v1.0.1, (c)2015 eomsoft.net */
"use strict";
var OS_TYPE_WINDOWS = 1;
@@ -73,10 +72,10 @@ ywl.on_init = function (cb_stack, cb_args) {
$("#tp-assist-current-version").text("褰撳墠鍔╂墜鐗堟湰锛" + ret.version);
},
function (ret, code, error) {
- if (code == TP_ERR_NO_ASSIST) {
+ if (code == TPE_NO_ASSIST) {
$("#tp-assist-current-version").text("鏈兘妫娴嬪埌TP鍔╂墜锛岃鎮ㄤ笅杞藉苟鍚姩TP鍔╂墜锛");
g_assist.alert_assist_not_found();
- } else if (code == TP_ERR_VERSION_TOO_LOW) {
+ } else if (code == TPE_OLD_ASSIST) {
ywl.notify_error(error);
$('#tp-assist-current-version').html('褰撳墠鍔╂墜鐗堟湰澶綆锛坴' + ret.version + '锛夛紝璇涓嬭浇鏈鏂扮増鏈!');
} else {
@@ -445,7 +444,7 @@ ywl.on_host_table_created = function (tbl) {
console.log('杩滅▼杩炴帴寤虹珛鎴愬姛锛')
},
function (code, error) {
- if (code == TP_ERR_NO_ASSIST)
+ if (code == TPE_NO_ASSIST)
g_assist.alert_assist_not_found();
else {
ywl.notify_error(error);
@@ -1104,7 +1103,7 @@ ywl.create_sys_user = function (tbl) {
console.log('杩滅▼杩炴帴寤虹珛鎴愬姛锛')
},
function (code, error) {
- if (code == TP_ERR_NO_ASSIST)
+ if (code == TPE_NO_ASSIST)
g_assist.alert_assist_not_found();
else {
ywl.notify_error(error);
diff --git a/server/www/teleport/static/js/ui/common_host.js b/server/www/teleport/static/js/ui/common_host.js
index 5468309..00480a0 100644
--- a/server/www/teleport/static/js/ui/common_host.js
+++ b/server/www/teleport/static/js/ui/common_host.js
@@ -23,16 +23,16 @@ ywl.on_init = function (cb_stack, cb_args) {
$("#tp-assist-current-version").text("褰撳墠鍔╂墜鐗堟湰锛" + ret.version);
},
function (ret, code, error) {
- if (code == TP_ERR_NO_ASSIST) {
+ if (code == TPE_NO_ASSIST) {
$("#tp-assist-current-version").text("鏈兘妫娴嬪埌TP鍔╂墜锛岃鎮ㄤ笅杞藉苟鍚姩TP鍔╂墜锛")
g_assist.alert_assist_not_found();
}
- else if (code == TP_ERR_VERSION_TOO_LOW) {
+ else if (code == TPE_OLD_ASSIST) {
ywl.notify_error(error);
$('#tp-assist-current-version').html('褰撳墠鍔╂墜鐗堟湰澶綆锛坴' + ret.version + '锛夛紝璇涓嬭浇鏈鏂扮増鏈!');
}
else {
- $("#tp-assist-current-version").text(error)
+ $("#tp-assist-current-version").text(error);
ywl.notify_error(error);
console.log('error:', error)
@@ -146,7 +146,7 @@ ywl.on_host_table_created = function (tbl) {
console.log('杩滅▼杩炴帴寤虹珛鎴愬姛锛')
},
function (code, error) {
- if (code == TP_ERR_NO_ASSIST)
+ if (code == TPE_NO_ASSIST)
g_assist.alert_assist_not_found();
else {
ywl.notify_error(error);
@@ -201,7 +201,7 @@ ywl.on_host_table_created = function (tbl) {
console.log('杩滅▼杩炴帴寤虹珛鎴愬姛锛')
},
function (code, error) {
- if (code == TP_ERR_NO_ASSIST)
+ if (code == TPE_NO_ASSIST)
g_assist.alert_assist_not_found();
else {
ywl.notify_error(error);
diff --git a/server/www/teleport/static/js/ui/log.js b/server/www/teleport/static/js/ui/log.js
index 38c0857..858a59d 100644
--- a/server/www/teleport/static/js/ui/log.js
+++ b/server/www/teleport/static/js/ui/log.js
@@ -185,14 +185,13 @@ ywl.on_host_table_created = function (tbl) {
start_rdp_replay(args,
function () {
ywl.notify_success('RDP 褰曞儚鎾斁鍣ㄦ垚鍔熷惎鍔紒');
- //console.log('RDP 褰曞儚鎾斁鍣ㄦ垚鍔熷惎鍔紒')
},
- function (code, error) {
- if (code == TP_ERR_NO_ASSIST)
+ function (code, msg) {
+ if (code == TPE_NO_ASSIST)
g_assist.alert_assist_not_found();
else {
- ywl.notify_error(error);
- console.log('error:', error)
+ ywl.notify_error(msg);
+ console.log('error:', msg)
}
});
});
diff --git a/server/www/teleport/static/js/ui/teleport.js b/server/www/teleport/static/js/ui/teleport.js
index 7b1866f..cd05681 100644
--- a/server/www/teleport/static/js/ui/teleport.js
+++ b/server/www/teleport/static/js/ui/teleport.js
@@ -1,16 +1,5 @@
-/**
- * Created by mi on 2016/6/28.
- */
"use strict";
-var TP_ERR_NETWORK = 1;
-var TP_ERR_START_CLIENT = 2;
-var TP_ERR_NO_ASSIST = 3;
-//var TP_ERR_ASSIST_DENIED = 4;
-var TP_ERR_CORE_SRV = 5;
-var TP_ERR_TRIAL_LIMITED = 6;
-var TP_ERR_VERSION_TOO_LOW = 7;
-
var g_low_version = "";
var g_last_version = "";
var g_current_version = "";
@@ -18,23 +7,23 @@ var g_current_version = "";
var g_host_name = window.location.hostname;
var error_process = function (ret, func_success, func_error) {
- console.log("ret", ret);
+// console.log("ret", ret);
var code = ret.code;
- if (code == 0) {
+ if (code == TPE_OK) {
func_success(ret);
return;
}
- if (code == 0x1006) {
- func_error(TP_ERR_START_CLIENT, '鍚姩鏈湴瀹㈡埛绔繘绋嬪け璐ワ紝璇锋鏌ュ懡浠よ鏄惁姝g‘锛' + ret.path);
+ if (code == TPE_START_CLIENT) {
+ func_error(TPE_START_CLIENT, '鍚姩鏈湴瀹㈡埛绔繘绋嬪け璐ワ紝璇锋鏌ュ懡浠よ鏄惁姝g‘锛' + ret.path);
console.log('鍚姩鏈湴杩涚▼澶辫触锛屽懡浠よ锛', ret.path);
- } else if (code == 0x1004) {
- func_error(TP_ERR_START_CLIENT, "鍚姩鏈湴瀹㈡埛绔繘绋嬪け璐ワ細鍚姩鍙傛暟閿欒锛");
- } else if (code == TP_ERR_VERSION_TOO_LOW) {
- func_error(TP_ERR_VERSION_TOO_LOW, '鍔╂墜鐗堟湰澶綆锛岃涓嬭浇鏈鏂扮増鏈紒');
+ } else if (code == TPE_JSON_FORMAT || code == TPE_PARAM) {
+ func_error(TPE_START_CLIENT, "鍚姩鏈湴瀹㈡埛绔繘绋嬪け璐ワ細鍚姩鍙傛暟閿欒锛");
+ } else if (code == TPE_OLD_ASSIST) {
+ func_error(TPE_OLD_ASSIST, '鍔╂墜鐗堟湰澶綆锛岃涓嬭浇鏈鏂扮増鏈紒');
}
else {
- func_error(TP_ERR_START_CLIENT, '鍚姩鏈湴瀹㈡埛绔け璐ワ紝閿欒浠g爜锛' + ret.code);
+ func_error(TPE_START_CLIENT, '鍚姩鏈湴瀹㈡埛绔け璐ワ紝閿欒浠g爜锛' + ret.code);
}
};
@@ -56,11 +45,11 @@ var teleport_init = function (low_version, last_version, func_success, func_erro
if (version_compare()) {
error_process(ret, func_success, func_error);
} else {
- func_error(ret, TP_ERR_VERSION_TOO_LOW, '鍔╂墜鐗堟湰澶綆锛岃涓嬭浇鏈鏂扮増鏈锛');
+ func_error(ret, TPE_OLD_ASSIST, '鍔╂墜鐗堟湰澶綆锛岃涓嬭浇鏈鏂扮増鏈锛');
}
},
error: function (jqXhr) {
- func_error({}, TP_ERR_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
+ func_error({}, TPE_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
}
});
};
@@ -109,15 +98,15 @@ var to_teleport = function (url, args, func_success, func_error) {
error_process(ret, func_success, func_error);
},
error: function (jqXhr) {
- func_error(TP_ERR_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
+ func_error(TPE_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
}
});
} else {
- func_error(TP_ERR_CORE_SRV, '杩滅▼杩炴帴璇锋眰澶辫触锛屽彲鑳絫eleport鏍稿績鏈嶅姟灏氭湭鍚姩锛');
+ func_error(TPE_NO_CORE_SERVER, '杩滅▼杩炴帴璇锋眰澶辫触锛屽彲鑳絫eleport鏍稿績鏈嶅姟灏氭湭鍚姩锛');
}
},
error: function () {
- func_error(TP_ERR_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
+ func_error(TPE_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
}
});
};
@@ -158,15 +147,15 @@ var to_admin_teleport = function (url, args, func_success, func_error) {
error_process(ret, func_success, func_error);
},
error: function () {
- func_error(TP_ERR_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
+ func_error(TPE_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
}
});
} else {
- func_error(TP_ERR_CORE_SRV, '杩滅▼杩炴帴璇锋眰澶辫触锛屽彲鑳絫eleport鏍稿績鏈嶅姟灏氭湭鍚姩锛');
+ func_error(TPE_NO_CORE_SERVER, '杩滅▼杩炴帴璇锋眰澶辫触锛屽彲鑳絫eleport鏍稿績鏈嶅姟灏氭湭鍚姩锛');
}
},
error: function () {
- func_error(TP_ERR_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
+ func_error(TPE_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
}
});
};
@@ -210,15 +199,15 @@ var to_admin_fast_teleport = function (url, args, func_success, func_error) {
console.log('e', _e);
console.log('state:', jqXhr.state());
- func_error(TP_ERR_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
+ func_error(TPE_NO_ASSIST, '鏃犳硶杩炴帴鍒皌eleport鍔╂墜锛屽彲鑳藉皻鏈惎鍔紒');
}
});
} else {
- func_error(TP_ERR_CORE_SRV, '杩滅▼杩炴帴璇锋眰澶辫触锛屽彲鑳絫eleport鏍稿績鏈嶅姟灏氭湭鍚姩锛');
+ func_error(TPE_NO_CORE_SERVER, '杩滅▼杩炴帴璇锋眰澶辫触锛屽彲鑳絫eleport鏍稿績鏈嶅姟灏氭湭鍚姩锛');
}
},
error: function () {
- func_error(TP_ERR_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
+ func_error(TPE_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
}
});
};
@@ -233,15 +222,15 @@ var start_rdp_replay = function (args, func_success, func_error) {
jsonp: 'callback',
dataType: 'json',
success: function (ret) {
- if (ret.code === 0) {
+ if (ret.code === TPE_OK) {
error_process(ret, func_success, func_error);
} else {
- func_error(1, '鏌ョ湅褰曞儚澶辫触锛');
+ func_error(ret.code, '鏌ョ湅褰曞儚澶辫触锛');
}
console.log('ret', ret);
},
error: function () {
- func_error(TP_ERR_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
+ func_error(TPE_NETWORK, '杩滅▼缃戠粶閫氳澶辫触锛');
}
});
};
diff --git a/server/www/teleport/static/js/ywl_const.js b/server/www/teleport/static/js/ywl_const.js
index 4c4b86c..aeab26d 100644
--- a/server/www/teleport/static/js/ywl_const.js
+++ b/server/www/teleport/static/js/ywl_const.js
@@ -1,4 +1,3 @@
-/*! ywl v1.0.1, (c)2016 eomsoft.net */
"use strict";
var USER_TYPE_TEAM_MEMBER = 1;
@@ -35,27 +34,73 @@ var SECONDS_PER_MINUTE = 60;
var system_group = [
- {id: 0, name: '鍏ㄩ儴'},
- {id: -1},
- {id: 1, name: 'Windows'},
- {id: -1},
- {id: 2, name: 'Linux'}
+ {id: 0, name: '鍏ㄩ儴'},
+ {id: -1},
+ {id: 1, name: 'Windows'},
+ {id: -1},
+ {id: 2, name: 'Linux'}
];
var paging_normal = {
- use_cookie: true,
- default_select: '25',
- selections: [
- {name: '10', val: 10},
- {name: "25", val: 25},
- {name: "50", val: 50},
- {name: "100", val: 100}]
+ use_cookie: true,
+ default_select: '25',
+ selections: [
+ {name: '10', val: 10},
+ {name: "25", val: 25},
+ {name: "50", val: 50},
+ {name: "100", val: 100}]
};
var paging_big = {
- use_cookie: false,
- default_select: '100',
- selections: [{name: "100", val: 100}]
+ use_cookie: false,
+ default_select: '100',
+ selections: [{name: "100", val: 100}]
};
+//========================================================
+// 閿欒鍊硷紙璇峰弬鑰冩簮浠g爜/common/teleport/teleport_const.h锛
+//========================================================
+var TPE_OK = 0;
+
+//-------------------------------------------------------
+// 閫氱敤閿欒鍊
+//-------------------------------------------------------
+var TPE_NEED_MORE_DATA = 1; // 闇瑕佹洿澶氭暟鎹紙涓嶄竴瀹氭槸閿欒锛
+
+
+// 100~299鏄氱敤閿欒鍊
+
+var TPE_FAILED = 100; // 鍐呴儴閿欒
+var TPE_NETWORK = 101; // 缃戠粶閿欒
+
+// HTTP璇锋眰鐩稿叧閿欒
+var TPE_HTTP_METHOD = 120; // 鏃犳晥鐨勮姹傛柟娉曪紙涓嶆槸GET/POST绛夛級锛屾垨鑰呴敊璇殑璇锋眰鏂规硶锛堜緥濡傞渶瑕丳OST锛屽嵈浣跨敤GET鏂瑰紡璇锋眰锛
+var TPE_HTTP_URL_ENCODE = 121; // URL缂栫爜閿欒锛堟棤娉曡В鐮侊級
+//#define TPE_HTTP_URI 122 // 鏃犳晥鐨刄RI
+
+var TPE_UNKNOWN_CMD = 124; // 鏈煡鐨勫懡浠
+var TPE_JSON_FORMAT = 125; // 閿欒鐨凧SON鏍煎紡锛堥渶瑕丣SON鏍煎紡鏁版嵁锛屼絾鏄嵈鏃犳硶鎸塉SON鏍煎紡瑙g爜锛
+var TPE_PARAM = 126; // 鍙傛暟閿欒
+var TPE_DATA = 127; // 鏁版嵁閿欒
+
+
+// #define TPE_OPENFILE_ERROR 0x1007 // 鏃犳硶鎵撳紑鏂囦欢
+// #define TPE_GETTEMPPATH_ERROR 0x1007
+
+
+//-------------------------------------------------------
+// 鍔╂墜绋嬪簭涓撶敤閿欒鍊
+//-------------------------------------------------------
+var TPE_NO_ASSIST = 100000; // 鏈兘妫娴嬪埌鍔╂墜绋嬪簭
+var TPE_OLD_ASSIST = 100001; // 鍔╂墜绋嬪簭鐗堟湰澶綆
+var TPE_START_CLIENT = 100002; // 鏃犳硶鍚姩瀹㈡埛绔▼搴忥紙鏃犳硶鍒涘缓杩涚▼锛
+
+
+//-------------------------------------------------------
+// 鏍稿績鏈嶅姟涓撶敤閿欒鍊
+//-------------------------------------------------------
+var TPE_NO_CORE_SERVER = 200000; // 鏈兘妫娴嬪埌鏍稿績鏈嶅姟
+
+
+