修正:配置了端口号后不能正常工作。

pull/32/head v2.2.6.1-hotfix
Apex Liu 2017-04-18 18:56:45 +08:00
parent 45edd4e21f
commit 32e0991164
5 changed files with 43 additions and 12 deletions

View File

@ -17,7 +17,7 @@ debug=0
; 'replay-path' define the replay file location. if not set, default location
; to $INSTDIR%/data/replay/
;replay-path=/var/lib/teleport/data/replay
;replay-path=/var/lib/teleport/replay
web-server-rpc=http://127.0.0.1:7190/rpc

View File

@ -117,6 +117,16 @@ bool TsEnv::init(bool load_config)
EXLOG_DEBUG(true);
ex_wstr tmp;
if (!ps->GetStr(L"web-server-rpc", tmp))
{
web_server_rpc = "http://127.0.0.1:7190/rpc";
}
else
{
ex_wstr2astr(tmp, web_server_rpc);
}
ps = m_ini.GetSection(L"rpc");
if (!ps->GetStr(L"bind-ip", tmp))
{
@ -125,11 +135,18 @@ bool TsEnv::init(bool load_config)
else
{
ex_wstr2astr(tmp, rpc_bind_ip);
if (rpc_bind_ip == "localhost")
rpc_bind_ip = "127.0.0.1";
}
if (!ps->GetInt(L"bind-port", rpc_bind_port))
{
rpc_bind_port = TS_HTTP_RPC_PORT;
}
char port_str[20] = { 0 };
ex_strformat(port_str, 20, "%d", rpc_bind_port);
core_server_rpc = "http://" + rpc_bind_ip + ":" + port_str + "/rpc";
return true;
}

View File

@ -22,6 +22,9 @@ public:
ex_astr rpc_bind_ip;
int rpc_bind_port;
ex_astr web_server_rpc;
ex_astr core_server_rpc;
private:
ExIniFile m_ini;
};

View File

@ -77,7 +77,11 @@ bool TsHttpRpc::init(void)
m_host_port = g_env.rpc_bind_port;
char addr[128] = { 0 };
if (0 == strcmp(m_host_ip.c_str(), "127.0.0.1") || 0 == strcmp(m_host_ip.c_str(), "localhost"))
// if (0 == strcmp(m_host_ip.c_str(), "127.0.0.1") || 0 == strcmp(m_host_ip.c_str(), "localhost"))
// ex_strformat(addr, 128, ":%d", m_host_port);
// else
// ex_strformat(addr, 128, "%s:%d", m_host_ip.c_str(), m_host_port);
if (0 == strcmp(m_host_ip.c_str(), "0.0.0.0"))
ex_strformat(addr, 128, ":%d", m_host_port);
else
ex_strformat(addr, 128, "%s:%d", m_host_ip.c_str(), m_host_port);

View File

@ -13,7 +13,8 @@ bool ts_web_rpc_register_core()
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"] = "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");
@ -33,7 +34,9 @@ bool ts_web_rpc_register_core()
ex_astr param;
ts_url_encode(json_param.c_str(), param);
ex_astr url = "http://127.0.0.1:7190/rpc?";
//ex_astr url = "http://127.0.0.1:7190/rpc?";
ex_astr url = g_env.web_server_rpc;
url += "?";
url += param;
ex_astr body;
@ -52,7 +55,10 @@ bool ts_web_rpc_get_auth_info(int auth_id, Json::Value& jret)
ex_astr param;
ts_url_encode(json_param.c_str(), param);
ex_astr url = "http://127.0.0.1:7190/rpc?";
//ex_astr url = "http://127.0.0.1:7190/rpc?";
ex_astr url = g_env.web_server_rpc;
url += "?";
url += param;
ex_astr body;
@ -114,7 +120,10 @@ bool ts_web_rpc_session_begin(TS_SESSION_INFO& info, int& record_id)
ex_astr param;
ts_url_encode(json_param.c_str(), param);
ex_astr url = "http://127.0.0.1:7190/rpc?";
//ex_astr url = "http://127.0.0.1:7190/rpc?";
ex_astr url = g_env.web_server_rpc;
url += "?";
url += param;
ex_astr body;
@ -157,13 +166,11 @@ bool ts_web_rpc_session_end(int record_id, int ret_code)
ex_astr param;
ts_url_encode(json_param.c_str(), param);
ex_astr url = "http://127.0.0.1:7190/rpc?";
url += param;
// ex_astr param;
// ts_url_encode("{\"method\":\"session_end\",\"param\":[]}", param);
// ex_astr url = "http://127.0.0.1:7190/rpc?";
// url += 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);