refactor: use readability-identifier-naming in clang-tidy (#3784)
This commit is contained in:
parent
32a4709b1a
commit
1782dc6d7a
|
@ -33,3 +33,9 @@ Checks: >
|
|||
-readability-identifier-length,
|
||||
-readability-magic-numbers,
|
||||
-readability-qualified-auto,
|
||||
|
||||
CheckOptions:
|
||||
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
|
||||
- { key: readability-identifier-naming.VariableCase, value: lower_case }
|
||||
|
||||
|
|
|
@ -770,7 +770,7 @@ static void tier_announce_remove_trailing(tr_tier* tier, tr_announce_event e)
|
|||
tier_update_announce_priority(tier);
|
||||
}
|
||||
|
||||
static void tier_announce_event_push(tr_tier* tier, tr_announce_event e, time_t announceAt)
|
||||
static void tier_announce_event_push(tr_tier* tier, tr_announce_event e, time_t announce_at)
|
||||
{
|
||||
TR_ASSERT(tier != nullptr);
|
||||
|
||||
|
@ -801,11 +801,11 @@ static void tier_announce_event_push(tr_tier* tier, tr_announce_event e, time_t
|
|||
|
||||
/* add it */
|
||||
events.push_back(e);
|
||||
tier->announceAt = announceAt;
|
||||
tier->announceAt = announce_at;
|
||||
tier_update_announce_priority(tier);
|
||||
|
||||
tr_logAddTrace_tier_announce_queue(tier);
|
||||
tr_logAddTraceTier(tier, fmt::format("announcing in {} seconds", difftime(announceAt, tr_time())));
|
||||
tr_logAddTraceTier(tier, fmt::format("announcing in {} seconds", difftime(announce_at, tr_time())));
|
||||
}
|
||||
|
||||
static auto tier_announce_event_pull(tr_tier* tier)
|
||||
|
@ -816,12 +816,12 @@ static auto tier_announce_event_pull(tr_tier* tier)
|
|||
return e;
|
||||
}
|
||||
|
||||
static void torrentAddAnnounce(tr_torrent* tor, tr_announce_event e, time_t announceAt)
|
||||
static void torrentAddAnnounce(tr_torrent* tor, tr_announce_event e, time_t announce_at)
|
||||
{
|
||||
// tell each tier to announce
|
||||
for (auto& tier : tor->torrent_announcer->tiers)
|
||||
{
|
||||
tier_announce_event_push(&tier, e, announceAt);
|
||||
tier_announce_event_push(&tier, e, announce_at);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -854,14 +854,14 @@ void tr_announcerChangeMyPort(tr_torrent* tor)
|
|||
****
|
||||
***/
|
||||
|
||||
void tr_announcerAddBytes(tr_torrent* tor, int type, uint32_t byteCount)
|
||||
void tr_announcerAddBytes(tr_torrent* tor, int type, uint32_t n_bytes)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
TR_ASSERT(type == TR_ANN_UP || type == TR_ANN_DOWN || type == TR_ANN_CORRUPT);
|
||||
|
||||
for (auto& tier : tor->torrent_announcer->tiers)
|
||||
{
|
||||
tier.byteCounts[type] += byteCount;
|
||||
tier.byteCounts[type] += n_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -982,7 +982,7 @@ static void on_announce_error(tr_tier* tier, char const* err, tr_announce_event
|
|||
}
|
||||
}
|
||||
|
||||
static void on_announce_done(tr_announce_response const* response, void* vdata)
|
||||
static void onAnnounceDone(tr_announce_response const* response, void* vdata)
|
||||
{
|
||||
auto* const data = static_cast<announce_data*>(vdata);
|
||||
|
||||
|
@ -1056,7 +1056,7 @@ static void on_announce_done(tr_announce_response const* response, void* vdata)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto const isStopped = event == TR_ANNOUNCE_EVENT_STOPPED;
|
||||
auto const is_stopped = event == TR_ANNOUNCE_EVENT_STOPPED;
|
||||
auto leechers = int{};
|
||||
auto scrape_fields = int{};
|
||||
auto seeders = int{};
|
||||
|
@ -1148,7 +1148,7 @@ static void on_announce_done(tr_announce_response const* response, void* vdata)
|
|||
tier->lastAnnounceSucceeded = true;
|
||||
tier->lastAnnouncePeerCount = std::size(response->pex) + std::size(response->pex6);
|
||||
|
||||
if (isStopped)
|
||||
if (is_stopped)
|
||||
{
|
||||
/* now that we've successfully stopped the torrent,
|
||||
* we can reset the up/down/corrupt count we've kept
|
||||
|
@ -1158,7 +1158,7 @@ static void on_announce_done(tr_announce_response const* response, void* vdata)
|
|||
tier->byteCounts[TR_ANN_CORRUPT] = 0;
|
||||
}
|
||||
|
||||
if (!isStopped && std::empty(tier->announce_events))
|
||||
if (!is_stopped && std::empty(tier->announce_events))
|
||||
{
|
||||
/* the queue is empty, so enqueue a periodic update */
|
||||
int const i = tier->announceIntervalSec;
|
||||
|
@ -1224,7 +1224,7 @@ static void tierAnnounce(tr_announcer* announcer, tr_tier* tier)
|
|||
tier->isAnnouncing = true;
|
||||
tier->lastAnnounceStartTime = now;
|
||||
|
||||
announce_request_delegate(announcer, req, on_announce_done, data);
|
||||
announce_request_delegate(announcer, req, onAnnounceDone, data);
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
|
@ -92,7 +92,7 @@ enum
|
|||
TR_ANN_CORRUPT
|
||||
};
|
||||
|
||||
void tr_announcerAddBytes(tr_torrent*, int type, uint32_t byteCount);
|
||||
void tr_announcerAddBytes(tr_torrent*, int type, uint32_t n_bytes);
|
||||
|
||||
time_t tr_announcerNextManualAnnounce(tr_torrent const*);
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ void tr_bitfield::setRaw(uint8_t const* raw, size_t byte_count)
|
|||
|
||||
void tr_bitfield::setFromBools(bool const* flags, size_t n)
|
||||
{
|
||||
size_t trueCount = 0;
|
||||
size_t true_count = 0;
|
||||
|
||||
freeArray();
|
||||
ensureBitsAlloced(n);
|
||||
|
@ -337,12 +337,12 @@ void tr_bitfield::setFromBools(bool const* flags, size_t n)
|
|||
{
|
||||
if (flags[i])
|
||||
{
|
||||
++trueCount;
|
||||
++true_count;
|
||||
flags_[i >> 3U] |= (0x80 >> (i & 7U));
|
||||
}
|
||||
}
|
||||
|
||||
setTrueCount(trueCount);
|
||||
setTrueCount(true_count);
|
||||
}
|
||||
|
||||
void tr_bitfield::set(size_t nth, bool value)
|
||||
|
|
|
@ -568,7 +568,7 @@ tr_sys_file_t tr_sys_file_open(char const* path, int flags, int permissions, tr_
|
|||
int native_value;
|
||||
};
|
||||
|
||||
auto constexpr native_map = std::array<native_map_item, 8>{
|
||||
auto constexpr NativeMap = std::array<native_map_item, 8>{
|
||||
{ { TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, O_RDWR },
|
||||
{ TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, TR_SYS_FILE_READ, O_RDONLY },
|
||||
{ TR_SYS_FILE_READ | TR_SYS_FILE_WRITE, TR_SYS_FILE_WRITE, O_WRONLY },
|
||||
|
@ -580,7 +580,7 @@ tr_sys_file_t tr_sys_file_open(char const* path, int flags, int permissions, tr_
|
|||
|
||||
int native_flags = O_BINARY | O_LARGEFILE | O_CLOEXEC;
|
||||
|
||||
for (auto const& item : native_map)
|
||||
for (auto const& item : NativeMap)
|
||||
{
|
||||
if ((flags & item.symbolic_mask) == item.symbolic_value)
|
||||
{
|
||||
|
|
|
@ -41,17 +41,17 @@ using namespace std::literals;
|
|||
#define HANDSHAKE_NAME "\023BitTorrent protocol"
|
||||
|
||||
// bittorrent handshake constants
|
||||
static auto constexpr HANDSHAKE_NAME_LEN = int{ 20 };
|
||||
static auto constexpr HANDSHAKE_FLAGS_LEN = int{ 8 };
|
||||
static auto constexpr HANDSHAKE_SIZE = int{ 68 };
|
||||
static auto constexpr INCOMING_HANDSHAKE_LEN = int{ 48 };
|
||||
static auto constexpr HandshakeNameLen = int{ 20 };
|
||||
static auto constexpr HandshakeFlagsLen = int{ 8 };
|
||||
static auto constexpr HandshakeSize = int{ 68 };
|
||||
static auto constexpr IncomingHandshakeLen = int{ 48 };
|
||||
|
||||
// encryption constants
|
||||
static auto constexpr PadA_MAXLEN = int{ 512 };
|
||||
static auto constexpr PadB_MAXLEN = int{ 512 };
|
||||
static auto constexpr PadC_MAXLEN = int{ 512 };
|
||||
static auto constexpr CRYPTO_PROVIDE_PLAINTEXT = int{ 1 };
|
||||
static auto constexpr CRYPTO_PROVIDE_CRYPTO = int{ 2 };
|
||||
static auto constexpr PadaMaxlen = int{ 512 };
|
||||
static auto constexpr PadbMaxlen = int{ 512 };
|
||||
static auto constexpr PadcMaxlen = int{ 512 };
|
||||
static auto constexpr CryptoProvidePlaintext = int{ 1 };
|
||||
static auto constexpr CryptoProvideCrypto = int{ 2 };
|
||||
|
||||
// "VC is a verification constant that is used to verify whether the
|
||||
// other side knows S and SKEY and thus defeats replay attacks of the
|
||||
|
@ -144,11 +144,11 @@ struct tr_handshake
|
|||
{
|
||||
case TR_ENCRYPTION_REQUIRED:
|
||||
case TR_ENCRYPTION_PREFERRED:
|
||||
provide |= CRYPTO_PROVIDE_CRYPTO;
|
||||
provide |= CryptoProvideCrypto;
|
||||
break;
|
||||
|
||||
case TR_CLEAR_PREFERRED:
|
||||
provide |= CRYPTO_PROVIDE_CRYPTO | CRYPTO_PROVIDE_PLAINTEXT;
|
||||
provide |= CryptoProvideCrypto | CryptoProvidePlaintext;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ struct tr_handshake
|
|||
|
||||
static constexpr std::string_view getStateName(handshake_state_t const state)
|
||||
{
|
||||
auto StateStrings = std::array<std::string_view, N_STATES>{
|
||||
auto state_strings = std::array<std::string_view, N_STATES>{
|
||||
"awaiting handshake"sv, /* AWAITING_HANDSHAKE */
|
||||
"awaiting peer id"sv, /* AWAITING_PEER_ID */
|
||||
"awaiting ya"sv, /* AWAITING_YA */
|
||||
|
@ -199,7 +199,7 @@ static constexpr std::string_view getStateName(handshake_state_t const state)
|
|||
"awaiting pad d"sv /* AWAITING_PAD_D */
|
||||
};
|
||||
|
||||
return state < N_STATES ? StateStrings[state] : "unknown state"sv;
|
||||
return state < N_STATES ? state_strings[state] : "unknown state"sv;
|
||||
}
|
||||
|
||||
static void setState(tr_handshake* handshake, handshake_state_t state)
|
||||
|
@ -224,9 +224,9 @@ static bool buildHandshakeMessage(tr_handshake const* const handshake, uint8_t*
|
|||
|
||||
uint8_t* walk = buf;
|
||||
|
||||
walk = std::copy_n(HANDSHAKE_NAME, HANDSHAKE_NAME_LEN, walk);
|
||||
walk = std::copy_n(HANDSHAKE_NAME, HandshakeNameLen, walk);
|
||||
|
||||
memset(walk, 0, HANDSHAKE_FLAGS_LEN);
|
||||
memset(walk, 0, HandshakeFlagsLen);
|
||||
HANDSHAKE_SET_LTEP(walk);
|
||||
HANDSHAKE_SET_FASTEXT(walk);
|
||||
/* Note that this doesn't depend on whether the torrent is private.
|
||||
|
@ -236,12 +236,12 @@ static bool buildHandshakeMessage(tr_handshake const* const handshake, uint8_t*
|
|||
{
|
||||
HANDSHAKE_SET_DHT(walk);
|
||||
}
|
||||
walk += HANDSHAKE_FLAGS_LEN;
|
||||
walk += HandshakeFlagsLen;
|
||||
|
||||
walk = std::copy_n(reinterpret_cast<char const*>(std::data(*info_hash)), std::size(*info_hash), walk);
|
||||
walk = std::copy(std::begin(info->client_peer_id), std::end(info->client_peer_id), walk);
|
||||
|
||||
TR_ASSERT(walk - buf == HANDSHAKE_SIZE);
|
||||
TR_ASSERT(walk - buf == HandshakeSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -257,15 +257,15 @@ enum handshake_parse_err_t
|
|||
|
||||
static handshake_parse_err_t parseHandshake(tr_handshake* handshake, struct evbuffer* inbuf)
|
||||
{
|
||||
tr_logAddTraceHand(handshake, fmt::format("payload: need {}, got {}", HANDSHAKE_SIZE, evbuffer_get_length(inbuf)));
|
||||
tr_logAddTraceHand(handshake, fmt::format("payload: need {}, got {}", HandshakeSize, evbuffer_get_length(inbuf)));
|
||||
|
||||
if (evbuffer_get_length(inbuf) < HANDSHAKE_SIZE)
|
||||
if (evbuffer_get_length(inbuf) < HandshakeSize)
|
||||
{
|
||||
return HANDSHAKE_ENCRYPTION_WRONG;
|
||||
}
|
||||
|
||||
/* confirm the protocol */
|
||||
auto name = std::array<uint8_t, HANDSHAKE_NAME_LEN>{};
|
||||
auto name = std::array<uint8_t, HandshakeNameLen>{};
|
||||
handshake->io->readBytes(std::data(name), std::size(name));
|
||||
if (memcmp(std::data(name), HANDSHAKE_NAME, std::size(name)) != 0)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ static handshake_parse_err_t parseHandshake(tr_handshake* handshake, struct evbu
|
|||
}
|
||||
|
||||
/* read the reserved bytes */
|
||||
auto reserved = std::array<uint8_t, HANDSHAKE_FLAGS_LEN>{};
|
||||
auto reserved = std::array<uint8_t, HandshakeFlagsLen>{};
|
||||
handshake->io->readBytes(std::data(reserved), std::size(reserved));
|
||||
|
||||
/* torrent hash */
|
||||
|
@ -332,7 +332,7 @@ static void sendPublicKeyAndPad(tr_handshake* handshake)
|
|||
// 1 A->B: our public key (Ya) and some padding (PadA)
|
||||
static void sendYa(tr_handshake* handshake)
|
||||
{
|
||||
sendPublicKeyAndPad<PadA_MAXLEN>(handshake);
|
||||
sendPublicKeyAndPad<PadaMaxlen>(handshake);
|
||||
setReadState(handshake, AWAITING_YB);
|
||||
}
|
||||
|
||||
|
@ -344,17 +344,17 @@ static constexpr uint32_t getCryptoSelect(tr_encryption_mode encryption_mode, ui
|
|||
switch (encryption_mode)
|
||||
{
|
||||
case TR_ENCRYPTION_REQUIRED:
|
||||
choices[n_choices++] = CRYPTO_PROVIDE_CRYPTO;
|
||||
choices[n_choices++] = CryptoProvideCrypto;
|
||||
break;
|
||||
|
||||
case TR_ENCRYPTION_PREFERRED:
|
||||
choices[n_choices++] = CRYPTO_PROVIDE_CRYPTO;
|
||||
choices[n_choices++] = CRYPTO_PROVIDE_PLAINTEXT;
|
||||
choices[n_choices++] = CryptoProvideCrypto;
|
||||
choices[n_choices++] = CryptoProvidePlaintext;
|
||||
break;
|
||||
|
||||
case TR_CLEAR_PREFERRED:
|
||||
choices[n_choices++] = CRYPTO_PROVIDE_PLAINTEXT;
|
||||
choices[n_choices++] = CRYPTO_PROVIDE_CRYPTO;
|
||||
choices[n_choices++] = CryptoProvidePlaintext;
|
||||
choices[n_choices++] = CryptoProvideCrypto;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -371,17 +371,17 @@ static constexpr uint32_t getCryptoSelect(tr_encryption_mode encryption_mode, ui
|
|||
|
||||
static ReadState readYb(tr_handshake* handshake, struct evbuffer* inbuf)
|
||||
{
|
||||
size_t needlen = HANDSHAKE_NAME_LEN;
|
||||
size_t needlen = HandshakeNameLen;
|
||||
|
||||
if (evbuffer_get_length(inbuf) < needlen)
|
||||
{
|
||||
return READ_LATER;
|
||||
}
|
||||
|
||||
bool const isEncrypted = memcmp(evbuffer_pullup(inbuf, HANDSHAKE_NAME_LEN), HANDSHAKE_NAME, HANDSHAKE_NAME_LEN) != 0;
|
||||
bool const is_encrypted = memcmp(evbuffer_pullup(inbuf, HandshakeNameLen), HANDSHAKE_NAME, HandshakeNameLen) != 0;
|
||||
|
||||
auto peer_public_key = DH::key_bigend_t{};
|
||||
if (isEncrypted)
|
||||
if (is_encrypted)
|
||||
{
|
||||
needlen = std::size(peer_public_key);
|
||||
|
||||
|
@ -391,9 +391,9 @@ static ReadState readYb(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
}
|
||||
}
|
||||
|
||||
tr_logAddTraceHand(handshake, isEncrypted ? "got an encrypted handshake" : "got a plain handshake");
|
||||
tr_logAddTraceHand(handshake, is_encrypted ? "got an encrypted handshake" : "got a plain handshake");
|
||||
|
||||
if (!isEncrypted)
|
||||
if (!is_encrypted)
|
||||
{
|
||||
setState(handshake, AWAITING_HANDSHAKE);
|
||||
return READ_NOW;
|
||||
|
@ -443,7 +443,7 @@ static ReadState readYb(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
evbuffer_add_uint16(outbuf, 0);
|
||||
|
||||
/* ENCRYPT len(IA)), ENCRYPT(IA) */
|
||||
if (auto msg = std::array<uint8_t, HANDSHAKE_SIZE>{}; buildHandshakeMessage(handshake, std::data(msg)))
|
||||
if (auto msg = std::array<uint8_t, HandshakeSize>{}; buildHandshakeMessage(handshake, std::data(msg)))
|
||||
{
|
||||
evbuffer_add_uint16(outbuf, std::size(msg));
|
||||
evbuffer_add(outbuf, std::data(msg), std::size(msg));
|
||||
|
@ -474,7 +474,7 @@ static ReadState readVC(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
filter.encryptInit(true, handshake->dh, *handshake->io->torrentHash());
|
||||
filter.encrypt(std::size(needle), std::data(needle));
|
||||
|
||||
for (size_t i = 0; i < PadB_MAXLEN; ++i)
|
||||
for (size_t i = 0; i < PadbMaxlen; ++i)
|
||||
{
|
||||
if (evbuffer_get_length(inbuf) < std::size(needle))
|
||||
{
|
||||
|
@ -561,9 +561,9 @@ static ReadState readPadD(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
|
||||
static ReadState readHandshake(tr_handshake* handshake, struct evbuffer* inbuf)
|
||||
{
|
||||
tr_logAddTraceHand(handshake, fmt::format("payload: need {}, got {}", INCOMING_HANDSHAKE_LEN, evbuffer_get_length(inbuf)));
|
||||
tr_logAddTraceHand(handshake, fmt::format("payload: need {}, got {}", IncomingHandshakeLen, evbuffer_get_length(inbuf)));
|
||||
|
||||
if (evbuffer_get_length(inbuf) < INCOMING_HANDSHAKE_LEN)
|
||||
if (evbuffer_get_length(inbuf) < IncomingHandshakeLen)
|
||||
{
|
||||
return READ_LATER;
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ static ReadState readHandshake(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
}
|
||||
|
||||
/* reserved bytes */
|
||||
auto reserved = std::array<uint8_t, HANDSHAKE_FLAGS_LEN>{};
|
||||
auto reserved = std::array<uint8_t, HandshakeFlagsLen>{};
|
||||
handshake->io->readBytes(std::data(reserved), std::size(reserved));
|
||||
|
||||
/**
|
||||
|
@ -654,7 +654,7 @@ static ReadState readHandshake(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
|
||||
if (!handshake->haveSentBitTorrentHandshake)
|
||||
{
|
||||
auto msg = std::array<uint8_t, HANDSHAKE_SIZE>{};
|
||||
auto msg = std::array<uint8_t, HandshakeSize>{};
|
||||
|
||||
if (!buildHandshakeMessage(handshake, std::data(msg)))
|
||||
{
|
||||
|
@ -712,7 +712,7 @@ static ReadState readYa(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
|
||||
// send our public key to the peer
|
||||
tr_logAddTraceHand(handshake, "sending B->A: Diffie Hellman Yb, PadB");
|
||||
sendPublicKeyAndPad<PadB_MAXLEN>(handshake);
|
||||
sendPublicKeyAndPad<PadbMaxlen>(handshake);
|
||||
|
||||
setReadState(handshake, AWAITING_PAD_A);
|
||||
return READ_NOW;
|
||||
|
@ -723,7 +723,7 @@ static ReadState readPadA(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
// find the end of PadA by looking for HASH('req1', S)
|
||||
auto const needle = tr_sha1::digest("req1"sv, handshake->dh.secret());
|
||||
|
||||
for (size_t i = 0; i < PadA_MAXLEN; ++i)
|
||||
for (size_t i = 0; i < PadaMaxlen; ++i)
|
||||
{
|
||||
if (evbuffer_get_length(inbuf) < std::size(needle))
|
||||
{
|
||||
|
@ -807,7 +807,7 @@ static ReadState readCryptoProvide(tr_handshake* handshake, struct evbuffer* inb
|
|||
|
||||
handshake->io->readUint16(&padc_len);
|
||||
tr_logAddTraceHand(handshake, fmt::format("padc is {}", padc_len));
|
||||
if (padc_len > PadC_MAXLEN)
|
||||
if (padc_len > PadcMaxlen)
|
||||
{
|
||||
tr_logAddTraceHand(handshake, "peer's PadC is too big");
|
||||
return tr_handshakeDone(handshake, false);
|
||||
|
@ -826,7 +826,7 @@ static ReadState readPadC(tr_handshake* handshake, struct evbuffer* inbuf)
|
|||
}
|
||||
|
||||
// read the throwaway padc
|
||||
auto pad_c = std::array<char, PadC_MAXLEN>{};
|
||||
auto pad_c = std::array<char, PadcMaxlen>{};
|
||||
handshake->io->readBytes(std::data(pad_c), handshake->pad_c_len);
|
||||
|
||||
/* read ia_len */
|
||||
|
@ -886,7 +886,7 @@ static ReadState readIA(tr_handshake* handshake, struct evbuffer const* inbuf)
|
|||
}
|
||||
|
||||
/* maybe de-encrypt our connection */
|
||||
if (crypto_select == CRYPTO_PROVIDE_PLAINTEXT)
|
||||
if (crypto_select == CryptoProvidePlaintext)
|
||||
{
|
||||
handshake->io->writeBuf(outbuf, false);
|
||||
}
|
||||
|
@ -894,7 +894,7 @@ static ReadState readIA(tr_handshake* handshake, struct evbuffer const* inbuf)
|
|||
tr_logAddTraceHand(handshake, "sending handshake");
|
||||
|
||||
/* send our handshake */
|
||||
if (auto msg = std::array<uint8_t, HANDSHAKE_SIZE>{}; buildHandshakeMessage(handshake, std::data(msg)))
|
||||
if (auto msg = std::array<uint8_t, HandshakeSize>{}; buildHandshakeMessage(handshake, std::data(msg)))
|
||||
{
|
||||
evbuffer_add(outbuf, std::data(msg), std::size(msg));
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
|
@ -915,7 +915,7 @@ static ReadState readIA(tr_handshake* handshake, struct evbuffer const* inbuf)
|
|||
|
||||
static ReadState readPayloadStream(tr_handshake* handshake, struct evbuffer* inbuf)
|
||||
{
|
||||
size_t const needlen = HANDSHAKE_SIZE;
|
||||
size_t const needlen = HandshakeSize;
|
||||
|
||||
tr_logAddTraceHand(
|
||||
handshake,
|
||||
|
@ -952,7 +952,7 @@ static ReadState canRead(tr_peerIo* io, void* vhandshake, size_t* piece)
|
|||
auto* handshake = static_cast<tr_handshake*>(vhandshake);
|
||||
|
||||
auto* const inbuf = io->readBuffer();
|
||||
bool readyForMore = true;
|
||||
bool ready_for_more = true;
|
||||
|
||||
/* no piece data in handshake */
|
||||
*piece = 0;
|
||||
|
@ -960,7 +960,7 @@ static ReadState canRead(tr_peerIo* io, void* vhandshake, size_t* piece)
|
|||
tr_logAddTraceHand(handshake, fmt::format("handling canRead; state is [{}]", getStateName(handshake->state)));
|
||||
|
||||
ReadState ret = READ_NOW;
|
||||
while (readyForMore)
|
||||
while (ready_for_more)
|
||||
{
|
||||
switch (handshake->state)
|
||||
{
|
||||
|
@ -1023,32 +1023,32 @@ static ReadState canRead(tr_peerIo* io, void* vhandshake, size_t* piece)
|
|||
|
||||
if (ret != READ_NOW)
|
||||
{
|
||||
readyForMore = false;
|
||||
ready_for_more = false;
|
||||
}
|
||||
else if (handshake->state == AWAITING_PAD_C)
|
||||
{
|
||||
readyForMore = evbuffer_get_length(inbuf) >= handshake->pad_c_len;
|
||||
ready_for_more = evbuffer_get_length(inbuf) >= handshake->pad_c_len;
|
||||
}
|
||||
else if (handshake->state == AWAITING_PAD_D)
|
||||
{
|
||||
readyForMore = evbuffer_get_length(inbuf) >= handshake->pad_d_len;
|
||||
ready_for_more = evbuffer_get_length(inbuf) >= handshake->pad_d_len;
|
||||
}
|
||||
else if (handshake->state == AWAITING_IA)
|
||||
{
|
||||
readyForMore = evbuffer_get_length(inbuf) >= handshake->ia_len;
|
||||
ready_for_more = evbuffer_get_length(inbuf) >= handshake->ia_len;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool fireDoneFunc(tr_handshake* handshake, bool isConnected)
|
||||
static bool fireDoneFunc(tr_handshake* handshake, bool is_connected)
|
||||
{
|
||||
auto result = tr_handshake_result{};
|
||||
result.handshake = handshake;
|
||||
result.io = handshake->io;
|
||||
result.readAnythingFromPeer = handshake->haveReadAnythingFromPeer;
|
||||
result.isConnected = isConnected;
|
||||
result.isConnected = is_connected;
|
||||
result.userData = handshake->done_func_user_data;
|
||||
result.peer_id = handshake->peer_id;
|
||||
bool const success = (*handshake->done_func)(result);
|
||||
|
@ -1093,7 +1093,7 @@ static void gotError(tr_peerIo* io, short what, void* vhandshake)
|
|||
|
||||
if (handshake->mediator->allowsTCP() && handshake->io->reconnect() == 0)
|
||||
{
|
||||
auto msg = std::array<uint8_t, HANDSHAKE_SIZE>{};
|
||||
auto msg = std::array<uint8_t, HandshakeSize>{};
|
||||
buildHandshakeMessage(handshake, std::data(msg));
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
setReadState(handshake, AWAITING_HANDSHAKE);
|
||||
|
@ -1108,7 +1108,7 @@ static void gotError(tr_peerIo* io, short what, void* vhandshake)
|
|||
handshake->encryption_mode != TR_ENCRYPTION_REQUIRED && handshake->mediator->allowsTCP() &&
|
||||
handshake->io->reconnect() == 0)
|
||||
{
|
||||
auto msg = std::array<uint8_t, HANDSHAKE_SIZE>{};
|
||||
auto msg = std::array<uint8_t, HandshakeSize>{};
|
||||
tr_logAddTraceHand(handshake, "handshake failed, trying plaintext...");
|
||||
buildHandshakeMessage(handshake, std::data(msg));
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
|
@ -1154,7 +1154,7 @@ tr_handshake* tr_handshakeNew(
|
|||
}
|
||||
else
|
||||
{
|
||||
auto msg = std::array<uint8_t, HANDSHAKE_SIZE>{};
|
||||
auto msg = std::array<uint8_t, HandshakeSize>{};
|
||||
buildHandshakeMessage(handshake, std::data(msg));
|
||||
|
||||
handshake->haveSentBitTorrentHandshake = true;
|
||||
|
|
|
@ -192,9 +192,9 @@ void tr_logSetLevel(tr_log_level level)
|
|||
log_state.level = level;
|
||||
}
|
||||
|
||||
void tr_logSetQueueEnabled(bool isEnabled)
|
||||
void tr_logSetQueueEnabled(bool is_enabled)
|
||||
{
|
||||
log_state.queue_enabled_ = isEnabled;
|
||||
log_state.queue_enabled_ = is_enabled;
|
||||
}
|
||||
|
||||
bool tr_logGetQueueEnabled()
|
||||
|
|
|
@ -73,7 +73,7 @@ struct tr_log_message
|
|||
|
||||
[[nodiscard]] bool tr_logGetQueueEnabled();
|
||||
|
||||
void tr_logSetQueueEnabled(bool isEnabled);
|
||||
void tr_logSetQueueEnabled(bool is_enabled);
|
||||
|
||||
[[nodiscard]] tr_log_message* tr_logGetQueue();
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ void tr_netClosePeerSocket(tr_session* session, tr_peer_socket socket)
|
|||
}
|
||||
}
|
||||
|
||||
static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool suppressMsgs, int* errOut)
|
||||
static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool suppress_msgs, int* err_out)
|
||||
{
|
||||
TR_ASSERT(tr_address_is_valid(addr));
|
||||
|
||||
|
@ -425,13 +425,13 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
auto const fd = socket(Domains[addr->type], SOCK_STREAM, 0);
|
||||
if (fd == TR_BAD_SOCKET)
|
||||
{
|
||||
*errOut = sockerrno;
|
||||
*err_out = sockerrno;
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
|
||||
if (evutil_make_socket_nonblocking(fd) == -1)
|
||||
{
|
||||
*errOut = sockerrno;
|
||||
*err_out = sockerrno;
|
||||
tr_netCloseSocket(fd);
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
(setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast<char const*>(&optval), sizeof(optval)) == -1) &&
|
||||
(sockerrno != ENOPROTOOPT)) // if the kernel doesn't support it, ignore it
|
||||
{
|
||||
*errOut = sockerrno;
|
||||
*err_out = sockerrno;
|
||||
tr_netCloseSocket(fd);
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
{
|
||||
int const err = sockerrno;
|
||||
|
||||
if (!suppressMsgs)
|
||||
if (!suppress_msgs)
|
||||
{
|
||||
tr_logAddError(fmt::format(
|
||||
err == EADDRINUSE ?
|
||||
|
@ -472,11 +472,11 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
}
|
||||
|
||||
tr_netCloseSocket(fd);
|
||||
*errOut = err;
|
||||
*err_out = err;
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
|
||||
if (!suppressMsgs)
|
||||
if (!suppress_msgs)
|
||||
{
|
||||
tr_logAddDebug(fmt::format(FMT_STRING("Bound socket {:d} to port {:d} on {:s}"), fd, port.host(), addr->readable()));
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
if (listen(fd, INT_MAX) == -1)
|
||||
#endif /* _WIN32 */
|
||||
{
|
||||
*errOut = sockerrno;
|
||||
*err_out = sockerrno;
|
||||
tr_netCloseSocket(fd);
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
|
@ -507,18 +507,18 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
return fd;
|
||||
}
|
||||
|
||||
tr_socket_t tr_netBindTCP(tr_address const* addr, tr_port port, bool suppressMsgs)
|
||||
tr_socket_t tr_netBindTCP(tr_address const* addr, tr_port port, bool suppress_msgs)
|
||||
{
|
||||
int unused = 0;
|
||||
return tr_netBindTCPImpl(addr, port, suppressMsgs, &unused);
|
||||
return tr_netBindTCPImpl(addr, port, suppress_msgs, &unused);
|
||||
}
|
||||
|
||||
bool tr_net_hasIPv6(tr_port port)
|
||||
{
|
||||
static bool result = false;
|
||||
static bool alreadyDone = false;
|
||||
static bool already_done = false;
|
||||
|
||||
if (!alreadyDone)
|
||||
if (!already_done)
|
||||
{
|
||||
int err = 0;
|
||||
auto const fd = tr_netBindTCPImpl(&tr_in6addr_any, port, true, &err);
|
||||
|
@ -533,7 +533,7 @@ bool tr_net_hasIPv6(tr_port port)
|
|||
tr_netCloseSocket(fd);
|
||||
}
|
||||
|
||||
alreadyDone = true;
|
||||
already_done = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -216,7 +216,7 @@ constexpr bool tr_address_is_valid(tr_address const* a)
|
|||
|
||||
struct tr_session;
|
||||
|
||||
tr_socket_t tr_netBindTCP(tr_address const* addr, tr_port port, bool suppressMsgs);
|
||||
tr_socket_t tr_netBindTCP(tr_address const* addr, tr_port port, bool suppress_msgs);
|
||||
|
||||
tr_socket_t tr_netAccept(tr_session* session, tr_socket_t listening_sockfd, tr_address* setme_addr, tr_port* setme_port);
|
||||
|
||||
|
|
|
@ -91,9 +91,9 @@ bool preallocate_file_full(tr_sys_file_t fd, uint64_t length, tr_error** error)
|
|||
/* fallback: the old-fashioned way */
|
||||
while (success && length > 0)
|
||||
{
|
||||
uint64_t const thisPass = std::min(length, uint64_t{ std::size(buf) });
|
||||
uint64_t const this_pass = std::min(length, uint64_t{ std::size(buf) });
|
||||
uint64_t bytes_written = 0;
|
||||
success = tr_sys_file_write(fd, std::data(buf), thisPass, &bytes_written, &my_error);
|
||||
success = tr_sys_file_write(fd, std::data(buf), this_pass, &bytes_written, &my_error);
|
||||
length -= bytes_written;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ public:
|
|||
tr_peer(tr_torrent const* tor, peer_atom* atom = nullptr);
|
||||
virtual ~tr_peer();
|
||||
|
||||
virtual bool isTransferringPieces(uint64_t now, tr_direction direction, unsigned int* setme_Bps) const = 0;
|
||||
virtual bool isTransferringPieces(uint64_t now, tr_direction dir, unsigned int* setme_bytes_per_second) const = 0;
|
||||
|
||||
[[nodiscard]] virtual std::string readable() const = 0;
|
||||
|
||||
|
|
|
@ -131,9 +131,9 @@ static void canReadWrapper(tr_peerIo* io_in)
|
|||
while (!done && !err)
|
||||
{
|
||||
size_t piece = 0;
|
||||
size_t const oldLen = evbuffer_get_length(io->inbuf.get());
|
||||
size_t const old_len = evbuffer_get_length(io->inbuf.get());
|
||||
int const ret = io->canRead(io.get(), io->userData, &piece);
|
||||
size_t const used = oldLen - evbuffer_get_length(io->inbuf.get());
|
||||
size_t const used = old_len - evbuffer_get_length(io->inbuf.get());
|
||||
unsigned int const overhead = guessPacketOverhead(used);
|
||||
|
||||
if (piece != 0 || piece != used)
|
||||
|
@ -822,11 +822,11 @@ static unsigned int getDesiredOutputBufferSize(tr_peerIo const* io, uint64_t now
|
|||
* being large enough to hold the next 20 seconds' worth of input,
|
||||
* or a few blocks, whichever is bigger.
|
||||
* It's okay to tweak this as needed */
|
||||
unsigned int const currentSpeed_Bps = io->bandwidth().getPieceSpeedBytesPerSecond(now, TR_UP);
|
||||
unsigned int const current_speed_bytes_per_second = io->bandwidth().getPieceSpeedBytesPerSecond(now, TR_UP);
|
||||
unsigned int const period = 15U; /* arbitrary */
|
||||
/* the 3 is arbitrary; the .5 is to leave room for messages */
|
||||
static auto const ceiling = (unsigned int)(tr_block_info::BlockSize * 3.5);
|
||||
return std::max(ceiling, currentSpeed_Bps * period);
|
||||
return std::max(ceiling, current_speed_bytes_per_second * period);
|
||||
}
|
||||
|
||||
size_t tr_peerIo::getWriteBufferSpace(uint64_t now) const
|
||||
|
@ -863,17 +863,17 @@ static inline void processBuffer(tr_peerIo& io, evbuffer* buffer, size_t offset,
|
|||
TR_ASSERT(size == 0);
|
||||
}
|
||||
|
||||
void tr_peerIo::writeBuf(struct evbuffer* buf, bool isPieceData)
|
||||
void tr_peerIo::writeBuf(struct evbuffer* buf, bool is_piece_data)
|
||||
{
|
||||
size_t const byteCount = evbuffer_get_length(buf);
|
||||
size_t const n_bytes = evbuffer_get_length(buf);
|
||||
|
||||
if (isEncrypted())
|
||||
{
|
||||
processBuffer(*this, buf, 0, byteCount);
|
||||
processBuffer(*this, buf, 0, n_bytes);
|
||||
}
|
||||
|
||||
evbuffer_add_buffer(outbuf.get(), buf);
|
||||
outbuf_info.emplace_back(byteCount, isPieceData);
|
||||
outbuf_info.emplace_back(n_bytes, is_piece_data);
|
||||
}
|
||||
|
||||
void tr_peerIo::writeBytes(void const* writeme, size_t writeme_len, bool is_piece_data)
|
||||
|
|
|
@ -146,7 +146,7 @@ public:
|
|||
int flush(tr_direction dir, size_t byte_limit);
|
||||
|
||||
void writeBytes(void const* writeme, size_t writeme_len, bool is_piece_data);
|
||||
void writeBuf(struct evbuffer* buf, bool isPieceData);
|
||||
void writeBuf(struct evbuffer* buf, bool is_piece_data);
|
||||
size_t getWriteBufferSpace(uint64_t now) const;
|
||||
|
||||
[[nodiscard]] auto hasBandwidthLeft(tr_direction dir) noexcept
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
return bandwidth_.clamp(dir, 1024) > 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto getPieceSpeed_Bps(uint64_t now, tr_direction dir) noexcept
|
||||
[[nodiscard]] auto getPieceSpeedBytesPerSecond(uint64_t now, tr_direction dir) noexcept
|
||||
{
|
||||
return bandwidth_.getPieceSpeedBytesPerSecond(now, dir);
|
||||
}
|
||||
|
|
|
@ -630,11 +630,11 @@ private:
|
|||
*** tr_peer virtual functions
|
||||
**/
|
||||
|
||||
unsigned int tr_peerGetPieceSpeed_Bps(tr_peer const* peer, uint64_t now, tr_direction direction)
|
||||
unsigned int tr_peerGetPieceSpeedBytesPerSecond(tr_peer const* peer, uint64_t now, tr_direction direction)
|
||||
{
|
||||
unsigned int Bps = 0;
|
||||
peer->isTransferringPieces(now, direction, &Bps);
|
||||
return Bps;
|
||||
unsigned int bytes_per_second = 0;
|
||||
peer->isTransferringPieces(now, direction, &bytes_per_second);
|
||||
return bytes_per_second;
|
||||
}
|
||||
|
||||
tr_peer::tr_peer(tr_torrent const* tor, peer_atom* atom_in)
|
||||
|
@ -949,7 +949,7 @@ static void peerSuggestedPiece(
|
|||
|
||||
void tr_peerMgrPieceCompleted(tr_torrent* tor, tr_piece_index_t p)
|
||||
{
|
||||
bool pieceCameFromPeers = false;
|
||||
bool piece_came_from_peers = false;
|
||||
tr_swarm* const s = tor->swarm;
|
||||
|
||||
/* walk through our peers */
|
||||
|
@ -958,13 +958,13 @@ void tr_peerMgrPieceCompleted(tr_torrent* tor, tr_piece_index_t p)
|
|||
// notify the peer that we now have this piece
|
||||
peer->on_piece_completed(p);
|
||||
|
||||
if (!pieceCameFromPeers)
|
||||
if (!piece_came_from_peers)
|
||||
{
|
||||
pieceCameFromPeers = peer->blame.test(p);
|
||||
piece_came_from_peers = peer->blame.test(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (pieceCameFromPeers) /* webseed downloads don't belong in announce totals */
|
||||
if (piece_came_from_peers) /* webseed downloads don't belong in announce totals */
|
||||
{
|
||||
tr_announcerAddBytes(tor, TR_ANN_DOWN, tor->pieceSize(p));
|
||||
}
|
||||
|
@ -1297,9 +1297,9 @@ size_t tr_peerMgrAddPex(tr_torrent* tor, uint8_t from, tr_pex const* pex, size_t
|
|||
return n_used;
|
||||
}
|
||||
|
||||
std::vector<tr_pex> tr_peerMgrCompactToPex(void const* compact, size_t compactLen, uint8_t const* added_f, size_t added_f_len)
|
||||
std::vector<tr_pex> tr_peerMgrCompactToPex(void const* compact, size_t compact_len, uint8_t const* added_f, size_t added_f_len)
|
||||
{
|
||||
size_t const n = compactLen / 6;
|
||||
size_t const n = compact_len / 6;
|
||||
auto const* walk = static_cast<uint8_t const*>(compact);
|
||||
auto pex = std::vector<tr_pex>(n);
|
||||
|
||||
|
@ -1317,9 +1317,9 @@ std::vector<tr_pex> tr_peerMgrCompactToPex(void const* compact, size_t compactLe
|
|||
return pex;
|
||||
}
|
||||
|
||||
std::vector<tr_pex> tr_peerMgrCompact6ToPex(void const* compact, size_t compactLen, uint8_t const* added_f, size_t added_f_len)
|
||||
std::vector<tr_pex> tr_peerMgrCompact6ToPex(void const* compact, size_t compact_len, uint8_t const* added_f, size_t added_f_len)
|
||||
{
|
||||
size_t const n = compactLen / 18;
|
||||
size_t const n = compact_len / 18;
|
||||
auto const* walk = static_cast<uint8_t const*>(compact);
|
||||
auto pex = std::vector<tr_pex>(n);
|
||||
|
||||
|
@ -1341,27 +1341,27 @@ std::vector<tr_pex> tr_peerMgrCompact6ToPex(void const* compact, size_t compactL
|
|||
***
|
||||
**/
|
||||
|
||||
void tr_peerMgrGotBadPiece(tr_torrent* tor, tr_piece_index_t pieceIndex)
|
||||
void tr_peerMgrGotBadPiece(tr_torrent* tor, tr_piece_index_t piece_index)
|
||||
{
|
||||
auto* const swarm = tor->swarm;
|
||||
auto const byteCount = tor->pieceSize(pieceIndex);
|
||||
auto const byte_count = tor->pieceSize(piece_index);
|
||||
|
||||
for (auto* const peer : swarm->peers)
|
||||
{
|
||||
if (peer->blame.test(pieceIndex))
|
||||
if (peer->blame.test(piece_index))
|
||||
{
|
||||
tr_logAddTraceSwarm(
|
||||
swarm,
|
||||
fmt::format(
|
||||
"peer {} contributed to corrupt piece ({}); now has {} strikes",
|
||||
peer->readable(),
|
||||
pieceIndex,
|
||||
piece_index,
|
||||
peer->strikes + 1));
|
||||
swarm->addStrike(peer);
|
||||
}
|
||||
}
|
||||
|
||||
tr_announcerAddBytes(tor, TR_ANN_CORRUPT, byteCount);
|
||||
tr_announcerAddBytes(tor, TR_ANN_CORRUPT, byte_count);
|
||||
}
|
||||
|
||||
namespace get_peers_helpers
|
||||
|
@ -1699,8 +1699,8 @@ namespace peer_stat_helpers
|
|||
stats.progress = peer->percentDone();
|
||||
stats.isUTP = peer->is_utp_connection();
|
||||
stats.isEncrypted = peer->is_encrypted();
|
||||
stats.rateToPeer_KBps = tr_toSpeedKBps(tr_peerGetPieceSpeed_Bps(peer, now_msec, TR_CLIENT_TO_PEER));
|
||||
stats.rateToClient_KBps = tr_toSpeedKBps(tr_peerGetPieceSpeed_Bps(peer, now_msec, TR_PEER_TO_CLIENT));
|
||||
stats.rateToPeer_KBps = tr_toSpeedKBps(tr_peerGetPieceSpeedBytesPerSecond(peer, now_msec, TR_CLIENT_TO_PEER));
|
||||
stats.rateToClient_KBps = tr_toSpeedKBps(tr_peerGetPieceSpeedBytesPerSecond(peer, now_msec, TR_PEER_TO_CLIENT));
|
||||
stats.peerIsChoked = peer->is_peer_choked();
|
||||
stats.peerIsInterested = peer->is_peer_interested();
|
||||
stats.clientIsChoked = peer->is_client_choked();
|
||||
|
@ -1894,7 +1894,7 @@ void rechokeDownloads(tr_swarm* s)
|
|||
{
|
||||
static auto constexpr MinInterestingPeers = uint16_t{ 5 };
|
||||
|
||||
auto const peerCount = s->peerCount();
|
||||
auto const peer_count = s->peerCount();
|
||||
auto const& peers = s->peers;
|
||||
auto const now = tr_time();
|
||||
|
||||
|
@ -1942,34 +1942,34 @@ void rechokeDownloads(tr_swarm* s)
|
|||
|
||||
if (cancels > 0)
|
||||
{
|
||||
/* cancelRate: of the block requests we've recently made, the percentage we cancelled.
|
||||
/* cancel_rate: of the block requests we've recently made, the percentage we cancelled.
|
||||
* higher values indicate more congestion. */
|
||||
double const cancelRate = cancels / (double)(cancels + blocks);
|
||||
double const mult = 1 - std::min(cancelRate, 0.5);
|
||||
double const cancel_rate = cancels / (double)(cancels + blocks);
|
||||
double const mult = 1 - std::min(cancel_rate, 0.5);
|
||||
max_peers = s->interested_count * mult;
|
||||
tr_logAddTraceSwarm(
|
||||
s,
|
||||
fmt::format(
|
||||
"cancel rate is {} -- reducing the number of peers we're interested in by {} percent",
|
||||
cancelRate,
|
||||
cancel_rate,
|
||||
mult * 100));
|
||||
s->lastCancel = now;
|
||||
}
|
||||
|
||||
time_t const timeSinceCancel = now - s->lastCancel;
|
||||
time_t const time_since_cancel = now - s->lastCancel;
|
||||
|
||||
if (timeSinceCancel != 0)
|
||||
if (time_since_cancel != 0)
|
||||
{
|
||||
int const maxIncrease = 15;
|
||||
time_t const maxHistory = 2 * CancelHistorySec;
|
||||
double const mult = std::min(timeSinceCancel, maxHistory) / (double)maxHistory;
|
||||
int const inc = maxIncrease * mult;
|
||||
int const max_increase = 15;
|
||||
time_t const max_history = 2 * CancelHistorySec;
|
||||
double const mult = std::min(time_since_cancel, max_history) / static_cast<double>(max_history);
|
||||
int const inc = max_increase * mult;
|
||||
max_peers = s->max_peers + inc;
|
||||
tr_logAddTraceSwarm(
|
||||
s,
|
||||
fmt::format(
|
||||
"time since last cancel is {} -- increasing the number of peers we're interested in by {}",
|
||||
timeSinceCancel,
|
||||
time_since_cancel,
|
||||
inc));
|
||||
}
|
||||
}
|
||||
|
@ -1979,9 +1979,9 @@ void rechokeDownloads(tr_swarm* s)
|
|||
|
||||
s->max_peers = max_peers;
|
||||
|
||||
if (peerCount > 0)
|
||||
if (peer_count > 0)
|
||||
{
|
||||
rechoke.reserve(peerCount);
|
||||
rechoke.reserve(peer_count);
|
||||
|
||||
auto const* const tor = s->tor;
|
||||
int const n = tor->pieceCount();
|
||||
|
@ -2126,18 +2126,19 @@ struct ChokeData
|
|||
{
|
||||
if (tor->isDone())
|
||||
{
|
||||
return tr_peerGetPieceSpeed_Bps(peer, now, TR_CLIENT_TO_PEER);
|
||||
return tr_peerGetPieceSpeedBytesPerSecond(peer, now, TR_CLIENT_TO_PEER);
|
||||
}
|
||||
|
||||
/* downloading a private torrent... take upload speed into account
|
||||
* because there may only be a small window of opportunity to share */
|
||||
if (tor->isPrivate())
|
||||
{
|
||||
return tr_peerGetPieceSpeed_Bps(peer, now, TR_PEER_TO_CLIENT) + tr_peerGetPieceSpeed_Bps(peer, now, TR_CLIENT_TO_PEER);
|
||||
return tr_peerGetPieceSpeedBytesPerSecond(peer, now, TR_PEER_TO_CLIENT) +
|
||||
tr_peerGetPieceSpeedBytesPerSecond(peer, now, TR_CLIENT_TO_PEER);
|
||||
}
|
||||
|
||||
/* downloading a public torrent */
|
||||
return tr_peerGetPieceSpeed_Bps(peer, now, TR_PEER_TO_CLIENT);
|
||||
return tr_peerGetPieceSpeedBytesPerSecond(peer, now, TR_PEER_TO_CLIENT);
|
||||
}
|
||||
|
||||
// an optimistically unchoked peer is immune from rechoking
|
||||
|
@ -2150,13 +2151,13 @@ void rechokeUploads(tr_swarm* s, uint64_t const now)
|
|||
{
|
||||
auto const lock = s->unique_lock();
|
||||
|
||||
auto const peerCount = s->peerCount();
|
||||
auto const peer_count = s->peerCount();
|
||||
auto& peers = s->peers;
|
||||
auto choked = std::vector<ChokeData>{};
|
||||
choked.reserve(peerCount);
|
||||
choked.reserve(peer_count);
|
||||
auto const* const session = s->manager->session;
|
||||
bool const chokeAll = !s->tor->clientCanUpload();
|
||||
bool const isMaxedOut = isBandwidthMaxedOut(s->tor->bandwidth_, now, TR_UP);
|
||||
bool const choke_all = !s->tor->clientCanUpload();
|
||||
bool const is_maxed_out = isBandwidthMaxedOut(s->tor->bandwidth_, now, TR_UP);
|
||||
|
||||
/* an optimistic unchoke peer's "optimistic"
|
||||
* state lasts for N calls to rechokeUploads(). */
|
||||
|
@ -2178,7 +2179,7 @@ void rechokeUploads(tr_swarm* s, uint64_t const now)
|
|||
/* choke seeds and partial seeds */
|
||||
peer->set_choke(true);
|
||||
}
|
||||
else if (chokeAll)
|
||||
else if (choke_all)
|
||||
{
|
||||
/* choke everyone if we're not uploading */
|
||||
peer->set_choke(true);
|
||||
|
@ -2222,7 +2223,7 @@ void rechokeUploads(tr_swarm* s, uint64_t const now)
|
|||
break;
|
||||
}
|
||||
|
||||
item.is_choked = isMaxedOut ? item.was_choked : false;
|
||||
item.is_choked = is_maxed_out ? item.was_choked : false;
|
||||
|
||||
++checked_choke_count;
|
||||
|
||||
|
@ -2233,7 +2234,7 @@ void rechokeUploads(tr_swarm* s, uint64_t const now)
|
|||
}
|
||||
|
||||
/* optimistic unchoke */
|
||||
if (s->optimistic == nullptr && !isMaxedOut && checked_choke_count < std::size(choked))
|
||||
if (s->optimistic == nullptr && !is_maxed_out && checked_choke_count < std::size(choked))
|
||||
{
|
||||
auto rand_pool = std::vector<ChokeData*>{};
|
||||
|
||||
|
@ -2310,7 +2311,7 @@ auto constexpr MinUploadIdleSecs = int{ 60 };
|
|||
// when few peers are available, keep idle ones this long
|
||||
auto constexpr MaxUploadIdleSecs = int{ 60 * 5 };
|
||||
|
||||
[[nodiscard]] bool shouldPeerBeClosed(tr_swarm const* s, tr_peerMsgs const* peer, int peerCount, time_t const now)
|
||||
[[nodiscard]] bool shouldPeerBeClosed(tr_swarm const* s, tr_peerMsgs const* peer, int peer_count, time_t const now)
|
||||
{
|
||||
/* if it's marked for purging, close it */
|
||||
if (peer->do_purge)
|
||||
|
@ -2331,21 +2332,22 @@ auto constexpr MaxUploadIdleSecs = int{ 60 * 5 };
|
|||
/* disconnect if it's been too long since piece data has been transferred.
|
||||
* this is on a sliding scale based on number of available peers... */
|
||||
{
|
||||
auto const relaxStrictnessIfFewerThanN = std::lround(getMaxPeerCount(tor) * 0.9);
|
||||
auto const relax_strictness_if_fewer_than_n = std::lround(getMaxPeerCount(tor) * 0.9);
|
||||
/* if we have >= relaxIfFewerThan, strictness is 100%.
|
||||
* if we have zero connections, strictness is 0% */
|
||||
float const strictness = peerCount >= relaxStrictnessIfFewerThanN ? 1.0 :
|
||||
peerCount / (float)relaxStrictnessIfFewerThanN;
|
||||
float const strictness = peer_count >= relax_strictness_if_fewer_than_n ?
|
||||
1.0 :
|
||||
peer_count / (float)relax_strictness_if_fewer_than_n;
|
||||
int const lo = MinUploadIdleSecs;
|
||||
int const hi = MaxUploadIdleSecs;
|
||||
int const limit = hi - (hi - lo) * strictness;
|
||||
int const idleTime = now - std::max(atom->time, atom->piece_data_time);
|
||||
int const idle_time = now - std::max(atom->time, atom->piece_data_time);
|
||||
|
||||
if (idleTime > limit)
|
||||
if (idle_time > limit)
|
||||
{
|
||||
tr_logAddTraceSwarm(
|
||||
s,
|
||||
fmt::format("purging peer {} because it's been {} secs since we shared anything", peer->readable(), idleTime));
|
||||
fmt::format("purging peer {} because it's been {} secs since we shared anything", peer->readable(), idle_time));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,9 +123,13 @@ size_t tr_peerMgrCountActiveRequestsToPeer(tr_torrent const* torrent, tr_peer co
|
|||
|
||||
void tr_peerMgrAddIncoming(tr_peerMgr* manager, tr_address const* addr, tr_port port, struct tr_peer_socket const socket);
|
||||
|
||||
std::vector<tr_pex> tr_peerMgrCompactToPex(void const* compact, size_t compactLen, uint8_t const* added_f, size_t added_f_len);
|
||||
std::vector<tr_pex> tr_peerMgrCompactToPex(void const* compact, size_t compact_len, uint8_t const* added_f, size_t added_f_len);
|
||||
|
||||
std::vector<tr_pex> tr_peerMgrCompact6ToPex(void const* compact, size_t compactLen, uint8_t const* added_f, size_t added_f_len);
|
||||
std::vector<tr_pex> tr_peerMgrCompact6ToPex(
|
||||
void const* compact,
|
||||
size_t compact_len,
|
||||
uint8_t const* added_f,
|
||||
size_t added_f_len);
|
||||
|
||||
size_t tr_peerMgrAddPex(tr_torrent* tor, uint8_t from, tr_pex const* pex, size_t n_pex);
|
||||
|
||||
|
@ -166,11 +170,11 @@ struct tr_peer_stat* tr_peerMgrPeerStats(tr_torrent const* tor, int* setme_count
|
|||
|
||||
tr_webseed_view tr_peerMgrWebseed(tr_torrent const* tor, size_t i);
|
||||
|
||||
unsigned int tr_peerGetPieceSpeed_Bps(tr_peer const* peer, uint64_t now, tr_direction direction);
|
||||
unsigned int tr_peerGetPieceSpeedBytesPerSecond(tr_peer const* peer, uint64_t now, tr_direction direction);
|
||||
|
||||
void tr_peerMgrClearInterest(tr_torrent* tor);
|
||||
|
||||
void tr_peerMgrGotBadPiece(tr_torrent* tor, tr_piece_index_t pieceIndex);
|
||||
void tr_peerMgrGotBadPiece(tr_torrent* tor, tr_piece_index_t piece_index);
|
||||
|
||||
void tr_peerMgrPieceCompleted(tr_torrent* tor, tr_piece_index_t pieceIndex);
|
||||
|
||||
|
|
|
@ -53,10 +53,12 @@ auto export_bits(UIntWide i)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// NOLINTBEGIN(readability-identifier-naming)
|
||||
auto WIDE_INTEGER_CONSTEXPR const G = wi::key_t{ "2" };
|
||||
auto WIDE_INTEGER_CONSTEXPR const P = wi::key_t{
|
||||
"0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A63A36210000000000090563"
|
||||
};
|
||||
// NOLINTEND(readability-identifier-naming)
|
||||
|
||||
} // namespace wi
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ class tr_peerMsgsImpl;
|
|||
// TODO: make these to be member functions
|
||||
static ReadState canRead(tr_peerIo* io, void* vmsgs, size_t* piece);
|
||||
static void cancelAllRequestsToClient(tr_peerMsgsImpl* msgs);
|
||||
static void didWrite(tr_peerIo* io, size_t bytesWritten, bool wasPieceData, void* vmsgs);
|
||||
static void didWrite(tr_peerIo* io, size_t bytes_written, bool was_piece_data, void* vmsgs);
|
||||
static void gotError(tr_peerIo* io, short what, void* vmsgs);
|
||||
static void peerPulse(void* vmsgs);
|
||||
static void protocolSendCancel(tr_peerMsgsImpl* msgs, struct peer_request const& req);
|
||||
|
@ -253,7 +253,7 @@ public:
|
|||
peer_atom* atom_in,
|
||||
std::shared_ptr<tr_peerIo> io_in,
|
||||
tr_peer_callback callback,
|
||||
void* callbackData)
|
||||
void* callback_data)
|
||||
: tr_peerMsgs{ torrent_in, atom_in }
|
||||
, outMessagesBatchPeriod{ LowPriorityIntervalSecs }
|
||||
, torrent{ torrent_in }
|
||||
|
@ -261,7 +261,7 @@ public:
|
|||
, io{ std::move(io_in) }
|
||||
, have_{ torrent_in->pieceCount() }
|
||||
, callback_{ callback }
|
||||
, callbackData_{ callbackData }
|
||||
, callback_data_{ callback_data }
|
||||
{
|
||||
if (torrent->allowsPex())
|
||||
{
|
||||
|
@ -327,16 +327,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool isTransferringPieces(uint64_t now, tr_direction direction, unsigned int* setme_Bps) const override
|
||||
bool isTransferringPieces(uint64_t now, tr_direction dir, unsigned int* setme_bytes_per_second) const override
|
||||
{
|
||||
auto const Bps = io->getPieceSpeed_Bps(now, direction);
|
||||
auto const bytes_per_second = io->getPieceSpeedBytesPerSecond(now, dir);
|
||||
|
||||
if (setme_Bps != nullptr)
|
||||
if (setme_bytes_per_second != nullptr)
|
||||
{
|
||||
*setme_Bps = Bps;
|
||||
*setme_bytes_per_second = bytes_per_second;
|
||||
}
|
||||
|
||||
return Bps > 0;
|
||||
return bytes_per_second > 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t activeReqCount(tr_direction dir) const noexcept override
|
||||
|
@ -465,9 +465,9 @@ public:
|
|||
void set_choke(bool peer_is_choked) override
|
||||
{
|
||||
time_t const now = tr_time();
|
||||
time_t const fibrillationTime = now - MinChokePeriodSec;
|
||||
time_t const fibrillation_time = now - MinChokePeriodSec;
|
||||
|
||||
if (chokeChangedAt > fibrillationTime)
|
||||
if (chokeChangedAt > fibrillation_time)
|
||||
{
|
||||
// TODO logtrace(msgs, "Not changing choke to %d to avoid fibrillation", peer_is_choked);
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ public:
|
|||
{
|
||||
if (callback_ != nullptr)
|
||||
{
|
||||
(*callback_)(this, peer_event, callbackData_);
|
||||
(*callback_)(this, peer_event, callback_data_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,18 +580,19 @@ private:
|
|||
// Get the rate limit we should use.
|
||||
// TODO: this needs to consider all the other peers as well...
|
||||
uint64_t const now = tr_time_msec();
|
||||
auto rate_Bps = tr_peerGetPieceSpeed_Bps(this, now, TR_PEER_TO_CLIENT);
|
||||
auto rate_bytes_per_second = tr_peerGetPieceSpeedBytesPerSecond(this, now, TR_PEER_TO_CLIENT);
|
||||
if (tr_torrentUsesSpeedLimit(torrent, TR_PEER_TO_CLIENT))
|
||||
{
|
||||
rate_Bps = std::min(rate_Bps, torrent->speedLimitBps(TR_PEER_TO_CLIENT));
|
||||
rate_bytes_per_second = std::min(rate_bytes_per_second, torrent->speedLimitBps(TR_PEER_TO_CLIENT));
|
||||
}
|
||||
|
||||
// honor the session limits, if enabled
|
||||
if (tr_torrentUsesSessionLimits(torrent))
|
||||
{
|
||||
if (auto const irate_Bps = torrent->session->activeSpeedLimitBps(TR_PEER_TO_CLIENT); irate_Bps)
|
||||
if (auto const irate_bytes_per_second = torrent->session->activeSpeedLimitBps(TR_PEER_TO_CLIENT);
|
||||
irate_bytes_per_second)
|
||||
{
|
||||
rate_Bps = std::min(rate_Bps, *irate_Bps);
|
||||
rate_bytes_per_second = std::min(rate_bytes_per_second, *irate_bytes_per_second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,7 +600,7 @@ private:
|
|||
// many requests we should send to this peer
|
||||
size_t constexpr Floor = 32;
|
||||
size_t constexpr Seconds = RequestBufSecs;
|
||||
size_t const estimated_blocks_in_period = (rate_Bps * Seconds) / tr_block_info::BlockSize;
|
||||
size_t const estimated_blocks_in_period = (rate_bytes_per_second * Seconds) / tr_block_info::BlockSize;
|
||||
size_t const ceil = reqq ? *reqq : 250;
|
||||
return std::clamp(estimated_blocks_in_period, Floor, ceil);
|
||||
}
|
||||
|
@ -748,7 +749,7 @@ private:
|
|||
std::array<bool, 2> is_active_ = { false, false };
|
||||
|
||||
tr_peer_callback const callback_;
|
||||
void* const callbackData_;
|
||||
void* const callback_data_;
|
||||
|
||||
mutable std::optional<float> percent_done_;
|
||||
|
||||
|
@ -1162,8 +1163,8 @@ static void parseUtMetadata(tr_peerMsgsImpl* msgs, uint32_t msglen)
|
|||
if (msg_type == MetadataMsgType::Data && !msgs->torrent->hasMetainfo() && msg_end - benc_end <= METADATA_PIECE_SIZE &&
|
||||
piece * METADATA_PIECE_SIZE + (msg_end - benc_end) <= total_size)
|
||||
{
|
||||
int const pieceLen = msg_end - benc_end;
|
||||
tr_torrentSetMetadataPiece(msgs->torrent, piece, benc_end, pieceLen);
|
||||
int const piece_len = msg_end - benc_end;
|
||||
tr_torrentSetMetadataPiece(msgs->torrent, piece, benc_end, piece_len);
|
||||
}
|
||||
|
||||
if (msg_type == MetadataMsgType::Request)
|
||||
|
@ -1848,13 +1849,13 @@ static int clientGotBlock(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void didWrite(tr_peerIo* io, size_t bytesWritten, bool wasPieceData, void* vmsgs)
|
||||
static void didWrite(tr_peerIo* io, size_t bytes_written, bool was_piece_data, void* vmsgs)
|
||||
{
|
||||
auto* msgs = static_cast<tr_peerMsgsImpl*>(vmsgs);
|
||||
|
||||
if (wasPieceData)
|
||||
if (was_piece_data)
|
||||
{
|
||||
msgs->publish(tr_peer_event::SentPieceData(bytesWritten));
|
||||
msgs->publish(tr_peer_event::SentPieceData(bytes_written));
|
||||
}
|
||||
|
||||
if (tr_isPeerIo(io) && io->userData != nullptr)
|
||||
|
@ -1987,23 +1988,23 @@ static void updateBlockRequests(tr_peerMsgsImpl* msgs)
|
|||
|
||||
static size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
|
||||
{
|
||||
size_t bytesWritten = 0;
|
||||
size_t bytes_written = 0;
|
||||
struct peer_request req;
|
||||
bool const haveMessages = evbuffer_get_length(msgs->outMessages) != 0;
|
||||
bool const have_messages = evbuffer_get_length(msgs->outMessages) != 0;
|
||||
bool const fext = msgs->io->supportsFEXT();
|
||||
|
||||
/**
|
||||
*** Protocol messages
|
||||
**/
|
||||
|
||||
if (haveMessages && msgs->outMessagesBatchedAt == 0) /* fresh batch */
|
||||
if (have_messages && msgs->outMessagesBatchedAt == 0) /* fresh batch */
|
||||
{
|
||||
logtrace(
|
||||
msgs,
|
||||
fmt::format(FMT_STRING("started an outMessages batch (length is {:d})"), evbuffer_get_length(msgs->outMessages)));
|
||||
msgs->outMessagesBatchedAt = now;
|
||||
}
|
||||
else if (haveMessages && now - msgs->outMessagesBatchedAt >= msgs->outMessagesBatchPeriod)
|
||||
else if (have_messages && now - msgs->outMessagesBatchedAt >= msgs->outMessagesBatchPeriod)
|
||||
{
|
||||
size_t const len = evbuffer_get_length(msgs->outMessages);
|
||||
/* flush the protocol messages */
|
||||
|
@ -2012,7 +2013,7 @@ static size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
|
|||
msgs->clientSentAnythingAt = now;
|
||||
msgs->outMessagesBatchedAt = 0;
|
||||
msgs->outMessagesBatchPeriod = LowPriorityIntervalSecs;
|
||||
bytesWritten += len;
|
||||
bytes_written += len;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2130,7 +2131,7 @@ static size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
|
|||
logtrace(msgs, fmt::format(FMT_STRING("sending block {:d}:{:d}->{:d}"), req.index, req.offset, req.length));
|
||||
TR_ASSERT(n == msglen);
|
||||
msgs->io->writeBuf(out, true);
|
||||
bytesWritten += n;
|
||||
bytes_written += n;
|
||||
msgs->clientSentAnythingAt = now;
|
||||
msgs->blocks_sent_to_peer.add(tr_time(), 1);
|
||||
}
|
||||
|
@ -2139,7 +2140,7 @@ static size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
|
|||
|
||||
if (err)
|
||||
{
|
||||
bytesWritten = 0;
|
||||
bytes_written = 0;
|
||||
msgs = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -2165,7 +2166,7 @@ static size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
|
|||
msgs->pokeBatchPeriod(ImmediatePriorityIntervalSecs);
|
||||
}
|
||||
|
||||
return bytesWritten;
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
static void peerPulse(void* vmsgs)
|
||||
|
|
|
@ -18,411 +18,411 @@ using namespace std::literals;
|
|||
namespace
|
||||
{
|
||||
|
||||
auto constexpr my_static = std::array<std::string_view, 399>{ ""sv,
|
||||
"activeTorrentCount"sv,
|
||||
"activity-date"sv,
|
||||
"activityDate"sv,
|
||||
"added"sv,
|
||||
"added-date"sv,
|
||||
"added.f"sv,
|
||||
"added6"sv,
|
||||
"added6.f"sv,
|
||||
"addedDate"sv,
|
||||
"address"sv,
|
||||
"alt-speed-down"sv,
|
||||
"alt-speed-enabled"sv,
|
||||
"alt-speed-time-begin"sv,
|
||||
"alt-speed-time-day"sv,
|
||||
"alt-speed-time-enabled"sv,
|
||||
"alt-speed-time-end"sv,
|
||||
"alt-speed-up"sv,
|
||||
"announce"sv,
|
||||
"announce-ip"sv,
|
||||
"announce-ip-enabled"sv,
|
||||
"announce-list"sv,
|
||||
"announceState"sv,
|
||||
"anti-brute-force-enabled"sv,
|
||||
"anti-brute-force-threshold"sv,
|
||||
"arguments"sv,
|
||||
"availability"sv,
|
||||
"bandwidth-priority"sv,
|
||||
"bandwidthPriority"sv,
|
||||
"bind-address-ipv4"sv,
|
||||
"bind-address-ipv6"sv,
|
||||
"bitfield"sv,
|
||||
"blocklist-date"sv,
|
||||
"blocklist-enabled"sv,
|
||||
"blocklist-size"sv,
|
||||
"blocklist-updates-enabled"sv,
|
||||
"blocklist-url"sv,
|
||||
"blocks"sv,
|
||||
"bytesCompleted"sv,
|
||||
"cache-size-mb"sv,
|
||||
"clientIsChoked"sv,
|
||||
"clientIsInterested"sv,
|
||||
"clientName"sv,
|
||||
"comment"sv,
|
||||
"comment_utf_8"sv,
|
||||
"compact-view"sv,
|
||||
"complete"sv,
|
||||
"config-dir"sv,
|
||||
"cookies"sv,
|
||||
"corrupt"sv,
|
||||
"corruptEver"sv,
|
||||
"created by"sv,
|
||||
"created by.utf-8"sv,
|
||||
"creation date"sv,
|
||||
"creator"sv,
|
||||
"cumulative-stats"sv,
|
||||
"current-stats"sv,
|
||||
"date"sv,
|
||||
"dateCreated"sv,
|
||||
"default-trackers"sv,
|
||||
"delete-local-data"sv,
|
||||
"desiredAvailable"sv,
|
||||
"destination"sv,
|
||||
"details-window-height"sv,
|
||||
"details-window-width"sv,
|
||||
"dht-enabled"sv,
|
||||
"dnd"sv,
|
||||
"done-date"sv,
|
||||
"doneDate"sv,
|
||||
"download-dir"sv,
|
||||
"download-dir-free-space"sv,
|
||||
"download-queue-enabled"sv,
|
||||
"download-queue-size"sv,
|
||||
"downloadCount"sv,
|
||||
"downloadDir"sv,
|
||||
"downloadLimit"sv,
|
||||
"downloadLimited"sv,
|
||||
"downloadSpeed"sv,
|
||||
"downloaded"sv,
|
||||
"downloaded-bytes"sv,
|
||||
"downloadedBytes"sv,
|
||||
"downloadedEver"sv,
|
||||
"downloaders"sv,
|
||||
"downloading-time-seconds"sv,
|
||||
"dropped"sv,
|
||||
"dropped6"sv,
|
||||
"e"sv,
|
||||
"editDate"sv,
|
||||
"encoding"sv,
|
||||
"encryption"sv,
|
||||
"error"sv,
|
||||
"errorString"sv,
|
||||
"eta"sv,
|
||||
"etaIdle"sv,
|
||||
"fields"sv,
|
||||
"file-count"sv,
|
||||
"fileStats"sv,
|
||||
"filename"sv,
|
||||
"files"sv,
|
||||
"files-added"sv,
|
||||
"files-unwanted"sv,
|
||||
"files-wanted"sv,
|
||||
"filesAdded"sv,
|
||||
"filter-mode"sv,
|
||||
"filter-text"sv,
|
||||
"filter-trackers"sv,
|
||||
"flagStr"sv,
|
||||
"flags"sv,
|
||||
"format"sv,
|
||||
"fromCache"sv,
|
||||
"fromDht"sv,
|
||||
"fromIncoming"sv,
|
||||
"fromLpd"sv,
|
||||
"fromLtep"sv,
|
||||
"fromPex"sv,
|
||||
"fromTracker"sv,
|
||||
"group"sv,
|
||||
"hasAnnounced"sv,
|
||||
"hasScraped"sv,
|
||||
"hashString"sv,
|
||||
"have"sv,
|
||||
"haveUnchecked"sv,
|
||||
"haveValid"sv,
|
||||
"honorsSessionLimits"sv,
|
||||
"host"sv,
|
||||
"id"sv,
|
||||
"idle-limit"sv,
|
||||
"idle-mode"sv,
|
||||
"idle-seeding-limit"sv,
|
||||
"idle-seeding-limit-enabled"sv,
|
||||
"ids"sv,
|
||||
"incomplete"sv,
|
||||
"incomplete-dir"sv,
|
||||
"incomplete-dir-enabled"sv,
|
||||
"info"sv,
|
||||
"inhibit-desktop-hibernation"sv,
|
||||
"ipv4"sv,
|
||||
"ipv6"sv,
|
||||
"isBackup"sv,
|
||||
"isDownloadingFrom"sv,
|
||||
"isEncrypted"sv,
|
||||
"isFinished"sv,
|
||||
"isIncoming"sv,
|
||||
"isPrivate"sv,
|
||||
"isStalled"sv,
|
||||
"isUTP"sv,
|
||||
"isUploadingTo"sv,
|
||||
"labels"sv,
|
||||
"lastAnnouncePeerCount"sv,
|
||||
"lastAnnounceResult"sv,
|
||||
"lastAnnounceStartTime"sv,
|
||||
"lastAnnounceSucceeded"sv,
|
||||
"lastAnnounceTime"sv,
|
||||
"lastAnnounceTimedOut"sv,
|
||||
"lastScrapeResult"sv,
|
||||
"lastScrapeStartTime"sv,
|
||||
"lastScrapeSucceeded"sv,
|
||||
"lastScrapeTime"sv,
|
||||
"lastScrapeTimedOut"sv,
|
||||
"leecherCount"sv,
|
||||
"leftUntilDone"sv,
|
||||
"length"sv,
|
||||
"location"sv,
|
||||
"lpd-enabled"sv,
|
||||
"m"sv,
|
||||
"magnetLink"sv,
|
||||
"main-window-height"sv,
|
||||
"main-window-is-maximized"sv,
|
||||
"main-window-layout-order"sv,
|
||||
"main-window-width"sv,
|
||||
"main-window-x"sv,
|
||||
"main-window-y"sv,
|
||||
"manualAnnounceTime"sv,
|
||||
"max-peers"sv,
|
||||
"maxConnectedPeers"sv,
|
||||
"memory-bytes"sv,
|
||||
"memory-units"sv,
|
||||
"message-level"sv,
|
||||
"metadataPercentComplete"sv,
|
||||
"metadata_size"sv,
|
||||
"metainfo"sv,
|
||||
"method"sv,
|
||||
"min_request_interval"sv,
|
||||
"move"sv,
|
||||
"msg_type"sv,
|
||||
"mtimes"sv,
|
||||
"name"sv,
|
||||
"name.utf-8"sv,
|
||||
"nextAnnounceTime"sv,
|
||||
"nextScrapeTime"sv,
|
||||
"nodes"sv,
|
||||
"nodes6"sv,
|
||||
"open-dialog-dir"sv,
|
||||
"p"sv,
|
||||
"path"sv,
|
||||
"path.utf-8"sv,
|
||||
"paused"sv,
|
||||
"pausedTorrentCount"sv,
|
||||
"peer-congestion-algorithm"sv,
|
||||
"peer-id-ttl-hours"sv,
|
||||
"peer-limit"sv,
|
||||
"peer-limit-global"sv,
|
||||
"peer-limit-per-torrent"sv,
|
||||
"peer-port"sv,
|
||||
"peer-port-random-high"sv,
|
||||
"peer-port-random-low"sv,
|
||||
"peer-port-random-on-start"sv,
|
||||
"peer-socket-tos"sv,
|
||||
"peerIsChoked"sv,
|
||||
"peerIsInterested"sv,
|
||||
"peers"sv,
|
||||
"peers2"sv,
|
||||
"peers2-6"sv,
|
||||
"peersConnected"sv,
|
||||
"peersFrom"sv,
|
||||
"peersGettingFromUs"sv,
|
||||
"peersSendingToUs"sv,
|
||||
"percentComplete"sv,
|
||||
"percentDone"sv,
|
||||
"pex-enabled"sv,
|
||||
"piece"sv,
|
||||
"piece length"sv,
|
||||
"pieceCount"sv,
|
||||
"pieceSize"sv,
|
||||
"pieces"sv,
|
||||
"play-download-complete-sound"sv,
|
||||
"port"sv,
|
||||
"port-forwarding-enabled"sv,
|
||||
"port-is-open"sv,
|
||||
"preallocation"sv,
|
||||
"prefetch-enabled"sv,
|
||||
"primary-mime-type"sv,
|
||||
"priorities"sv,
|
||||
"priority"sv,
|
||||
"priority-high"sv,
|
||||
"priority-low"sv,
|
||||
"priority-normal"sv,
|
||||
"private"sv,
|
||||
"progress"sv,
|
||||
"prompt-before-exit"sv,
|
||||
"queue-move-bottom"sv,
|
||||
"queue-move-down"sv,
|
||||
"queue-move-top"sv,
|
||||
"queue-move-up"sv,
|
||||
"queue-stalled-enabled"sv,
|
||||
"queue-stalled-minutes"sv,
|
||||
"queuePosition"sv,
|
||||
"rateDownload"sv,
|
||||
"rateToClient"sv,
|
||||
"rateToPeer"sv,
|
||||
"rateUpload"sv,
|
||||
"ratio-limit"sv,
|
||||
"ratio-limit-enabled"sv,
|
||||
"ratio-mode"sv,
|
||||
"read-clipboard"sv,
|
||||
"recent-download-dir-1"sv,
|
||||
"recent-download-dir-2"sv,
|
||||
"recent-download-dir-3"sv,
|
||||
"recent-download-dir-4"sv,
|
||||
"recent-relocate-dir-1"sv,
|
||||
"recent-relocate-dir-2"sv,
|
||||
"recent-relocate-dir-3"sv,
|
||||
"recent-relocate-dir-4"sv,
|
||||
"recheckProgress"sv,
|
||||
"remote-session-enabled"sv,
|
||||
"remote-session-host"sv,
|
||||
"remote-session-password"sv,
|
||||
"remote-session-port"sv,
|
||||
"remote-session-requres-authentication"sv,
|
||||
"remote-session-username"sv,
|
||||
"removed"sv,
|
||||
"rename-partial-files"sv,
|
||||
"reqq"sv,
|
||||
"result"sv,
|
||||
"rpc-authentication-required"sv,
|
||||
"rpc-bind-address"sv,
|
||||
"rpc-enabled"sv,
|
||||
"rpc-host-whitelist"sv,
|
||||
"rpc-host-whitelist-enabled"sv,
|
||||
"rpc-password"sv,
|
||||
"rpc-port"sv,
|
||||
"rpc-socket-mode"sv,
|
||||
"rpc-url"sv,
|
||||
"rpc-username"sv,
|
||||
"rpc-version"sv,
|
||||
"rpc-version-minimum"sv,
|
||||
"rpc-version-semver"sv,
|
||||
"rpc-whitelist"sv,
|
||||
"rpc-whitelist-enabled"sv,
|
||||
"scrape"sv,
|
||||
"scrape-paused-torrents-enabled"sv,
|
||||
"scrapeState"sv,
|
||||
"script-torrent-added-enabled"sv,
|
||||
"script-torrent-added-filename"sv,
|
||||
"script-torrent-done-enabled"sv,
|
||||
"script-torrent-done-filename"sv,
|
||||
"script-torrent-done-seeding-enabled"sv,
|
||||
"script-torrent-done-seeding-filename"sv,
|
||||
"seconds-active"sv,
|
||||
"secondsActive"sv,
|
||||
"secondsDownloading"sv,
|
||||
"secondsSeeding"sv,
|
||||
"seed-queue-enabled"sv,
|
||||
"seed-queue-size"sv,
|
||||
"seedIdleLimit"sv,
|
||||
"seedIdleMode"sv,
|
||||
"seedRatioLimit"sv,
|
||||
"seedRatioLimited"sv,
|
||||
"seedRatioMode"sv,
|
||||
"seederCount"sv,
|
||||
"seeding-time-seconds"sv,
|
||||
"session-count"sv,
|
||||
"session-id"sv,
|
||||
"sessionCount"sv,
|
||||
"show-backup-trackers"sv,
|
||||
"show-extra-peer-details"sv,
|
||||
"show-filterbar"sv,
|
||||
"show-notification-area-icon"sv,
|
||||
"show-options-window"sv,
|
||||
"show-statusbar"sv,
|
||||
"show-toolbar"sv,
|
||||
"show-tracker-scrapes"sv,
|
||||
"sitename"sv,
|
||||
"size-bytes"sv,
|
||||
"size-units"sv,
|
||||
"sizeWhenDone"sv,
|
||||
"sort-mode"sv,
|
||||
"sort-reversed"sv,
|
||||
"source"sv,
|
||||
"speed"sv,
|
||||
"speed-Bps"sv,
|
||||
"speed-bytes"sv,
|
||||
"speed-limit-down"sv,
|
||||
"speed-limit-down-enabled"sv,
|
||||
"speed-limit-up"sv,
|
||||
"speed-limit-up-enabled"sv,
|
||||
"speed-units"sv,
|
||||
"start-added-torrents"sv,
|
||||
"start-minimized"sv,
|
||||
"startDate"sv,
|
||||
"status"sv,
|
||||
"statusbar-stats"sv,
|
||||
"tag"sv,
|
||||
"tcp-enabled"sv,
|
||||
"tier"sv,
|
||||
"time-checked"sv,
|
||||
"torrent-added"sv,
|
||||
"torrent-added-notification-command"sv,
|
||||
"torrent-added-notification-enabled"sv,
|
||||
"torrent-complete-notification-command"sv,
|
||||
"torrent-complete-notification-enabled"sv,
|
||||
"torrent-complete-sound-command"sv,
|
||||
"torrent-complete-sound-enabled"sv,
|
||||
"torrent-duplicate"sv,
|
||||
"torrent-get"sv,
|
||||
"torrent-set"sv,
|
||||
"torrent-set-location"sv,
|
||||
"torrentCount"sv,
|
||||
"torrentFile"sv,
|
||||
"torrents"sv,
|
||||
"totalSize"sv,
|
||||
"total_size"sv,
|
||||
"trackerAdd"sv,
|
||||
"trackerList"sv,
|
||||
"trackerRemove"sv,
|
||||
"trackerReplace"sv,
|
||||
"trackerStats"sv,
|
||||
"trackers"sv,
|
||||
"trash-can-enabled"sv,
|
||||
"trash-original-torrent-files"sv,
|
||||
"umask"sv,
|
||||
"units"sv,
|
||||
"upload-slots-per-torrent"sv,
|
||||
"uploadLimit"sv,
|
||||
"uploadLimited"sv,
|
||||
"uploadRatio"sv,
|
||||
"uploadSpeed"sv,
|
||||
"upload_only"sv,
|
||||
"uploaded"sv,
|
||||
"uploaded-bytes"sv,
|
||||
"uploadedBytes"sv,
|
||||
"uploadedEver"sv,
|
||||
"url-list"sv,
|
||||
"use-global-speed-limit"sv,
|
||||
"use-speed-limit"sv,
|
||||
"user-has-given-informed-consent"sv,
|
||||
"ut_comment"sv,
|
||||
"ut_holepunch"sv,
|
||||
"ut_metadata"sv,
|
||||
"ut_pex"sv,
|
||||
"ut_recommend"sv,
|
||||
"utp-enabled"sv,
|
||||
"v"sv,
|
||||
"version"sv,
|
||||
"wanted"sv,
|
||||
"watch-dir"sv,
|
||||
"watch-dir-enabled"sv,
|
||||
"webseeds"sv,
|
||||
"webseedsSendingToUs"sv };
|
||||
auto constexpr MyStatic = std::array<std::string_view, 399>{ ""sv,
|
||||
"activeTorrentCount"sv,
|
||||
"activity-date"sv,
|
||||
"activityDate"sv,
|
||||
"added"sv,
|
||||
"added-date"sv,
|
||||
"added.f"sv,
|
||||
"added6"sv,
|
||||
"added6.f"sv,
|
||||
"addedDate"sv,
|
||||
"address"sv,
|
||||
"alt-speed-down"sv,
|
||||
"alt-speed-enabled"sv,
|
||||
"alt-speed-time-begin"sv,
|
||||
"alt-speed-time-day"sv,
|
||||
"alt-speed-time-enabled"sv,
|
||||
"alt-speed-time-end"sv,
|
||||
"alt-speed-up"sv,
|
||||
"announce"sv,
|
||||
"announce-ip"sv,
|
||||
"announce-ip-enabled"sv,
|
||||
"announce-list"sv,
|
||||
"announceState"sv,
|
||||
"anti-brute-force-enabled"sv,
|
||||
"anti-brute-force-threshold"sv,
|
||||
"arguments"sv,
|
||||
"availability"sv,
|
||||
"bandwidth-priority"sv,
|
||||
"bandwidthPriority"sv,
|
||||
"bind-address-ipv4"sv,
|
||||
"bind-address-ipv6"sv,
|
||||
"bitfield"sv,
|
||||
"blocklist-date"sv,
|
||||
"blocklist-enabled"sv,
|
||||
"blocklist-size"sv,
|
||||
"blocklist-updates-enabled"sv,
|
||||
"blocklist-url"sv,
|
||||
"blocks"sv,
|
||||
"bytesCompleted"sv,
|
||||
"cache-size-mb"sv,
|
||||
"clientIsChoked"sv,
|
||||
"clientIsInterested"sv,
|
||||
"clientName"sv,
|
||||
"comment"sv,
|
||||
"comment_utf_8"sv,
|
||||
"compact-view"sv,
|
||||
"complete"sv,
|
||||
"config-dir"sv,
|
||||
"cookies"sv,
|
||||
"corrupt"sv,
|
||||
"corruptEver"sv,
|
||||
"created by"sv,
|
||||
"created by.utf-8"sv,
|
||||
"creation date"sv,
|
||||
"creator"sv,
|
||||
"cumulative-stats"sv,
|
||||
"current-stats"sv,
|
||||
"date"sv,
|
||||
"dateCreated"sv,
|
||||
"default-trackers"sv,
|
||||
"delete-local-data"sv,
|
||||
"desiredAvailable"sv,
|
||||
"destination"sv,
|
||||
"details-window-height"sv,
|
||||
"details-window-width"sv,
|
||||
"dht-enabled"sv,
|
||||
"dnd"sv,
|
||||
"done-date"sv,
|
||||
"doneDate"sv,
|
||||
"download-dir"sv,
|
||||
"download-dir-free-space"sv,
|
||||
"download-queue-enabled"sv,
|
||||
"download-queue-size"sv,
|
||||
"downloadCount"sv,
|
||||
"downloadDir"sv,
|
||||
"downloadLimit"sv,
|
||||
"downloadLimited"sv,
|
||||
"downloadSpeed"sv,
|
||||
"downloaded"sv,
|
||||
"downloaded-bytes"sv,
|
||||
"downloadedBytes"sv,
|
||||
"downloadedEver"sv,
|
||||
"downloaders"sv,
|
||||
"downloading-time-seconds"sv,
|
||||
"dropped"sv,
|
||||
"dropped6"sv,
|
||||
"e"sv,
|
||||
"editDate"sv,
|
||||
"encoding"sv,
|
||||
"encryption"sv,
|
||||
"error"sv,
|
||||
"errorString"sv,
|
||||
"eta"sv,
|
||||
"etaIdle"sv,
|
||||
"fields"sv,
|
||||
"file-count"sv,
|
||||
"fileStats"sv,
|
||||
"filename"sv,
|
||||
"files"sv,
|
||||
"files-added"sv,
|
||||
"files-unwanted"sv,
|
||||
"files-wanted"sv,
|
||||
"filesAdded"sv,
|
||||
"filter-mode"sv,
|
||||
"filter-text"sv,
|
||||
"filter-trackers"sv,
|
||||
"flagStr"sv,
|
||||
"flags"sv,
|
||||
"format"sv,
|
||||
"fromCache"sv,
|
||||
"fromDht"sv,
|
||||
"fromIncoming"sv,
|
||||
"fromLpd"sv,
|
||||
"fromLtep"sv,
|
||||
"fromPex"sv,
|
||||
"fromTracker"sv,
|
||||
"group"sv,
|
||||
"hasAnnounced"sv,
|
||||
"hasScraped"sv,
|
||||
"hashString"sv,
|
||||
"have"sv,
|
||||
"haveUnchecked"sv,
|
||||
"haveValid"sv,
|
||||
"honorsSessionLimits"sv,
|
||||
"host"sv,
|
||||
"id"sv,
|
||||
"idle-limit"sv,
|
||||
"idle-mode"sv,
|
||||
"idle-seeding-limit"sv,
|
||||
"idle-seeding-limit-enabled"sv,
|
||||
"ids"sv,
|
||||
"incomplete"sv,
|
||||
"incomplete-dir"sv,
|
||||
"incomplete-dir-enabled"sv,
|
||||
"info"sv,
|
||||
"inhibit-desktop-hibernation"sv,
|
||||
"ipv4"sv,
|
||||
"ipv6"sv,
|
||||
"isBackup"sv,
|
||||
"isDownloadingFrom"sv,
|
||||
"isEncrypted"sv,
|
||||
"isFinished"sv,
|
||||
"isIncoming"sv,
|
||||
"isPrivate"sv,
|
||||
"isStalled"sv,
|
||||
"isUTP"sv,
|
||||
"isUploadingTo"sv,
|
||||
"labels"sv,
|
||||
"lastAnnouncePeerCount"sv,
|
||||
"lastAnnounceResult"sv,
|
||||
"lastAnnounceStartTime"sv,
|
||||
"lastAnnounceSucceeded"sv,
|
||||
"lastAnnounceTime"sv,
|
||||
"lastAnnounceTimedOut"sv,
|
||||
"lastScrapeResult"sv,
|
||||
"lastScrapeStartTime"sv,
|
||||
"lastScrapeSucceeded"sv,
|
||||
"lastScrapeTime"sv,
|
||||
"lastScrapeTimedOut"sv,
|
||||
"leecherCount"sv,
|
||||
"leftUntilDone"sv,
|
||||
"length"sv,
|
||||
"location"sv,
|
||||
"lpd-enabled"sv,
|
||||
"m"sv,
|
||||
"magnetLink"sv,
|
||||
"main-window-height"sv,
|
||||
"main-window-is-maximized"sv,
|
||||
"main-window-layout-order"sv,
|
||||
"main-window-width"sv,
|
||||
"main-window-x"sv,
|
||||
"main-window-y"sv,
|
||||
"manualAnnounceTime"sv,
|
||||
"max-peers"sv,
|
||||
"maxConnectedPeers"sv,
|
||||
"memory-bytes"sv,
|
||||
"memory-units"sv,
|
||||
"message-level"sv,
|
||||
"metadataPercentComplete"sv,
|
||||
"metadata_size"sv,
|
||||
"metainfo"sv,
|
||||
"method"sv,
|
||||
"min_request_interval"sv,
|
||||
"move"sv,
|
||||
"msg_type"sv,
|
||||
"mtimes"sv,
|
||||
"name"sv,
|
||||
"name.utf-8"sv,
|
||||
"nextAnnounceTime"sv,
|
||||
"nextScrapeTime"sv,
|
||||
"nodes"sv,
|
||||
"nodes6"sv,
|
||||
"open-dialog-dir"sv,
|
||||
"p"sv,
|
||||
"path"sv,
|
||||
"path.utf-8"sv,
|
||||
"paused"sv,
|
||||
"pausedTorrentCount"sv,
|
||||
"peer-congestion-algorithm"sv,
|
||||
"peer-id-ttl-hours"sv,
|
||||
"peer-limit"sv,
|
||||
"peer-limit-global"sv,
|
||||
"peer-limit-per-torrent"sv,
|
||||
"peer-port"sv,
|
||||
"peer-port-random-high"sv,
|
||||
"peer-port-random-low"sv,
|
||||
"peer-port-random-on-start"sv,
|
||||
"peer-socket-tos"sv,
|
||||
"peerIsChoked"sv,
|
||||
"peerIsInterested"sv,
|
||||
"peers"sv,
|
||||
"peers2"sv,
|
||||
"peers2-6"sv,
|
||||
"peersConnected"sv,
|
||||
"peersFrom"sv,
|
||||
"peersGettingFromUs"sv,
|
||||
"peersSendingToUs"sv,
|
||||
"percentComplete"sv,
|
||||
"percentDone"sv,
|
||||
"pex-enabled"sv,
|
||||
"piece"sv,
|
||||
"piece length"sv,
|
||||
"pieceCount"sv,
|
||||
"pieceSize"sv,
|
||||
"pieces"sv,
|
||||
"play-download-complete-sound"sv,
|
||||
"port"sv,
|
||||
"port-forwarding-enabled"sv,
|
||||
"port-is-open"sv,
|
||||
"preallocation"sv,
|
||||
"prefetch-enabled"sv,
|
||||
"primary-mime-type"sv,
|
||||
"priorities"sv,
|
||||
"priority"sv,
|
||||
"priority-high"sv,
|
||||
"priority-low"sv,
|
||||
"priority-normal"sv,
|
||||
"private"sv,
|
||||
"progress"sv,
|
||||
"prompt-before-exit"sv,
|
||||
"queue-move-bottom"sv,
|
||||
"queue-move-down"sv,
|
||||
"queue-move-top"sv,
|
||||
"queue-move-up"sv,
|
||||
"queue-stalled-enabled"sv,
|
||||
"queue-stalled-minutes"sv,
|
||||
"queuePosition"sv,
|
||||
"rateDownload"sv,
|
||||
"rateToClient"sv,
|
||||
"rateToPeer"sv,
|
||||
"rateUpload"sv,
|
||||
"ratio-limit"sv,
|
||||
"ratio-limit-enabled"sv,
|
||||
"ratio-mode"sv,
|
||||
"read-clipboard"sv,
|
||||
"recent-download-dir-1"sv,
|
||||
"recent-download-dir-2"sv,
|
||||
"recent-download-dir-3"sv,
|
||||
"recent-download-dir-4"sv,
|
||||
"recent-relocate-dir-1"sv,
|
||||
"recent-relocate-dir-2"sv,
|
||||
"recent-relocate-dir-3"sv,
|
||||
"recent-relocate-dir-4"sv,
|
||||
"recheckProgress"sv,
|
||||
"remote-session-enabled"sv,
|
||||
"remote-session-host"sv,
|
||||
"remote-session-password"sv,
|
||||
"remote-session-port"sv,
|
||||
"remote-session-requres-authentication"sv,
|
||||
"remote-session-username"sv,
|
||||
"removed"sv,
|
||||
"rename-partial-files"sv,
|
||||
"reqq"sv,
|
||||
"result"sv,
|
||||
"rpc-authentication-required"sv,
|
||||
"rpc-bind-address"sv,
|
||||
"rpc-enabled"sv,
|
||||
"rpc-host-whitelist"sv,
|
||||
"rpc-host-whitelist-enabled"sv,
|
||||
"rpc-password"sv,
|
||||
"rpc-port"sv,
|
||||
"rpc-socket-mode"sv,
|
||||
"rpc-url"sv,
|
||||
"rpc-username"sv,
|
||||
"rpc-version"sv,
|
||||
"rpc-version-minimum"sv,
|
||||
"rpc-version-semver"sv,
|
||||
"rpc-whitelist"sv,
|
||||
"rpc-whitelist-enabled"sv,
|
||||
"scrape"sv,
|
||||
"scrape-paused-torrents-enabled"sv,
|
||||
"scrapeState"sv,
|
||||
"script-torrent-added-enabled"sv,
|
||||
"script-torrent-added-filename"sv,
|
||||
"script-torrent-done-enabled"sv,
|
||||
"script-torrent-done-filename"sv,
|
||||
"script-torrent-done-seeding-enabled"sv,
|
||||
"script-torrent-done-seeding-filename"sv,
|
||||
"seconds-active"sv,
|
||||
"secondsActive"sv,
|
||||
"secondsDownloading"sv,
|
||||
"secondsSeeding"sv,
|
||||
"seed-queue-enabled"sv,
|
||||
"seed-queue-size"sv,
|
||||
"seedIdleLimit"sv,
|
||||
"seedIdleMode"sv,
|
||||
"seedRatioLimit"sv,
|
||||
"seedRatioLimited"sv,
|
||||
"seedRatioMode"sv,
|
||||
"seederCount"sv,
|
||||
"seeding-time-seconds"sv,
|
||||
"session-count"sv,
|
||||
"session-id"sv,
|
||||
"sessionCount"sv,
|
||||
"show-backup-trackers"sv,
|
||||
"show-extra-peer-details"sv,
|
||||
"show-filterbar"sv,
|
||||
"show-notification-area-icon"sv,
|
||||
"show-options-window"sv,
|
||||
"show-statusbar"sv,
|
||||
"show-toolbar"sv,
|
||||
"show-tracker-scrapes"sv,
|
||||
"sitename"sv,
|
||||
"size-bytes"sv,
|
||||
"size-units"sv,
|
||||
"sizeWhenDone"sv,
|
||||
"sort-mode"sv,
|
||||
"sort-reversed"sv,
|
||||
"source"sv,
|
||||
"speed"sv,
|
||||
"speed-Bps"sv,
|
||||
"speed-bytes"sv,
|
||||
"speed-limit-down"sv,
|
||||
"speed-limit-down-enabled"sv,
|
||||
"speed-limit-up"sv,
|
||||
"speed-limit-up-enabled"sv,
|
||||
"speed-units"sv,
|
||||
"start-added-torrents"sv,
|
||||
"start-minimized"sv,
|
||||
"startDate"sv,
|
||||
"status"sv,
|
||||
"statusbar-stats"sv,
|
||||
"tag"sv,
|
||||
"tcp-enabled"sv,
|
||||
"tier"sv,
|
||||
"time-checked"sv,
|
||||
"torrent-added"sv,
|
||||
"torrent-added-notification-command"sv,
|
||||
"torrent-added-notification-enabled"sv,
|
||||
"torrent-complete-notification-command"sv,
|
||||
"torrent-complete-notification-enabled"sv,
|
||||
"torrent-complete-sound-command"sv,
|
||||
"torrent-complete-sound-enabled"sv,
|
||||
"torrent-duplicate"sv,
|
||||
"torrent-get"sv,
|
||||
"torrent-set"sv,
|
||||
"torrent-set-location"sv,
|
||||
"torrentCount"sv,
|
||||
"torrentFile"sv,
|
||||
"torrents"sv,
|
||||
"totalSize"sv,
|
||||
"total_size"sv,
|
||||
"trackerAdd"sv,
|
||||
"trackerList"sv,
|
||||
"trackerRemove"sv,
|
||||
"trackerReplace"sv,
|
||||
"trackerStats"sv,
|
||||
"trackers"sv,
|
||||
"trash-can-enabled"sv,
|
||||
"trash-original-torrent-files"sv,
|
||||
"umask"sv,
|
||||
"units"sv,
|
||||
"upload-slots-per-torrent"sv,
|
||||
"uploadLimit"sv,
|
||||
"uploadLimited"sv,
|
||||
"uploadRatio"sv,
|
||||
"uploadSpeed"sv,
|
||||
"upload_only"sv,
|
||||
"uploaded"sv,
|
||||
"uploaded-bytes"sv,
|
||||
"uploadedBytes"sv,
|
||||
"uploadedEver"sv,
|
||||
"url-list"sv,
|
||||
"use-global-speed-limit"sv,
|
||||
"use-speed-limit"sv,
|
||||
"user-has-given-informed-consent"sv,
|
||||
"ut_comment"sv,
|
||||
"ut_holepunch"sv,
|
||||
"ut_metadata"sv,
|
||||
"ut_pex"sv,
|
||||
"ut_recommend"sv,
|
||||
"utp-enabled"sv,
|
||||
"v"sv,
|
||||
"version"sv,
|
||||
"wanted"sv,
|
||||
"watch-dir"sv,
|
||||
"watch-dir-enabled"sv,
|
||||
"webseeds"sv,
|
||||
"webseedsSendingToUs"sv };
|
||||
|
||||
bool constexpr quarks_are_sorted()
|
||||
{
|
||||
for (size_t i = 1; i < std::size(my_static); ++i)
|
||||
for (size_t i = 1; i < std::size(MyStatic); ++i)
|
||||
{
|
||||
if (my_static[i - 1] >= my_static[i])
|
||||
if (MyStatic[i - 1] >= MyStatic[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ bool constexpr quarks_are_sorted()
|
|||
}
|
||||
|
||||
static_assert(quarks_are_sorted(), "Predefined quarks must be sorted by their string value");
|
||||
static_assert(std::size(my_static) == TR_N_KEYS);
|
||||
static_assert(std::size(MyStatic) == TR_N_KEYS);
|
||||
|
||||
auto& my_runtime{ *new std::vector<std::string_view>{} };
|
||||
|
||||
|
@ -441,12 +441,12 @@ auto& my_runtime{ *new std::vector<std::string_view>{} };
|
|||
std::optional<tr_quark> tr_quark_lookup(std::string_view key)
|
||||
{
|
||||
// is it in our static array?
|
||||
auto constexpr sbegin = std::begin(my_static);
|
||||
auto constexpr send = std::end(my_static);
|
||||
auto const sit = std::lower_bound(sbegin, send, key);
|
||||
if (sit != send && *sit == key)
|
||||
auto constexpr Sbegin = std::begin(MyStatic);
|
||||
auto constexpr Send = std::end(MyStatic);
|
||||
auto const sit = std::lower_bound(Sbegin, Send, key);
|
||||
if (sit != Send && *sit == key)
|
||||
{
|
||||
return std::distance(sbegin, sit);
|
||||
return std::distance(Sbegin, sit);
|
||||
}
|
||||
|
||||
/* was it added during runtime? */
|
||||
|
@ -479,5 +479,5 @@ tr_quark tr_quark_new(std::string_view str)
|
|||
|
||||
std::string_view tr_quark_get_string_view(tr_quark q)
|
||||
{
|
||||
return q < TR_N_KEYS ? my_static[q] : my_runtime[q - TR_N_KEYS];
|
||||
return q < TR_N_KEYS ? MyStatic[q] : my_runtime[q - TR_N_KEYS];
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ using namespace std::literals;
|
|||
namespace
|
||||
{
|
||||
|
||||
constexpr int MAX_REMEMBERED_PEERS = 200;
|
||||
constexpr int MaxRememberedPeers = 200;
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
|
@ -41,12 +41,12 @@ constexpr int MAX_REMEMBERED_PEERS = 200;
|
|||
|
||||
static void savePeers(tr_variant* dict, tr_torrent const* tor)
|
||||
{
|
||||
if (auto const pex = tr_peerMgrGetPeers(tor, TR_AF_INET, TR_PEERS_INTERESTING, MAX_REMEMBERED_PEERS); !std::empty(pex))
|
||||
if (auto const pex = tr_peerMgrGetPeers(tor, TR_AF_INET, TR_PEERS_INTERESTING, MaxRememberedPeers); !std::empty(pex))
|
||||
{
|
||||
tr_variantDictAddRaw(dict, TR_KEY_peers2, std::data(pex), sizeof(tr_pex) * std::size(pex));
|
||||
}
|
||||
|
||||
if (auto const pex = tr_peerMgrGetPeers(tor, TR_AF_INET6, TR_PEERS_INTERESTING, MAX_REMEMBERED_PEERS); !std::empty(pex))
|
||||
if (auto const pex = tr_peerMgrGetPeers(tor, TR_AF_INET6, TR_PEERS_INTERESTING, MaxRememberedPeers); !std::empty(pex))
|
||||
{
|
||||
tr_variantDictAddRaw(dict, TR_KEY_peers2_6, std::data(pex), sizeof(tr_pex) * std::size(pex));
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ static void savePeers(tr_variant* dict, tr_torrent const* tor)
|
|||
static size_t addPeers(tr_torrent* tor, uint8_t const* buf, size_t buflen)
|
||||
{
|
||||
size_t const n_in = buflen / sizeof(tr_pex);
|
||||
size_t const n_pex = std::min(n_in, size_t{ MAX_REMEMBERED_PEERS });
|
||||
size_t const n_pex = std::min(n_in, size_t{ MaxRememberedPeers });
|
||||
|
||||
auto pex = std::array<tr_pex, MAX_REMEMBERED_PEERS>{};
|
||||
auto pex = std::array<tr_pex, MaxRememberedPeers>{};
|
||||
memcpy(std::data(pex), buf, sizeof(tr_pex) * n_pex);
|
||||
return tr_peerMgrAddPex(tor, TR_PEER_FROM_RESUME, std::data(pex), n_pex);
|
||||
}
|
||||
|
@ -70,15 +70,15 @@ static auto loadPeers(tr_variant* dict, tr_torrent* tor)
|
|||
auto len = size_t{};
|
||||
if (tr_variantDictFindRaw(dict, TR_KEY_peers2, &str, &len))
|
||||
{
|
||||
size_t const numAdded = addPeers(tor, str, len);
|
||||
tr_logAddTraceTor(tor, fmt::format("Loaded {} IPv4 peers from resume file", numAdded));
|
||||
size_t const num_added = addPeers(tor, str, len);
|
||||
tr_logAddTraceTor(tor, fmt::format("Loaded {} IPv4 peers from resume file", num_added));
|
||||
ret = tr_resume::Peers;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindRaw(dict, TR_KEY_peers2_6, &str, &len))
|
||||
{
|
||||
size_t const numAdded = addPeers(tor, str, len);
|
||||
tr_logAddTraceTor(tor, fmt::format("Loaded {} IPv6 peers from resume file", numAdded));
|
||||
size_t const num_added = addPeers(tor, str, len);
|
||||
tr_logAddTraceTor(tor, fmt::format("Loaded {} IPv6 peers from resume file", num_added));
|
||||
ret = tr_resume::Peers;
|
||||
}
|
||||
|
||||
|
@ -275,26 +275,23 @@ static void saveIdleLimits(tr_variant* dict, tr_torrent const* tor)
|
|||
|
||||
static void loadSingleSpeedLimit(tr_variant* d, tr_direction dir, tr_torrent* tor)
|
||||
{
|
||||
auto i = int64_t{};
|
||||
auto boolVal = false;
|
||||
|
||||
if (tr_variantDictFindInt(d, TR_KEY_speed_Bps, &i))
|
||||
if (auto val = int64_t{}; tr_variantDictFindInt(d, TR_KEY_speed_Bps, &val))
|
||||
{
|
||||
tor->setSpeedLimitBps(dir, i);
|
||||
tor->setSpeedLimitBps(dir, val);
|
||||
}
|
||||
else if (tr_variantDictFindInt(d, TR_KEY_speed, &i))
|
||||
else if (tr_variantDictFindInt(d, TR_KEY_speed, &val))
|
||||
{
|
||||
tor->setSpeedLimitBps(dir, i * 1024);
|
||||
tor->setSpeedLimitBps(dir, val * 1024);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(d, TR_KEY_use_speed_limit, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(d, TR_KEY_use_speed_limit, &val))
|
||||
{
|
||||
tr_torrentUseSpeedLimit(tor, dir, boolVal);
|
||||
tr_torrentUseSpeedLimit(tor, dir, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(d, TR_KEY_use_global_speed_limit, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(d, TR_KEY_use_global_speed_limit, &val))
|
||||
{
|
||||
tr_torrentUseSessionLimits(tor, boolVal);
|
||||
tr_torrentUseSessionLimits(tor, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,16 +299,15 @@ static auto loadSpeedLimits(tr_variant* dict, tr_torrent* tor)
|
|||
{
|
||||
auto ret = tr_resume::fields_t{};
|
||||
|
||||
tr_variant* d = nullptr;
|
||||
if (tr_variantDictFindDict(dict, TR_KEY_speed_limit_up, &d))
|
||||
if (tr_variant* child = nullptr; tr_variantDictFindDict(dict, TR_KEY_speed_limit_up, &child))
|
||||
{
|
||||
loadSingleSpeedLimit(d, TR_UP, tor);
|
||||
loadSingleSpeedLimit(child, TR_UP, tor);
|
||||
ret = tr_resume::Speedlimit;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindDict(dict, TR_KEY_speed_limit_down, &d))
|
||||
if (tr_variant* child = nullptr; tr_variantDictFindDict(dict, TR_KEY_speed_limit_down, &child))
|
||||
{
|
||||
loadSingleSpeedLimit(d, TR_DOWN, tor);
|
||||
loadSingleSpeedLimit(child, TR_DOWN, tor);
|
||||
ret = tr_resume::Speedlimit;
|
||||
}
|
||||
|
||||
|
@ -647,12 +643,12 @@ static auto loadProgress(tr_variant* dict, tr_torrent* tor)
|
|||
****
|
||||
***/
|
||||
|
||||
static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool* did_migrate_filename)
|
||||
static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fields_to_load, bool* did_migrate_filename)
|
||||
{
|
||||
auto fields_loaded = tr_resume::fields_t{};
|
||||
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
auto const wasDirty = tor->isDirty;
|
||||
auto const was_dirty = tor->isDirty;
|
||||
|
||||
auto const migrated = tr_torrent_metainfo::migrateFile(
|
||||
tor->session->resumeDir(),
|
||||
|
@ -678,17 +674,16 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
|
||||
tr_logAddDebugTor(tor, fmt::format("Read resume file '{}'", filename));
|
||||
|
||||
auto boolVal = false;
|
||||
auto i = int64_t{};
|
||||
auto sv = std::string_view{};
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Corrupt) != 0 && tr_variantDictFindInt(&top, TR_KEY_corrupt, &i))
|
||||
if ((fields_to_load & tr_resume::Corrupt) != 0 && tr_variantDictFindInt(&top, TR_KEY_corrupt, &i))
|
||||
{
|
||||
tor->corruptPrev = i;
|
||||
fields_loaded |= tr_resume::Corrupt;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & (tr_resume::Progress | tr_resume::DownloadDir)) != 0 &&
|
||||
if ((fields_to_load & (tr_resume::Progress | tr_resume::DownloadDir)) != 0 &&
|
||||
tr_variantDictFindStrView(&top, TR_KEY_destination, &sv) && !std::empty(sv))
|
||||
{
|
||||
bool const is_current_dir = tor->current_dir == tor->download_dir;
|
||||
|
@ -701,7 +696,7 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
fields_loaded |= tr_resume::DownloadDir;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & (tr_resume::Progress | tr_resume::IncompleteDir)) != 0 &&
|
||||
if ((fields_to_load & (tr_resume::Progress | tr_resume::IncompleteDir)) != 0 &&
|
||||
tr_variantDictFindStrView(&top, TR_KEY_incomplete_dir, &sv) && !std::empty(sv))
|
||||
{
|
||||
bool const is_current_dir = tor->current_dir == tor->incomplete_dir;
|
||||
|
@ -714,68 +709,68 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
fields_loaded |= tr_resume::IncompleteDir;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Downloaded) != 0 && tr_variantDictFindInt(&top, TR_KEY_downloaded, &i))
|
||||
if ((fields_to_load & tr_resume::Downloaded) != 0 && tr_variantDictFindInt(&top, TR_KEY_downloaded, &i))
|
||||
{
|
||||
tor->downloadedPrev = i;
|
||||
fields_loaded |= tr_resume::Downloaded;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Uploaded) != 0 && tr_variantDictFindInt(&top, TR_KEY_uploaded, &i))
|
||||
if ((fields_to_load & tr_resume::Uploaded) != 0 && tr_variantDictFindInt(&top, TR_KEY_uploaded, &i))
|
||||
{
|
||||
tor->uploadedPrev = i;
|
||||
fields_loaded |= tr_resume::Uploaded;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::MaxPeers) != 0 && tr_variantDictFindInt(&top, TR_KEY_max_peers, &i))
|
||||
if ((fields_to_load & tr_resume::MaxPeers) != 0 && tr_variantDictFindInt(&top, TR_KEY_max_peers, &i))
|
||||
{
|
||||
tor->max_connected_peers = static_cast<uint16_t>(i);
|
||||
fields_loaded |= tr_resume::MaxPeers;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Run) != 0 && tr_variantDictFindBool(&top, TR_KEY_paused, &boolVal))
|
||||
if (auto val = bool{}; (fields_to_load & tr_resume::Run) != 0 && tr_variantDictFindBool(&top, TR_KEY_paused, &val))
|
||||
{
|
||||
tor->isRunning = !boolVal;
|
||||
tor->isRunning = !val;
|
||||
fields_loaded |= tr_resume::Run;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::AddedDate) != 0 && tr_variantDictFindInt(&top, TR_KEY_added_date, &i))
|
||||
if ((fields_to_load & tr_resume::AddedDate) != 0 && tr_variantDictFindInt(&top, TR_KEY_added_date, &i))
|
||||
{
|
||||
tor->addedDate = i;
|
||||
fields_loaded |= tr_resume::AddedDate;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::DoneDate) != 0 && tr_variantDictFindInt(&top, TR_KEY_done_date, &i))
|
||||
if ((fields_to_load & tr_resume::DoneDate) != 0 && tr_variantDictFindInt(&top, TR_KEY_done_date, &i))
|
||||
{
|
||||
tor->doneDate = i;
|
||||
fields_loaded |= tr_resume::DoneDate;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::ActivityDate) != 0 && tr_variantDictFindInt(&top, TR_KEY_activity_date, &i))
|
||||
if ((fields_to_load & tr_resume::ActivityDate) != 0 && tr_variantDictFindInt(&top, TR_KEY_activity_date, &i))
|
||||
{
|
||||
tor->setDateActive(i);
|
||||
fields_loaded |= tr_resume::ActivityDate;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::TimeSeeding) != 0 && tr_variantDictFindInt(&top, TR_KEY_seeding_time_seconds, &i))
|
||||
if ((fields_to_load & tr_resume::TimeSeeding) != 0 && tr_variantDictFindInt(&top, TR_KEY_seeding_time_seconds, &i))
|
||||
{
|
||||
tor->secondsSeeding = i;
|
||||
fields_loaded |= tr_resume::TimeSeeding;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::TimeDownloading) != 0 && tr_variantDictFindInt(&top, TR_KEY_downloading_time_seconds, &i))
|
||||
if ((fields_to_load & tr_resume::TimeDownloading) != 0 && tr_variantDictFindInt(&top, TR_KEY_downloading_time_seconds, &i))
|
||||
{
|
||||
tor->secondsDownloading = i;
|
||||
fields_loaded |= tr_resume::TimeDownloading;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::BandwidthPriority) != 0 && tr_variantDictFindInt(&top, TR_KEY_bandwidth_priority, &i) &&
|
||||
if ((fields_to_load & tr_resume::BandwidthPriority) != 0 && tr_variantDictFindInt(&top, TR_KEY_bandwidth_priority, &i) &&
|
||||
tr_isPriority(i))
|
||||
{
|
||||
tr_torrentSetPriority(tor, i);
|
||||
fields_loaded |= tr_resume::BandwidthPriority;
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Peers) != 0)
|
||||
if ((fields_to_load & tr_resume::Peers) != 0)
|
||||
{
|
||||
fields_loaded |= loadPeers(&top, tor);
|
||||
}
|
||||
|
@ -783,7 +778,7 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
// Note: loadFilenames() must come before loadProgress()
|
||||
// so that loadProgress() -> tor->initCheckedPieces() -> tor->findFile()
|
||||
// will know where to look
|
||||
if ((fieldsToLoad & tr_resume::Filenames) != 0)
|
||||
if ((fields_to_load & tr_resume::Filenames) != 0)
|
||||
{
|
||||
fields_loaded |= loadFilenames(&top, tor);
|
||||
}
|
||||
|
@ -791,47 +786,47 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
// Note: loadProgress should come before loadFilePriorities()
|
||||
// so that we can skip loading priorities iff the torrent is a
|
||||
// seed or a partial seed.
|
||||
if ((fieldsToLoad & tr_resume::Progress) != 0)
|
||||
if ((fields_to_load & tr_resume::Progress) != 0)
|
||||
{
|
||||
fields_loaded |= loadProgress(&top, tor);
|
||||
}
|
||||
|
||||
if (!tor->isDone() && (fieldsToLoad & tr_resume::FilePriorities) != 0)
|
||||
if (!tor->isDone() && (fields_to_load & tr_resume::FilePriorities) != 0)
|
||||
{
|
||||
fields_loaded |= loadFilePriorities(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Dnd) != 0)
|
||||
if ((fields_to_load & tr_resume::Dnd) != 0)
|
||||
{
|
||||
fields_loaded |= loadDND(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Speedlimit) != 0)
|
||||
if ((fields_to_load & tr_resume::Speedlimit) != 0)
|
||||
{
|
||||
fields_loaded |= loadSpeedLimits(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Ratiolimit) != 0)
|
||||
if ((fields_to_load & tr_resume::Ratiolimit) != 0)
|
||||
{
|
||||
fields_loaded |= loadRatioLimits(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Idlelimit) != 0)
|
||||
if ((fields_to_load & tr_resume::Idlelimit) != 0)
|
||||
{
|
||||
fields_loaded |= loadIdleLimits(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Name) != 0)
|
||||
if ((fields_to_load & tr_resume::Name) != 0)
|
||||
{
|
||||
fields_loaded |= loadName(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Labels) != 0)
|
||||
if ((fields_to_load & tr_resume::Labels) != 0)
|
||||
{
|
||||
fields_loaded |= loadLabels(&top, tor);
|
||||
}
|
||||
|
||||
if ((fieldsToLoad & tr_resume::Group) != 0)
|
||||
if ((fields_to_load & tr_resume::Group) != 0)
|
||||
{
|
||||
fields_loaded |= loadGroup(&top, tor);
|
||||
}
|
||||
|
@ -839,7 +834,7 @@ static auto loadFromFile(tr_torrent* tor, tr_resume::fields_t fieldsToLoad, bool
|
|||
/* loading the resume file triggers of a lot of changes,
|
||||
* but none of them needs to trigger a re-saving of the
|
||||
* same resume information... */
|
||||
tor->isDirty = wasDirty;
|
||||
tor->isDirty = was_dirty;
|
||||
|
||||
tr_variantClear(&top);
|
||||
return fields_loaded;
|
||||
|
@ -851,10 +846,9 @@ static auto setFromCtor(tr_torrent* tor, tr_resume::fields_t fields, tr_ctor con
|
|||
|
||||
if ((fields & tr_resume::Run) != 0)
|
||||
{
|
||||
auto isPaused = bool{};
|
||||
if (tr_ctorGetPaused(ctor, mode, &isPaused))
|
||||
if (auto is_paused = bool{}; tr_ctorGetPaused(ctor, mode, &is_paused))
|
||||
{
|
||||
tor->isRunning = !isPaused;
|
||||
tor->isRunning = !is_paused;
|
||||
ret |= tr_resume::Run;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -892,19 +892,18 @@ tr_rpc_server::tr_rpc_server(tr_session* session_in, tr_variant* settings)
|
|||
, bindAddress(std::make_unique<struct tr_rpc_address>())
|
||||
, session{ session_in }
|
||||
{
|
||||
auto boolVal = bool{};
|
||||
auto i = int64_t{};
|
||||
auto sv = std::string_view{};
|
||||
|
||||
auto key = TR_KEY_rpc_enabled;
|
||||
|
||||
if (!tr_variantDictFindBool(settings, key, &boolVal))
|
||||
if (auto val = bool{}; !tr_variantDictFindBool(settings, key, &val))
|
||||
{
|
||||
missing_settings_key(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->is_enabled_ = boolVal;
|
||||
this->is_enabled_ = val;
|
||||
}
|
||||
|
||||
key = TR_KEY_rpc_port;
|
||||
|
@ -935,24 +934,24 @@ tr_rpc_server::tr_rpc_server(tr_session* session_in, tr_variant* settings)
|
|||
|
||||
key = TR_KEY_rpc_whitelist_enabled;
|
||||
|
||||
if (!tr_variantDictFindBool(settings, key, &boolVal))
|
||||
if (auto val = bool{}; !tr_variantDictFindBool(settings, key, &val))
|
||||
{
|
||||
missing_settings_key(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setWhitelistEnabled(boolVal);
|
||||
this->setWhitelistEnabled(val);
|
||||
}
|
||||
|
||||
key = TR_KEY_rpc_host_whitelist_enabled;
|
||||
|
||||
if (!tr_variantDictFindBool(settings, key, &boolVal))
|
||||
if (auto val = bool{}; !tr_variantDictFindBool(settings, key, &val))
|
||||
{
|
||||
missing_settings_key(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->isHostWhitelistEnabled = boolVal;
|
||||
this->isHostWhitelistEnabled = val;
|
||||
}
|
||||
|
||||
key = TR_KEY_rpc_host_whitelist;
|
||||
|
@ -968,13 +967,13 @@ tr_rpc_server::tr_rpc_server(tr_session* session_in, tr_variant* settings)
|
|||
|
||||
key = TR_KEY_rpc_authentication_required;
|
||||
|
||||
if (!tr_variantDictFindBool(settings, key, &boolVal))
|
||||
if (auto val = bool{}; !tr_variantDictFindBool(settings, key, &val))
|
||||
{
|
||||
missing_settings_key(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setPasswordEnabled(boolVal);
|
||||
this->setPasswordEnabled(val);
|
||||
}
|
||||
|
||||
key = TR_KEY_rpc_whitelist;
|
||||
|
@ -1012,13 +1011,13 @@ tr_rpc_server::tr_rpc_server(tr_session* session_in, tr_variant* settings)
|
|||
|
||||
key = TR_KEY_anti_brute_force_enabled;
|
||||
|
||||
if (!tr_variantDictFindBool(settings, key, &boolVal))
|
||||
if (auto val = bool{}; !tr_variantDictFindBool(settings, key, &val))
|
||||
{
|
||||
missing_settings_key(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setAntiBruteForceEnabled(boolVal);
|
||||
this->setAntiBruteForceEnabled(val);
|
||||
}
|
||||
|
||||
key = TR_KEY_anti_brute_force_threshold;
|
||||
|
|
|
@ -428,12 +428,12 @@ static void addTrackerStats(tr_tracker_view const& tracker, tr_variant* list)
|
|||
|
||||
static void addPeers(tr_torrent const* tor, tr_variant* list)
|
||||
{
|
||||
auto peerCount = int{};
|
||||
tr_peer_stat* peers = tr_torrentPeers(tor, &peerCount);
|
||||
auto peer_count = int{};
|
||||
tr_peer_stat* peers = tr_torrentPeers(tor, &peer_count);
|
||||
|
||||
tr_variantInitList(list, peerCount);
|
||||
tr_variantInitList(list, peer_count);
|
||||
|
||||
for (int i = 0; i < peerCount; ++i)
|
||||
for (int i = 0; i < peer_count; ++i)
|
||||
{
|
||||
tr_variant* d = tr_variantListAddDict(list, 16);
|
||||
tr_peer_stat const* peer = peers + i;
|
||||
|
@ -455,7 +455,7 @@ static void addPeers(tr_torrent const* tor, tr_variant* list)
|
|||
tr_variantDictAddInt(d, TR_KEY_rateToPeer, tr_toSpeedBytes(peer->rateToPeer_KBps));
|
||||
}
|
||||
|
||||
tr_torrentPeersFree(peers, peerCount);
|
||||
tr_torrentPeersFree(peers, peer_count);
|
||||
}
|
||||
|
||||
static void initField(tr_torrent const* const tor, tr_stat const* const st, tr_variant* const initme, tr_quark key)
|
||||
|
@ -825,22 +825,22 @@ static void initField(tr_torrent const* const tor, tr_stat const* const st, tr_v
|
|||
}
|
||||
}
|
||||
|
||||
static void addTorrentInfo(tr_torrent* tor, TrFormat format, tr_variant* entry, tr_quark const* fields, size_t fieldCount)
|
||||
static void addTorrentInfo(tr_torrent* tor, TrFormat format, tr_variant* entry, tr_quark const* fields, size_t field_count)
|
||||
{
|
||||
if (format == TrFormat::Table)
|
||||
{
|
||||
tr_variantInitList(entry, fieldCount);
|
||||
tr_variantInitList(entry, field_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_variantInitDict(entry, fieldCount);
|
||||
tr_variantInitDict(entry, field_count);
|
||||
}
|
||||
|
||||
if (fieldCount > 0)
|
||||
if (field_count > 0)
|
||||
{
|
||||
tr_stat const* const st = tr_torrentStat(tor);
|
||||
|
||||
for (size_t i = 0; i < fieldCount; ++i)
|
||||
for (size_t i = 0; i < field_count; ++i)
|
||||
{
|
||||
tr_variant* child = format == TrFormat::Table ? tr_variantListAdd(entry) : tr_variantDictAdd(entry, fields[i]);
|
||||
|
||||
|
@ -1127,7 +1127,6 @@ static char const* torrentSet(
|
|||
{
|
||||
auto tmp = int64_t{};
|
||||
auto d = double{};
|
||||
auto boolVal = bool{};
|
||||
tr_variant* tmp_variant = nullptr;
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_bandwidthPriority, &tmp))
|
||||
|
@ -1185,14 +1184,14 @@ static char const* torrentSet(
|
|||
tr_torrentSetSpeedLimit_KBps(tor, TR_DOWN, tmp);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_downloadLimited, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_downloadLimited, &val))
|
||||
{
|
||||
tr_torrentUseSpeedLimit(tor, TR_DOWN, boolVal);
|
||||
tr_torrentUseSpeedLimit(tor, TR_DOWN, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_honorsSessionLimits, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_honorsSessionLimits, &val))
|
||||
{
|
||||
tr_torrentUseSessionLimits(tor, boolVal);
|
||||
tr_torrentUseSessionLimits(tor, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_uploadLimit, &tmp))
|
||||
|
@ -1200,9 +1199,9 @@ static char const* torrentSet(
|
|||
tr_torrentSetSpeedLimit_KBps(tor, TR_UP, tmp);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_uploadLimited, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_uploadLimited, &val))
|
||||
{
|
||||
tr_torrentUseSpeedLimit(tor, TR_UP, boolVal);
|
||||
tr_torrentUseSpeedLimit(tor, TR_UP, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_seedIdleLimit, &tmp))
|
||||
|
@ -1350,8 +1349,8 @@ static void onPortTested(tr_web::FetchResponse const& web_response)
|
|||
}
|
||||
else /* success */
|
||||
{
|
||||
bool const isOpen = tr_strvStartsWith(body, '1');
|
||||
tr_variantDictAddBool(data->args_out, TR_KEY_port_is_open, isOpen);
|
||||
bool const is_open = tr_strvStartsWith(body, '1');
|
||||
tr_variantDictAddBool(data->args_out, TR_KEY_port_is_open, is_open);
|
||||
tr_idle_function_done(data, SuccessResult);
|
||||
}
|
||||
}
|
||||
|
@ -1576,7 +1575,6 @@ static char const* torrentAdd(tr_session* session, tr_variant* args_in, tr_varia
|
|||
}
|
||||
|
||||
auto i = int64_t{};
|
||||
auto boolVal = bool{};
|
||||
tr_variant* l = nullptr;
|
||||
tr_ctor* ctor = tr_ctorNew(session);
|
||||
|
||||
|
@ -1591,9 +1589,9 @@ static char const* torrentAdd(tr_session* session, tr_variant* args_in, tr_varia
|
|||
tr_ctorSetDownloadDir(ctor, TR_FORCE, sz_download_dir.c_str());
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_paused, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_paused, &val))
|
||||
{
|
||||
tr_ctorSetPaused(ctor, TR_FORCE, boolVal);
|
||||
tr_ctorSetPaused(ctor, TR_FORCE, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_peer_limit, &i))
|
||||
|
@ -1695,13 +1693,13 @@ static char const* groupGet(tr_session* s, tr_variant* args_in, tr_variant* args
|
|||
{
|
||||
names.insert(one_name);
|
||||
}
|
||||
else if (tr_variant* namesList = nullptr; tr_variantDictFindList(args_in, TR_KEY_name, &namesList))
|
||||
else if (tr_variant* names_list = nullptr; tr_variantDictFindList(args_in, TR_KEY_name, &names_list))
|
||||
{
|
||||
auto const names_count = tr_variantListSize(namesList);
|
||||
auto const names_count = tr_variantListSize(names_list);
|
||||
|
||||
for (size_t i = 0; i < names_count; ++i)
|
||||
{
|
||||
auto const* const v = tr_variantListChild(namesList, i);
|
||||
auto const* const v = tr_variantListChild(names_list, i);
|
||||
if (std::string_view l; tr_variantIsString(v) && tr_variantGetStrView(v, &l))
|
||||
{
|
||||
names.insert(l);
|
||||
|
@ -1792,7 +1790,6 @@ static char const* sessionSet(
|
|||
return "incomplete torrents directory path is not absolute";
|
||||
}
|
||||
|
||||
auto boolVal = bool{};
|
||||
auto d = double{};
|
||||
auto i = int64_t{};
|
||||
auto sv = std::string_view{};
|
||||
|
@ -1812,9 +1809,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetAltSpeed_KBps(session, TR_DOWN, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_alt_speed_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_alt_speed_enabled, &val))
|
||||
{
|
||||
tr_sessionUseAltSpeed(session, boolVal);
|
||||
tr_sessionUseAltSpeed(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_alt_speed_time_begin, &i))
|
||||
|
@ -1832,14 +1829,14 @@ static char const* sessionSet(
|
|||
tr_sessionSetAltSpeedDay(session, tr_sched_day(i));
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_alt_speed_time_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_alt_speed_time_enabled, &val))
|
||||
{
|
||||
tr_sessionUseAltSpeedTime(session, boolVal);
|
||||
tr_sessionUseAltSpeedTime(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_blocklist_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_blocklist_enabled, &val))
|
||||
{
|
||||
session->useBlocklist(boolVal);
|
||||
session->useBlocklist(val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStrView(args_in, TR_KEY_blocklist_url, &sv))
|
||||
|
@ -1857,9 +1854,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetQueueStalledMinutes(session, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_queue_stalled_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_queue_stalled_enabled, &val))
|
||||
{
|
||||
tr_sessionSetQueueStalledEnabled(session, boolVal);
|
||||
tr_sessionSetQueueStalledEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStrView(args_in, TR_KEY_default_trackers, &sv))
|
||||
|
@ -1872,9 +1869,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetQueueSize(session, TR_DOWN, (int)i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_download_queue_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_download_queue_enabled, &val))
|
||||
{
|
||||
tr_sessionSetQueueEnabled(session, TR_DOWN, boolVal);
|
||||
tr_sessionSetQueueEnabled(session, TR_DOWN, val);
|
||||
}
|
||||
|
||||
if (!std::empty(incomplete_dir))
|
||||
|
@ -1882,9 +1879,9 @@ static char const* sessionSet(
|
|||
session->setIncompleteDir(incomplete_dir);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_incomplete_dir_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_incomplete_dir_enabled, &val))
|
||||
{
|
||||
session->useIncompleteDir(boolVal);
|
||||
session->useIncompleteDir(val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_peer_limit_global, &i))
|
||||
|
@ -1897,29 +1894,29 @@ static char const* sessionSet(
|
|||
tr_sessionSetPeerLimitPerTorrent(session, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_pex_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_pex_enabled, &val))
|
||||
{
|
||||
tr_sessionSetPexEnabled(session, boolVal);
|
||||
tr_sessionSetPexEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_dht_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_dht_enabled, &val))
|
||||
{
|
||||
tr_sessionSetDHTEnabled(session, boolVal);
|
||||
tr_sessionSetDHTEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_utp_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_utp_enabled, &val))
|
||||
{
|
||||
tr_sessionSetUTPEnabled(session, boolVal);
|
||||
tr_sessionSetUTPEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_lpd_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_lpd_enabled, &val))
|
||||
{
|
||||
tr_sessionSetLPDEnabled(session, boolVal);
|
||||
tr_sessionSetLPDEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_peer_port_random_on_start, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_peer_port_random_on_start, &val))
|
||||
{
|
||||
tr_sessionSetPeerPortRandomOnStart(session, boolVal);
|
||||
tr_sessionSetPeerPortRandomOnStart(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_peer_port, &i))
|
||||
|
@ -1927,14 +1924,14 @@ static char const* sessionSet(
|
|||
tr_sessionSetPeerPort(session, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_port_forwarding_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_port_forwarding_enabled, &val))
|
||||
{
|
||||
tr_sessionSetPortForwardingEnabled(session, boolVal);
|
||||
tr_sessionSetPortForwardingEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_rename_partial_files, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_rename_partial_files, &val))
|
||||
{
|
||||
tr_sessionSetIncompleteFileNamingEnabled(session, boolVal);
|
||||
tr_sessionSetIncompleteFileNamingEnabled(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindReal(args_in, TR_KEY_seedRatioLimit, &d))
|
||||
|
@ -1942,9 +1939,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetRatioLimit(session, d);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_seedRatioLimited, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_seedRatioLimited, &val))
|
||||
{
|
||||
tr_sessionSetRatioLimited(session, boolVal);
|
||||
tr_sessionSetRatioLimited(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_idle_seeding_limit, &i))
|
||||
|
@ -1952,19 +1949,19 @@ static char const* sessionSet(
|
|||
tr_sessionSetIdleLimit(session, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_idle_seeding_limit_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_idle_seeding_limit_enabled, &val))
|
||||
{
|
||||
tr_sessionSetIdleLimited(session, boolVal);
|
||||
tr_sessionSetIdleLimited(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_start_added_torrents, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_start_added_torrents, &val))
|
||||
{
|
||||
tr_sessionSetPaused(session, !boolVal);
|
||||
tr_sessionSetPaused(session, !val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_seed_queue_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_seed_queue_enabled, &val))
|
||||
{
|
||||
tr_sessionSetQueueEnabled(session, TR_UP, boolVal);
|
||||
tr_sessionSetQueueEnabled(session, TR_UP, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_seed_queue_size, &i))
|
||||
|
@ -1985,9 +1982,9 @@ static char const* sessionSet(
|
|||
}
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_trash_original_torrent_files, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_trash_original_torrent_files, &val))
|
||||
{
|
||||
tr_sessionSetDeleteSource(session, boolVal);
|
||||
tr_sessionSetDeleteSource(session, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_speed_limit_down, &i))
|
||||
|
@ -1995,9 +1992,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetSpeedLimit_KBps(session, TR_DOWN, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_speed_limit_down_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_speed_limit_down_enabled, &val))
|
||||
{
|
||||
tr_sessionLimitSpeed(session, TR_DOWN, boolVal);
|
||||
tr_sessionLimitSpeed(session, TR_DOWN, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(args_in, TR_KEY_speed_limit_up, &i))
|
||||
|
@ -2005,9 +2002,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetSpeedLimit_KBps(session, TR_UP, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_speed_limit_up_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_speed_limit_up_enabled, &val))
|
||||
{
|
||||
tr_sessionLimitSpeed(session, TR_UP, boolVal);
|
||||
tr_sessionLimitSpeed(session, TR_UP, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStrView(args_in, TR_KEY_encryption, &sv))
|
||||
|
@ -2031,9 +2028,9 @@ static char const* sessionSet(
|
|||
tr_sessionSetAntiBruteForceThreshold(session, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(args_in, TR_KEY_anti_brute_force_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(args_in, TR_KEY_anti_brute_force_enabled, &val))
|
||||
{
|
||||
tr_sessionSetAntiBruteForceEnabled(session, boolVal);
|
||||
tr_sessionSetAntiBruteForceEnabled(session, val);
|
||||
}
|
||||
|
||||
session->rpcNotify(TR_RPC_SESSION_CHANGED, nullptr);
|
||||
|
@ -2568,19 +2565,19 @@ void tr_rpc_request_exec_json(
|
|||
void tr_rpc_parse_list_str(tr_variant* setme, std::string_view str)
|
||||
{
|
||||
auto const values = tr_parseNumberRange(str);
|
||||
auto const valueCount = std::size(values);
|
||||
auto const value_count = std::size(values);
|
||||
|
||||
if (valueCount == 0)
|
||||
if (value_count == 0)
|
||||
{
|
||||
tr_variantInitStr(setme, str);
|
||||
}
|
||||
else if (valueCount == 1)
|
||||
else if (value_count == 1)
|
||||
{
|
||||
tr_variantInitInt(setme, values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_variantInitList(setme, valueCount);
|
||||
tr_variantInitList(setme, value_count);
|
||||
|
||||
for (auto const& value : values)
|
||||
{
|
||||
|
|
|
@ -285,19 +285,19 @@ void tr_bindinfo::close()
|
|||
}
|
||||
}
|
||||
|
||||
static void accept_incoming_peer(evutil_socket_t fd, short /*what*/, void* vsession)
|
||||
static void acceptIncomingPeer(evutil_socket_t fd, short /*what*/, void* vsession)
|
||||
{
|
||||
auto* session = static_cast<tr_session*>(vsession);
|
||||
|
||||
auto clientAddr = tr_address{};
|
||||
auto clientPort = tr_port{};
|
||||
auto const clientSocket = tr_netAccept(session, fd, &clientAddr, &clientPort);
|
||||
auto client_addr = tr_address{};
|
||||
auto client_port = tr_port{};
|
||||
auto const client_socket = tr_netAccept(session, fd, &client_addr, &client_port);
|
||||
|
||||
if (clientSocket != TR_BAD_SOCKET)
|
||||
if (client_socket != TR_BAD_SOCKET)
|
||||
{
|
||||
tr_logAddTrace(fmt::format("new incoming connection {} ({})", clientSocket, clientAddr.readable(clientPort)));
|
||||
tr_logAddTrace(fmt::format("new incoming connection {} ({})", client_socket, client_addr.readable(client_port)));
|
||||
|
||||
tr_peerMgrAddIncoming(session->peerMgr, &clientAddr, clientPort, tr_peer_socket_tcp_create(clientSocket));
|
||||
tr_peerMgrAddIncoming(session->peerMgr, &client_addr, client_port, tr_peer_socket_tcp_create(client_socket));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ void tr_bindinfo::bindAndListenForIncomingPeers(tr_session* session)
|
|||
tr_logAddInfo(fmt::format(
|
||||
_("Listening to incoming peer connections on {hostport}"),
|
||||
fmt::arg("hostport", addr_.readable(session->private_peer_port))));
|
||||
ev_ = event_new(session->eventBase(), socket_, EV_READ | EV_PERSIST, accept_incoming_peer, session);
|
||||
ev_ = event_new(session->eventBase(), socket_, EV_READ | EV_PERSIST, acceptIncomingPeer, session);
|
||||
event_add(ev_, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -539,31 +539,30 @@ static void getSettingsFilename(tr_pathbuf& setme, char const* config_dir, char
|
|||
setme.assign(std::string_view{ default_config_dir }, "/settings.json"sv);
|
||||
}
|
||||
|
||||
bool tr_sessionLoadSettings(tr_variant* dict, char const* config_dir, char const* appName)
|
||||
bool tr_sessionLoadSettings(tr_variant* dict, char const* config_dir, char const* app_name)
|
||||
{
|
||||
TR_ASSERT(tr_variantIsDict(dict));
|
||||
|
||||
/* initializing the defaults: caller may have passed in some app-level defaults.
|
||||
* preserve those and use the session defaults to fill in any missing gaps. */
|
||||
auto oldDict = *dict;
|
||||
auto old_dict = *dict;
|
||||
tr_variantInitDict(dict, 0);
|
||||
tr_sessionGetDefaultSettings(dict);
|
||||
tr_variantMergeDicts(dict, &oldDict);
|
||||
tr_variantClear(&oldDict);
|
||||
tr_variantMergeDicts(dict, &old_dict);
|
||||
tr_variantClear(&old_dict);
|
||||
|
||||
/* file settings override the defaults */
|
||||
auto fileSettings = tr_variant{};
|
||||
auto success = bool{};
|
||||
auto filename = tr_pathbuf{};
|
||||
getSettingsFilename(filename, config_dir, appName);
|
||||
getSettingsFilename(filename, config_dir, app_name);
|
||||
if (!tr_sys_path_exists(filename))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
else if (tr_variantFromFile(&fileSettings, TR_VARIANT_PARSE_JSON, filename))
|
||||
else if (auto file_settings = tr_variant{}; tr_variantFromFile(&file_settings, TR_VARIANT_PARSE_JSON, filename))
|
||||
{
|
||||
tr_variantMergeDicts(dict, &fileSettings);
|
||||
tr_variantClear(&fileSettings);
|
||||
tr_variantMergeDicts(dict, &file_settings);
|
||||
tr_variantClear(&file_settings);
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
|
@ -596,11 +595,11 @@ void tr_sessionSaveSettings(tr_session* session, char const* config_dir, tr_vari
|
|||
|
||||
/* the session's true values override the file & client settings */
|
||||
{
|
||||
tr_variant sessionSettings;
|
||||
tr_variantInitDict(&sessionSettings, 0);
|
||||
tr_sessionGetSettings(session, &sessionSettings);
|
||||
tr_variantMergeDicts(&settings, &sessionSettings);
|
||||
tr_variantClear(&sessionSettings);
|
||||
auto session_settings = tr_variant{};
|
||||
tr_variantInitDict(&session_settings, 0);
|
||||
tr_sessionGetSettings(session, &session_settings);
|
||||
tr_variantMergeDicts(&settings, &session_settings);
|
||||
tr_variantClear(&session_settings);
|
||||
}
|
||||
|
||||
/* save the result */
|
||||
|
@ -777,7 +776,6 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_variant* const settings = data.client_settings;
|
||||
TR_ASSERT(tr_variantIsDict(settings));
|
||||
|
||||
auto boolVal = bool{};
|
||||
auto d = double{};
|
||||
auto i = int64_t{};
|
||||
auto sv = std::string_view{};
|
||||
|
@ -820,29 +818,29 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetPeerLimitPerTorrent(this, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_pex_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_pex_enabled, &val))
|
||||
{
|
||||
tr_sessionSetPexEnabled(this, boolVal);
|
||||
tr_sessionSetPexEnabled(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_dht_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_dht_enabled, &val))
|
||||
{
|
||||
tr_sessionSetDHTEnabled(this, boolVal);
|
||||
tr_sessionSetDHTEnabled(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_tcp_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_tcp_enabled, &val))
|
||||
{
|
||||
is_tcp_enabled_ = boolVal;
|
||||
is_tcp_enabled_ = val;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_utp_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_utp_enabled, &val))
|
||||
{
|
||||
tr_sessionSetUTPEnabled(this, boolVal);
|
||||
tr_sessionSetUTPEnabled(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_lpd_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_lpd_enabled, &val))
|
||||
{
|
||||
tr_sessionSetLPDEnabled(this, boolVal);
|
||||
tr_sessionSetLPDEnabled(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_encryption, &i))
|
||||
|
@ -866,9 +864,9 @@ void tr_session::setImpl(init_data& data)
|
|||
(void)tr_variantDictFindStrView(settings, TR_KEY_peer_congestion_algorithm, &sv);
|
||||
setPeerCongestionAlgorithm(sv);
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_blocklist_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_blocklist_enabled, &val))
|
||||
{
|
||||
useBlocklist(boolVal);
|
||||
useBlocklist(val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStrView(settings, TR_KEY_blocklist_url, &sv))
|
||||
|
@ -876,14 +874,14 @@ void tr_session::setImpl(init_data& data)
|
|||
setBlocklistUrl(sv);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_start_added_torrents, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_start_added_torrents, &val))
|
||||
{
|
||||
tr_sessionSetPaused(this, !boolVal);
|
||||
tr_sessionSetPaused(this, !val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_trash_original_torrent_files, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_trash_original_torrent_files, &val))
|
||||
{
|
||||
tr_sessionSetDeleteSource(this, boolVal);
|
||||
tr_sessionSetDeleteSource(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_peer_id_ttl_hours, &i))
|
||||
|
@ -897,9 +895,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetQueueStalledMinutes(this, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_queue_stalled_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_queue_stalled_enabled, &val))
|
||||
{
|
||||
tr_sessionSetQueueStalledEnabled(this, boolVal);
|
||||
tr_sessionSetQueueStalledEnabled(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_download_queue_size, &i))
|
||||
|
@ -907,9 +905,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetQueueSize(this, TR_DOWN, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_download_queue_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_download_queue_enabled, &val))
|
||||
{
|
||||
tr_sessionSetQueueEnabled(this, TR_DOWN, boolVal);
|
||||
tr_sessionSetQueueEnabled(this, TR_DOWN, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_seed_queue_size, &i))
|
||||
|
@ -917,15 +915,15 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetQueueSize(this, TR_UP, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_seed_queue_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_seed_queue_enabled, &val))
|
||||
{
|
||||
tr_sessionSetQueueEnabled(this, TR_UP, boolVal);
|
||||
tr_sessionSetQueueEnabled(this, TR_UP, val);
|
||||
}
|
||||
|
||||
/* files and directories */
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_prefetch_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_prefetch_enabled, &val))
|
||||
{
|
||||
this->is_prefetch_enabled_ = boolVal;
|
||||
this->is_prefetch_enabled_ = val;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_preallocation, &i))
|
||||
|
@ -943,14 +941,14 @@ void tr_session::setImpl(init_data& data)
|
|||
this->setIncompleteDir(sv);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_incomplete_dir_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_incomplete_dir_enabled, &val))
|
||||
{
|
||||
this->useIncompleteDir(boolVal);
|
||||
this->useIncompleteDir(val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_rename_partial_files, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_rename_partial_files, &val))
|
||||
{
|
||||
tr_sessionSetIncompleteFileNamingEnabled(this, boolVal);
|
||||
tr_sessionSetIncompleteFileNamingEnabled(this, val);
|
||||
}
|
||||
|
||||
/* rpc server */
|
||||
|
@ -995,9 +993,9 @@ void tr_session::setImpl(init_data& data)
|
|||
this->random_port_high_.setHost(i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_peer_port_random_on_start, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_peer_port_random_on_start, &val))
|
||||
{
|
||||
tr_sessionSetPeerPortRandomOnStart(this, boolVal);
|
||||
tr_sessionSetPeerPortRandomOnStart(this, val);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1008,12 +1006,12 @@ void tr_session::setImpl(init_data& data)
|
|||
peer_port.setHost(static_cast<uint16_t>(port));
|
||||
}
|
||||
|
||||
::setPeerPort(this, boolVal ? randomPort() : peer_port);
|
||||
::setPeerPort(this, isPortRandom() ? randomPort() : peer_port);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_port_forwarding_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_port_forwarding_enabled, &val))
|
||||
{
|
||||
tr_sessionSetPortForwardingEnabled(this, boolVal);
|
||||
tr_sessionSetPortForwardingEnabled(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_peer_limit_global, &i))
|
||||
|
@ -1034,9 +1032,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetSpeedLimit_KBps(this, TR_UP, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_speed_limit_up_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_speed_limit_up_enabled, &val))
|
||||
{
|
||||
tr_sessionLimitSpeed(this, TR_UP, boolVal);
|
||||
tr_sessionLimitSpeed(this, TR_UP, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_speed_limit_down, &i))
|
||||
|
@ -1044,9 +1042,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetSpeedLimit_KBps(this, TR_DOWN, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_speed_limit_down_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_speed_limit_down_enabled, &val))
|
||||
{
|
||||
tr_sessionLimitSpeed(this, TR_DOWN, boolVal);
|
||||
tr_sessionLimitSpeed(this, TR_DOWN, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindReal(settings, TR_KEY_ratio_limit, &d))
|
||||
|
@ -1054,9 +1052,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetRatioLimit(this, d);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_ratio_limit_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_ratio_limit_enabled, &val))
|
||||
{
|
||||
tr_sessionSetRatioLimited(this, boolVal);
|
||||
tr_sessionSetRatioLimited(this, val);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindInt(settings, TR_KEY_idle_seeding_limit, &i))
|
||||
|
@ -1064,9 +1062,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetIdleLimit(this, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_idle_seeding_limit_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_idle_seeding_limit_enabled, &val))
|
||||
{
|
||||
tr_sessionSetIdleLimited(this, boolVal);
|
||||
tr_sessionSetIdleLimited(this, val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1099,14 +1097,14 @@ void tr_session::setImpl(init_data& data)
|
|||
turtle.days = tr_sched_day(i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_alt_speed_time_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_alt_speed_time_enabled, &val))
|
||||
{
|
||||
turtle.isClockEnabled = boolVal;
|
||||
turtle.isClockEnabled = val;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_alt_speed_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_alt_speed_enabled, &val))
|
||||
{
|
||||
turtle.isEnabled = boolVal;
|
||||
turtle.isEnabled = val;
|
||||
}
|
||||
|
||||
turtleBootstrap(this, &turtle);
|
||||
|
@ -1124,9 +1122,9 @@ void tr_session::setImpl(init_data& data)
|
|||
}
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_scrape_paused_torrents_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_scrape_paused_torrents_enabled, &val))
|
||||
{
|
||||
this->should_scrape_paused_torrents_ = boolVal;
|
||||
this->should_scrape_paused_torrents_ = val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1138,9 +1136,9 @@ void tr_session::setImpl(init_data& data)
|
|||
tr_sessionSetAntiBruteForceThreshold(this, i);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_anti_brute_force_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_anti_brute_force_enabled, &val))
|
||||
{
|
||||
tr_sessionSetAntiBruteForceEnabled(this, boolVal);
|
||||
tr_sessionSetAntiBruteForceEnabled(this, val);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1151,9 +1149,9 @@ void tr_session::setImpl(init_data& data)
|
|||
this->setAnnounceIP(sv);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindBool(settings, TR_KEY_announce_ip_enabled, &boolVal))
|
||||
if (auto val = bool{}; tr_variantDictFindBool(settings, TR_KEY_announce_ip_enabled, &val))
|
||||
{
|
||||
this->useAnnounceIP(boolVal);
|
||||
this->useAnnounceIP(val);
|
||||
}
|
||||
|
||||
data.done_cv.notify_one();
|
||||
|
@ -1414,10 +1412,10 @@ std::optional<unsigned int> tr_session::activeSpeedLimitBps(tr_direction dir) co
|
|||
|
||||
static void updateBandwidth(tr_session* session, tr_direction dir)
|
||||
{
|
||||
if (auto const limit_Bps = session->activeSpeedLimitBps(dir); limit_Bps)
|
||||
if (auto const limit_bytes_per_second = session->activeSpeedLimitBps(dir); limit_bytes_per_second)
|
||||
{
|
||||
session->top_bandwidth_.setLimited(dir, *limit_Bps > 0U);
|
||||
session->top_bandwidth_.setDesiredSpeedBytesPerSecond(dir, *limit_Bps);
|
||||
session->top_bandwidth_.setLimited(dir, *limit_bytes_per_second > 0U);
|
||||
session->top_bandwidth_.setDesiredSpeedBytesPerSecond(dir, *limit_bytes_per_second);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1468,7 +1466,7 @@ static void altSpeedToggled(tr_session* const session)
|
|||
}
|
||||
}
|
||||
|
||||
static void useAltSpeed(tr_session* s, struct tr_turtle_info* t, bool enabled, bool byUser)
|
||||
static void useAltSpeed(tr_session* s, struct tr_turtle_info* t, bool enabled, bool by_user)
|
||||
{
|
||||
TR_ASSERT(s != nullptr);
|
||||
TR_ASSERT(t != nullptr);
|
||||
|
@ -1476,7 +1474,7 @@ static void useAltSpeed(tr_session* s, struct tr_turtle_info* t, bool enabled, b
|
|||
if (t->isEnabled != enabled)
|
||||
{
|
||||
t->isEnabled = enabled;
|
||||
t->changedByUser = byUser;
|
||||
t->changedByUser = by_user;
|
||||
tr_runInEventThread(s, altSpeedToggled, s);
|
||||
}
|
||||
}
|
||||
|
@ -1508,14 +1506,14 @@ static void turtleCheckClock(tr_session* s, struct tr_turtle_info* t)
|
|||
{
|
||||
TR_ASSERT(t->isClockEnabled);
|
||||
|
||||
bool const enabled = getInTurtleTime(t);
|
||||
tr_auto_switch_state_t const newAutoTurtleState = autoSwitchState(enabled);
|
||||
bool const alreadySwitched = t->autoTurtleState == newAutoTurtleState;
|
||||
auto const enabled = getInTurtleTime(t);
|
||||
auto const new_auto_turtle_state = autoSwitchState(enabled);
|
||||
auto const already_switched = t->autoTurtleState == new_auto_turtle_state;
|
||||
|
||||
if (!alreadySwitched)
|
||||
if (!already_switched)
|
||||
{
|
||||
tr_logAddInfo(enabled ? _("Time to turn on turtle mode") : _("Time to turn off turtle mode"));
|
||||
t->autoTurtleState = newAutoTurtleState;
|
||||
t->autoTurtleState = new_auto_turtle_state;
|
||||
useAltSpeed(s, t, enabled, false);
|
||||
}
|
||||
}
|
||||
|
@ -1544,19 +1542,19 @@ static void turtleBootstrap(tr_session* session, struct tr_turtle_info* turtle)
|
|||
**** Primary session speed limits
|
||||
***/
|
||||
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, unsigned int Bps)
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session* session, tr_direction dir, unsigned int bytes_per_second)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
session->speed_limit_Bps_[dir] = Bps;
|
||||
session->speed_limit_Bps_[dir] = bytes_per_second;
|
||||
|
||||
updateBandwidth(session, dir);
|
||||
}
|
||||
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session* session, tr_direction dir, unsigned int KBps)
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session* session, tr_direction dir, unsigned int kilo_per_second)
|
||||
{
|
||||
tr_sessionSetSpeedLimit_Bps(session, dir, tr_toSpeedBytes(KBps));
|
||||
tr_sessionSetSpeedLimit_Bps(session, dir, tr_toSpeedBytes(kilo_per_second));
|
||||
}
|
||||
|
||||
unsigned int tr_sessionGetSpeedLimit_KBps(tr_session const* s, tr_direction d)
|
||||
|
@ -1586,19 +1584,19 @@ bool tr_sessionIsSpeedLimited(tr_session const* session, tr_direction dir)
|
|||
**** Alternative speed limits that are used during scheduled times
|
||||
***/
|
||||
|
||||
static void tr_sessionSetAltSpeed_Bps(tr_session* s, tr_direction d, unsigned int Bps)
|
||||
static void tr_sessionSetAltSpeed_Bps(tr_session* s, tr_direction d, unsigned int bytes_per_second)
|
||||
{
|
||||
TR_ASSERT(s != nullptr);
|
||||
TR_ASSERT(tr_isDirection(d));
|
||||
|
||||
s->turtle.speedLimit_Bps[d] = Bps;
|
||||
s->turtle.speedLimit_Bps[d] = bytes_per_second;
|
||||
|
||||
updateBandwidth(s, d);
|
||||
}
|
||||
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session* s, tr_direction d, unsigned int KBps)
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session* s, tr_direction d, unsigned int kilo_per_second)
|
||||
{
|
||||
tr_sessionSetAltSpeed_Bps(s, d, tr_toSpeedBytes(KBps));
|
||||
tr_sessionSetAltSpeed_Bps(s, d, tr_toSpeedBytes(kilo_per_second));
|
||||
}
|
||||
|
||||
static unsigned int tr_sessionGetAltSpeed_Bps(tr_session const* s, tr_direction d)
|
||||
|
@ -1720,12 +1718,12 @@ bool tr_sessionUsesAltSpeed(tr_session const* s)
|
|||
return s->turtle.isEnabled;
|
||||
}
|
||||
|
||||
void tr_sessionSetAltSpeedFunc(tr_session* session, tr_altSpeedFunc func, void* userData)
|
||||
void tr_sessionSetAltSpeedFunc(tr_session* session, tr_altSpeedFunc func, void* user_data)
|
||||
{
|
||||
TR_ASSERT(session != nullptr);
|
||||
|
||||
session->turtle.callback = func;
|
||||
session->turtle.callbackUserData = userData;
|
||||
session->turtle.callbackUserData = user_data;
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -1832,9 +1830,9 @@ void tr_session::closeImplStart()
|
|||
std::end(torrents),
|
||||
[](auto const* a, auto const* b)
|
||||
{
|
||||
auto const aCur = a->downloadedCur + a->uploadedCur;
|
||||
auto const bCur = b->downloadedCur + b->uploadedCur;
|
||||
return aCur > bCur; // larger xfers go first
|
||||
auto const a_cur = a->downloadedCur + a->uploadedCur;
|
||||
auto const b_cur = b->downloadedCur + b->uploadedCur;
|
||||
return a_cur > b_cur; // larger xfers go first
|
||||
});
|
||||
|
||||
for (auto* tor : torrents)
|
||||
|
|
|
@ -132,20 +132,20 @@ bool tr_ctorSaveContents(tr_ctor const* ctor, std::string_view filename, tr_erro
|
|||
****
|
||||
***/
|
||||
|
||||
void tr_ctorSetFilePriorities(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t fileCount, tr_priority_t priority)
|
||||
void tr_ctorSetFilePriorities(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t file_count, tr_priority_t priority)
|
||||
{
|
||||
switch (priority)
|
||||
{
|
||||
case TR_PRI_LOW:
|
||||
ctor->low.assign(files, files + fileCount);
|
||||
ctor->low.assign(files, files + file_count);
|
||||
break;
|
||||
|
||||
case TR_PRI_HIGH:
|
||||
ctor->high.assign(files, files + fileCount);
|
||||
ctor->high.assign(files, files + file_count);
|
||||
break;
|
||||
|
||||
default: // TR_PRI_NORMAL
|
||||
ctor->normal.assign(files, files + fileCount);
|
||||
ctor->normal.assign(files, files + file_count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -157,10 +157,10 @@ void tr_ctorInitTorrentPriorities(tr_ctor const* ctor, tr_torrent* tor)
|
|||
tor->setFilePriorities(std::data(ctor->high), std::size(ctor->high), TR_PRI_HIGH);
|
||||
}
|
||||
|
||||
void tr_ctorSetFilesWanted(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t fileCount, bool wanted)
|
||||
void tr_ctorSetFilesWanted(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t file_count, bool wanted)
|
||||
{
|
||||
auto& indices = wanted ? ctor->wanted : ctor->unwanted;
|
||||
indices.assign(files, files + fileCount);
|
||||
indices.assign(files, files + file_count);
|
||||
}
|
||||
|
||||
void tr_ctorInitTorrentWanted(tr_ctor const* ctor, tr_torrent* tor)
|
||||
|
|
|
@ -404,11 +404,11 @@ void appendSanitizedComponent(std::string_view in, tr_pathbuf& out)
|
|||
}
|
||||
|
||||
// replace reserved characters with an underscore
|
||||
static auto constexpr add_char = [](auto ch)
|
||||
static auto constexpr AddChar = [](auto ch)
|
||||
{
|
||||
return isReservedChar(ch) ? '_' : ch;
|
||||
};
|
||||
std::transform(std::begin(in), std::end(in), std::back_inserter(out), add_char);
|
||||
std::transform(std::begin(in), std::end(in), std::back_inserter(out), AddChar);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -188,19 +188,19 @@ tr_peer_id_t const& tr_torrentGetPeerId(tr_torrent* tor)
|
|||
**** PER-TORRENT UL / DL SPEEDS
|
||||
***/
|
||||
|
||||
void tr_torrent::setSpeedLimitBps(tr_direction dir, unsigned int Bps)
|
||||
void tr_torrent::setSpeedLimitBps(tr_direction dir, unsigned int bytes_per_second)
|
||||
{
|
||||
TR_ASSERT(tr_isDirection(dir));
|
||||
|
||||
if (this->bandwidth_.setDesiredSpeedBytesPerSecond(dir, Bps))
|
||||
if (this->bandwidth_.setDesiredSpeedBytesPerSecond(dir, bytes_per_second))
|
||||
{
|
||||
this->setDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent* tor, tr_direction dir, unsigned int KBps)
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent* tor, tr_direction dir, unsigned int kilo_per_second)
|
||||
{
|
||||
tor->setSpeedLimitBps(dir, tr_toSpeedBytes(KBps));
|
||||
tor->setSpeedLimitBps(dir, tr_toSpeedBytes(kilo_per_second));
|
||||
}
|
||||
|
||||
unsigned int tr_torrent::speedLimitBps(tr_direction dir) const
|
||||
|
@ -236,11 +236,11 @@ bool tr_torrentUsesSpeedLimit(tr_torrent const* tor, tr_direction dir)
|
|||
return tor->bandwidth_.isLimited(dir);
|
||||
}
|
||||
|
||||
void tr_torrentUseSessionLimits(tr_torrent* tor, bool doUse)
|
||||
void tr_torrentUseSessionLimits(tr_torrent* tor, bool do_use)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
|
||||
if (tor->bandwidth_.honorParentLimits(TR_UP, doUse) || tor->bandwidth_.honorParentLimits(TR_DOWN, doUse))
|
||||
if (tor->bandwidth_.honorParentLimits(TR_UP, do_use) || tor->bandwidth_.honorParentLimits(TR_DOWN, do_use))
|
||||
{
|
||||
tor->setDirty();
|
||||
}
|
||||
|
@ -277,13 +277,13 @@ tr_ratiolimit tr_torrentGetRatioMode(tr_torrent const* tor)
|
|||
return tor->ratioLimitMode;
|
||||
}
|
||||
|
||||
void tr_torrentSetRatioLimit(tr_torrent* tor, double desiredRatio)
|
||||
void tr_torrentSetRatioLimit(tr_torrent* tor, double desired_ratio)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
|
||||
if ((int)(desiredRatio * 100.0) != (int)(tor->desiredRatio * 100.0))
|
||||
if ((int)(desired_ratio * 100.0) != (int)(tor->desiredRatio * 100.0))
|
||||
{
|
||||
tor->desiredRatio = desiredRatio;
|
||||
tor->desiredRatio = desired_ratio;
|
||||
|
||||
tor->setDirty();
|
||||
}
|
||||
|
@ -364,8 +364,8 @@ static bool tr_torrentGetSeedRatioBytes(tr_torrent const* tor, uint64_t* setme_l
|
|||
|
||||
static bool tr_torrentIsSeedRatioDone(tr_torrent const* tor)
|
||||
{
|
||||
auto bytesLeft = uint64_t{};
|
||||
return tr_torrentGetSeedRatioBytes(tor, &bytesLeft, nullptr) && bytesLeft == 0;
|
||||
auto bytes_left = uint64_t{};
|
||||
return tr_torrentGetSeedRatioBytes(tor, &bytes_left, nullptr) && bytes_left == 0;
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -392,13 +392,13 @@ tr_idlelimit tr_torrentGetIdleMode(tr_torrent const* tor)
|
|||
return tor->idleLimitMode;
|
||||
}
|
||||
|
||||
void tr_torrentSetIdleLimit(tr_torrent* tor, uint16_t idleMinutes)
|
||||
void tr_torrentSetIdleLimit(tr_torrent* tor, uint16_t idle_minutes)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
|
||||
if (idleMinutes > 0)
|
||||
if (idle_minutes > 0)
|
||||
{
|
||||
tor->idleLimitMinutes = idleMinutes;
|
||||
tor->idleLimitMinutes = idle_minutes;
|
||||
|
||||
tor->setDirty();
|
||||
}
|
||||
|
@ -411,45 +411,45 @@ uint16_t tr_torrentGetIdleLimit(tr_torrent const* tor)
|
|||
return tor->idleLimitMinutes;
|
||||
}
|
||||
|
||||
bool tr_torrentGetSeedIdle(tr_torrent const* tor, uint16_t* idleMinutes)
|
||||
bool tr_torrentGetSeedIdle(tr_torrent const* tor, uint16_t* idle_minutes)
|
||||
{
|
||||
auto isLimited = bool{};
|
||||
auto is_limited = bool{};
|
||||
|
||||
switch (tr_torrentGetIdleMode(tor))
|
||||
{
|
||||
case TR_IDLELIMIT_SINGLE:
|
||||
isLimited = true;
|
||||
is_limited = true;
|
||||
|
||||
if (idleMinutes != nullptr)
|
||||
if (idle_minutes != nullptr)
|
||||
{
|
||||
*idleMinutes = tr_torrentGetIdleLimit(tor);
|
||||
*idle_minutes = tr_torrentGetIdleLimit(tor);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TR_IDLELIMIT_GLOBAL:
|
||||
isLimited = tor->session->isIdleLimited();
|
||||
is_limited = tor->session->isIdleLimited();
|
||||
|
||||
if (isLimited && idleMinutes != nullptr)
|
||||
if (is_limited && idle_minutes != nullptr)
|
||||
{
|
||||
*idleMinutes = tor->session->idleLimitMinutes();
|
||||
*idle_minutes = tor->session->idleLimitMinutes();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default: /* TR_IDLELIMIT_UNLIMITED */
|
||||
isLimited = false;
|
||||
is_limited = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return isLimited;
|
||||
return is_limited;
|
||||
}
|
||||
|
||||
static bool tr_torrentIsSeedIdleLimitDone(tr_torrent const* tor)
|
||||
{
|
||||
auto idleMinutes = uint16_t{};
|
||||
return tr_torrentGetSeedIdle(tor, &idleMinutes) &&
|
||||
difftime(tr_time(), std::max(tor->startDate, tor->activityDate)) >= idleMinutes * 60U;
|
||||
auto idle_minutes = uint16_t{};
|
||||
return tr_torrentGetSeedIdle(tor, &idle_minutes) &&
|
||||
difftime(tr_time(), std::max(tor->startDate, tor->activityDate)) >= idle_minutes * 60U;
|
||||
}
|
||||
|
||||
static void torrentCallScript(tr_torrent const* tor, std::string const& script);
|
||||
|
@ -749,7 +749,7 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor)
|
|||
|
||||
tor->refreshCurrentDir();
|
||||
|
||||
bool const doStart = tor->isRunning;
|
||||
bool const do_start = tor->isRunning;
|
||||
tor->isRunning = false;
|
||||
|
||||
if ((loaded & tr_resume::Speedlimit) == 0)
|
||||
|
@ -824,7 +824,7 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor)
|
|||
callScriptIfEnabled(tor, TR_SCRIPT_ON_TORRENT_ADDED);
|
||||
}
|
||||
|
||||
if (!tor->hasMetainfo() && !doStart)
|
||||
if (!tor->hasMetainfo() && !do_start)
|
||||
{
|
||||
auto opts = torrent_start_opts{};
|
||||
opts.bypass_queue = true;
|
||||
|
@ -839,11 +839,11 @@ static void torrentInit(tr_torrent* tor, tr_ctor const* ctor)
|
|||
}
|
||||
else
|
||||
{
|
||||
tor->startAfterVerify = doStart;
|
||||
tor->startAfterVerify = do_start;
|
||||
tr_torrentVerify(tor);
|
||||
}
|
||||
}
|
||||
else if (doStart)
|
||||
else if (do_start)
|
||||
{
|
||||
// if checked_pieces_ got populated from the loading the resume
|
||||
// file above, then torrentStart doesn't need to check again
|
||||
|
@ -1041,10 +1041,10 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
s->peersFrom[i] = swarm_stats.peer_from_count[i];
|
||||
}
|
||||
|
||||
auto const pieceUploadSpeed_Bps = tor->bandwidth_.getPieceSpeedBytesPerSecond(now, TR_UP);
|
||||
s->pieceUploadSpeed_KBps = tr_toSpeedKBps(pieceUploadSpeed_Bps);
|
||||
auto const pieceDownloadSpeed_Bps = tor->bandwidth_.getPieceSpeedBytesPerSecond(now, TR_DOWN);
|
||||
s->pieceDownloadSpeed_KBps = tr_toSpeedKBps(pieceDownloadSpeed_Bps);
|
||||
auto const piece_upload_speed_bytes_per_second = tor->bandwidth_.getPieceSpeedBytesPerSecond(now, TR_UP);
|
||||
s->pieceUploadSpeed_KBps = tr_toSpeedKBps(piece_upload_speed_bytes_per_second);
|
||||
auto const piece_download_speed_bytes_per_second = tor->bandwidth_.getPieceSpeedBytesPerSecond(now, TR_DOWN);
|
||||
s->pieceDownloadSpeed_KBps = tr_toSpeedKBps(piece_download_speed_bytes_per_second);
|
||||
|
||||
s->percentComplete = tor->completion.percentComplete();
|
||||
s->metadataPercentComplete = tr_torrentGetMetadataPercent(tor);
|
||||
|
@ -1072,9 +1072,9 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
|
||||
s->ratio = tr_getRatio(s->uploadedEver, tor->sizeWhenDone());
|
||||
|
||||
auto seedRatioBytesLeft = uint64_t{};
|
||||
auto seedRatioBytesGoal = uint64_t{};
|
||||
bool const seedRatioApplies = tr_torrentGetSeedRatioBytes(tor, &seedRatioBytesLeft, &seedRatioBytesGoal);
|
||||
auto seed_ratio_bytes_left = uint64_t{};
|
||||
auto seed_ratio_bytes_goal = uint64_t{};
|
||||
bool const seed_ratio_applies = tr_torrentGetSeedRatioBytes(tor, &seed_ratio_bytes_left, &seed_ratio_bytes_goal);
|
||||
|
||||
switch (s->activity)
|
||||
{
|
||||
|
@ -1086,8 +1086,8 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
if (tor->etaSpeedCalculatedAt + 800 < now)
|
||||
{
|
||||
tor->etaSpeed_Bps = tor->etaSpeedCalculatedAt + 4000 < now ?
|
||||
pieceDownloadSpeed_Bps : /* if no recent previous speed, no need to smooth */
|
||||
(tor->etaSpeed_Bps * 4.0 + pieceDownloadSpeed_Bps) / 5.0; /* smooth across 5 readings */
|
||||
piece_download_speed_bytes_per_second : /* if no recent previous speed, no need to smooth */
|
||||
(tor->etaSpeed_Bps * 4.0 + piece_download_speed_bytes_per_second) / 5.0; /* smooth across 5 readings */
|
||||
tor->etaSpeedCalculatedAt = now;
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
break;
|
||||
|
||||
case TR_STATUS_SEED:
|
||||
if (!seedRatioApplies)
|
||||
if (!seed_ratio_applies)
|
||||
{
|
||||
s->eta = TR_ETA_NOT_AVAIL;
|
||||
}
|
||||
|
@ -1117,8 +1117,8 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
if (tor->etaSpeedCalculatedAt + 800 < now)
|
||||
{
|
||||
tor->etaSpeed_Bps = tor->etaSpeedCalculatedAt + 4000 < now ?
|
||||
pieceUploadSpeed_Bps : /* if no recent previous speed, no need to smooth */
|
||||
(tor->etaSpeed_Bps * 4.0 + pieceUploadSpeed_Bps) / 5.0; /* smooth across 5 readings */
|
||||
piece_upload_speed_bytes_per_second : /* if no recent previous speed, no need to smooth */
|
||||
(tor->etaSpeed_Bps * 4.0 + piece_upload_speed_bytes_per_second) / 5.0; /* smooth across 5 readings */
|
||||
tor->etaSpeedCalculatedAt = now;
|
||||
}
|
||||
|
||||
|
@ -1128,14 +1128,14 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
}
|
||||
else
|
||||
{
|
||||
s->eta = seedRatioBytesLeft / tor->etaSpeed_Bps;
|
||||
s->eta = seed_ratio_bytes_left / tor->etaSpeed_Bps;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto seedIdleMinutes = uint16_t{};
|
||||
s->etaIdle = tor->etaSpeed_Bps < 1 && tr_torrentGetSeedIdle(tor, &seedIdleMinutes) ?
|
||||
seedIdleMinutes * 60 - s->idleSecs :
|
||||
auto seed_idle_minutes = uint16_t{};
|
||||
s->etaIdle = tor->etaSpeed_Bps < 1 && tr_torrentGetSeedIdle(tor, &seed_idle_minutes) ?
|
||||
seed_idle_minutes * 60 - s->idleSecs :
|
||||
TR_ETA_NOT_AVAIL;
|
||||
}
|
||||
|
||||
|
@ -1149,19 +1149,19 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
|
||||
/* s->haveValid is here to make sure a torrent isn't marked 'finished'
|
||||
* when the user hits "uncheck all" prior to starting the torrent... */
|
||||
s->finished = tor->finishedSeedingByIdle || (seedRatioApplies && seedRatioBytesLeft == 0 && s->haveValid != 0);
|
||||
s->finished = tor->finishedSeedingByIdle || (seed_ratio_applies && seed_ratio_bytes_left == 0 && s->haveValid != 0);
|
||||
|
||||
if (!seedRatioApplies || s->finished)
|
||||
if (!seed_ratio_applies || s->finished)
|
||||
{
|
||||
s->seedRatioPercentDone = 1.0F;
|
||||
}
|
||||
else if (seedRatioBytesGoal == 0) /* impossible? safeguard for div by zero */
|
||||
else if (seed_ratio_bytes_goal == 0) /* impossible? safeguard for div by zero */
|
||||
{
|
||||
s->seedRatioPercentDone = 0.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
s->seedRatioPercentDone = float(seedRatioBytesGoal - seedRatioBytesLeft) / seedRatioBytesGoal;
|
||||
s->seedRatioPercentDone = float(seed_ratio_bytes_goal - seed_ratio_bytes_left) / seed_ratio_bytes_goal;
|
||||
}
|
||||
|
||||
/* test some of the constraints */
|
||||
|
@ -1257,11 +1257,11 @@ size_t tr_torrentFilenameToBuf(tr_torrent const* tor, char* buf, size_t buflen)
|
|||
****
|
||||
***/
|
||||
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* tor, int* peerCount)
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* tor, int* peer_count)
|
||||
{
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
|
||||
return tr_peerMgrPeerStats(tor, peerCount);
|
||||
return tr_peerMgrPeerStats(tor, peer_count);
|
||||
}
|
||||
|
||||
void tr_torrentPeersFree(tr_peer_stat* peers, int /*peerCount*/)
|
||||
|
@ -1502,7 +1502,7 @@ static void verifyTorrent(tr_torrent* const tor)
|
|||
/* if the torrent's already being verified, stop it */
|
||||
tor->session->verifyRemove(tor);
|
||||
|
||||
bool const startAfter = (tor->isRunning || tor->startAfterVerify) && !tor->isStopping;
|
||||
bool const start_after = (tor->isRunning || tor->startAfterVerify) && !tor->isStopping;
|
||||
|
||||
if (tor->isRunning)
|
||||
{
|
||||
|
@ -1515,7 +1515,7 @@ static void verifyTorrent(tr_torrent* const tor)
|
|||
}
|
||||
else
|
||||
{
|
||||
tor->startAfterVerify = startAfter;
|
||||
tor->startAfterVerify = start_after;
|
||||
tor->session->verifyAdd(tor);
|
||||
}
|
||||
}
|
||||
|
@ -1771,11 +1771,11 @@ void tr_torrent::recheckCompleteness()
|
|||
|
||||
if (new_completeness != completeness)
|
||||
{
|
||||
bool const recentChange = downloadedCur != 0;
|
||||
bool const wasLeeching = !this->isDone();
|
||||
bool const wasRunning = isRunning;
|
||||
bool const recent_change = downloadedCur != 0;
|
||||
bool const was_leeching = !this->isDone();
|
||||
bool const was_running = isRunning;
|
||||
|
||||
if (recentChange)
|
||||
if (recent_change)
|
||||
{
|
||||
tr_logAddTraceTor(
|
||||
this,
|
||||
|
@ -1790,14 +1790,14 @@ void tr_torrent::recheckCompleteness()
|
|||
|
||||
if (this->isDone())
|
||||
{
|
||||
if (recentChange)
|
||||
if (recent_change)
|
||||
{
|
||||
tr_announcerTorrentCompleted(this);
|
||||
this->markChanged();
|
||||
this->doneDate = tr_time();
|
||||
}
|
||||
|
||||
if (wasLeeching && wasRunning)
|
||||
if (was_leeching && was_running)
|
||||
{
|
||||
/* clear interested flag on all peers */
|
||||
tr_peerMgrClearInterest(this);
|
||||
|
@ -1809,9 +1809,9 @@ void tr_torrent::recheckCompleteness()
|
|||
}
|
||||
}
|
||||
|
||||
this->session->onTorrentCompletenessChanged(this, completeness, wasRunning);
|
||||
this->session->onTorrentCompletenessChanged(this, completeness, was_running);
|
||||
|
||||
if (this->isDone() && wasLeeching && wasRunning)
|
||||
if (this->isDone() && was_leeching && was_running)
|
||||
{
|
||||
/* if completeness was TR_LEECH, the seed limit check
|
||||
will have been skipped in bandwidthPulse */
|
||||
|
@ -2711,10 +2711,10 @@ void tr_torrentRenamePath(
|
|||
void tr_torrentSetFilePriorities(
|
||||
tr_torrent* tor,
|
||||
tr_file_index_t const* files,
|
||||
tr_file_index_t fileCount,
|
||||
tr_file_index_t file_count,
|
||||
tr_priority_t priority)
|
||||
{
|
||||
tor->setFilePriorities(files, fileCount, priority);
|
||||
tor->setFilePriorities(files, file_count, priority);
|
||||
}
|
||||
|
||||
bool tr_torrentHasMetadata(tr_torrent const* tor)
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
|
||||
/// SPEED LIMIT
|
||||
|
||||
void setSpeedLimitBps(tr_direction, unsigned int Bps);
|
||||
void setSpeedLimitBps(tr_direction, unsigned int bytes_per_second);
|
||||
|
||||
[[nodiscard]] unsigned int speedLimitBps(tr_direction) const;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ using namespace std::literals;
|
|||
|
||||
static std::unique_ptr<libtransmission::Timer> dht_timer;
|
||||
static std::array<unsigned char, 20> myid;
|
||||
static tr_session* session_ = nullptr;
|
||||
static tr_session* my_session = nullptr;
|
||||
|
||||
static bool bootstrap_done(tr_session* session, int af)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ static void bootstrap_from_name(char const* name, tr_port port, int af)
|
|||
|
||||
nap(15);
|
||||
|
||||
if (bootstrap_done(session_, af))
|
||||
if (bootstrap_done(my_session, af))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -158,14 +158,14 @@ static void dht_boostrap_from_file(tr_session* session)
|
|||
}
|
||||
else
|
||||
{
|
||||
bootstrap_from_name(addrstr.c_str(), tr_port::fromHost(hport), bootstrap_af(session_));
|
||||
bootstrap_from_name(addrstr.c_str(), tr_port::fromHost(hport), bootstrap_af(my_session));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void dht_bootstrap(tr_session* session, std::vector<uint8_t> nodes, std::vector<uint8_t> nodes6)
|
||||
{
|
||||
if (session_ != session)
|
||||
if (my_session != session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ static void dht_bootstrap(tr_session* session, std::vector<uint8_t> nodes, std::
|
|||
nap(15);
|
||||
}
|
||||
|
||||
if (bootstrap_done(session_, 0))
|
||||
if (bootstrap_done(my_session, 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ static void dht_bootstrap(tr_session* session, std::vector<uint8_t> nodes, std::
|
|||
tr_logAddDebug("Attempting bootstrap from dht.transmissionbt.com");
|
||||
}
|
||||
|
||||
bootstrap_from_name("dht.transmissionbt.com", tr_port::fromHost(6881), bootstrap_af(session_));
|
||||
bootstrap_from_name("dht.transmissionbt.com", tr_port::fromHost(6881), bootstrap_af(my_session));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ static void dht_bootstrap(tr_session* session, std::vector<uint8_t> nodes, std::
|
|||
|
||||
int tr_dhtInit(tr_session* ss)
|
||||
{
|
||||
if (session_ != nullptr) /* already initialized */
|
||||
if (my_session != nullptr) /* already initialized */
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -316,15 +316,15 @@ int tr_dhtInit(tr_session* ss)
|
|||
{
|
||||
auto const errcode = errno;
|
||||
tr_logAddDebug(fmt::format("DHT initialization failed: {} ({})", tr_strerror(errcode), errcode));
|
||||
session_ = nullptr;
|
||||
my_session = nullptr;
|
||||
return -1;
|
||||
}
|
||||
|
||||
session_ = ss;
|
||||
my_session = ss;
|
||||
|
||||
std::thread(dht_bootstrap, session_, nodes, nodes6).detach();
|
||||
std::thread(dht_bootstrap, my_session, nodes, nodes6).detach();
|
||||
|
||||
dht_timer = session_->timerMaker().create([]() { tr_dhtCallback(nullptr, 0, nullptr, 0, session_); });
|
||||
dht_timer = my_session->timerMaker().create([]() { tr_dhtCallback(nullptr, 0, nullptr, 0, my_session); });
|
||||
auto const random_percent = tr_rand_int_weak(1000) / 1000.0;
|
||||
static auto constexpr MinInterval = 10ms;
|
||||
static auto constexpr MaxInterval = 1s;
|
||||
|
@ -338,7 +338,7 @@ int tr_dhtInit(tr_session* ss)
|
|||
|
||||
void tr_dhtUninit(tr_session* ss)
|
||||
{
|
||||
if (session_ != ss)
|
||||
if (my_session != ss)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -411,12 +411,12 @@ void tr_dhtUninit(tr_session* ss)
|
|||
dht_uninit();
|
||||
tr_logAddTrace("Done uninitializing DHT");
|
||||
|
||||
session_ = nullptr;
|
||||
my_session = nullptr;
|
||||
}
|
||||
|
||||
bool tr_dhtEnabled(tr_session const* ss)
|
||||
{
|
||||
return ss != nullptr && ss == session_;
|
||||
return ss != nullptr && ss == my_session;
|
||||
}
|
||||
|
||||
struct getstatus_closure
|
||||
|
@ -558,8 +558,8 @@ static void callback(void* /*ignore*/, int event, unsigned char const* info_hash
|
|||
{
|
||||
auto hash = tr_sha1_digest_t{};
|
||||
std::copy_n(reinterpret_cast<std::byte const*>(info_hash), std::size(hash), std::data(hash));
|
||||
auto const lock = session_->unique_lock();
|
||||
auto* const tor = session_->torrents().get(hash);
|
||||
auto const lock = my_session->unique_lock();
|
||||
auto* const tor = my_session->torrents().get(hash);
|
||||
|
||||
if (event == DHT_EVENT_VALUES || event == DHT_EVENT_VALUES6)
|
||||
{
|
||||
|
@ -624,7 +624,7 @@ static AnnounceResult tr_dhtAnnounce(tr_torrent* tor, int af, bool announce)
|
|||
}
|
||||
|
||||
auto const* dht_hash = reinterpret_cast<unsigned char const*>(std::data(tor->infoHash()));
|
||||
auto const hport = announce ? session_->peerPort().host() : 0;
|
||||
auto const hport = announce ? my_session->peerPort().host() : 0;
|
||||
int const rc = dht_search(dht_hash, hport, af, callback, nullptr);
|
||||
if (rc < 0)
|
||||
{
|
||||
|
@ -684,7 +684,7 @@ void tr_dhtCallback(unsigned char* buf, int buflen, struct sockaddr* from, sockl
|
|||
{
|
||||
TR_ASSERT(sv != nullptr);
|
||||
|
||||
if (sv != session_)
|
||||
if (sv != my_session)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ static void maxWidth(struct tr_option const* o, size_t& long_width, size_t& shor
|
|||
}
|
||||
}
|
||||
|
||||
void tr_getopt_usage(char const* appName, char const* description, struct tr_option const* opts)
|
||||
void tr_getopt_usage(char const* app_name, char const* description, struct tr_option const* opts)
|
||||
{
|
||||
auto long_width = size_t{ 0 };
|
||||
auto short_width = size_t{ 0 };
|
||||
|
@ -119,7 +119,7 @@ void tr_getopt_usage(char const* appName, char const* description, struct tr_opt
|
|||
description = "Usage: %s [options]";
|
||||
}
|
||||
|
||||
printf(description, appName);
|
||||
printf(description, app_name);
|
||||
printf("\n\nOptions:\n");
|
||||
getopts_usage_line(&help, long_width, short_width, arg_width);
|
||||
|
||||
|
|
|
@ -41,6 +41,6 @@ enum
|
|||
int tr_getopt(char const* usage, int argc, char const* const* argv, tr_option const* opts, char const** setme_optarg);
|
||||
|
||||
/** @brief prints the `Usage' help section to stdout */
|
||||
void tr_getopt_usage(char const* appName, char const* description, tr_option const* opts);
|
||||
void tr_getopt_usage(char const* app_name, char const* description, tr_option const* opts);
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -335,15 +335,15 @@ private:
|
|||
}
|
||||
|
||||
/* we want to join that LPD multicast group */
|
||||
struct ip_mreq mcastReq = {};
|
||||
mcastReq.imr_multiaddr = mcast_addr_.sin_addr;
|
||||
mcastReq.imr_interface.s_addr = INADDR_ANY;
|
||||
struct ip_mreq mcast_req = {};
|
||||
mcast_req.imr_multiaddr = mcast_addr_.sin_addr;
|
||||
mcast_req.imr_interface.s_addr = INADDR_ANY;
|
||||
|
||||
if (setsockopt(
|
||||
mcast_rcv_socket_,
|
||||
IPPROTO_IP,
|
||||
IP_ADD_MEMBERSHIP,
|
||||
reinterpret_cast<char const*>(&mcastReq),
|
||||
reinterpret_cast<char const*>(&mcast_req),
|
||||
sizeof(struct ip_mreq)) == -1)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -186,7 +186,7 @@ void tr_sessionGetSettings(tr_session const* session, struct tr_variant* setme_d
|
|||
* @see tr_sessionInit()
|
||||
* @see tr_sessionSaveSettings()
|
||||
*/
|
||||
bool tr_sessionLoadSettings(struct tr_variant* dictionary, char const* config_dir, char const* appName);
|
||||
bool tr_sessionLoadSettings(struct tr_variant* dictionary, char const* config_dir, char const* app_name);
|
||||
|
||||
/**
|
||||
* Add the session's configuration settings to the benc dictionary
|
||||
|
@ -507,8 +507,8 @@ enum tr_direction
|
|||
**** Primary session speed limits
|
||||
***/
|
||||
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session*, tr_direction, unsigned int Bps);
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session*, tr_direction, unsigned int KBps);
|
||||
void tr_sessionSetSpeedLimit_Bps(tr_session*, tr_direction, unsigned int bytes_per_second);
|
||||
void tr_sessionSetSpeedLimit_KBps(tr_session*, tr_direction, unsigned int kilo_per_second);
|
||||
unsigned int tr_sessionGetSpeedLimit_KBps(tr_session const*, tr_direction);
|
||||
|
||||
void tr_sessionLimitSpeed(tr_session*, tr_direction, bool);
|
||||
|
@ -518,7 +518,7 @@ bool tr_sessionIsSpeedLimited(tr_session const*, tr_direction);
|
|||
**** Alternative speed limits that are used during scheduled times
|
||||
***/
|
||||
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session*, tr_direction, unsigned int Bps);
|
||||
void tr_sessionSetAltSpeed_KBps(tr_session*, tr_direction, unsigned int kilo_per_seond);
|
||||
unsigned int tr_sessionGetAltSpeed_KBps(tr_session const*, tr_direction);
|
||||
|
||||
void tr_sessionUseAltSpeed(tr_session*, bool);
|
||||
|
@ -552,7 +552,7 @@ tr_sched_day tr_sessionGetAltSpeedDay(tr_session const*);
|
|||
|
||||
using tr_altSpeedFunc = void (*)(tr_session*, bool active, bool userDriven, void*);
|
||||
|
||||
void tr_sessionSetAltSpeedFunc(tr_session*, tr_altSpeedFunc, void*);
|
||||
void tr_sessionSetAltSpeedFunc(tr_session*, tr_altSpeedFunc, void* user_data);
|
||||
|
||||
/***
|
||||
****
|
||||
|
@ -828,10 +828,10 @@ void tr_ctorSetIncompleteDir(tr_ctor* ctor, char const* directory);
|
|||
void tr_ctorSetPaused(tr_ctor* ctor, tr_ctorMode mode, bool isPaused);
|
||||
|
||||
/** @brief Set the priorities for files in a torrent */
|
||||
void tr_ctorSetFilePriorities(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t fileCount, tr_priority_t priority);
|
||||
void tr_ctorSetFilePriorities(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t file_count, tr_priority_t priority);
|
||||
|
||||
/** @brief Set the download flag for files in a torrent */
|
||||
void tr_ctorSetFilesWanted(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t fileCount, bool wanted);
|
||||
void tr_ctorSetFilesWanted(tr_ctor* ctor, tr_file_index_t const* files, tr_file_index_t file_count, bool wanted);
|
||||
|
||||
/** @brief Get this peer constructor's peer limit */
|
||||
bool tr_ctorGetPeerLimit(tr_ctor const* ctor, tr_ctorMode mode, uint16_t* setmeCount);
|
||||
|
@ -1015,7 +1015,7 @@ size_t tr_torrentFindFileToBuf(tr_torrent const* tor, tr_file_index_t file_num,
|
|||
****
|
||||
***/
|
||||
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent*, tr_direction, unsigned int KBps);
|
||||
void tr_torrentSetSpeedLimit_KBps(tr_torrent*, tr_direction, unsigned int kilo_per_second);
|
||||
unsigned int tr_torrentGetSpeedLimit_KBps(tr_torrent const*, tr_direction);
|
||||
|
||||
void tr_torrentUseSpeedLimit(tr_torrent*, tr_direction, bool);
|
||||
|
@ -1042,7 +1042,7 @@ void tr_torrentSetRatioMode(tr_torrent* tor, tr_ratiolimit mode);
|
|||
|
||||
tr_ratiolimit tr_torrentGetRatioMode(tr_torrent const* tor);
|
||||
|
||||
void tr_torrentSetRatioLimit(tr_torrent* tor, double ratio);
|
||||
void tr_torrentSetRatioLimit(tr_torrent* tor, double desired_ratio);
|
||||
|
||||
double tr_torrentGetRatioLimit(tr_torrent const* tor);
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ void tr_torrentSetIdleMode(tr_torrent* tor, tr_idlelimit mode);
|
|||
|
||||
tr_idlelimit tr_torrentGetIdleMode(tr_torrent const* tor);
|
||||
|
||||
void tr_torrentSetIdleLimit(tr_torrent* tor, uint16_t idleMinutes);
|
||||
void tr_torrentSetIdleLimit(tr_torrent* tor, uint16_t idle_minutes);
|
||||
|
||||
uint16_t tr_torrentGetIdleLimit(tr_torrent const* tor);
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ enum
|
|||
void tr_torrentSetFilePriorities(
|
||||
tr_torrent* torrent,
|
||||
tr_file_index_t const* files,
|
||||
tr_file_index_t fileCount,
|
||||
tr_file_index_t file_count,
|
||||
tr_priority_t priority);
|
||||
|
||||
/** @brief Set a batch of files to be downloaded or not. */
|
||||
|
@ -1296,7 +1296,7 @@ struct tr_peer_stat
|
|||
int activeReqsToPeer;
|
||||
};
|
||||
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, int* peerCount);
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, int* peer_count);
|
||||
|
||||
void tr_torrentPeersFree(tr_peer_stat* peerStats, int peerCount);
|
||||
|
||||
|
|
|
@ -42,14 +42,14 @@ void* lock_alloc(unsigned /*locktype*/)
|
|||
return new std::recursive_mutex{};
|
||||
}
|
||||
|
||||
void lock_free(void* lock_, unsigned /*locktype*/)
|
||||
void lock_free(void* vlock, unsigned /*locktype*/)
|
||||
{
|
||||
delete static_cast<std::recursive_mutex*>(lock_);
|
||||
delete static_cast<std::recursive_mutex*>(vlock);
|
||||
}
|
||||
|
||||
int lock_lock(unsigned mode, void* lock_)
|
||||
int lock_lock(unsigned mode, void* vlock)
|
||||
{
|
||||
auto* lock = static_cast<std::recursive_mutex*>(lock_);
|
||||
auto* lock = static_cast<std::recursive_mutex*>(vlock);
|
||||
if ((mode & EVTHREAD_TRY) != 0U)
|
||||
{
|
||||
auto const success = lock->try_lock();
|
||||
|
@ -59,9 +59,9 @@ int lock_lock(unsigned mode, void* lock_)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lock_unlock(unsigned /*mode*/, void* lock_)
|
||||
int lock_unlock(unsigned /*mode*/, void* vlock)
|
||||
{
|
||||
static_cast<std::recursive_mutex*>(lock_)->unlock();
|
||||
static_cast<std::recursive_mutex*>(vlock)->unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -70,14 +70,14 @@ void* cond_alloc(unsigned /*condflags*/)
|
|||
return new std::condition_variable_any();
|
||||
}
|
||||
|
||||
void cond_free(void* cond_)
|
||||
void cond_free(void* vcond)
|
||||
{
|
||||
delete static_cast<std::condition_variable_any*>(cond_);
|
||||
delete static_cast<std::condition_variable_any*>(vcond);
|
||||
}
|
||||
|
||||
int cond_signal(void* cond_, int broadcast)
|
||||
int cond_signal(void* vcond, int broadcast)
|
||||
{
|
||||
auto* cond = static_cast<std::condition_variable_any*>(cond_);
|
||||
auto* cond = static_cast<std::condition_variable_any*>(vcond);
|
||||
if (broadcast != 0)
|
||||
{
|
||||
cond->notify_all();
|
||||
|
@ -89,10 +89,10 @@ int cond_signal(void* cond_, int broadcast)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cond_wait(void* cond_, void* lock_, struct timeval const* tv)
|
||||
int cond_wait(void* vcond, void* vlock, struct timeval const* tv)
|
||||
{
|
||||
auto* cond = static_cast<std::condition_variable_any*>(cond_);
|
||||
auto* lock = static_cast<std::recursive_mutex*>(lock_);
|
||||
auto* cond = static_cast<std::condition_variable_any*>(vcond);
|
||||
auto* lock = static_cast<std::recursive_mutex*>(vlock);
|
||||
if (tv == nullptr)
|
||||
{
|
||||
cond->wait(*lock);
|
||||
|
@ -115,17 +115,17 @@ void initEvthreadsOnce()
|
|||
{
|
||||
tr_net_init();
|
||||
|
||||
evthread_lock_callbacks constexpr lock_cbs{
|
||||
evthread_lock_callbacks constexpr LockCbs{
|
||||
EVTHREAD_LOCK_API_VERSION, EVTHREAD_LOCKTYPE_RECURSIVE, lock_alloc, lock_free, lock_lock, lock_unlock
|
||||
};
|
||||
evthread_set_lock_callbacks(&lock_cbs);
|
||||
evthread_set_lock_callbacks(&LockCbs);
|
||||
|
||||
evthread_condition_callbacks constexpr cond_cbs{ EVTHREAD_CONDITION_API_VERSION,
|
||||
cond_alloc,
|
||||
cond_free,
|
||||
cond_signal,
|
||||
cond_wait };
|
||||
evthread_set_condition_callbacks(&cond_cbs);
|
||||
evthread_condition_callbacks constexpr CondCbs{ EVTHREAD_CONDITION_API_VERSION,
|
||||
cond_alloc,
|
||||
cond_free,
|
||||
cond_signal,
|
||||
cond_wait };
|
||||
evthread_set_condition_callbacks(&CondCbs);
|
||||
|
||||
evthread_set_id_callback(thread_current_id);
|
||||
}
|
||||
|
|
|
@ -256,9 +256,9 @@ static bool isFutureReady(std::future<T> const& future)
|
|||
return future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
|
||||
}
|
||||
|
||||
tr_port_forwarding tr_upnpPulse(tr_upnp* handle, tr_port port, bool isEnabled, bool doPortCheck, std::string bindaddr)
|
||||
tr_port_forwarding tr_upnpPulse(tr_upnp* handle, tr_port port, bool is_enabled, bool do_port_check, std::string bindaddr)
|
||||
{
|
||||
if (isEnabled && handle->state == UpnpState::WILL_DISCOVER)
|
||||
if (is_enabled && handle->state == UpnpState::WILL_DISCOVER)
|
||||
{
|
||||
TR_ASSERT(!handle->discover_future);
|
||||
|
||||
|
@ -269,7 +269,7 @@ tr_port_forwarding tr_upnpPulse(tr_upnp* handle, tr_port port, bool isEnabled, b
|
|||
std::thread(std::move(task), std::move(bindaddr)).detach();
|
||||
}
|
||||
|
||||
if (isEnabled && handle->state == UpnpState::DISCOVERING && handle->discover_future &&
|
||||
if (is_enabled && handle->state == UpnpState::DISCOVERING && handle->discover_future &&
|
||||
isFutureReady(*handle->discover_future))
|
||||
{
|
||||
auto* const devlist = handle->discover_future->get();
|
||||
|
@ -296,12 +296,12 @@ tr_port_forwarding tr_upnpPulse(tr_upnp* handle, tr_port port, bool isEnabled, b
|
|||
freeUPNPDevlist(devlist);
|
||||
}
|
||||
|
||||
if ((handle->state == UpnpState::IDLE) && (handle->isMapped) && (!isEnabled || handle->port != port))
|
||||
if ((handle->state == UpnpState::IDLE) && (handle->isMapped) && (!is_enabled || handle->port != port))
|
||||
{
|
||||
handle->state = UpnpState::WILL_UNMAP;
|
||||
}
|
||||
|
||||
if (isEnabled && handle->isMapped && doPortCheck &&
|
||||
if (is_enabled && handle->isMapped && do_port_check &&
|
||||
((tr_upnpGetSpecificPortMappingEntry(handle, "TCP") != UPNPCOMMAND_SUCCESS) ||
|
||||
(tr_upnpGetSpecificPortMappingEntry(handle, "UDP") != UPNPCOMMAND_SUCCESS)))
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ tr_port_forwarding tr_upnpPulse(tr_upnp* handle, tr_port port, bool isEnabled, b
|
|||
handle->port = {};
|
||||
}
|
||||
|
||||
if ((handle->state == UpnpState::IDLE) && isEnabled && !handle->isMapped)
|
||||
if ((handle->state == UpnpState::IDLE) && is_enabled && !handle->isMapped)
|
||||
{
|
||||
handle->state = UpnpState::WILL_MAP;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ tr_upnp* tr_upnpInit(void);
|
|||
|
||||
void tr_upnpClose(tr_upnp*);
|
||||
|
||||
tr_port_forwarding tr_upnpPulse(tr_upnp*, tr_port port, bool isEnabled, bool doPortCheck, std::string);
|
||||
tr_port_forwarding tr_upnpPulse(tr_upnp*, tr_port port, bool is_enabled, bool do_port_check, std::string);
|
||||
|
||||
/* @} */
|
||||
|
|
|
@ -222,15 +222,15 @@ char const* tr_strerror(int errnum)
|
|||
|
||||
std::string_view tr_strvStrip(std::string_view str)
|
||||
{
|
||||
auto constexpr test = [](auto ch)
|
||||
auto constexpr Test = [](auto ch)
|
||||
{
|
||||
return isspace(static_cast<unsigned char>(ch));
|
||||
};
|
||||
|
||||
auto const it = std::find_if_not(std::begin(str), std::end(str), test);
|
||||
auto const it = std::find_if_not(std::begin(str), std::end(str), Test);
|
||||
str.remove_prefix(std::distance(std::begin(str), it));
|
||||
|
||||
auto const rit = std::find_if_not(std::rbegin(str), std::rend(str), test);
|
||||
auto const rit = std::find_if_not(std::rbegin(str), std::rend(str), Test);
|
||||
str.remove_suffix(std::distance(std::rbegin(str), rit));
|
||||
|
||||
return str;
|
||||
|
@ -868,19 +868,19 @@ void tr_formatter_speed_init(size_t kilo, char const* kb, char const* mb, char c
|
|||
formatter_init(speed_units, kilo, kb, mb, gb, tb);
|
||||
}
|
||||
|
||||
std::string tr_formatter_speed_KBps(double KBps)
|
||||
std::string tr_formatter_speed_KBps(double kilo_per_second)
|
||||
{
|
||||
using namespace formatter_impl;
|
||||
|
||||
auto speed = KBps;
|
||||
auto speed = kilo_per_second;
|
||||
|
||||
if (speed <= 999.95) // 0.0 KB to 999.9 KB
|
||||
{
|
||||
return fmt::format("{:d} {:s}", int(speed), std::data(speed_units[TR_FMT_KB].name));
|
||||
}
|
||||
|
||||
double const K = speed_units[TR_FMT_KB].value;
|
||||
speed /= K;
|
||||
double const kilo = speed_units[TR_FMT_KB].value;
|
||||
speed /= kilo;
|
||||
|
||||
if (speed <= 99.995) // 0.98 MB to 99.99 MB
|
||||
{
|
||||
|
@ -892,7 +892,7 @@ std::string tr_formatter_speed_KBps(double KBps)
|
|||
return fmt::format("{:.1f} {:s}", speed, std::data(speed_units[TR_FMT_MB].name));
|
||||
}
|
||||
|
||||
return fmt::format("{:.1f} {:s}", speed / K, std::data(speed_units[TR_FMT_GB].name));
|
||||
return fmt::format("{:.1f} {:s}", speed / kilo, std::data(speed_units[TR_FMT_GB].name));
|
||||
}
|
||||
|
||||
size_t tr_mem_K = 0;
|
||||
|
@ -1029,7 +1029,7 @@ void tr_net_init()
|
|||
|
||||
std::string_view tr_get_mime_type_for_filename(std::string_view filename)
|
||||
{
|
||||
auto constexpr compare = [](mime_type_suffix const& entry, auto const& suffix)
|
||||
auto constexpr Compare = [](mime_type_suffix const& entry, auto const& suffix)
|
||||
{
|
||||
return entry.suffix < suffix;
|
||||
};
|
||||
|
@ -1037,7 +1037,7 @@ std::string_view tr_get_mime_type_for_filename(std::string_view filename)
|
|||
if (auto const pos = filename.rfind('.'); pos != std::string_view::npos)
|
||||
{
|
||||
auto const suffix_lc = tr_strlower(filename.substr(pos + 1));
|
||||
auto const it = std::lower_bound(std::begin(mime_type_suffixes), std::end(mime_type_suffixes), suffix_lc, compare);
|
||||
auto const it = std::lower_bound(std::begin(mime_type_suffixes), std::end(mime_type_suffixes), suffix_lc, Compare);
|
||||
if (it != std::end(mime_type_suffixes) && suffix_lc == it->suffix)
|
||||
{
|
||||
return it->mime_type;
|
||||
|
|
|
@ -312,7 +312,7 @@ extern size_t tr_mem_K;
|
|||
extern uint64_t tr_size_K; /* unused? */
|
||||
|
||||
/* format a speed from KBps into a user-readable string. */
|
||||
[[nodiscard]] std::string tr_formatter_speed_KBps(double KBps);
|
||||
[[nodiscard]] std::string tr_formatter_speed_KBps(double kilo_per_second);
|
||||
|
||||
/* format a memory size from bytes into a user-readable string. */
|
||||
[[nodiscard]] std::string tr_formatter_mem_B(size_t bytes);
|
||||
|
|
|
@ -30,7 +30,7 @@ struct VariantWalkFuncs
|
|||
VariantWalkFunc containerEndFunc;
|
||||
};
|
||||
|
||||
void tr_variantWalk(tr_variant const* top, struct VariantWalkFuncs const* walkFuncs, void* user_data, bool sort_dicts);
|
||||
void tr_variantWalk(tr_variant const* top, VariantWalkFuncs const* walk_funcs, void* user_data, bool sort_dicts);
|
||||
|
||||
void tr_variantToBufJson(tr_variant const* top, struct evbuffer* buf, bool lean);
|
||||
|
||||
|
|
|
@ -638,13 +638,13 @@ static void jsonDictBeginFunc(tr_variant const* val, void* vdata)
|
|||
|
||||
static void jsonListBeginFunc(tr_variant const* val, void* vdata)
|
||||
{
|
||||
size_t const nChildren = tr_variantListSize(val);
|
||||
size_t const n_children = tr_variantListSize(val);
|
||||
auto* data = static_cast<struct jsonWalk*>(vdata);
|
||||
|
||||
jsonPushParent(data, val);
|
||||
evbuffer_add(data->out, "[", 1);
|
||||
|
||||
if (nChildren != 0)
|
||||
if (n_children != 0)
|
||||
{
|
||||
jsonIndent(data);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void tr_variantInit(tr_variant* v, char type)
|
|||
****
|
||||
***/
|
||||
|
||||
static auto constexpr STRING_INIT = tr_variant_string{
|
||||
static auto constexpr StringInit = tr_variant_string{
|
||||
TR_STRING_TYPE_QUARK,
|
||||
0,
|
||||
{},
|
||||
|
@ -65,7 +65,7 @@ static void tr_variant_string_clear(struct tr_variant_string* str)
|
|||
delete[]((char*)(str->str.str));
|
||||
}
|
||||
|
||||
*str = STRING_INIT;
|
||||
*str = StringInit;
|
||||
}
|
||||
|
||||
/* returns a const pointer to the variant's string */
|
||||
|
@ -808,7 +808,7 @@ private:
|
|||
* easier to read, but was vulnerable to a smash-stacking
|
||||
* attack via maliciously-crafted data. (#667)
|
||||
*/
|
||||
void tr_variantWalk(tr_variant const* top, struct VariantWalkFuncs const* walkFuncs, void* user_data, bool sort_dicts)
|
||||
void tr_variantWalk(tr_variant const* top, struct VariantWalkFuncs const* walk_funcs, void* user_data, bool sort_dicts)
|
||||
{
|
||||
auto stack = VariantWalker{};
|
||||
stack.emplace(top, sort_dicts);
|
||||
|
@ -834,14 +834,14 @@ void tr_variantWalk(tr_variant const* top, struct VariantWalkFuncs const* walkFu
|
|||
{
|
||||
auto tmp = tr_variant{};
|
||||
tr_variantInitQuark(&tmp, v->key);
|
||||
walkFuncs->stringFunc(&tmp, user_data);
|
||||
walk_funcs->stringFunc(&tmp, user_data);
|
||||
}
|
||||
}
|
||||
else // finished with this node
|
||||
{
|
||||
if (tr_variantIsContainer(&node.v))
|
||||
{
|
||||
walkFuncs->containerEndFunc(&node.v, user_data);
|
||||
walk_funcs->containerEndFunc(&node.v, user_data);
|
||||
}
|
||||
|
||||
stack.pop();
|
||||
|
@ -854,25 +854,25 @@ void tr_variantWalk(tr_variant const* top, struct VariantWalkFuncs const* walkFu
|
|||
switch (v->type)
|
||||
{
|
||||
case TR_VARIANT_TYPE_INT:
|
||||
walkFuncs->intFunc(v, user_data);
|
||||
walk_funcs->intFunc(v, user_data);
|
||||
break;
|
||||
|
||||
case TR_VARIANT_TYPE_BOOL:
|
||||
walkFuncs->boolFunc(v, user_data);
|
||||
walk_funcs->boolFunc(v, user_data);
|
||||
break;
|
||||
|
||||
case TR_VARIANT_TYPE_REAL:
|
||||
walkFuncs->realFunc(v, user_data);
|
||||
walk_funcs->realFunc(v, user_data);
|
||||
break;
|
||||
|
||||
case TR_VARIANT_TYPE_STR:
|
||||
walkFuncs->stringFunc(v, user_data);
|
||||
walk_funcs->stringFunc(v, user_data);
|
||||
break;
|
||||
|
||||
case TR_VARIANT_TYPE_LIST:
|
||||
if (v == &node.v)
|
||||
{
|
||||
walkFuncs->listBeginFunc(v, user_data);
|
||||
walk_funcs->listBeginFunc(v, user_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -883,7 +883,7 @@ void tr_variantWalk(tr_variant const* top, struct VariantWalkFuncs const* walkFu
|
|||
case TR_VARIANT_TYPE_DICT:
|
||||
if (v == &node.v)
|
||||
{
|
||||
walkFuncs->dictBeginFunc(v, user_data);
|
||||
walk_funcs->dictBeginFunc(v, user_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -918,7 +918,7 @@ static void freeContainerEndFunc(tr_variant const* v, void* /*user_data*/)
|
|||
delete[] v->val.l.vals;
|
||||
}
|
||||
|
||||
static struct VariantWalkFuncs const freeWalkFuncs = {
|
||||
static VariantWalkFuncs constexpr FreeWalkFuncs = {
|
||||
freeDummyFunc, //
|
||||
freeDummyFunc, //
|
||||
freeDummyFunc, //
|
||||
|
@ -932,7 +932,7 @@ void tr_variantClear(tr_variant* v)
|
|||
{
|
||||
if (!tr_variantIsEmpty(v))
|
||||
{
|
||||
tr_variantWalk(v, &freeWalkFuncs, nullptr, false);
|
||||
tr_variantWalk(v, &FreeWalkFuncs, nullptr, false);
|
||||
}
|
||||
|
||||
*v = {};
|
||||
|
@ -944,49 +944,50 @@ void tr_variantClear(tr_variant* v)
|
|||
|
||||
static void tr_variantListCopy(tr_variant* target, tr_variant const* src)
|
||||
{
|
||||
int i = 0;
|
||||
tr_variant const* val = nullptr;
|
||||
|
||||
while ((val = tr_variantListChild(const_cast<tr_variant*>(src), i)) != nullptr)
|
||||
for (size_t i = 0;; ++i)
|
||||
{
|
||||
if (tr_variantIsBool(val))
|
||||
auto const* const child = tr_variantListChild(const_cast<tr_variant*>(src), i);
|
||||
if (child == nullptr)
|
||||
{
|
||||
bool boolVal = false;
|
||||
tr_variantGetBool(val, &boolVal);
|
||||
tr_variantListAddBool(target, boolVal);
|
||||
break;
|
||||
}
|
||||
else if (tr_variantIsReal(val))
|
||||
|
||||
if (tr_variantIsBool(child))
|
||||
{
|
||||
double realVal = 0;
|
||||
tr_variantGetReal(val, &realVal);
|
||||
tr_variantListAddReal(target, realVal);
|
||||
auto val = bool{};
|
||||
tr_variantGetBool(child, &val);
|
||||
tr_variantListAddBool(target, val);
|
||||
}
|
||||
else if (tr_variantIsInt(val))
|
||||
else if (tr_variantIsReal(child))
|
||||
{
|
||||
int64_t intVal = 0;
|
||||
tr_variantGetInt(val, &intVal);
|
||||
tr_variantListAddInt(target, intVal);
|
||||
auto val = double{};
|
||||
tr_variantGetReal(child, &val);
|
||||
tr_variantListAddReal(target, val);
|
||||
}
|
||||
else if (tr_variantIsString(val))
|
||||
else if (tr_variantIsInt(child))
|
||||
{
|
||||
auto sv = std::string_view{};
|
||||
(void)tr_variantGetStrView(val, &sv);
|
||||
tr_variantListAddRaw(target, std::data(sv), std::size(sv));
|
||||
auto val = int64_t{};
|
||||
tr_variantGetInt(child, &val);
|
||||
tr_variantListAddInt(target, val);
|
||||
}
|
||||
else if (tr_variantIsDict(val))
|
||||
else if (tr_variantIsString(child))
|
||||
{
|
||||
tr_variantMergeDicts(tr_variantListAddDict(target, 0), val);
|
||||
auto val = std::string_view{};
|
||||
(void)tr_variantGetStrView(child, &val);
|
||||
tr_variantListAddRaw(target, std::data(val), std::size(val));
|
||||
}
|
||||
else if (tr_variantIsList(val))
|
||||
else if (tr_variantIsDict(child))
|
||||
{
|
||||
tr_variantListCopy(tr_variantListAddList(target, 0), val);
|
||||
tr_variantMergeDicts(tr_variantListAddDict(target, 0), child);
|
||||
}
|
||||
else if (tr_variantIsList(child))
|
||||
{
|
||||
tr_variantListCopy(tr_variantListAddList(target, 0), child);
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_logAddWarn("tr_variantListCopy skipping item");
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1016,72 +1017,72 @@ void tr_variantMergeDicts(tr_variant* target, tr_variant const* source)
|
|||
TR_ASSERT(tr_variantIsDict(target));
|
||||
TR_ASSERT(tr_variantIsDict(source));
|
||||
|
||||
size_t const sourceCount = tr_variantDictSize(source);
|
||||
size_t const source_count = tr_variantDictSize(source);
|
||||
|
||||
tr_variantDictReserve(target, sourceCount + tr_variantDictSize(target));
|
||||
tr_variantDictReserve(target, source_count + tr_variantDictSize(target));
|
||||
|
||||
for (size_t i = 0; i < sourceCount; ++i)
|
||||
for (size_t i = 0; i < source_count; ++i)
|
||||
{
|
||||
auto key = tr_quark{};
|
||||
tr_variant* val = nullptr;
|
||||
if (tr_variantDictChild(const_cast<tr_variant*>(source), i, &key, &val))
|
||||
tr_variant* child = nullptr;
|
||||
if (tr_variantDictChild(const_cast<tr_variant*>(source), i, &key, &child))
|
||||
{
|
||||
tr_variant* t = nullptr;
|
||||
|
||||
// if types differ, ensure that target will overwrite source
|
||||
auto const* const target_child = tr_variantDictFind(target, key);
|
||||
if ((target_child != nullptr) && !tr_variantIsType(target_child, val->type))
|
||||
if ((target_child != nullptr) && !tr_variantIsType(target_child, child->type))
|
||||
{
|
||||
tr_variantDictRemove(target, key);
|
||||
}
|
||||
|
||||
if (tr_variantIsBool(val))
|
||||
if (tr_variantIsBool(child))
|
||||
{
|
||||
bool boolVal = false;
|
||||
tr_variantGetBool(val, &boolVal);
|
||||
tr_variantDictAddBool(target, key, boolVal);
|
||||
auto val = bool{};
|
||||
tr_variantGetBool(child, &val);
|
||||
tr_variantDictAddBool(target, key, val);
|
||||
}
|
||||
else if (tr_variantIsReal(val))
|
||||
else if (tr_variantIsReal(child))
|
||||
{
|
||||
double realVal = 0;
|
||||
tr_variantGetReal(val, &realVal);
|
||||
tr_variantDictAddReal(target, key, realVal);
|
||||
auto val = double{};
|
||||
tr_variantGetReal(child, &val);
|
||||
tr_variantDictAddReal(target, key, val);
|
||||
}
|
||||
else if (tr_variantIsInt(val))
|
||||
else if (tr_variantIsInt(child))
|
||||
{
|
||||
int64_t intVal = 0;
|
||||
tr_variantGetInt(val, &intVal);
|
||||
tr_variantDictAddInt(target, key, intVal);
|
||||
auto val = int64_t{};
|
||||
tr_variantGetInt(child, &val);
|
||||
tr_variantDictAddInt(target, key, val);
|
||||
}
|
||||
else if (tr_variantIsString(val))
|
||||
else if (tr_variantIsString(child))
|
||||
{
|
||||
auto sv = std::string_view{};
|
||||
(void)tr_variantGetStrView(val, &sv);
|
||||
tr_variantDictAddRaw(target, key, std::data(sv), std::size(sv));
|
||||
auto val = std::string_view{};
|
||||
(void)tr_variantGetStrView(child, &val);
|
||||
tr_variantDictAddRaw(target, key, std::data(val), std::size(val));
|
||||
}
|
||||
else if (tr_variantIsDict(val) && tr_variantDictFindDict(target, key, &t))
|
||||
else if (tr_variantIsDict(child) && tr_variantDictFindDict(target, key, &t))
|
||||
{
|
||||
tr_variantMergeDicts(t, val);
|
||||
tr_variantMergeDicts(t, child);
|
||||
}
|
||||
else if (tr_variantIsList(val))
|
||||
else if (tr_variantIsList(child))
|
||||
{
|
||||
if (tr_variantDictFind(target, key) == nullptr)
|
||||
{
|
||||
tr_variantListCopy(tr_variantDictAddList(target, key, tr_variantListSize(val)), val);
|
||||
tr_variantListCopy(tr_variantDictAddList(target, key, tr_variantListSize(child)), child);
|
||||
}
|
||||
}
|
||||
else if (tr_variantIsDict(val))
|
||||
else if (tr_variantIsDict(child))
|
||||
{
|
||||
tr_variant* target_dict = tr_variantDictFind(target, key);
|
||||
|
||||
if (target_dict == nullptr)
|
||||
{
|
||||
target_dict = tr_variantDictAddDict(target, key, tr_variantDictSize(val));
|
||||
target_dict = tr_variantDictAddDict(target, key, tr_variantDictSize(child));
|
||||
}
|
||||
|
||||
if (tr_variantIsDict(target_dict))
|
||||
{
|
||||
tr_variantMergeDicts(target_dict, val);
|
||||
tr_variantMergeDicts(target_dict, child);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -188,20 +188,20 @@ public:
|
|||
return tr_torrentFindFromId(session, torrent_id);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool isTransferringPieces(uint64_t now, tr_direction direction, unsigned int* setme_Bps) const override
|
||||
[[nodiscard]] bool isTransferringPieces(uint64_t now, tr_direction dir, unsigned int* setme_bytes_per_second) const override
|
||||
{
|
||||
unsigned int Bps = 0;
|
||||
unsigned int bytes_per_second = 0;
|
||||
bool is_active = false;
|
||||
|
||||
if (direction == TR_DOWN)
|
||||
if (dir == TR_DOWN)
|
||||
{
|
||||
is_active = !std::empty(tasks);
|
||||
Bps = bandwidth_.getPieceSpeedBytesPerSecond(now, direction);
|
||||
bytes_per_second = bandwidth_.getPieceSpeedBytesPerSecond(now, dir);
|
||||
}
|
||||
|
||||
if (setme_Bps != nullptr)
|
||||
if (setme_bytes_per_second != nullptr)
|
||||
{
|
||||
*setme_Bps = Bps;
|
||||
*setme_bytes_per_second = bytes_per_second;
|
||||
}
|
||||
|
||||
return is_active;
|
||||
|
|
Loading…
Reference in New Issue