forked from premiere/premiere-libtorrent
add make_tcp() and make_udp() to convert endpoint types
This commit is contained in:
parent
c5b415b89f
commit
81356cfce1
|
@ -93,6 +93,12 @@ namespace libtorrent {
|
||||||
using null_buffers = boost::asio::null_buffers;
|
using null_buffers = boost::asio::null_buffers;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline udp::endpoint make_udp(tcp::endpoint const ep)
|
||||||
|
{ return {ep.address(), ep.port()}; }
|
||||||
|
|
||||||
|
inline tcp::endpoint make_tcp(udp::endpoint const ep)
|
||||||
|
{ return {ep.address(), ep.port()}; }
|
||||||
|
|
||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
|
|
||||||
#ifndef PROTECTION_LEVEL_UNRESTRICTED
|
#ifndef PROTECTION_LEVEL_UNRESTRICTED
|
||||||
|
|
|
@ -773,7 +773,7 @@ entry write_nodes_entry(std::vector<node_entry> const& nodes)
|
||||||
for (auto const& n : nodes)
|
for (auto const& n : nodes)
|
||||||
{
|
{
|
||||||
std::copy(n.id.begin(), n.id.end(), out);
|
std::copy(n.id.begin(), n.id.end(), out);
|
||||||
detail::write_endpoint(udp::endpoint(n.addr(), std::uint16_t(n.port())), out);
|
detail::write_endpoint(n.ep(), out);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2104,11 +2104,6 @@ namespace aux {
|
||||||
if (ep != EndpointType())
|
if (ep != EndpointType())
|
||||||
map_handle = m.add_mapping(protocol, ep.port(), ep);
|
map_handle = m.add_mapping(protocol, ep.port(), ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp::endpoint to_tcp(udp::endpoint const& ep)
|
|
||||||
{
|
|
||||||
return tcp::endpoint(ep.address(), ep.port());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::remap_ports(remap_port_mask_t const mask
|
void session_impl::remap_ports(remap_port_mask_t const mask
|
||||||
|
@ -2120,12 +2115,12 @@ namespace aux {
|
||||||
if ((mask & remap_natpmp) && s.natpmp_mapper)
|
if ((mask & remap_natpmp) && s.natpmp_mapper)
|
||||||
{
|
{
|
||||||
map_port(*s.natpmp_mapper, portmap_protocol::tcp, tcp_ep, s.tcp_port_mapping[0]);
|
map_port(*s.natpmp_mapper, portmap_protocol::tcp, tcp_ep, s.tcp_port_mapping[0]);
|
||||||
map_port(*s.natpmp_mapper, portmap_protocol::udp, to_tcp(udp_ep), s.udp_port_mapping[0]);
|
map_port(*s.natpmp_mapper, portmap_protocol::udp, make_tcp(udp_ep), s.udp_port_mapping[0]);
|
||||||
}
|
}
|
||||||
if ((mask & remap_upnp) && m_upnp)
|
if ((mask & remap_upnp) && m_upnp)
|
||||||
{
|
{
|
||||||
map_port(*m_upnp, portmap_protocol::tcp, tcp_ep, s.tcp_port_mapping[1]);
|
map_port(*m_upnp, portmap_protocol::tcp, tcp_ep, s.tcp_port_mapping[1]);
|
||||||
map_port(*m_upnp, portmap_protocol::udp, to_tcp(udp_ep), s.udp_port_mapping[1]);
|
map_port(*m_upnp, portmap_protocol::udp, make_tcp(udp_ep), s.udp_port_mapping[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ namespace libtorrent {
|
||||||
{
|
{
|
||||||
// m_target failed. remove it from the endpoint list
|
// m_target failed. remove it from the endpoint list
|
||||||
auto const i = std::find(m_endpoints.begin()
|
auto const i = std::find(m_endpoints.begin()
|
||||||
, m_endpoints.end(), tcp::endpoint(m_target.address(), m_target.port()));
|
, m_endpoints.end(), make_tcp(m_target));
|
||||||
|
|
||||||
if (i != m_endpoints.end()) m_endpoints.erase(i);
|
if (i != m_endpoints.end()) m_endpoints.erase(i);
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ namespace libtorrent {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// pick another target endpoint and try again
|
// pick another target endpoint and try again
|
||||||
m_target = udp::endpoint(m_endpoints.front().address(), m_endpoints.front().port());
|
m_target = make_udp(m_endpoints.front());
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
if (cb && cb->should_log())
|
if (cb && cb->should_log())
|
||||||
|
@ -252,7 +252,7 @@ namespace libtorrent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_target = udp::endpoint(m_endpoints.front().address(), m_endpoints.front().port());
|
m_target = make_udp(m_endpoints.front());
|
||||||
|
|
||||||
start_announce();
|
start_announce();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue