mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +00:00
f14e741052
* fix: pass-large-object-by-reference-to-const warning Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0Gz8ze7dx8i2lkKEvq\&open\=AX0Gz8ze7dx8i2lkKEvq * fix: use-std-array-instead-of-C-array warning Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5B-\&open\=AX0L8qcgUnpKTxYiu5B- * fix: extract-assignment-from-expression Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CH\&open\=AX0L8qcgUnpKTxYiu5CH * fix: move-include-directives-to-top Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qlYUnpKTxYiu5CQ\&open\=AX0L8qlYUnpKTxYiu5CQ * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CK\&open\=AX0L8qcgUnpKTxYiu5CK * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh * fix: ensure-move-constructor-is-noexcept https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlWzwxvzFbF6whWU\&open\=AX0WPlWzwxvzFbF6whWU * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP20jI_aUyxGBxCD\&open\=AX0bZP20jI_aUyxGBxCD * fix: replace-redundant-type-with-auto Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP0rjI_aUyxGBxCB\&open\=AX0bZP0rjI_aUyxGBxCB * fix: make-parameter-const Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQqqPDVGqE4PY-io\&open\=AX0gkQqqPDVGqE4PY-io * fix: use-init-statement https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0rARJbfJ-O-YIDS9xM\&open\=AX0rARJbfJ-O-YIDS9xM * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh * fix: explicitly-delete-copy-ctor Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQr6PDVGqE4PY-i4\&open\=AX0gkQr6PDVGqE4PY-i4 * fix: use-init-statement Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP9wjI_aUyxGBxCF\&open\=AX0bZP9wjI_aUyxGBxCF
74 lines
1.6 KiB
C++
74 lines
1.6 KiB
C++
/*
|
|
* This file Copyright (C) Mnemosyne LLC
|
|
*
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef __TRANSMISSION__
|
|
#error only libtransmission should #include this header.
|
|
#endif
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "transmission.h"
|
|
|
|
#include "error.h"
|
|
#include "quark.h"
|
|
|
|
struct tr_variant;
|
|
|
|
struct tr_magnet_metainfo
|
|
{
|
|
bool parseMagnet(std::string_view magnet_link, tr_error** error = nullptr);
|
|
|
|
std::string magnet() const;
|
|
|
|
void toVariant(tr_variant*) const;
|
|
|
|
static bool convertAnnounceToScrape(std::string& setme, std::string_view announce_url);
|
|
|
|
std::string_view infoHashString() const
|
|
{
|
|
// trim one byte off the end because of zero termination
|
|
return std::string_view{ std::data(info_hash_chars), std::size(info_hash_chars) - 1 };
|
|
}
|
|
|
|
struct tracker_t
|
|
{
|
|
tr_quark announce_url;
|
|
tr_quark scrape_url;
|
|
tr_tracker_tier_t tier;
|
|
|
|
tracker_t(tr_quark announce_in, tr_quark scrape_in, tr_tracker_tier_t tier_in)
|
|
: announce_url{ announce_in }
|
|
, scrape_url{ scrape_in }
|
|
, tier{ tier_in }
|
|
{
|
|
}
|
|
|
|
bool operator<(tracker_t const& that) const
|
|
{
|
|
return announce_url < that.announce_url;
|
|
}
|
|
};
|
|
|
|
std::vector<std::string> webseed_urls;
|
|
|
|
std::string name;
|
|
|
|
std::multimap<tr_tracker_tier_t, tracker_t> trackers;
|
|
|
|
tr_sha1_digest_string_t info_hash_chars;
|
|
|
|
tr_sha1_digest_t info_hash;
|
|
|
|
protected:
|
|
bool addTracker(tr_tracker_tier_t tier, std::string_view announce_url);
|
|
};
|