expose UPnP and NAT-PMP mapping in session object
This commit is contained in:
parent
52c45556fb
commit
3858025c3c
|
@ -1,3 +1,4 @@
|
|||
* expose UPnP and NAT-PMP mapping in session object
|
||||
* DHT refactoring and support for storing arbitrary data with put
|
||||
* support building on android
|
||||
* improved support for web seeds that don't support keep-alive
|
||||
|
|
|
@ -879,6 +879,15 @@ namespace libtorrent
|
|||
void start_upnp();
|
||||
void stop_upnp();
|
||||
|
||||
enum protocol_type { udp = 1, tcp = 2 };
|
||||
|
||||
// add_port_mapping adds a port forwarding on UPnP and/or NAT-PMP,
|
||||
// whichever is enabled. The return value is a handle referring to
|
||||
// the port mapping that was just created. Pass it to delete_port_mapping()
|
||||
// to remove it.
|
||||
int add_port_mapping(protocol_type t, int external_port, int local_port);
|
||||
void delete_port_mapping(int handle);
|
||||
|
||||
// Starts and stops the NAT-PMP service. When started, the listen port and the DHT
|
||||
// port are attempted to be forwarded on the router through NAT-PMP.
|
||||
//
|
||||
|
|
|
@ -1161,6 +1161,16 @@ namespace libtorrent
|
|||
TORRENT_ASYNC_CALL(start_upnp);
|
||||
}
|
||||
|
||||
int session::add_port_mapping(protocol_type t, int external_port, int local_port)
|
||||
{
|
||||
TORRENT_SYNC_CALL_RET3(add_port_forward, int, t, external_port, local_port);
|
||||
}
|
||||
|
||||
void session::delete_port_mapping(int handle)
|
||||
{
|
||||
TORRENT_ASYNC_CALL1(delete_port_forward, handle);
|
||||
}
|
||||
|
||||
void session::stop_lsd()
|
||||
{
|
||||
TORRENT_ASYNC_CALL(stop_lsd);
|
||||
|
|
|
@ -6173,6 +6173,24 @@ retry:
|
|||
return u;
|
||||
}
|
||||
|
||||
int session_impl::add_port_mapping(protocol_type t, int external_port
|
||||
, int local_port)
|
||||
{
|
||||
int ret = 0;
|
||||
if (m_upnp) ret = m_upnp->add_mapping(t, external_port
|
||||
, internal_port);
|
||||
if (m_natpmp) ret = m_natpmp->add_mapping(t, external_port
|
||||
, internal_port);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void session_impl::delete_port_mapping(int handle)
|
||||
{
|
||||
int ret = 0;
|
||||
if (m_upnp) ret = m_upnp->delete_mapping(handle);
|
||||
if (m_natpmp) ret = m_natpmp->delete_mapping(handle);
|
||||
}
|
||||
|
||||
void session_impl::stop_lsd()
|
||||
{
|
||||
if (m_lsd.get())
|
||||
|
|
Loading…
Reference in New Issue