forked from premiere/premiere-libtorrent
support having torrents that the IP filter doesn't apply to
This commit is contained in:
parent
8c2d496992
commit
c15880be91
|
@ -2194,6 +2194,8 @@ Its declaration looks like this::
|
|||
void set_upload_mode(bool m) const;
|
||||
void set_share_mode(bool m) const;
|
||||
|
||||
void apply_ip_filter(bool b) const;
|
||||
|
||||
void flush_cache() const;
|
||||
|
||||
void resolve_countries(bool r);
|
||||
|
@ -2705,6 +2707,16 @@ not necessarily be downloaded, especially not the whole of it. Only parts that a
|
|||
to be distributed to more than 2 other peers are downloaded, and only if the previous
|
||||
prediction was correct.
|
||||
|
||||
apply_ip_filter()
|
||||
-----------------
|
||||
|
||||
::
|
||||
|
||||
void apply_ip_filter(bool b) const;
|
||||
|
||||
Set to true to apply the session global IP filter to this torrent (which is the
|
||||
default). Set to false to make this torrent ignore the IP filter.
|
||||
|
||||
resolve_countries()
|
||||
-------------------
|
||||
|
||||
|
@ -3304,6 +3316,7 @@ It contains the following fields::
|
|||
|
||||
int queue_position;
|
||||
bool need_save_resume;
|
||||
bool ip_filter_applies;
|
||||
};
|
||||
|
||||
``handle`` is a handle to the torrent whose status the object represents.
|
||||
|
@ -3574,6 +3587,9 @@ queue. If the torrent is a seed or finished, this is -1.
|
|||
to its download state and statistics since the last resume data
|
||||
was saved.
|
||||
|
||||
``ip_filter_applies`` is true if the session global IP filter applies
|
||||
to this torrent. This defaults to true.
|
||||
|
||||
peer_info
|
||||
=========
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace libtorrent
|
|||
, upload_mode(false)
|
||||
, file_priorities(0)
|
||||
, share_mode(false)
|
||||
, apply_ip_filter(true)
|
||||
{}
|
||||
|
||||
// libtorrent version. Used for forward binary compatibility
|
||||
|
@ -88,6 +89,7 @@ namespace libtorrent
|
|||
std::string url;
|
||||
std::string uuid;
|
||||
std::string source_feed_url;
|
||||
bool apply_ip_filter;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -823,6 +823,9 @@ namespace libtorrent
|
|||
|
||||
void update_last_upload() { m_last_upload = 0; }
|
||||
|
||||
void set_apply_ip_filter(bool b);
|
||||
bool apply_ip_filter() const { return m_apply_ip_filter; }
|
||||
|
||||
private:
|
||||
|
||||
void on_files_deleted(int ret, disk_io_job const& j);
|
||||
|
@ -1300,6 +1303,10 @@ namespace libtorrent
|
|||
// by default for such torrents. It does not necessarily
|
||||
// have to be a magnet link.
|
||||
bool m_magnet_link:1;
|
||||
|
||||
// set to true if the session IP filter applies to this
|
||||
// torrent or not. Defaults to true.
|
||||
bool m_apply_ip_filter:1;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,8 @@ namespace libtorrent
|
|||
void set_share_mode(bool b) const;
|
||||
void flush_cache() const;
|
||||
|
||||
void apply_ip_filter(bool b) const;
|
||||
|
||||
void force_recheck() const;
|
||||
|
||||
enum save_resume_flags_t { flush_disk_cache = 1, save_info_dict = 2 };
|
||||
|
@ -475,6 +477,7 @@ namespace libtorrent
|
|||
, time_since_download(0)
|
||||
, queue_position(0)
|
||||
, need_save_resume(false)
|
||||
, ip_filter_applies(true)
|
||||
{}
|
||||
|
||||
// handle to the torrent
|
||||
|
@ -683,6 +686,10 @@ namespace libtorrent
|
|||
// true if this torrent has had changes since the last
|
||||
// time resume data was saved
|
||||
bool need_save_resume;
|
||||
|
||||
// defaults to true. Determines whether the session
|
||||
// IP filter applies to this torrent or not
|
||||
bool ip_filter_applies;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -347,6 +347,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
aux::session_impl& ses = m_torrent->session();
|
||||
if (!m_torrent->apply_ip_filter()) return;
|
||||
|
||||
for (iterator i = m_peers.begin(); i != m_peers.end();)
|
||||
{
|
||||
|
|
|
@ -406,6 +406,7 @@ namespace libtorrent
|
|||
, m_need_connect_boost(true)
|
||||
, m_lsd_seq(0)
|
||||
, m_magnet_link(false)
|
||||
, m_apply_ip_filter(p.apply_ip_filter)
|
||||
{
|
||||
if (!p.ti || !p.ti->is_valid())
|
||||
{
|
||||
|
@ -786,6 +787,13 @@ namespace libtorrent
|
|||
set_state(torrent_status::downloading_metadata);
|
||||
}
|
||||
|
||||
void torrent::set_apply_ip_filter(bool b)
|
||||
{
|
||||
if (b == m_apply_ip_filter) return;
|
||||
m_apply_ip_filter = b;
|
||||
m_policy.ip_filter_updated();
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
bool torrent::should_announce_dht() const
|
||||
{
|
||||
|
@ -2293,7 +2301,8 @@ namespace libtorrent
|
|||
if (e || host == tcp::resolver::iterator() ||
|
||||
m_ses.is_aborted()) return;
|
||||
|
||||
if (m_ses.m_ip_filter.access(host->endpoint().address()) & ip_filter::blocked)
|
||||
if (m_apply_ip_filter
|
||||
&& m_ses.m_ip_filter.access(host->endpoint().address()) & ip_filter::blocked)
|
||||
{
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
error_code ec;
|
||||
|
@ -3937,7 +3946,8 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
|
||||
if (m_apply_ip_filter
|
||||
&& m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
|
||||
{
|
||||
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
|
||||
m_ses.m_alerts.post_alert(peer_blocked_alert(get_handle(), a.address()));
|
||||
|
@ -3986,7 +3996,8 @@ namespace libtorrent
|
|||
void torrent::connect_web_seed(std::list<web_seed_entry>::iterator web, tcp::endpoint a)
|
||||
{
|
||||
TORRENT_ASSERT(m_ses.is_network_thread());
|
||||
if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
|
||||
if (m_apply_ip_filter
|
||||
&& m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
|
||||
{
|
||||
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
|
||||
m_ses.m_alerts.post_alert(peer_blocked_alert(get_handle(), a.address()));
|
||||
|
@ -4822,7 +4833,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_ses.num_connections() < m_ses.settings().connections_limit || ignore_limit);
|
||||
|
||||
tcp::endpoint a(peerinfo->ip());
|
||||
TORRENT_ASSERT((m_ses.m_ip_filter.access(peerinfo->address()) & ip_filter::blocked) == 0);
|
||||
TORRENT_ASSERT(!m_apply_ip_filter
|
||||
|| (m_ses.m_ip_filter.access(peerinfo->address()) & ip_filter::blocked) == 0);
|
||||
|
||||
boost::shared_ptr<socket_type> s(new socket_type(m_ses.m_io_service));
|
||||
|
||||
|
@ -7310,6 +7322,7 @@ namespace libtorrent
|
|||
|
||||
st->queue_position = queue_position();
|
||||
st->need_save_resume = need_save_resume_data();
|
||||
st->ip_filter_applies = m_apply_ip_filter;
|
||||
|
||||
st->state = (torrent_status::state_t)m_state;
|
||||
|
||||
|
|
|
@ -351,6 +351,12 @@ namespace libtorrent
|
|||
TORRENT_ASYNC_CALL1(pause, bool(flags & graceful_pause));
|
||||
}
|
||||
|
||||
void torrent_handle::apply_ip_filter(bool b) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASYNC_CALL1(set_apply_ip_filter, b);
|
||||
}
|
||||
|
||||
void torrent_handle::set_share_mode(bool b) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
|
Loading…
Reference in New Issue