mirror of https://github.com/aria2/aria2
New round of clang-modernize
parent
c8ccb43428
commit
b9fe4119c0
|
@ -66,8 +66,8 @@ namespace aria2 {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AdaptiveURISelector::AdaptiveURISelector
|
AdaptiveURISelector::AdaptiveURISelector
|
||||||
(const std::shared_ptr<ServerStatMan>& serverStatMan, RequestGroup* requestGroup)
|
(std::shared_ptr<ServerStatMan> serverStatMan, RequestGroup* requestGroup)
|
||||||
: serverStatMan_(serverStatMan),
|
: serverStatMan_(std::move(serverStatMan)),
|
||||||
requestGroup_(requestGroup)
|
requestGroup_(requestGroup)
|
||||||
{
|
{
|
||||||
resetCounters();
|
resetCounters();
|
||||||
|
|
|
@ -71,7 +71,7 @@ private:
|
||||||
int getNbTestedServers(const std::deque<std::string>& uris) const;
|
int getNbTestedServers(const std::deque<std::string>& uris) const;
|
||||||
std::string getBestMirror(const std::deque<std::string>& uris) const;
|
std::string getBestMirror(const std::deque<std::string>& uris) const;
|
||||||
public:
|
public:
|
||||||
AdaptiveURISelector(const std::shared_ptr<ServerStatMan>& serverStatMan,
|
AdaptiveURISelector(std::shared_ptr<ServerStatMan> serverStatMan,
|
||||||
RequestGroup* requestGroup);
|
RequestGroup* requestGroup);
|
||||||
|
|
||||||
virtual ~AdaptiveURISelector();
|
virtual ~AdaptiveURISelector();
|
||||||
|
|
|
@ -108,7 +108,7 @@ unsigned char* BtBitfieldMessage::createMessage() {
|
||||||
* total: 5+bitfieldLength bytes
|
* total: 5+bitfieldLength bytes
|
||||||
*/
|
*/
|
||||||
const size_t msgLength = 5+bitfieldLength_;
|
const size_t msgLength = 5+bitfieldLength_;
|
||||||
auto msg = new unsigned char[msgLength];
|
auto msg = new unsigned char[msgLength];
|
||||||
bittorrent::createPeerMessageString(msg, msgLength, 1+bitfieldLength_, ID);
|
bittorrent::createPeerMessageString(msg, msgLength, 1+bitfieldLength_, ID);
|
||||||
memcpy(msg+5, bitfield_, bitfieldLength_);
|
memcpy(msg+5, bitfield_, bitfieldLength_);
|
||||||
return msg;
|
return msg;
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace colors {
|
namespace colors {
|
||||||
|
@ -105,7 +107,7 @@ public:
|
||||||
elems.push_back(std::make_pair(eString, ""));
|
elems.push_back(std::make_pair(eString, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
traits_t::int_type overflow(traits_t::int_type c)
|
traits_t::int_type overflow(traits_t::int_type c) CXX11_OVERRIDE
|
||||||
{
|
{
|
||||||
elems.back().second.push_back((char)c);
|
elems.back().second.push_back((char)c);
|
||||||
return std::char_traits<char>::not_eof(c);
|
return std::char_traits<char>::not_eof(c);
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
(OutputIterator out, const std::string& hostname, uint16_t port) const
|
(OutputIterator out, const std::string& hostname, uint16_t port) const
|
||||||
{
|
{
|
||||||
std::shared_ptr<CacheEntry> target(new CacheEntry(hostname, port));
|
std::shared_ptr<CacheEntry> target(new CacheEntry(hostname, port));
|
||||||
CacheEntrySet::iterator i = entries_.find(target);
|
auto i = entries_.find(target);
|
||||||
if(i != entries_.end()) {
|
if(i != entries_.end()) {
|
||||||
(*i)->getAllGoodAddrs(out);
|
(*i)->getAllGoodAddrs(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,9 +314,9 @@ private:
|
||||||
sock_t sockets_[ARES_GETSOCK_MAXNUM];
|
sock_t sockets_[ARES_GETSOCK_MAXNUM];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncNameResolverEntry(const std::shared_ptr<AsyncNameResolver>& nameResolver,
|
AsyncNameResolverEntry(std::shared_ptr<AsyncNameResolver> nameResolver,
|
||||||
Command* command):
|
Command* command):
|
||||||
nameResolver_(nameResolver), command_(command), socketsSize_(0) {}
|
nameResolver_(std::move(nameResolver)), command_(command), socketsSize_(0) {}
|
||||||
|
|
||||||
bool operator==(const AsyncNameResolverEntry& entry)
|
bool operator==(const AsyncNameResolverEntry& entry)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,8 +50,8 @@ struct HashFuncEntry {
|
||||||
typedef HashFunc HashFuncType;
|
typedef HashFunc HashFuncType;
|
||||||
std::string hashType;
|
std::string hashType;
|
||||||
HashFunc hashFunc;
|
HashFunc hashFunc;
|
||||||
HashFuncEntry(const std::string& hashType, const HashFunc& hashFunc):
|
HashFuncEntry(std::string hashType, const HashFunc& hashFunc):
|
||||||
hashType(hashType), hashFunc(hashFunc)
|
hashType(std::move(hashType)), hashFunc(hashFunc)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ void handleError(gcry_error_t err)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ARC4Encryptor::ARC4Encryptor()
|
ARC4Encryptor::ARC4Encryptor()
|
||||||
: hdl_(0)
|
: hdl_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ARC4Encryptor::~ARC4Encryptor()
|
ARC4Encryptor::~ARC4Encryptor()
|
||||||
|
@ -71,7 +71,7 @@ void ARC4Encryptor::init(const unsigned char* key, size_t keyLength)
|
||||||
if((r = gcry_cipher_setkey(hdl_, key, keyLength))) {
|
if((r = gcry_cipher_setkey(hdl_, key, keyLength))) {
|
||||||
handleError(r);
|
handleError(r);
|
||||||
}
|
}
|
||||||
if((r = gcry_cipher_setiv(hdl_, 0, 0))) {
|
if((r = gcry_cipher_setiv(hdl_, nullptr, 0))) {
|
||||||
handleError(r);
|
handleError(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ void ARC4Encryptor::encrypt
|
||||||
size_t inlen;
|
size_t inlen;
|
||||||
if(in == out) {
|
if(in == out) {
|
||||||
out = const_cast<unsigned char*>(in);
|
out = const_cast<unsigned char*>(in);
|
||||||
in = 0;
|
in = nullptr;
|
||||||
inlen = 0;
|
inlen = 0;
|
||||||
} else {
|
} else {
|
||||||
inlen = len;
|
inlen = len;
|
||||||
|
|
|
@ -49,10 +49,10 @@ void handleError(gcry_error_t err)
|
||||||
|
|
||||||
DHKeyExchange::DHKeyExchange()
|
DHKeyExchange::DHKeyExchange()
|
||||||
: keyLength_(0),
|
: keyLength_(0),
|
||||||
prime_(0),
|
prime_(nullptr),
|
||||||
generator_(0),
|
generator_(nullptr),
|
||||||
privateKey_(0),
|
privateKey_(nullptr),
|
||||||
publicKey_(0)
|
publicKey_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DHKeyExchange::~DHKeyExchange()
|
DHKeyExchange::~DHKeyExchange()
|
||||||
|
@ -72,14 +72,14 @@ void DHKeyExchange::init(const unsigned char* prime, size_t primeBits,
|
||||||
gcry_mpi_release(privateKey_);
|
gcry_mpi_release(privateKey_);
|
||||||
{
|
{
|
||||||
gcry_error_t r = gcry_mpi_scan(&prime_, GCRYMPI_FMT_HEX,
|
gcry_error_t r = gcry_mpi_scan(&prime_, GCRYMPI_FMT_HEX,
|
||||||
prime, 0, 0);
|
prime, 0, nullptr);
|
||||||
if(r) {
|
if(r) {
|
||||||
handleError(r);
|
handleError(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
gcry_error_t r = gcry_mpi_scan(&generator_, GCRYMPI_FMT_HEX,
|
gcry_error_t r = gcry_mpi_scan(&generator_, GCRYMPI_FMT_HEX,
|
||||||
generator, 0, 0);
|
generator, 0, nullptr);
|
||||||
if(r) {
|
if(r) {
|
||||||
handleError(r);
|
handleError(r);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ size_t DHKeyExchange::computeSecret(unsigned char* out, size_t outLength,
|
||||||
GCRYMPI_FMT_USG,
|
GCRYMPI_FMT_USG,
|
||||||
peerPublicKeyData,
|
peerPublicKeyData,
|
||||||
peerPublicKeyLength,
|
peerPublicKeyLength,
|
||||||
0);
|
nullptr);
|
||||||
if(r) {
|
if(r) {
|
||||||
handleError(r);
|
handleError(r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ TLSSession* TLSSession::make(TLSContext* ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
GnuTLSSession::GnuTLSSession(GnuTLSContext* tlsContext)
|
GnuTLSSession::GnuTLSSession(GnuTLSContext* tlsContext)
|
||||||
: sslSession_(0),
|
: sslSession_(nullptr),
|
||||||
tlsContext_(tlsContext),
|
tlsContext_(tlsContext),
|
||||||
rv_(0)
|
rv_(0)
|
||||||
{}
|
{}
|
||||||
|
@ -265,7 +265,7 @@ int GnuTLSSession::tlsConnect(const std::string& hostname,
|
||||||
for(int i = 0; !(ret < 0); ++i) {
|
for(int i = 0; !(ret < 0); ++i) {
|
||||||
altNameLen = sizeof(altName);
|
altNameLen = sizeof(altName);
|
||||||
ret = gnutls_x509_crt_get_subject_alt_name(cert, i, altName,
|
ret = gnutls_x509_crt_get_subject_alt_name(cert, i, altName,
|
||||||
&altNameLen, 0);
|
&altNameLen, nullptr);
|
||||||
if(ret == GNUTLS_SAN_DNSNAME) {
|
if(ret == GNUTLS_SAN_DNSNAME) {
|
||||||
dnsNames.push_back(std::string(altName, altNameLen));
|
dnsNames.push_back(std::string(altName, altNameLen));
|
||||||
} else if(ret == GNUTLS_SAN_IPADDRESS) {
|
} else if(ret == GNUTLS_SAN_IPADDRESS) {
|
||||||
|
|
|
@ -49,17 +49,17 @@ void handleError(const std::string& funName)
|
||||||
{
|
{
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt("Exception in libssl routine %s(DHKeyExchange class): %s",
|
(fmt("Exception in libssl routine %s(DHKeyExchange class): %s",
|
||||||
funName.c_str(), ERR_error_string(ERR_get_error(), 0)));
|
funName.c_str(), ERR_error_string(ERR_get_error(), nullptr)));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DHKeyExchange::DHKeyExchange()
|
DHKeyExchange::DHKeyExchange()
|
||||||
: bnCtx_(0),
|
: bnCtx_(nullptr),
|
||||||
keyLength_(0),
|
keyLength_(0),
|
||||||
prime_(0),
|
prime_(nullptr),
|
||||||
generator_(0),
|
generator_(nullptr),
|
||||||
privateKey_(0),
|
privateKey_(nullptr),
|
||||||
publicKey_(0)
|
publicKey_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
DHKeyExchange::~DHKeyExchange()
|
DHKeyExchange::~DHKeyExchange()
|
||||||
|
@ -82,11 +82,11 @@ void DHKeyExchange::init(const unsigned char* prime, size_t primeBits,
|
||||||
}
|
}
|
||||||
|
|
||||||
BN_free(prime_);
|
BN_free(prime_);
|
||||||
prime_ = 0;
|
prime_ = nullptr;
|
||||||
BN_free(generator_);
|
BN_free(generator_);
|
||||||
generator_ = 0;
|
generator_ = nullptr;
|
||||||
BN_free(privateKey_);
|
BN_free(privateKey_);
|
||||||
privateKey_ = 0;
|
privateKey_ = nullptr;
|
||||||
|
|
||||||
if(BN_hex2bn(&prime_, reinterpret_cast<const char*>(prime)) == 0) {
|
if(BN_hex2bn(&prime_, reinterpret_cast<const char*>(prime)) == 0) {
|
||||||
handleError("BN_hex2bn in init");
|
handleError("BN_hex2bn in init");
|
||||||
|
@ -150,7 +150,7 @@ size_t DHKeyExchange::computeSecret(unsigned char* out, size_t outLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BIGNUM* peerPublicKey = BN_bin2bn(peerPublicKeyData, peerPublicKeyLength, 0);
|
BIGNUM* peerPublicKey = BN_bin2bn(peerPublicKeyData, peerPublicKeyLength, nullptr);
|
||||||
if(!peerPublicKey) {
|
if(!peerPublicKey) {
|
||||||
handleError("BN_bin2bn in computeSecret");
|
handleError("BN_bin2bn in computeSecret");
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
return len_;
|
return len_;
|
||||||
}
|
}
|
||||||
virtual void reset() CXX11_OVERRIDE {
|
virtual void reset() CXX11_OVERRIDE {
|
||||||
EVP_DigestInit_ex(&ctx_, md_, 0);
|
EVP_DigestInit_ex(&ctx_, md_, nullptr);
|
||||||
}
|
}
|
||||||
virtual void update(const void* data, size_t length) CXX11_OVERRIDE {
|
virtual void update(const void* data, size_t length) CXX11_OVERRIDE {
|
||||||
auto bytes = reinterpret_cast<const char*>(data);
|
auto bytes = reinterpret_cast<const char*>(data);
|
||||||
|
|
|
@ -87,7 +87,7 @@ TLSContext* TLSContext::make(TLSSessionSide side)
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side)
|
OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side)
|
||||||
: sslCtx_(0),
|
: sslCtx_(nullptr),
|
||||||
side_(side),
|
side_(side),
|
||||||
verifyPeer_(true)
|
verifyPeer_(true)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side)
|
||||||
} else {
|
} else {
|
||||||
good_ = false;
|
good_ = false;
|
||||||
A2_LOG_ERROR(fmt("SSL_CTX_new() failed. Cause: %s",
|
A2_LOG_ERROR(fmt("SSL_CTX_new() failed. Cause: %s",
|
||||||
ERR_error_string(ERR_get_error(), 0)));
|
ERR_error_string(ERR_get_error(), nullptr)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Disable SSLv2 and enable all workarounds for buggy servers
|
// Disable SSLv2 and enable all workarounds for buggy servers
|
||||||
|
@ -139,13 +139,13 @@ bool OpenSSLTLSContext::addCredentialFile(const std::string& certfile,
|
||||||
SSL_FILETYPE_PEM) != 1) {
|
SSL_FILETYPE_PEM) != 1) {
|
||||||
A2_LOG_ERROR(fmt("Failed to load private key from %s. Cause: %s",
|
A2_LOG_ERROR(fmt("Failed to load private key from %s. Cause: %s",
|
||||||
keyfile.c_str(),
|
keyfile.c_str(),
|
||||||
ERR_error_string(ERR_get_error(), 0)));
|
ERR_error_string(ERR_get_error(), nullptr)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(SSL_CTX_use_certificate_chain_file(sslCtx_, certfile.c_str()) != 1) {
|
if(SSL_CTX_use_certificate_chain_file(sslCtx_, certfile.c_str()) != 1) {
|
||||||
A2_LOG_ERROR(fmt("Failed to load certificate from %s. Cause: %s",
|
A2_LOG_ERROR(fmt("Failed to load certificate from %s. Cause: %s",
|
||||||
certfile.c_str(),
|
certfile.c_str(),
|
||||||
ERR_error_string(ERR_get_error(), 0)));
|
ERR_error_string(ERR_get_error(), nullptr)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
A2_LOG_INFO(fmt("Credential files(cert=%s, key=%s) were successfully added.",
|
A2_LOG_INFO(fmt("Credential files(cert=%s, key=%s) were successfully added.",
|
||||||
|
@ -177,7 +177,7 @@ bool OpenSSLTLSContext::addP12CredentialFile(const std::string& p12file)
|
||||||
}
|
}
|
||||||
EVP_PKEY *pkey;
|
EVP_PKEY *pkey;
|
||||||
X509 *cert;
|
X509 *cert;
|
||||||
STACK_OF(X509) *ca = 0;
|
STACK_OF(X509) *ca = nullptr;
|
||||||
if (!PKCS12_parse(p12.get(), "", &pkey, &cert, &ca)) {
|
if (!PKCS12_parse(p12.get(), "", &pkey, &cert, &ca)) {
|
||||||
A2_LOG_ERROR(fmt("Failed to parse PKCS12 file: %s. "
|
A2_LOG_ERROR(fmt("Failed to parse PKCS12 file: %s. "
|
||||||
"If you meant to use PEM, you'll also have to specify "
|
"If you meant to use PEM, you'll also have to specify "
|
||||||
|
@ -219,7 +219,7 @@ bool OpenSSLTLSContext::addSystemTrustedCACerts()
|
||||||
{
|
{
|
||||||
if(SSL_CTX_set_default_verify_paths(sslCtx_) != 1) {
|
if(SSL_CTX_set_default_verify_paths(sslCtx_) != 1) {
|
||||||
A2_LOG_INFO(fmt(MSG_LOADING_SYSTEM_TRUSTED_CA_CERTS_FAILED,
|
A2_LOG_INFO(fmt(MSG_LOADING_SYSTEM_TRUSTED_CA_CERTS_FAILED,
|
||||||
ERR_error_string(ERR_get_error(), 0)));
|
ERR_error_string(ERR_get_error(), nullptr)));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_INFO("System trusted CA certificates were successfully added.");
|
A2_LOG_INFO("System trusted CA certificates were successfully added.");
|
||||||
|
@ -229,10 +229,10 @@ bool OpenSSLTLSContext::addSystemTrustedCACerts()
|
||||||
|
|
||||||
bool OpenSSLTLSContext::addTrustedCACertFile(const std::string& certfile)
|
bool OpenSSLTLSContext::addTrustedCACertFile(const std::string& certfile)
|
||||||
{
|
{
|
||||||
if(SSL_CTX_load_verify_locations(sslCtx_, certfile.c_str(), 0) != 1) {
|
if(SSL_CTX_load_verify_locations(sslCtx_, certfile.c_str(), nullptr) != 1) {
|
||||||
A2_LOG_ERROR(fmt(MSG_LOADING_TRUSTED_CA_CERT_FAILED,
|
A2_LOG_ERROR(fmt(MSG_LOADING_TRUSTED_CA_CERT_FAILED,
|
||||||
certfile.c_str(),
|
certfile.c_str(),
|
||||||
ERR_error_string(ERR_get_error(), 0)));
|
ERR_error_string(ERR_get_error(), nullptr)));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_INFO("Trusted CA certificates were successfully added.");
|
A2_LOG_INFO("Trusted CA certificates were successfully added.");
|
||||||
|
|
|
@ -50,7 +50,7 @@ TLSSession* TLSSession::make(TLSContext* ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenSSLTLSSession::OpenSSLTLSSession(OpenSSLTLSContext* tlsContext)
|
OpenSSLTLSSession::OpenSSLTLSSession(OpenSSLTLSContext* tlsContext)
|
||||||
: ssl_(0),
|
: ssl_(nullptr),
|
||||||
tlsContext_(tlsContext),
|
tlsContext_(tlsContext),
|
||||||
rv_(1)
|
rv_(1)
|
||||||
{}
|
{}
|
||||||
|
@ -205,7 +205,7 @@ int OpenSSLTLSSession::tlsConnect(const std::string& hostname,
|
||||||
std::vector<std::string> ipAddrs;
|
std::vector<std::string> ipAddrs;
|
||||||
GENERAL_NAMES* altNames;
|
GENERAL_NAMES* altNames;
|
||||||
altNames = reinterpret_cast<GENERAL_NAMES*>
|
altNames = reinterpret_cast<GENERAL_NAMES*>
|
||||||
(X509_get_ext_d2i(peerCert, NID_subject_alt_name, NULL, NULL));
|
(X509_get_ext_d2i(peerCert, NID_subject_alt_name, nullptr, NULL));
|
||||||
if(altNames) {
|
if(altNames) {
|
||||||
std::unique_ptr<GENERAL_NAMES, decltype(&GENERAL_NAMES_free)>
|
std::unique_ptr<GENERAL_NAMES, decltype(&GENERAL_NAMES_free)>
|
||||||
altNamesDeleter(altNames, GENERAL_NAMES_free);
|
altNamesDeleter(altNames, GENERAL_NAMES_free);
|
||||||
|
@ -289,7 +289,7 @@ std::string OpenSSLTLSSession::getLastErrorString()
|
||||||
return "unknown syscall error";
|
return "unknown syscall error";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ERR_error_string(err, 0);
|
return ERR_error_string(err, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SSL_ERROR_SSL:
|
case SSL_ERROR_SSL:
|
||||||
|
|
|
@ -228,7 +228,7 @@ class AuthHostMatch {
|
||||||
private:
|
private:
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
public:
|
public:
|
||||||
AuthHostMatch(const std::string& hostname):hostname(hostname) {}
|
AuthHostMatch(std::string hostname) : hostname(std::move(hostname)) {}
|
||||||
|
|
||||||
bool operator()(const std::unique_ptr<Authenticator>& authenticator)
|
bool operator()(const std::unique_ptr<Authenticator>& authenticator)
|
||||||
{
|
{
|
||||||
|
|
|
@ -869,9 +869,9 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
DefaultOptionHandler* op(new DefaultOptionHandler
|
auto op = new DefaultOptionHandler
|
||||||
(PREF_RPC_SECRET,
|
(PREF_RPC_SECRET,
|
||||||
TEXT_RPC_SECRET));
|
TEXT_RPC_SECRET);
|
||||||
op->addTag(TAG_RPC);
|
op->addTag(TAG_RPC);
|
||||||
op->setEraseAfterParse(true);
|
op->setEraseAfterParse(true);
|
||||||
op->setAllowEmpty(false);
|
op->setAllowEmpty(false);
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
|
Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
|
||||||
ipaddr_(ipaddr),
|
ipaddr_(std::move(ipaddr)),
|
||||||
port_(port),
|
port_(port),
|
||||||
origPort_(port),
|
origPort_(port),
|
||||||
cuid_(0),
|
cuid_(0),
|
||||||
|
|
|
@ -45,10 +45,10 @@ namespace aria2 {
|
||||||
class RequestSlot {
|
class RequestSlot {
|
||||||
public:
|
public:
|
||||||
RequestSlot(size_t index, int32_t begin, int32_t length, size_t blockIndex,
|
RequestSlot(size_t index, int32_t begin, int32_t length, size_t blockIndex,
|
||||||
const std::shared_ptr<Piece>& piece = nullptr)
|
std::shared_ptr<Piece> piece = nullptr)
|
||||||
: dispatchedTime_(global::wallclock()),
|
: dispatchedTime_(global::wallclock()),
|
||||||
index_(index), begin_(begin), length_(length), blockIndex_(blockIndex),
|
index_(index), begin_(begin), length_(length), blockIndex_(blockIndex),
|
||||||
piece_(piece)
|
piece_(std::move(piece))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RequestSlot():dispatchedTime_(0), index_(0), begin_(0), length_(0),
|
RequestSlot():dispatchedTime_(0), index_(0), begin_(0), length_(0),
|
||||||
|
|
|
@ -347,7 +347,7 @@ class FindSegmentEntry {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Segment> segment_;
|
std::shared_ptr<Segment> segment_;
|
||||||
public:
|
public:
|
||||||
FindSegmentEntry(const std::shared_ptr<Segment>& segment):segment_(segment) {}
|
FindSegmentEntry(std::shared_ptr<Segment> segment):segment_(std::move(segment)) {}
|
||||||
|
|
||||||
bool operator()(const std::shared_ptr<SegmentEntry>& segmentEntry) const
|
bool operator()(const std::shared_ptr<SegmentEntry>& segmentEntry) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,8 +122,8 @@ struct CollectAddrPortMatch {
|
||||||
std::string remoteAddr;
|
std::string remoteAddr;
|
||||||
uint16_t remotePort;
|
uint16_t remotePort;
|
||||||
CollectAddrPortMatch(std::vector<std::shared_ptr<UDPTrackerRequest> >& dest,
|
CollectAddrPortMatch(std::vector<std::shared_ptr<UDPTrackerRequest> >& dest,
|
||||||
const std::string& remoteAddr, uint16_t remotePort)
|
std::string remoteAddr, uint16_t remotePort)
|
||||||
: dest(dest), remoteAddr(remoteAddr), remotePort(remotePort)
|
: dest(dest), remoteAddr(std::move(remoteAddr)), remotePort(remotePort)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -501,9 +501,9 @@ struct FailConnectDelete {
|
||||||
std::string remoteAddr;
|
std::string remoteAddr;
|
||||||
uint16_t remotePort;
|
uint16_t remotePort;
|
||||||
int error;
|
int error;
|
||||||
FailConnectDelete(const std::string& remoteAddr, uint16_t remotePort,
|
FailConnectDelete(std::string remoteAddr, uint16_t remotePort,
|
||||||
int error)
|
int error)
|
||||||
: remoteAddr(remoteAddr), remotePort(remotePort), error(error)
|
: remoteAddr(std::move(remoteAddr)), remotePort(remotePort), error(error)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -522,9 +522,8 @@ std::vector<A2Gid> getActiveDownload(Session* session)
|
||||||
auto& e = session->context->reqinfo->getDownloadEngine();
|
auto& e = session->context->reqinfo->getDownloadEngine();
|
||||||
const RequestGroupList& groups = e->getRequestGroupMan()->getRequestGroups();
|
const RequestGroupList& groups = e->getRequestGroupMan()->getRequestGroups();
|
||||||
std::vector<A2Gid> res;
|
std::vector<A2Gid> res;
|
||||||
for(RequestGroupList::const_iterator i = groups.begin(),
|
for(const auto& group : groups) {
|
||||||
eoi = groups.end(); i != eoi; ++i) {
|
res.push_back(group->getGID());
|
||||||
res.push_back((*i)->getGID());
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -815,8 +814,8 @@ struct RequestGroupDH : public DownloadHandle {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct DownloadResultDH : public DownloadHandle {
|
struct DownloadResultDH : public DownloadHandle {
|
||||||
DownloadResultDH(const std::shared_ptr<DownloadResult>& dr)
|
DownloadResultDH(std::shared_ptr<DownloadResult> dr)
|
||||||
: dr(dr)
|
: dr(std::move(dr))
|
||||||
{}
|
{}
|
||||||
virtual ~DownloadResultDH() {}
|
virtual ~DownloadResultDH() {}
|
||||||
virtual DownloadStatus getStatus() CXX11_OVERRIDE
|
virtual DownloadStatus getStatus() CXX11_OVERRIDE
|
||||||
|
|
|
@ -65,13 +65,13 @@ int daemon(int nochdir, int noclose)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(noclose == 0) {
|
if(noclose == 0) {
|
||||||
if(freopen("/dev/null", "r", stdin) == 0) {
|
if(freopen("/dev/null", "r", stdin) == nullptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(freopen("/dev/null", "w", stdout) == 0) {
|
if(freopen("/dev/null", "w", stdout) == nullptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(freopen("/dev/null", "w", stderr) == 0) {
|
if(freopen("/dev/null", "w", stderr) == nullptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,10 +332,10 @@ private:
|
||||||
bool throwOnError_;
|
bool throwOnError_;
|
||||||
public:
|
public:
|
||||||
AccRequestGroup(std::vector<std::shared_ptr<RequestGroup>>& requestGroups,
|
AccRequestGroup(std::vector<std::shared_ptr<RequestGroup>>& requestGroups,
|
||||||
const std::shared_ptr<Option>& option,
|
std::shared_ptr<Option> option,
|
||||||
bool ignoreLocalPath = false,
|
bool ignoreLocalPath = false,
|
||||||
bool throwOnError = false):
|
bool throwOnError = false):
|
||||||
requestGroups_(requestGroups), option_(option),
|
requestGroups_(requestGroups), option_(std::move(option)),
|
||||||
ignoreLocalPath_(ignoreLocalPath),
|
ignoreLocalPath_(ignoreLocalPath),
|
||||||
throwOnError_(throwOnError)
|
throwOnError_(throwOnError)
|
||||||
{}
|
{}
|
||||||
|
|
Loading…
Reference in New Issue