added more logging to upnp. fixed upnp test
This commit is contained in:
parent
c5e150ee69
commit
36898ecc12
13
src/upnp.cpp
13
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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use-project /torrent : .. ;
|
||||
|
||||
exe test_upnp : test_upnp.cpp /torrent : <threading>multi <logging>verbose <define>TORRENT_UPNP_LOGGING ;
|
||||
exe test_upnp : test_upnp.cpp /torrent : <threading>multi <logging>verbose <upnp-logging>on ;
|
||||
|
||||
project
|
||||
:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue