/** \brief Return true if the object is to be considered null, false otherwise */ bool bt_handshake_t::is_null() const throw() { // test if all the mandatory fields have acceptable values if( protocolid().empty() ) return true; if( infohash().is_null() ) return true; if( peerid().is_null() ) return true; // if this point is reached, the object is NOT null return false; }
/** \brief convert the object to a string */ std::string bt_handshake_t::to_string() const throw() { std::ostringstream oss; // handle the null case if( is_null() ) return "null"; // build the string to return oss << "protocolid=" << protocolid(); oss << " " << "protoflag=" << protoflag(); oss << " " << "infohash=" << infohash(); oss << " " << "peerid=" << peerid(); // return the just built string return oss.str(); }
void TorrentBase::sanitize_announce_urls(const TorrentSanitize &san, const TorrentBase *mergefromother) { AnnounceList list(san); list.force_merge(san.additional_announce_urls); list.merge(*this); if (0 != mergefromother) list.merge(*mergefromother); t_announce_list.clear(); if (list.list.empty()) { std::string hash = infohash(); for (size_t i = 0; i < hash.length(); i++) hash[i] = ::toupper(hash[i]); t_announce = std::string("dht://") + hash; } else { t_announce = list.list[0][0]; t_announce_list = list.list; } }