fixed bind_port for outgoing peer connections

This commit is contained in:
Arvid Norberg 2008-09-25 07:40:55 +00:00
parent 92bac424eb
commit bb674134e3
2 changed files with 18 additions and 11 deletions

View File

@ -3636,7 +3636,22 @@ namespace libtorrent
disconnect(ec.message().c_str());
return;
}
m_socket->bind(t->get_interface(), ec);
tcp::endpoint bind_interface = t->get_interface();
std::pair<int, int> const& out_ports = m_ses.settings().outgoing_ports;
if (out_ports.first > 0 && out_ports.second >= out_ports.first)
{
m_socket->set_option(socket_acceptor::reuse_address(true), ec);
if (ec)
{
disconnect(ec.message().c_str());
return;
}
bind_interface.port(m_ses.next_port());
}
m_socket->bind(bind_interface, ec);
if (ec)
{
disconnect(ec.message().c_str());

View File

@ -2308,11 +2308,6 @@ namespace libtorrent
s->get<http_stream>().set_no_connect(true);
}
std::pair<int, int> const& out_ports = m_settings.outgoing_ports;
error_code ec;
if (out_ports.first > 0 && out_ports.second >= out_ports.first)
s->bind(tcp::endpoint(address(), m_ses.next_port()), ec);
boost::intrusive_ptr<peer_connection> c(new (std::nothrow) web_peer_connection(
m_ses, shared_from_this(), s, a, url, 0));
if (!c) return;
@ -2891,10 +2886,6 @@ namespace libtorrent
bool ret = instantiate_connection(m_ses.m_io_service, m_ses.peer_proxy(), *s);
(void)ret;
TORRENT_ASSERT(ret);
std::pair<int, int> const& out_ports = m_ses.settings().outgoing_ports;
error_code ec;
if (out_ports.first > 0 && out_ports.second >= out_ports.first)
s->bind(tcp::endpoint(address(), m_ses.next_port()), ec);
boost::intrusive_ptr<peer_connection> c(new bt_peer_connection(
m_ses, shared_from_this(), s, a, peerinfo));
@ -2950,7 +2941,8 @@ namespace libtorrent
return false;
}
#endif
return true;
return peerinfo->connection;
}
bool torrent::set_metadata(char const* metadata_buf, int metadata_size)