Correctly set the aria2 secret rpc.

This commit is contained in:
Matthieu Gautier 2018-10-16 17:29:41 +02:00
parent 996829e4d7
commit 18fc5cb4df
2 changed files with 7 additions and 5 deletions

View File

@ -34,6 +34,7 @@ Aria2::Aria2():
callCmd.push_back("aria2c");
callCmd.push_back("--enable-rpc");
callCmd.push_back(rpc_secret.c_str());
callCmd.push_back(rpc_port.c_str());
callCmd.push_back(download_dir.c_str());
// callCmd.push_back(log_dir.c_str());
@ -99,8 +100,7 @@ std::string Aria2::doRequest(const MethodCall& methodCall)
std::string Aria2::addUri(const std::vector<std::string>& uris)
{
MethodCall methodCall("aria2.addUri");
methodCall.getParams().addParam().getValue().set(m_secret);
MethodCall methodCall("aria2.addUri", m_secret);
auto uriParams = methodCall.getParams().addParam().getValue().getArray();
for (auto& uri : uris) {
uriParams.addValue().set(uri);
@ -117,8 +117,7 @@ std::string Aria2::addUri(const std::vector<std::string>& uris)
std::string Aria2::tellStatus(const std::string& gid, const std::vector<std::string>& statusKey)
{
MethodCall methodCall("aria2.tellStatus");
methodCall.getParams().addParam().getValue().set(m_secret);
MethodCall methodCall("aria2.tellStatus", m_secret);
methodCall.getParams().addParam().getValue().set(gid);
if (!statusKey.empty()) {
auto statusArray = methodCall.getParams().addParam().getValue().getArray();

View File

@ -202,10 +202,13 @@ class MethodCall {
pugi::xml_document m_doc;
public:
MethodCall(const std::string& methodName) {
MethodCall(const std::string& methodName, const std::string& secret) {
auto mCall = m_doc.append_child("methodCall");
mCall.append_child("methodName").text().set(methodName.c_str());
mCall.append_child("params");
if (!secret.empty()) {
getParams().addParam().getValue().set(secret);
}
}
Params getParams() const {