From 942325b1ae98fdf496acfccfb95e21d8dae13a09 Mon Sep 17 00:00:00 2001 From: Nagi5Yeq Date: Thu, 7 Nov 2019 21:47:16 +0800 Subject: rearrange args --- src/DefaultBtAnnounce.cc | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'src/DefaultBtAnnounce.cc') diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 74830c0a..cce627d1 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -72,7 +72,7 @@ DefaultBtAnnounce::DefaultBtAnnounce(DownloadContext* downloadContext, randomizer_(SimpleRandomizer::getInstance().get()), tcpPort_(0) { - httpAnnounceKey_ = randomizer_.getRandomNumber(INT_MAX); + httpAnnounceKey_ = randomizer_->getRandomNumber(INT_MAX); } DefaultBtAnnounce::~DefaultBtAnnounce() = default; @@ -162,28 +162,30 @@ std::string DefaultBtAnnounce::getAnnounceUrl() const size_t keyLen = 8; std::string uri = announceList_.getAnnounce(); uri += uriHasQuery(uri) ? "&" : "?"; - uri += - fmt("info_hash=%s&" - "peer_id=%s&" - "uploaded=%" PRId64 "&" - "downloaded=%" PRId64 "&" - "left=%" PRId64 "&" - "compact=1&" - "key=%x&" - "numwant=%d&" - "no_peer_id=1", - util::percentEncode(bittorrent::getInfoHash(downloadContext_), + uri += fmt("info_hash=%s&" + "peer_id=%s&", + util::percentEncode(bittorrent::getInfoHash(downloadContext_), INFO_HASH_LENGTH) .c_str(), - util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH) - .c_str(), - stat.getSessionUploadLength(), stat.getSessionDownloadLength(), left, - httpAnnounceKey_, - numWant); + util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH) + .c_str()); if (tcpPort_) { uri += fmt("&port=%u", tcpPort_); } + uri += fmt("uploaded=%" PRId64 "&" + "downloaded=%" PRId64 "&" + "left=%" PRId64 "&" + "numwant=%d&" + "key=%x&" + "compact=1&" + stat.getSessionUploadLength(), stat.getSessionDownloadLength(), left, + numWant, + httpAnnounceKey_); const char* event = announceList_.getEventString(); + if (option_->getAsBool(PREF_BT_FORCE_ENCRYPTION) || + option_->getAsBool(PREF_BT_REQUIRE_CRYPTO)) { + uri += "&requirecrypto=1"; + } if (event[0]) { uri += "&event="; uri += event; @@ -192,10 +194,6 @@ std::string DefaultBtAnnounce::getAnnounceUrl() uri += "&trackerid="; uri += util::percentEncode(trackerId_); } - if (option_->getAsBool(PREF_BT_FORCE_ENCRYPTION) || - option_->getAsBool(PREF_BT_REQUIRE_CRYPTO)) { - uri += "&requirecrypto=1"; - } else { uri += "&supportcrypto=1"; } -- cgit