diff --git a/src/upnp.cpp b/src/upnp.cpp index 45e0b65bf..c7e175681 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -195,6 +195,13 @@ catch (std::exception&) void upnp::set_mappings(int tcp, int udp) { +#ifdef TORRENT_UPNP_LOGGING + m_log << time_now_string() + << " *** set mappings " << tcp << " " << udp; + if (m_disabled) m_log << " DISABLED"; + m_log << std::endl; +#endif + if (m_disabled) return; if (udp != 0) m_udp_local_port = udp; if (tcp != 0) m_tcp_local_port = tcp; @@ -392,11 +399,17 @@ try { d.mapping[0].need_update = true; d.mapping[0].local_port = m_tcp_local_port; +#ifdef TORRENT_UPNP_LOGGING + m_log << time_now_string() << " *** Mapping 0 will be updated" << std::endl; +#endif } if (m_udp_local_port != 0) { d.mapping[1].need_update = true; d.mapping[1].local_port = m_udp_local_port; +#ifdef TORRENT_UPNP_LOGGING + m_log << time_now_string() << " *** Mapping 1 will be updated" << std::endl; +#endif } boost::tie(i, boost::tuples::ignore) = m_devices.insert(d); } diff --git a/test/Jamfile b/test/Jamfile index 890477948..17ca9cdbf 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,6 +1,6 @@ use-project /torrent : .. ; -exe test_upnp : test_upnp.cpp /torrent : multi verbose TORRENT_UPNP_LOGGING ; +exe test_upnp : test_upnp.cpp /torrent : multi verbose on ; project : diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index 5948b5381..d9a6f581a 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -35,6 +35,9 @@ int main(int argc, char* argv[]) ios.run(); upnp_handler.rebind(address_v4::from_string(argv[1])); + timer.expires_from_now(seconds(2)); + timer.async_wait(boost::bind(&io_service::stop, boost::ref(ios))); + std::cerr << "rebinding to IP " << argv[1] << " broadcasting for UPnP device" << std::endl;