forked from premiere/premiere-libtorrent
fix reopening of listen sockets when disabling force-proxy
This commit is contained in:
parent
4d32d45100
commit
96bf0ad5de
|
@ -1 +1 @@
|
||||||
Subproject commit 5688f98f79279de6eee99ef10d54fc8e83587fe9
|
Subproject commit bbba24fc9caf24261e67028b7f8f9b89b832e9eb
|
|
@ -6373,6 +6373,31 @@ namespace {
|
||||||
|
|
||||||
void session_impl::update_force_proxy()
|
void session_impl::update_force_proxy()
|
||||||
{
|
{
|
||||||
|
if (!m_settings.get_bool(settings_pack::force_proxy))
|
||||||
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
session_log("force-proxy disabled");
|
||||||
|
#endif
|
||||||
|
// we need to close and remove all listen sockets during a transition
|
||||||
|
// from force-proxy to not-force-proxy. reopen_listen_sockets() won't
|
||||||
|
// do anything with half-opened sockets.
|
||||||
|
error_code ec;
|
||||||
|
for (auto& i : m_listen_sockets)
|
||||||
|
{
|
||||||
|
if (i->udp_sock) i->udp_sock->sock.close();
|
||||||
|
if (i->sock) i->sock->close(ec);
|
||||||
|
}
|
||||||
|
m_listen_sockets.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
|
session_log("force-proxy enabled");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// when enabling force-proxy, we no longer wand to accept connections via
|
||||||
|
// a regular listen socket, only via a proxy. We also want to enable
|
||||||
|
// force-proxy on all udp sockets
|
||||||
for (auto& i : m_listen_sockets)
|
for (auto& i : m_listen_sockets)
|
||||||
{
|
{
|
||||||
i->udp_sock->sock.set_force_proxy(m_settings.get_bool(settings_pack::force_proxy));
|
i->udp_sock->sock.set_force_proxy(m_settings.get_bool(settings_pack::force_proxy));
|
||||||
|
@ -6386,18 +6411,6 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_settings.get_bool(settings_pack::force_proxy))
|
|
||||||
{
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
|
||||||
session_log("force-proxy disabled");
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
|
||||||
session_log("force-proxy enabled");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// enable force_proxy mode. We don't want to accept any incoming
|
// enable force_proxy mode. We don't want to accept any incoming
|
||||||
// connections, except through a proxy.
|
// connections, except through a proxy.
|
||||||
stop_lsd();
|
stop_lsd();
|
||||||
|
|
Loading…
Reference in New Issue