mirror of https://github.com/kiwix/libkiwix.git
Make aria2 secret a random value
Apps using this service will not have a default aria secret (previously 'kiwixariarpc')
This commit is contained in:
parent
91a4491b74
commit
8bdcb90818
|
@ -3,12 +3,14 @@
|
||||||
#include "aria2.h"
|
#include "aria2.h"
|
||||||
#include "xmlrpc.h"
|
#include "xmlrpc.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "tools/pathTools.h"
|
#include "tools/pathTools.h"
|
||||||
#include "tools/stringTools.h"
|
#include "tools/stringTools.h"
|
||||||
|
#include "tools/otherTools.h"
|
||||||
#include "downloader.h" // For AriaError
|
#include "downloader.h" // For AriaError
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -30,7 +32,7 @@ namespace kiwix {
|
||||||
Aria2::Aria2():
|
Aria2::Aria2():
|
||||||
mp_aria(nullptr),
|
mp_aria(nullptr),
|
||||||
m_port(42042),
|
m_port(42042),
|
||||||
m_secret("kiwixariarpc"),
|
m_secret(getNewRpcSecret()),
|
||||||
m_curlErrorBuffer(new char[CURL_ERROR_SIZE]),
|
m_curlErrorBuffer(new char[CURL_ERROR_SIZE]),
|
||||||
mp_curl(nullptr)
|
mp_curl(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -195,6 +197,13 @@ std::string Aria2::tellStatus(const std::string& gid, const std::vector<std::str
|
||||||
return doRequest(methodCall);
|
return doRequest(methodCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Aria2::getNewRpcSecret()
|
||||||
|
{
|
||||||
|
std::string uuid = gen_uuid("");
|
||||||
|
uuid.erase(std::remove(uuid.begin(), uuid.end(), '-'));
|
||||||
|
return uuid.substr(0, 9);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> Aria2::tellActive()
|
std::vector<std::string> Aria2::tellActive()
|
||||||
{
|
{
|
||||||
MethodCall methodCall("aria2.tellActive", m_secret);
|
MethodCall methodCall("aria2.tellActive", m_secret);
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Aria2
|
||||||
|
|
||||||
std::string addUri(const std::vector<std::string>& uri, const std::vector<std::pair<std::string, std::string>>& options = {});
|
std::string addUri(const std::vector<std::string>& uri, const std::vector<std::pair<std::string, std::string>>& options = {});
|
||||||
std::string tellStatus(const std::string& gid, const std::vector<std::string>& statusKey);
|
std::string tellStatus(const std::string& gid, const std::vector<std::string>& statusKey);
|
||||||
|
static std::string getNewRpcSecret();
|
||||||
std::vector<std::string> tellActive();
|
std::vector<std::string> tellActive();
|
||||||
std::vector<std::string> tellWaiting();
|
std::vector<std::string> tellWaiting();
|
||||||
void saveSession();
|
void saveSession();
|
||||||
|
|
Loading…
Reference in New Issue