prepare for v3.
							parent
							
								
									a40af30a15
								
							
						
					
					
						commit
						73d51a2563
					
				|  | @ -1,38 +1,86 @@ | |||
| #ifndef __TELEPORT_CONST_H__ | ||||
| #define __TELEPORT_CONST_H__ | ||||
| 
 | ||||
| // 注意同步更新三个不同语言的const文件
 | ||||
| 
 | ||||
| // 本文件设定teleport各个模块之间通讯时的错误值(JSON数据),包括:
 | ||||
| //  - WEB界面与助手
 | ||||
| //  - WEB界面与WEB后台
 | ||||
| //  - WEB后台与CORE核心服务
 | ||||
| 
 | ||||
| // 成功
 | ||||
| #define TPE_OK			0 | ||||
| //=======================================================
 | ||||
| // 远程连接认证方式
 | ||||
| //=======================================================
 | ||||
| #define TP_AUTH_TYPE_NONE			0 | ||||
| #define TP_AUTH_TYPE_PASSWORD		1 | ||||
| #define TP_AUTH_TYPE_PRIVATE_KEY	2 | ||||
| 
 | ||||
| //=======================================================
 | ||||
| // 远程连接协议
 | ||||
| //=======================================================
 | ||||
| #define TP_PROTOCOL_TYPE_RDP		1 | ||||
| #define TP_PROTOCOL_TYPE_SSH		2 | ||||
| #define TP_PROTOCOL_TYPE_TELNET		3 | ||||
| 
 | ||||
| //=======================================================
 | ||||
| // 远程连接子协议
 | ||||
| //=======================================================
 | ||||
| #define TP_PROTOCOL_SUB_TYPE_RDP		100 | ||||
| #define TP_PROTOCOL_SUB_TYPE_SSH		200 | ||||
| #define TP_PROTOCOL_SUB_TYPE_SFTP		201 | ||||
| #define TP_PROTOCOL_SUB_TYPE_TELNET		300 | ||||
| 
 | ||||
| 
 | ||||
| //=======================================================
 | ||||
| // 远程主机操作系统
 | ||||
| //=======================================================
 | ||||
| #define TP_OS_TYPE_WINDOWS	1 | ||||
| #define TP_OS_TYPE_LINUX	2 | ||||
| 
 | ||||
| //=======================================================
 | ||||
| // 远程连接会话状态
 | ||||
| //=======================================================
 | ||||
| #define TP_SESS_STAT_RUNNING				0		// 会话开始了,尚未结束
 | ||||
| #define TP_SESS_STAT_END					9999	// 会话成功结束
 | ||||
| #define TP_SESS_STAT_ERR_AUTH_DENIED		1		// 会话结束,因为认证失败
 | ||||
| #define TP_SESS_STAT_ERR_CONNECT			2		// 会话结束,因为无法连接到远程主机
 | ||||
| #define TP_SESS_STAT_ERR_BAD_SSH_KEY		3		// 会话结束,因为无法识别SSH私钥
 | ||||
| #define TP_SESS_STAT_ERR_INTERNAL			4		// 会话结束,因为内部错误
 | ||||
| #define TP_SESS_STAT_ERR_UNSUPPORT_PROTOCOL	5		// 会话结束,因为协议不支持(RDP)
 | ||||
| #define TP_SESS_STAT_ERR_BAD_PKG			6		// 会话结束,因为收到错误的报文
 | ||||
| #define TP_SESS_STAT_ERR_RESET				7		// 会话结束,因为teleport核心服务重置了
 | ||||
| #define TP_SESS_STAT_ERR_IO					8		// 会话结束,因为网络中断
 | ||||
| #define TP_SESS_STAT_ERR_SESSION			9		// 会话结束,因为无效的会话ID
 | ||||
| 
 | ||||
| 
 | ||||
| //=======================================================
 | ||||
| // 错误值
 | ||||
| //=======================================================
 | ||||
| #define TPE_OK						0		// 成功
 | ||||
| //-------------------------------------------------------
 | ||||
| // 通用错误值
 | ||||
| //-------------------------------------------------------
 | ||||
| #define TPE_NEED_MORE_DATA			1	// 需要更多数据(不一定是错误)
 | ||||
| #define TPE_NEED_LOGIN				2	// 需要登录
 | ||||
| #define TPE_PRIVILEGE				3	// 没有操作权限
 | ||||
| #define TPE_EXISTS					8	// 目标已经存在
 | ||||
| #define TPE_NOT_EXISTS              9   // 目标不存在
 | ||||
| #define TPE_NEED_MORE_DATA			1		// 需要更多数据(不一定是错误)
 | ||||
| #define TPE_NEED_LOGIN				2		// 需要登录
 | ||||
| #define TPE_PRIVILEGE				3		// 没有操作权限
 | ||||
| #define TPE_EXISTS					8		// 目标已经存在
 | ||||
| #define TPE_NOT_EXISTS              9		// 目标不存在
 | ||||
| 
 | ||||
| // 100~299是通用错误值
 | ||||
| 
 | ||||
| #define TPE_FAILED					100	// 内部错误
 | ||||
| #define TPE_NETWORK					101	// 网络错误
 | ||||
| #define TPE_DATABASE				102 // 数据库操作失败
 | ||||
| #define TPE_FAILED					100		// 内部错误
 | ||||
| #define TPE_NETWORK					101		// 网络错误
 | ||||
| #define TPE_DATABASE				102		// 数据库操作失败
 | ||||
| 
 | ||||
| // 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_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_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
 | ||||
|  |  | |||
|  | @ -3,14 +3,14 @@ | |||
| 
 | ||||
| //#include "ts_types.h"
 | ||||
| 
 | ||||
| #define TS_RDP_PROXY_PORT		3389 | ||||
| #define TS_RDP_PROXY_HOST		"0.0.0.0" | ||||
| 
 | ||||
| #define TS_SSH_PROXY_PORT		22 | ||||
| #define TS_SSH_PROXY_HOST		"0.0.0.0" | ||||
| 
 | ||||
| #define TS_TELNET_PROXY_PORT		23 | ||||
| #define TS_TELNET_PROXY_HOST		"0.0.0.0" | ||||
| // #define TS_RDP_PROXY_PORT		3389
 | ||||
| // #define TS_RDP_PROXY_HOST		"0.0.0.0"
 | ||||
| // 
 | ||||
| // #define TS_SSH_PROXY_PORT		22
 | ||||
| // #define TS_SSH_PROXY_HOST		"0.0.0.0"
 | ||||
| // 
 | ||||
| // #define TS_TELNET_PROXY_PORT		23
 | ||||
| // #define TS_TELNET_PROXY_HOST		"0.0.0.0"
 | ||||
| 
 | ||||
| #define TS_HTTP_RPC_PORT		52080 | ||||
| #define TS_HTTP_RPC_HOST		"127.0.0.1" | ||||
|  | @ -23,48 +23,46 @@ | |||
| #define TS_RDP_PROTOCOL_RDSTLS       4 | ||||
| #define TS_RDP_PROTOCOL_HYBRID_EX    8 | ||||
| 
 | ||||
| #define TS_AUTH_MODE_NONE			0 | ||||
| #define TS_AUTH_MODE_PASSWORD		1 | ||||
| #define TS_AUTH_MODE_PRIVATE_KEY	2 | ||||
| // #define TS_AUTH_MODE_NONE			0
 | ||||
| // #define TS_AUTH_MODE_PASSWORD		1
 | ||||
| // #define TS_AUTH_MODE_PRIVATE_KEY	2
 | ||||
| // 
 | ||||
| // #define TS_PROXY_PROTOCOL_RDP		1
 | ||||
| // #define TS_PROXY_PROTOCOL_SSH		2
 | ||||
| // #define TS_PROXY_PROTOCOL_TELNET	3
 | ||||
| 
 | ||||
| #define TS_PROXY_PROTOCOL_RDP		1 | ||||
| #define TS_PROXY_PROTOCOL_SSH		2 | ||||
| #define TS_PROXY_PROTOCOL_TELNET	3 | ||||
| 
 | ||||
| //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_DATA_LEN_ZERO			0x0007 | ||||
| 
 | ||||
| #define TSR_MAX_CONN_REACHED		0x0010 | ||||
| #define TSR_MAX_HOST_REACHED		0x0011 | ||||
| 
 | ||||
| #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_GETAUTH_INFO_ERROR		0x1006 | ||||
| #define TSR_HOST_LOCK_ERROR			0x1007 | ||||
| #define TSR_ACCOUNT_LOCK_ERROR		0x1008 | ||||
| // #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_DATA_LEN_ZERO			0x0007
 | ||||
| // 
 | ||||
| // #define TSR_MAX_CONN_REACHED		0x0010
 | ||||
| // #define TSR_MAX_HOST_REACHED		0x0011
 | ||||
| // 
 | ||||
| // #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_GETAUTH_INFO_ERROR		0x1006
 | ||||
| // #define TSR_HOST_LOCK_ERROR			0x1007
 | ||||
| // #define TSR_ACCOUNT_LOCK_ERROR		0x1008
 | ||||
| 
 | ||||
| //================================================
 | ||||
| #define SESS_STAT_RUNNING				0		// 会话开始了,尚未结束
 | ||||
| #define SESS_STAT_END					9999	// 会话成功结束
 | ||||
| #define SESS_STAT_ERR_AUTH_DENIED		1		// 会话结束,因为认证失败
 | ||||
| #define SESS_STAT_ERR_CONNECT			2		// 会话结束,因为无法连接到远程主机
 | ||||
| #define SESS_STAT_ERR_BAD_SSH_KEY		3		// 会话结束,因为无法识别SSH私钥
 | ||||
| #define SESS_STAT_ERR_INTERNAL			4		// 会话结束,因为内部错误
 | ||||
| #define SESS_STAT_ERR_UNSUPPORT_PROTOCOL	5	// 会话结束,因为协议不支持(RDP)
 | ||||
| #define SESS_STAT_ERR_BAD_PKG			6		// 会话结束,因为收到错误的报文
 | ||||
| #define SESS_STAT_ERR_RESET				7		// 会话结束,因为teleport核心服务重置了
 | ||||
| #define SESS_STAT_ERR_IO				8		// 会话结束,因为网络中断
 | ||||
| #define SESS_STAT_ERR_SESSION			9		// 会话结束,因为无效的会话ID
 | ||||
| // #define SESS_STAT_RUNNING				0		// 会话开始了,尚未结束
 | ||||
| // #define SESS_STAT_END					9999	// 会话成功结束
 | ||||
| // #define SESS_STAT_ERR_AUTH_DENIED		1		// 会话结束,因为认证失败
 | ||||
| // #define SESS_STAT_ERR_CONNECT			2		// 会话结束,因为无法连接到远程主机
 | ||||
| // #define SESS_STAT_ERR_BAD_SSH_KEY		3		// 会话结束,因为无法识别SSH私钥
 | ||||
| // #define SESS_STAT_ERR_INTERNAL			4		// 会话结束,因为内部错误
 | ||||
| // #define SESS_STAT_ERR_UNSUPPORT_PROTOCOL	5	// 会话结束,因为协议不支持(RDP)
 | ||||
| // #define SESS_STAT_ERR_BAD_PKG			6		// 会话结束,因为收到错误的报文
 | ||||
| // #define SESS_STAT_ERR_RESET				7		// 会话结束,因为teleport核心服务重置了
 | ||||
| // #define SESS_STAT_ERR_IO				8		// 会话结束,因为网络中断
 | ||||
| // #define SESS_STAT_ERR_SESSION			9		// 会话结束,因为无效的会话ID
 | ||||
| 
 | ||||
| 
 | ||||
| #endif // __TS_ERRNO_H__
 | ||||
|  |  | |||
|  | @ -100,7 +100,7 @@ | |||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories> | ||||
|       <AdditionalIncludeDirectories>../../../common/teleport;../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories> | ||||
|       <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|  | @ -137,7 +137,7 @@ | |||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <SDLCheck>true</SDLCheck> | ||||
|       <AdditionalIncludeDirectories>../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories> | ||||
|       <AdditionalIncludeDirectories>../../../common/teleport;../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose</AdditionalIncludeDirectories> | ||||
|       <RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|  | @ -204,6 +204,7 @@ | |||
|     <ClInclude Include="..\..\..\common\libex\include\ex\ex_types.h" /> | ||||
|     <ClInclude Include="..\..\..\common\libex\include\ex\ex_util.h" /> | ||||
|     <ClInclude Include="..\..\..\common\libex\include\ex\ex_winsrv.h" /> | ||||
|     <ClInclude Include="..\..\..\common\teleport\teleport_const.h" /> | ||||
|     <ClInclude Include="..\..\..\external\jsoncpp\include\json\json.h" /> | ||||
|     <ClInclude Include="..\..\..\external\mongoose\mongoose.h" /> | ||||
|     <ClInclude Include="..\common\protocol_interface.h" /> | ||||
|  |  | |||
|  | @ -180,6 +180,9 @@ | |||
|     <ClInclude Include="ts_ver.h"> | ||||
|       <Filter>main app</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\..\..\common\teleport\teleport_const.h"> | ||||
|       <Filter>common</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="tp_core.rc"> | ||||
|  |  | |||
|  | @ -5,6 +5,8 @@ | |||
| #include "ts_crypto.h" | ||||
| #include "ts_web_rpc.h" | ||||
| 
 | ||||
| #include <teleport_const.h> | ||||
| 
 | ||||
| 
 | ||||
| #define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W') | ||||
| int ts_url_decode(const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded) | ||||
|  | @ -135,7 +137,7 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat | |||
| 			Json::Value json_param; | ||||
| 
 | ||||
| 			ex_rv rv = _this->_parse_request(hm, method, json_param); | ||||
| 			if (TSR_OK != rv) | ||||
| 			if (TPE_OK != rv) | ||||
| 			{ | ||||
| 				EXLOGE("[core] rpc got invalid request.\n"); | ||||
| 				_this->_create_json_ret(ret_buf, rv); | ||||
|  | @ -149,7 +151,7 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat | |||
| 		else | ||||
| 		{ | ||||
| 			EXLOGE("[core] rpc got invalid request: not `rpc` uri.\n"); | ||||
| 			_this->_create_json_ret(ret_buf, TSR_INVALID_REQUEST, "not a `rpc` request."); | ||||
| 			_this->_create_json_ret(ret_buf, TPE_PARAM, "not a `rpc` request."); | ||||
| 		} | ||||
| 		 | ||||
| 		mg_printf(nc, "HTTP/1.0 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-Length: %d\r\nContent-Type: application/json\r\n\r\n%s", (int)ret_buf.size() - 1, &ret_buf[0]); | ||||
|  | @ -164,7 +166,7 @@ void TsHttpRpc::_mg_event_handler(struct mg_connection *nc, int ev, void *ev_dat | |||
| ex_rv TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, Json::Value& json_param) | ||||
| { | ||||
| 	if (NULL == req) | ||||
| 		return TSR_INVALID_REQUEST; | ||||
| 		return TPE_PARAM; | ||||
| 
 | ||||
| 	bool is_get = true; | ||||
| 	if (req->method.len == 3 && 0 == memcmp(req->method.p, "GET", req->method.len)) | ||||
|  | @ -172,7 +174,7 @@ ex_rv TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, Jso | |||
| 	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_astr json_str; | ||||
| 	if (is_get) | ||||
|  | @ -181,7 +183,7 @@ ex_rv TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, Jso | |||
| 		json_str.assign(req->body.p, req->body.len); | ||||
| 
 | ||||
| 	if (0 == json_str.length()) | ||||
| 		return TSR_INVALID_REQUEST; | ||||
| 		return TPE_PARAM; | ||||
| 
 | ||||
| 	// 将参数进行 url-decode 解码
 | ||||
| 	int len = json_str.length() * 2; | ||||
|  | @ -189,25 +191,25 @@ ex_rv TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, Jso | |||
| 	sztmp.resize(len); | ||||
| 	memset(&sztmp[0], 0, len); | ||||
| 	if (-1 == ts_url_decode(json_str.c_str(), json_str.length(), &sztmp[0], len, 0)) | ||||
| 		return TSR_INVALID_URL_ENCODE; | ||||
| 		return TPE_HTTP_URL_ENCODE; | ||||
| 
 | ||||
| 	json_str = &sztmp[0]; | ||||
| 
 | ||||
| 	Json::Reader jreader; | ||||
| 
 | ||||
| 	if (!jreader.parse(json_str.c_str(), json_param)) | ||||
| 		return TSR_INVALID_JSON_FORMAT; | ||||
| 		return TPE_JSON_FORMAT; | ||||
| 
 | ||||
| 	if (json_param.isArray()) | ||||
| 		return TSR_INVALID_JSON_PARAM; | ||||
| 		return TPE_PARAM; | ||||
| 
 | ||||
| 	if (json_param["method"].isNull() || !json_param["method"].isString()) | ||||
| 		return TSR_INVALID_JSON_PARAM; | ||||
| 		return TPE_PARAM; | ||||
| 
 | ||||
| 	func_cmd = json_param["method"].asCString(); | ||||
| 	json_param = json_param["param"]; | ||||
| 
 | ||||
| 	return TSR_OK; | ||||
| 	return TPE_OK; | ||||
| } | ||||
| 
 | ||||
| void TsHttpRpc::_create_json_ret(ex_astr& buf, int errcode, const Json::Value& jr_data) | ||||
|  | @ -266,7 +268,7 @@ void TsHttpRpc::_process_request(const ex_astr& func_cmd, const Json::Value& jso | |||
| 	else | ||||
| 	{ | ||||
| 		EXLOGE("[core] 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); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -275,7 +277,7 @@ void TsHttpRpc::_rpc_func_exit(const Json::Value& json_param, ex_astr& buf) | |||
| { | ||||
| 	// 设置一个全局退出标志
 | ||||
| 	g_exit_flag = true; | ||||
| 	_create_json_ret(buf, TSR_OK); | ||||
| 	_create_json_ret(buf, TPE_OK); | ||||
| } | ||||
| 
 | ||||
| void TsHttpRpc::_rpc_func_get_config(const Json::Value& json_param, ex_astr& buf) | ||||
|  | @ -322,7 +324,7 @@ void TsHttpRpc::_rpc_func_get_config(const Json::Value& json_param, ex_astr& buf | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	_create_json_ret(buf, TSR_OK, jr_data); | ||||
| 	_create_json_ret(buf, TPE_OK, jr_data); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -330,7 +332,8 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr | |||
| { | ||||
| 	// https://github.com/eomsoft/teleport/wiki/TELEPORT-CORE-JSON-RPC#request_session
 | ||||
| 
 | ||||
| 	int authid = 0; | ||||
| 	int conn_id = 0; | ||||
| 	ex_rv rv = TPE_OK; | ||||
| 
 | ||||
| 	ex_astr host_ip; | ||||
| 	int host_port = 0; | ||||
|  | @ -347,28 +350,28 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr | |||
| 
 | ||||
| 	// 如果authid为正整数,这是一个长期保留的认证ID,如果是负整数,这是一个临时的认证ID(用于连接测试),如果为0,则报错
 | ||||
| 
 | ||||
| 	if (json_param["authid"].isNull()) | ||||
| 	if (json_param["conn_id"].isNull()) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_INVALID_JSON_PARAM); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (!json_param["authid"].isInt()) | ||||
| 	if (!json_param["conn_id"].isInt()) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_INVALID_JSON_PARAM); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	authid = json_param["authid"].asInt(); | ||||
| 	if (0 == authid) | ||||
| 	conn_id = json_param["conn_id"].asInt(); | ||||
| 	if (0 == conn_id) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_INVALID_JSON_PARAM); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	Json::Value jret; | ||||
| 	if (!ts_web_rpc_get_auth_info(authid, jret)) | ||||
| 	if ((rv = ts_web_rpc_get_conn_info(conn_id, jret)) != TPE_OK) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_GETAUTH_INFO_ERROR); | ||||
| 		_create_json_ret(buf, rv); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -377,25 +380,25 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr | |||
| 	host_ip = _jret["host_ip"].asString(); | ||||
| 	host_port = _jret["host_port"].asInt(); | ||||
| 	//host_lock = 0;
 | ||||
| 	sys_type = _jret["sys_type"].asInt(); | ||||
| 	protocol = _jret["protocol"].asInt(); | ||||
| 	is_enc = _jret["encrypt"].asInt() == 0 ? false : true; | ||||
| 	auth_mode = _jret["auth_mode"].asInt(); | ||||
| 	account_lock = _jret["account_lock"].asInt() == 0 ? true : false; | ||||
| 	sys_type = 1;// _jret["sys_type"].asInt();
 | ||||
| 	protocol = _jret["protocol_type"].asInt(); | ||||
| 	is_enc = _jret["_enc"].asInt() == 0 ? false : true; | ||||
| 	auth_mode = _jret["auth_type"].asInt(); | ||||
| 	//account_lock = _jret["account_lock"].asInt() == 0 ? true : false;
 | ||||
| 	user_name = _jret["user_name"].asString(); | ||||
| 	user_auth = _jret["user_auth"].asString(); | ||||
| 	user_param = _jret["user_param"].asString(); | ||||
| 	user_auth = _jret["secret"].asString(); | ||||
| 	user_param = "";// _jret["user_param"].asString();
 | ||||
| 	account_name = _jret["account_name"].asString(); | ||||
| 
 | ||||
| 
 | ||||
| 	// 进一步判断参数是否合法
 | ||||
| 	if (host_ip.length() == 0 || host_port >= 65535 || account_name.length() == 0  | ||||
| 		|| !(auth_mode == TS_AUTH_MODE_NONE || auth_mode == TS_AUTH_MODE_PASSWORD || auth_mode == TS_AUTH_MODE_PRIVATE_KEY) | ||||
| 		|| !(protocol == TS_PROXY_PROTOCOL_RDP || protocol == TS_PROXY_PROTOCOL_SSH || protocol == TS_PROXY_PROTOCOL_TELNET) | ||||
| 		|| !(auth_mode == TP_AUTH_TYPE_NONE || auth_mode == TP_AUTH_TYPE_PASSWORD || auth_mode == TP_AUTH_TYPE_PRIVATE_KEY) | ||||
| 		|| !(protocol == TP_PROTOCOL_TYPE_RDP || protocol == TP_PROTOCOL_TYPE_SSH || protocol == TP_PROTOCOL_TYPE_TELNET) | ||||
| 		//|| !(is_enc == 0 || is_enc == 1)
 | ||||
| 		) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_INVALID_JSON_PARAM); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -407,7 +410,7 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr | |||
| 			ex_astr _auth; | ||||
| 			if (!ts_db_field_decrypt(user_auth, _auth)) | ||||
| 			{ | ||||
| 				_create_json_ret(buf, TSR_FAILED); | ||||
| 				_create_json_ret(buf, TPE_FAILED); | ||||
| 				return; | ||||
| 			} | ||||
| 
 | ||||
|  | @ -417,10 +420,9 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr | |||
| 
 | ||||
| 	// 生成一个session-id(内部会避免重复)
 | ||||
| 	ex_astr sid; | ||||
| 	ex_rv rv = g_session_mgr.request_session(sid, account_name, authid,  | ||||
| 	if((rv = g_session_mgr.request_session(sid, account_name, conn_id,  | ||||
| 		host_ip, host_port, sys_type, protocol,  | ||||
| 		user_name, user_auth, user_param, auth_mode); | ||||
| 	if (rv != TSR_OK) | ||||
| 		user_name, user_auth, user_param, auth_mode)) != TPE_OK) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, rv); | ||||
| 		return; | ||||
|  | @ -431,7 +433,7 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr | |||
| 	Json::Value jr_data; | ||||
| 	jr_data["sid"] = sid; | ||||
| 
 | ||||
| 	_create_json_ret(buf, TSR_OK, jr_data); | ||||
| 	_create_json_ret(buf, TPE_OK, jr_data); | ||||
| } | ||||
| 
 | ||||
| // void TsHttpRpc::_rpc_func_request_session(const ex_astr& func_args, ex_astr& buf)
 | ||||
|  | @ -615,7 +617,7 @@ void TsHttpRpc::_rpc_func_enc(const Json::Value& json_param, ex_astr& buf) | |||
| 
 | ||||
| 	if (json_param.isArray()) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_INVALID_JSON_PARAM); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -623,27 +625,27 @@ void TsHttpRpc::_rpc_func_enc(const Json::Value& json_param, ex_astr& buf) | |||
| 
 | ||||
| 	if (json_param["p"].isNull() || !json_param["p"].isString()) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_INVALID_JSON_PARAM); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	plain_text = json_param["p"].asCString(); | ||||
| 	if (plain_text.length() == 0) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_DATA_LEN_ZERO); | ||||
| 		_create_json_ret(buf, TPE_PARAM); | ||||
| 		return; | ||||
| 	} | ||||
| 	ex_astr cipher_text; | ||||
| 
 | ||||
| 	if (!ts_db_field_encrypt(plain_text, cipher_text)) | ||||
| 	{ | ||||
| 		_create_json_ret(buf, TSR_FAILED); | ||||
| 		_create_json_ret(buf, TPE_FAILED); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	Json::Value jr_data; | ||||
| 	jr_data["c"] = cipher_text; | ||||
| 	_create_json_ret(buf, TSR_OK, jr_data); | ||||
| 	_create_json_ret(buf, TPE_OK, jr_data); | ||||
| } | ||||
| 
 | ||||
| #if 0 | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| #include "ts_env.h" | ||||
| 
 | ||||
| #include <mbedtls/sha1.h> | ||||
| #include <teleport_const.h> | ||||
| 
 | ||||
| TsSessionManager g_session_mgr; | ||||
| 
 | ||||
|  | @ -89,7 +90,7 @@ ex_rv TsSessionManager::request_session( | |||
| 	info->user_auth = user_auth; | ||||
| 	info->auth_mode = auth_mode; | ||||
| 	info->user_param = user_param; | ||||
| 	if (protocol == TS_PROXY_PROTOCOL_RDP) | ||||
| 	if (protocol == TP_PROTOCOL_TYPE_RDP) | ||||
| 		info->ref_count = 2; | ||||
| 	else | ||||
| 		info->ref_count = 1; | ||||
|  |  | |||
|  | @ -1,177 +1,167 @@ | |||
| #include "ts_web_rpc.h" | ||||
| #include "ts_env.h" | ||||
| #include "ts_http_client.h" | ||||
| 
 | ||||
| #include "../common/ts_const.h" | ||||
| 
 | ||||
| #include <ex/ex_str.h> | ||||
| 
 | ||||
| bool ts_web_rpc_register_core() | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 	jreq["method"] = "register_core"; | ||||
| 	//jreq["param"]["ip"] = g_env.rpc_bind_ip.c_str();
 | ||||
| 	//jreq["param"]["port"] = g_env.rpc_bind_port;
 | ||||
| 	//jreq["param"]["rpc"] = "http://127.0.0.1:52080/rpc";
 | ||||
| 	jreq["param"]["rpc"] = g_env.core_server_rpc; | ||||
| 
 | ||||
| // 	ExIniFile& ini = g_env.get_ini();
 | ||||
| // 	ExIniSection* sec = ini.GetSection(L"common");
 | ||||
| // 	if (NULL == sec)
 | ||||
| // 	{
 | ||||
| // 		return false;
 | ||||
| // 	}
 | ||||
| // 
 | ||||
| // 	ex_wstr rpc;
 | ||||
| // 	if (!sec->GetStr(L"", L""))
 | ||||
| // 		return false;
 | ||||
| 
 | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	//ex_astr url = "http://127.0.0.1:7190/rpc?";
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	return ts_http_get(url, body); | ||||
| } | ||||
| 
 | ||||
| bool ts_web_rpc_get_auth_info(int auth_id, Json::Value& jret) | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 	jreq["method"] = "get_auth_info"; | ||||
| 	jreq["param"]["authid"] = auth_id; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	//ex_astr url = "http://127.0.0.1:7190/rpc?";
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	if (!ts_http_get(url, body)) | ||||
| 	{ | ||||
| // 		EXLOGV("request `get_auth_info` from web return: ");
 | ||||
| // 		EXLOGV(body.c_str());
 | ||||
| // 		EXLOGV("\n");
 | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	Json::Reader jreader; | ||||
| 
 | ||||
| 	if (!jreader.parse(body.c_str(), jret)) | ||||
| 		return false; | ||||
| 	if (!jret.isObject()) | ||||
| 		return false; | ||||
| 	if (!jret["data"].isObject()) | ||||
| 		return false; | ||||
| 
 | ||||
| 	Json::Value& _jret = jret["data"]; | ||||
| 
 | ||||
| 	if ( | ||||
| 		!_jret["host_ip"].isString() | ||||
| 		|| !_jret["host_port"].isInt() | ||||
| 		|| !_jret["sys_type"].isInt() | ||||
| 		|| !_jret["protocol"].isInt() | ||||
| 		|| !_jret["auth_mode"].isInt() | ||||
| 		|| !_jret["account_lock"].isInt() | ||||
| 		|| !_jret["user_name"].isString() | ||||
| 		|| !_jret["user_auth"].isString() | ||||
| 		|| !_jret["user_param"].isString() | ||||
| 		|| !_jret["account_name"].isString() | ||||
| 		) | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| bool ts_web_rpc_session_begin(TS_SESSION_INFO& info, int& record_id) | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 
 | ||||
| 	jreq["method"] = "session_begin"; | ||||
| 	jreq["param"]["sid"] = info.sid.c_str(); | ||||
| 	jreq["param"]["account_name"] = info.account_name.c_str(); | ||||
| 	jreq["param"]["host_ip"] = info.host_ip.c_str(); | ||||
| 	jreq["param"]["sys_type"] = info.sys_type; | ||||
| 	jreq["param"]["host_port"] = info.host_port; | ||||
| 	jreq["param"]["auth_mode"] = info.auth_mode, | ||||
| 	jreq["param"]["user_name"] = info.user_name.c_str(); | ||||
| 	jreq["param"]["protocol"] = info.protocol; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	//ex_astr url = "http://127.0.0.1:7190/rpc?";
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	if (!ts_http_get(url, body)) | ||||
| 	{ | ||||
| 		// 		EXLOGV("request `get_auth_info` from web return: ");
 | ||||
| 		// 		EXLOGV(body.c_str());
 | ||||
| 		// 		EXLOGV("\n");
 | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	Json::Reader jreader; | ||||
| 	Json::Value jret; | ||||
| 
 | ||||
| 	if (!jreader.parse(body.c_str(), jret)) | ||||
| 		return false; | ||||
| 	if (!jret.isObject()) | ||||
| 		return false; | ||||
| 	if (!jret["data"].isObject()) | ||||
| 		return false; | ||||
| 	if (!jret["data"]["rid"].isUInt()) | ||||
| 		return false; | ||||
| 
 | ||||
| 	record_id = jret["data"]["rid"].asUInt(); | ||||
| 
 | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| //session ½áÊø
 | ||||
| bool ts_web_rpc_session_end(int record_id, int ret_code) | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 	jreq["method"] = "session_end"; | ||||
| 	jreq["param"]["rid"] = record_id; | ||||
| 	jreq["param"]["code"] = ret_code; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	//ex_astr url = "http://127.0.0.1:7190/rpc?";
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	return ts_http_get(url, body); | ||||
| } | ||||
| #include "ts_web_rpc.h" | ||||
| #include "ts_env.h" | ||||
| #include "ts_http_client.h" | ||||
| 
 | ||||
| #include "../common/ts_const.h" | ||||
| 
 | ||||
| #include <ex/ex_str.h> | ||||
| #include <teleport_const.h> | ||||
| 
 | ||||
| bool ts_web_rpc_register_core() | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 	jreq["method"] = "register_core"; | ||||
| 	jreq["param"]["rpc"] = g_env.core_server_rpc; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	return ts_http_get(url, body); | ||||
| } | ||||
| 
 | ||||
| int ts_web_rpc_get_conn_info(int conn_id, Json::Value& jret) | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 	jreq["method"] = "get_conn_info"; | ||||
| 	jreq["param"]["conn_id"] = conn_id; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	if (!ts_http_get(url, body)) | ||||
| 	{ | ||||
| // 		EXLOGV("request `get_auth_info` from web return: ");
 | ||||
| // 		EXLOGV(body.c_str());
 | ||||
| // 		EXLOGV("\n");
 | ||||
| 		return TPE_NETWORK; | ||||
| 	} | ||||
| 
 | ||||
| 	Json::Reader jreader; | ||||
| 
 | ||||
| 	if (!jreader.parse(body.c_str(), jret)) | ||||
| 		return TPE_PARAM; | ||||
| 	if (!jret.isObject()) | ||||
| 		return TPE_PARAM; | ||||
| 	if (!jret["data"].isObject()) | ||||
| 		return TPE_PARAM; | ||||
| 
 | ||||
| 	Json::Value& _jret = jret["data"]; | ||||
| 
 | ||||
| 	if ( | ||||
| 		!_jret["host_ip"].isString() | ||||
| 		|| !_jret["host_port"].isInt() | ||||
| //		|| !_jret["sys_type"].isInt()
 | ||||
| 
 | ||||
| 		|| !_jret["protocol_type"].isInt() | ||||
| 		|| !_jret["protocol_sub_type"].isInt() | ||||
| 		|| !_jret["auth_type"].isInt() | ||||
| 		|| !_jret["account_name"].isString() | ||||
| 		|| !_jret["secret"].isString() | ||||
| //		|| !_jret["user_param"].isString()
 | ||||
| //		|| !_jret["conn_param"].isInt()
 | ||||
| 
 | ||||
| 		|| !_jret["user_name"].isString() | ||||
| 		|| !_jret["client_ip"].isString() | ||||
| 
 | ||||
| 		|| !_jret["_enc"].isInt() | ||||
| 		|| !_jret["_test"].isInt() | ||||
| 		) | ||||
| 	{ | ||||
| 		EXLOGE("got connection info from web-server, but not all info valid.\n"); | ||||
| 		return TPE_PARAM; | ||||
| 	} | ||||
| 
 | ||||
| 	return TPE_OK; | ||||
| } | ||||
| 
 | ||||
| bool ts_web_rpc_session_begin(TS_SESSION_INFO& info, int& record_id) | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 
 | ||||
| 	jreq["method"] = "session_begin"; | ||||
| 	jreq["param"]["sid"] = info.sid.c_str(); | ||||
| 	jreq["param"]["account_name"] = info.account_name.c_str(); | ||||
| 	jreq["param"]["host_ip"] = info.host_ip.c_str(); | ||||
| 	jreq["param"]["sys_type"] = info.sys_type; | ||||
| 	jreq["param"]["host_port"] = info.host_port; | ||||
| 	jreq["param"]["auth_mode"] = info.auth_mode, | ||||
| 	jreq["param"]["user_name"] = info.user_name.c_str(); | ||||
| 	jreq["param"]["protocol"] = info.protocol; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	if (!ts_http_get(url, body)) | ||||
| 	{ | ||||
| 		// 		EXLOGV("request `rpc::session_begin` from web return: ");
 | ||||
| 		// 		EXLOGV(body.c_str());
 | ||||
| 		// 		EXLOGV("\n");
 | ||||
| 		return false; | ||||
| 	} | ||||
| 
 | ||||
| 	Json::Reader jreader; | ||||
| 	Json::Value jret; | ||||
| 
 | ||||
| 	if (!jreader.parse(body.c_str(), jret)) | ||||
| 		return false; | ||||
| 	if (!jret.isObject()) | ||||
| 		return false; | ||||
| 	if (!jret["data"].isObject()) | ||||
| 		return false; | ||||
| 	if (!jret["data"]["rid"].isUInt()) | ||||
| 		return false; | ||||
| 
 | ||||
| 	record_id = jret["data"]["rid"].asUInt(); | ||||
| 
 | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| //session ½áÊø
 | ||||
| bool ts_web_rpc_session_end(int record_id, int ret_code) | ||||
| { | ||||
| 	Json::FastWriter json_writer; | ||||
| 	Json::Value jreq; | ||||
| 	jreq["method"] = "session_end"; | ||||
| 	jreq["param"]["rid"] = record_id; | ||||
| 	jreq["param"]["code"] = ret_code; | ||||
| 
 | ||||
| 	ex_astr json_param; | ||||
| 	json_param = json_writer.write(jreq); | ||||
| 
 | ||||
| 	ex_astr param; | ||||
| 	ts_url_encode(json_param.c_str(), param); | ||||
| 
 | ||||
| 	ex_astr url = g_env.web_server_rpc; | ||||
| 	url += "?"; | ||||
| 	url += param; | ||||
| 
 | ||||
| 	ex_astr body; | ||||
| 	return ts_http_get(url, body); | ||||
| } | ||||
|  |  | |||
|  | @ -8,8 +8,8 @@ | |||
| // 重置log日志状态
 | ||||
| bool ts_web_rpc_register_core(); | ||||
| 
 | ||||
| // 根据认证ID获取认证信息(包括服务器IP、端口,用户名、密码或私钥、协议如RDP或SSH等等)
 | ||||
| bool ts_web_rpc_get_auth_info(int auth_id, Json::Value& jret); | ||||
| // 根据连接ID获取远程连接信息(包括服务器IP、端口,用户名、密码或私钥、协议如RDP或SSH等等)
 | ||||
| int ts_web_rpc_get_conn_info(int conn_id, Json::Value& jret); | ||||
| 
 | ||||
| // 记录会话的开始
 | ||||
| bool ts_web_rpc_session_begin(TS_SESSION_INFO& info, int& record_id); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Apex Liu
						Apex Liu