diff --git a/server/tp_core/core/tp_core.rc b/server/tp_core/core/tp_core.rc index 3503ea9..1d34819 100644 Binary files a/server/tp_core/core/tp_core.rc and b/server/tp_core/core/tp_core.rc differ diff --git a/server/tp_core/core/ts_http_rpc.cpp b/server/tp_core/core/ts_http_rpc.cpp index 81232ea..e8bd3f6 100644 --- a/server/tp_core/core/ts_http_rpc.cpp +++ b/server/tp_core/core/ts_http_rpc.cpp @@ -176,9 +176,18 @@ ex_rv TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, Jso return TPE_HTTP_METHOD; ex_astr json_str; + bool need_decode = false; if (is_get) { json_str.assign(req->query_string.p, req->query_string.len); + need_decode = true; + } + else { + json_str.assign(req->body.p, req->body.len); + if (json_str.length() > 0 && json_str[0] == '%') + need_decode = true; + } + if (need_decode) { // 将参数进行 url-decode 解码 int len = json_str.length() * 2; ex_chars sztmp; @@ -189,9 +198,6 @@ ex_rv TsHttpRpc::_parse_request(struct http_message* req, ex_astr& func_cmd, Jso json_str = &sztmp[0]; } - else { - json_str.assign(req->body.p, req->body.len); - } if (0 == json_str.length()) return TPE_PARAM; @@ -331,7 +337,7 @@ void TsHttpRpc::_rpc_func_get_config(const Json::Value& json_param, ex_astr& buf void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr& buf) { - // https://github.com/eomsoft/teleport/wiki/TELEPORT-CORE-JSON-RPC#request_session + // https://github.com/tp4a/teleport/wiki/TELEPORT-CORE-JSON-RPC#request_session int conn_id = 0; ex_rv rv = TPE_OK; @@ -414,7 +420,7 @@ void TsHttpRpc::_rpc_func_kill_sessions(const Json::Value& json_param, ex_astr& void TsHttpRpc::_rpc_func_enc(const Json::Value& json_param, ex_astr& buf) { - // https://github.com/eomsoft/teleport/wiki/TELEPORT-CORE-JSON-RPC#enc + // https://github.com/tp4a/teleport/wiki/TELEPORT-CORE-JSON-RPC#enc // 加密一个字符串 [ p=plain-text, c=cipher-text ] // 入参: {"p":"need be encrypt"} // 示例: {"p":"this-is-a-password"} @@ -459,7 +465,7 @@ void TsHttpRpc::_rpc_func_enc(const Json::Value& json_param, ex_astr& buf) void TsHttpRpc::_rpc_func_set_config(const Json::Value& json_param, ex_astr& buf) { - // https://github.com/eomsoft/teleport/wiki/TELEPORT-CORE-JSON-RPC#set_config + // https://github.com/tp4a/teleport/wiki/TELEPORT-CORE-JSON-RPC#set_config /* { "noop-timeout": 15 # 按分钟计 @@ -477,11 +483,6 @@ void TsHttpRpc::_rpc_func_set_config(const Json::Value& json_param, ex_astr& buf } int noop_timeout = json_param["noop_timeout"].asUInt(); - // if (noop_timeout == 0) { - // _create_json_ret(buf, TPE_PARAM); - // return; - // } - EXLOGV("[core] set run-time config:\n"); EXLOGV("[core] noop_timeout = %dm\n", noop_timeout); @@ -495,7 +496,7 @@ void TsHttpRpc::_rpc_func_set_config(const Json::Value& json_param, ex_astr& buf /* void TsHttpRpc::_rpc_func_enc(const Json::Value& json_param, ex_astr& buf) { - // https://github.com/eomsoft/teleport/wiki/TELEPORT-CORE-JSON-RPC#enc + // https://github.com/tp4a/teleport/wiki/TELEPORT-CORE-JSON-RPC#enc // 加密多个个字符串 [ p=plain-text, c=cipher-text ] // 入参: {"p":["need be encrypt", "plain to cipher"]} // 示例: {"p":["password-for-A"]} diff --git a/server/tp_core/core/ts_http_rpc.h b/server/tp_core/core/ts_http_rpc.h index fc19d2e..76178b5 100644 --- a/server/tp_core/core/ts_http_rpc.h +++ b/server/tp_core/core/ts_http_rpc.h @@ -7,8 +7,7 @@ #include // JSON-RPC documentation at: -// https://github.com/eomsoft/teleport/wiki/TELEPORT-CORE-JSON-RPC - +// https://github.com/tp4a/teleport/wiki/TELEPORT-CORE-JSON-RPC class TsHttpRpc : public ExThreadBase {