lt sync 1912
This commit is contained in:
parent
e0fc7f3d2e
commit
7b39f7adf5
|
@ -117,6 +117,7 @@ namespace libtorrent
|
|||
, use_dht_as_fallback(true)
|
||||
#endif
|
||||
, free_torrent_hashes(true)
|
||||
, upnp_ignore_nonrouters(true)
|
||||
{}
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
|
@ -292,6 +293,11 @@ namespace libtorrent
|
|||
// make the get_torrent_info() function to return an incomplete
|
||||
// torrent object that cannot be passed back to add_torrent()
|
||||
bool free_torrent_hashes;
|
||||
|
||||
// when this is true, the upnp port mapper will ignore
|
||||
// any upnp devices that don't have an address that matches
|
||||
// our currently configured router.
|
||||
bool upnp_ignore_nonrouters;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
|
|
@ -68,7 +68,7 @@ class upnp : public intrusive_ptr_base<upnp>
|
|||
public:
|
||||
upnp(io_service& ios, connection_queue& cc
|
||||
, address const& listen_interface, std::string const& user_agent
|
||||
, portmap_callback_t const& cb);
|
||||
, portmap_callback_t const& cb, bool ignore_nonrouters);
|
||||
~upnp();
|
||||
|
||||
// maps the ports, if a port is set to 0
|
||||
|
@ -233,6 +233,8 @@ private:
|
|||
|
||||
connection_queue& m_cc;
|
||||
|
||||
std::vector<address> m_filter;
|
||||
|
||||
#ifdef TORRENT_UPNP_LOGGING
|
||||
std::ofstream m_log;
|
||||
#endif
|
||||
|
|
|
@ -2350,7 +2350,8 @@ namespace detail
|
|||
, m_listen_interface.address()
|
||||
, m_settings.user_agent
|
||||
, bind(&session_impl::on_port_mapping
|
||||
, this, _1, _2, _3));
|
||||
, this, _1, _2, _3)
|
||||
, m_settings.upnp_ignore_nonrouters);
|
||||
|
||||
m_upnp->discover_device();
|
||||
m_upnp->set_mappings(m_listen_interface.port(),
|
||||
|
|
|
@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/http_tracker_connection.hpp"
|
||||
#include "libtorrent/xml_parse.hpp"
|
||||
#include "libtorrent/connection_queue.hpp"
|
||||
#include "libtorrent/enum_net.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
|
@ -61,7 +62,7 @@ namespace libtorrent
|
|||
|
||||
upnp::upnp(io_service& ios, connection_queue& cc
|
||||
, address const& listen_interface, std::string const& user_agent
|
||||
, portmap_callback_t const& cb)
|
||||
, portmap_callback_t const& cb, bool ignore_nonrouters)
|
||||
: m_udp_local_port(0)
|
||||
, m_tcp_local_port(0)
|
||||
, m_user_agent(user_agent)
|
||||
|
@ -81,6 +82,21 @@ upnp::upnp(io_service& ios, connection_queue& cc
|
|||
m_log.open("upnp.log", std::ios::in | std::ios::out | std::ios::trunc);
|
||||
#endif
|
||||
m_retry_count = 0;
|
||||
|
||||
if (ignore_nonrouters)
|
||||
{
|
||||
asio::error_code ec;
|
||||
std::vector<address> const& net = enum_net_interfaces(m_io_service, ec);
|
||||
m_filter.reserve(net.size());
|
||||
for (std::vector<address>::const_iterator i = net.begin()
|
||||
, end(net.end()); i != end; ++i)
|
||||
{
|
||||
asio::error_code e;
|
||||
address a = router_for_interface(*i, e);
|
||||
if (e || is_loopback(a)) continue;
|
||||
m_filter.push_back(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
upnp::~upnp()
|
||||
|
@ -265,6 +281,18 @@ try
|
|||
Server:Microsoft-Windows-NT/5.1 UPnP/1.0 UPnP-Device-Host/1.0
|
||||
|
||||
*/
|
||||
if (!m_filter.empty() && std::find(m_filter.begin(), m_filter.end()
|
||||
, from.address()) == m_filter.end())
|
||||
{
|
||||
// this upnp device is filtered because it's not in the
|
||||
// list of configured routers
|
||||
#ifdef TORRENT_UPNP_LOGGING
|
||||
m_log << time_now_string() << " <== (" << from << ") Rootdevice "
|
||||
"ignored because it's not out router" << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
http_parser p;
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue