diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index 3e3d60667..b105b63cb 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -2829,7 +2829,13 @@ namespace libtorrent m_connection_ticket = ticket; boost::shared_ptr t = m_torrent.lock(); - TORRENT_ASSERT(t); + if (!t || m_disconnecting) + { + m_ses.m_half_open.done(m_connection_ticket); + m_connecting = false; + disconnect(); + return; + } m_queued = false; TORRENT_ASSERT(m_connecting); diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index a65cf6fb8..26bfedd22 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -1619,6 +1619,54 @@ namespace libtorrent (*m_ses.m_logger) << time_now_string() << " resolving web seed: " << url << "\n"; #endif + std::string protocol; + std::string auth; + std::string hostname; + int port; + std::string path; + boost::tie(protocol, auth, hostname, port, path) + = parse_url_components(url); + +#ifdef TORRENT_USE_OPENSSL + if (protocol != "http" && protocol != "https") +#else + if (protocol != "http") +#endif + { + if (m_ses.m_alerts.should_post(alert::warning)) + { + m_ses.m_alerts.post_alert( + url_seed_alert(get_handle(), url, "unknown protocol")); + } + // never try it again + remove_url_seed(url); + return; + } + + if (hostname.empty()) + { + if (m_ses.m_alerts.should_post(alert::warning)) + { + m_ses.m_alerts.post_alert( + url_seed_alert(get_handle(), url, "invalid hostname")); + } + // never try it again + remove_url_seed(url); + return; + } + + if (port == 0) + { + if (m_ses.m_alerts.should_post(alert::warning)) + { + m_ses.m_alerts.post_alert( + url_seed_alert(get_handle(), url, "invalid port")); + } + // never try it again + remove_url_seed(url); + return; + } + m_resolving_web_seeds.insert(url); proxy_settings const& ps = m_ses.web_seed_proxy(); if (ps.type == proxy_settings::http @@ -1632,16 +1680,6 @@ namespace libtorrent } else { - std::string protocol; - std::string auth; - std::string hostname; - int port; - std::string path; - boost::tie(protocol, auth, hostname, port, path) - = parse_url_components(url); - - // TODO: should auth be used here? - tcp::resolver::query q(hostname, boost::lexical_cast(port)); m_host_resolver.async_resolve(q, m_ses.m_strand.wrap( bind(&torrent::on_name_lookup, shared_from_this(), _1, _2, url diff --git a/libtorrent/src/torrent_handle.cpp b/libtorrent/src/torrent_handle.cpp index eae0f1729..4635f4411 100755 --- a/libtorrent/src/torrent_handle.cpp +++ b/libtorrent/src/torrent_handle.cpp @@ -261,12 +261,12 @@ namespace libtorrent TORRENT_FORWARD_RETURN(is_seed(), false); } - bool torrent_handle::is_finished() const - { - INVARIANT_CHECK; - TORRENT_FORWARD_RETURN(is_finished(), false); - } - + bool torrent_handle::is_finished() const + { + INVARIANT_CHECK; + TORRENT_FORWARD_RETURN(is_finished(), false); + } + bool torrent_handle::is_paused() const { INVARIANT_CHECK; diff --git a/libtorrent/src/torrent_info.cpp b/libtorrent/src/torrent_info.cpp index 57c8a9737..cc199c069 100755 --- a/libtorrent/src/torrent_info.cpp +++ b/libtorrent/src/torrent_info.cpp @@ -636,6 +636,8 @@ namespace libtorrent if (!info.find_key("name")) info["name"] = m_name; + if (m_private) info["private"] = 1; + if (!m_multifile) { info["length"] = m_files.front().size; @@ -696,8 +698,6 @@ namespace libtorrent entry dict; - if (m_private) dict["private"] = 1; - if (!m_urls.empty()) dict["announce"] = m_urls.front().url;