Committing updates.
This commit is contained in:
@@ -80,6 +80,23 @@ namespace Apostol {
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
int CWebService::CurrentContextIndex(const CString &Params) {
|
||||
int index = 0;
|
||||
while (index < m_Servers.Count()) {
|
||||
const auto &caContext = m_Servers[index].Value();
|
||||
if (caContext.Status() == Context::csRunning) {
|
||||
if (Params == caContext.Name() || Params == caContext.URL().Origin()) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool CWebService::DoProxyExecute(CTCPConnection *AConnection) {
|
||||
|
||||
auto pConnection = dynamic_cast<CHTTPClientConnection *> (AConnection);
|
||||
@@ -228,7 +245,10 @@ namespace Apostol {
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
|
||||
const auto &caServer = caServerParam.IsEmpty() ? m_CurrentServer.URL().Origin() : caServerParam;
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||
const auto &caServer = caContext.URL().Origin();
|
||||
|
||||
CLocation Location(caServer);
|
||||
|
||||
@@ -424,7 +444,7 @@ namespace Apostol {
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, "POST", URI.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + m_CurrentServer.Tokens()["access_token"]);
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
@@ -464,7 +484,10 @@ namespace Apostol {
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
|
||||
const auto &caServer = caServerParam.IsEmpty() ? m_CurrentServer.URL().Origin() : caServerParam;
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||
const auto &caServer = caContext.URL().Origin();
|
||||
|
||||
CLocation Location(caServer);
|
||||
|
||||
@@ -764,7 +787,7 @@ namespace Apostol {
|
||||
Node = YAML::Load(pServerRequest->Content.c_str());
|
||||
}
|
||||
|
||||
const auto &BTCKeys = m_CurrentServer.BTCKeys();
|
||||
const auto &BTCKeys = caContext.BTCKeys();
|
||||
|
||||
if (BTCKeys.Count() < 2)
|
||||
throw ExceptionFrm("Bitcoin keys cannot be empty.");
|
||||
@@ -847,7 +870,7 @@ namespace Apostol {
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, "POST", URI.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + m_CurrentServer.Tokens()["access_token"]);
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
@@ -894,7 +917,10 @@ namespace Apostol {
|
||||
const auto &pgpValue = pServerRequest->Params["pgp"];
|
||||
const auto &caServerParam = pServerRequest->Params["server"];
|
||||
|
||||
const auto &caServer = caServerParam.IsEmpty() ? m_CurrentServer.URL().Origin() : caServerParam;
|
||||
const auto index = CurrentContextIndex(caServerParam);
|
||||
|
||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||
const auto &caServer = caContext.URL().Origin();
|
||||
|
||||
CLocation Location(caServer);
|
||||
|
||||
@@ -914,7 +940,7 @@ namespace Apostol {
|
||||
|
||||
CHTTPRequest::Prepare(pProxyRequest, Method.c_str(), URI.c_str(), caContentType.c_str());
|
||||
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + m_CurrentServer.Tokens()["access_token"]);
|
||||
pProxyRequest->AddHeader("Authorization", "Bearer " + caContext.Tokens()["access_token"]);
|
||||
|
||||
if (!caModuleAddress.IsEmpty())
|
||||
pProxyRequest->AddHeader("Module-Address", caModuleAddress);
|
||||
@@ -944,10 +970,14 @@ namespace Apostol {
|
||||
return;
|
||||
}
|
||||
|
||||
auto &Keys = m_CurrentServer.PGP();
|
||||
const auto &caServerParam = pRequest->Params["server"];
|
||||
int index = CurrentContextIndex(caServerParam);
|
||||
const auto &caContext = index == -1 ? m_CurrentServer : m_Servers[index].Value();
|
||||
|
||||
int index = 0;
|
||||
while (index < Keys.Count() && Keys[index].Name != m_CurrentServer.Name()) {
|
||||
auto &Keys = caContext.PGP();
|
||||
|
||||
index = 0;
|
||||
while (index < Keys.Count() && Keys[index].Name != caContext.Name()) {
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user