diff options
| author | Nagi5Yeq <wu@x-nagi.com> | 2019-11-07 20:31:53 +0800 |
|---|---|---|
| committer | Nagi5Yeq <wu@x-nagi.com> | 2019-11-07 20:31:53 +0800 |
| commit | 9c6dd30463dc4d6b53c32a30a4ea0c6442d27802 (patch) | |
| tree | fd5d5a99cec1632221737ac534398cc87ae4e1ae /src/DefaultBtAnnounce.cc | |
| parent | bb8c2329132d6e6b650e92c05705f14f977192ef (diff) | |
use a random key
Diffstat (limited to 'src/DefaultBtAnnounce.cc')
| -rw-r--r-- | src/DefaultBtAnnounce.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 98d4ac0d..74830c0a 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -72,6 +72,7 @@ DefaultBtAnnounce::DefaultBtAnnounce(DownloadContext* downloadContext, randomizer_(SimpleRandomizer::getInstance().get()), tcpPort_(0) { + httpAnnounceKey_ = randomizer_.getRandomNumber(INT_MAX); } DefaultBtAnnounce::~DefaultBtAnnounce() = default; @@ -168,7 +169,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() "downloaded=%" PRId64 "&" "left=%" PRId64 "&" "compact=1&" - "key=%s&" + "key=%x&" "numwant=%d&" "no_peer_id=1", util::percentEncode(bittorrent::getInfoHash(downloadContext_), @@ -177,9 +178,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() util::percentEncode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH) .c_str(), stat.getSessionUploadLength(), stat.getSessionDownloadLength(), left, - util::percentEncode( - bittorrent::getStaticPeerId() + PEER_ID_LENGTH - keyLen, keyLen) - .c_str(), + httpAnnounceKey_, numWant); if (tcpPort_) { uri += fmt("&port=%u", tcpPort_); |
