cleanup and added another known peer-id

This commit is contained in:
Arvid Norberg 2007-05-14 12:02:57 +00:00
parent 0720a96ac2
commit e79817cfc5
1 changed files with 68 additions and 62 deletions

View File

@ -135,72 +135,77 @@ namespace
return boost::optional<fingerprint>(ret); return boost::optional<fingerprint>(ret);
} }
typedef std::pair<char const*, char const*> map_entry; struct map_entry
{
char const* id;
char const* name;
};
// only support BitTorrentSpecification // only support BitTorrentSpecification
// must be ordered alphabetically // must be ordered alphabetically
map_entry name_map[] = map_entry name_map[] =
{ {
map_entry("A", "ABC") {"A", "ABC"}
, map_entry("A~", "Ares") , {"AG", "Ares"}
, map_entry("AG", "Ares") , {"AR", "Arctic Torrent"}
, map_entry("AR", "Arctic Torrent") , {"AV", "Avicora"}
, map_entry("AV", "Avicora") , {"AX", "BitPump"}
, map_entry("AX", "BitPump") , {"AZ", "Azureus"}
, map_entry("AZ", "Azureus") , {"A~", "Ares"}
, map_entry("BB", "BitBuddy") , {"BB", "BitBuddy"}
, map_entry("BC", "BitComet") , {"BC", "BitComet"}
, map_entry("BF", "Bitflu") , {"BF", "Bitflu"}
, map_entry("BG", "BTG") , {"BG", "BTG"}
, map_entry("BR", "BitRocket") , {"BR", "BitRocket"}
, map_entry("BS", "BTSlave") , {"BS", "BTSlave"}
, map_entry("BX", "BittorrentX") , {"BX", "BittorrentX"}
, map_entry("CD", "Enhanced CTorrent") , {"CD", "Enhanced CTorrent"}
, map_entry("CT", "CTorrent") , {"CT", "CTorrent"}
, map_entry("DE", "Deluge Torrent") , {"DE", "Deluge Torrent"}
, map_entry("ES", "electric sheep") , {"EB", "EBit"}
, map_entry("EB", "EBit") , {"ES", "electric sheep"}
, map_entry("HL", "Halite") , {"HL", "Halite"}
, map_entry("HN", "Hydranode") , {"HN", "Hydranode"}
, map_entry("KT", "KTorrent") , {"KT", "KTorrent"}
, map_entry("LK", "Linkage") , {"LK", "Linkage"}
, map_entry("LP", "lphant") , {"LP", "lphant"}
, map_entry("LT", "libtorrent") , {"LT", "libtorrent"}
, map_entry("M", "Mainline") , {"M", "Mainline"}
, map_entry("ML", "MLDonkey") , {"ML", "MLDonkey"}
, map_entry("MO", "Mono Torrent") , {"MO", "Mono Torrent"}
, map_entry("MP", "MooPolice") , {"MP", "MooPolice"}
, map_entry("MT", "Moonlight Torrent") , {"MT", "Moonlight Torrent"}
, map_entry("O", "Osprey Permaseed") , {"O", "Osprey Permaseed"}
, map_entry("PD", "Pando") , {"PD", "Pando"}
, map_entry("QT", "Qt 4") , {"Q", "BTQueue"}
, map_entry("R", "Tribler") , {"QT", "Qt 4"}
, map_entry("S", "Shadow") , {"R", "Tribler"}
, map_entry("S~", "Shareaza (beta)") , {"S", "Shadow"}
, map_entry("SB", "Swiftbit") , {"SB", "Swiftbit"}
, map_entry("SN", "ShareNet") , {"SN", "ShareNet"}
, map_entry("SS", "SwarmScope") , {"SS", "SwarmScope"}
, map_entry("SZ", "Shareaza") , {"SZ", "Shareaza"}
, map_entry("T", "BitTornado") , {"S~", "Shareaza (beta}"}
, map_entry("TN", "Torrent.NET") , {"T", "BitTornado"}
, map_entry("TR", "Transmission") , {"TN", "Torrent.NET"}
, map_entry("TS", "TorrentStorm") , {"TR", "Transmission"}
, map_entry("TT", "TuoTu") , {"TS", "TorrentStorm"}
, map_entry("U", "UPnP") , {"TT", "TuoTu"}
, map_entry("UL", "uLeecher") , {"U", "UPnP"}
, map_entry("UT", "MicroTorrent") , {"UL", "uLeecher"}
, map_entry("XT", "XanTorrent") , {"UT", "MicroTorrent"}
, map_entry("XX", "Xtorrent") , {"XT", "XanTorrent"}
, map_entry("ZT", "ZipTorrent") , {"XX", "Xtorrent"}
, map_entry("lt", "libTorrent (libtorrent.rakshasa.no/)") , {"ZT", "ZipTorrent"}
, map_entry("pX", "pHoeniX") , {"lt", "libTorrent (libtorrent.rakshasa.no/}"}
, map_entry("qB", "qBittorrent") , {"pX", "pHoeniX"}
, {"qB", "qBittorrent"}
}; };
bool compare_first_string(map_entry const& lhs, map_entry const& rhs) bool compare_id(map_entry const& lhs, map_entry const& rhs)
{ {
return lhs.first[0] < rhs.first[0] return lhs.id[0] < rhs.id[0]
|| ((lhs.first[0] == rhs.first[0]) && (lhs.first[1] < rhs.first[1])); || ((lhs.id[0] == rhs.id[0]) && (lhs.id[1] < rhs.id[1]));
} }
std::string lookup(fingerprint const& f) std::string lookup(fingerprint const& f)
@ -208,20 +213,21 @@ namespace
std::stringstream identity; std::stringstream identity;
const int size = sizeof(name_map)/sizeof(name_map[0]); const int size = sizeof(name_map)/sizeof(name_map[0]);
map_entry tmp = {f.name, ""};
map_entry* i = map_entry* i =
std::lower_bound(name_map, name_map + size std::lower_bound(name_map, name_map + size
, map_entry(f.name, ""), &compare_first_string); , tmp, &compare_id);
#ifndef NDEBUG #ifndef NDEBUG
for (int i = 1; i < size; ++i) for (int i = 1; i < size; ++i)
{ {
assert(compare_first_string(name_map[i-1] assert(compare_id(name_map[i-1]
, name_map[i])); , name_map[i]));
} }
#endif #endif
if (i < name_map + size && std::equal(f.name, f.name + 2, i->first)) if (i < name_map + size && std::equal(f.name, f.name + 2, i->id))
identity << i->second; identity << i->name;
else else
{ {
identity << f.name[0]; identity << f.name[0];