forked from premiere/premiere-libtorrent
Merge pull request #144 from thomas-yuan/master
load_state should restart dht/proxy if there is dht state/proxy.
This commit is contained in:
commit
8b6b8240c1
|
@ -758,6 +758,7 @@ namespace aux {
|
||||||
if (e->type() != bdecode_node::dict_t) return;
|
if (e->type() != bdecode_node::dict_t) return;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
bool need_update_dht = false;
|
||||||
// load from the old settings names
|
// load from the old settings names
|
||||||
settings = e->dict_find_dict("dht");
|
settings = e->dict_find_dict("dht");
|
||||||
if (settings)
|
if (settings)
|
||||||
|
@ -796,9 +797,17 @@ namespace aux {
|
||||||
val = settings.dict_find_int("read_only");
|
val = settings.dict_find_int("read_only");
|
||||||
if (val) m_dht_settings.read_only = val.int_value();
|
if (val) m_dht_settings.read_only = val.int_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings = e->dict_find_dict("dht state");
|
||||||
|
if (settings)
|
||||||
|
{
|
||||||
|
m_dht_state = settings;
|
||||||
|
need_update_dht = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
bool need_update_proxy = false;
|
||||||
settings = e->dict_find_dict("proxy");
|
settings = e->dict_find_dict("proxy");
|
||||||
if (settings)
|
if (settings)
|
||||||
{
|
{
|
||||||
|
@ -817,6 +826,7 @@ namespace aux {
|
||||||
if (val) m_settings.set_str(settings_pack::proxy_password, val.string_value());
|
if (val) m_settings.set_str(settings_pack::proxy_password, val.string_value());
|
||||||
val = settings.dict_find_string("username");
|
val = settings.dict_find_string("username");
|
||||||
if (val) m_settings.set_str(settings_pack::proxy_username, val.string_value());
|
if (val) m_settings.set_str(settings_pack::proxy_username, val.string_value());
|
||||||
|
need_update_proxy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = e->dict_find_dict("encryption");
|
settings = e->dict_find_dict("encryption");
|
||||||
|
@ -832,32 +842,7 @@ namespace aux {
|
||||||
val = settings.dict_find_int("allowed_enc_level");
|
val = settings.dict_find_int("allowed_enc_level");
|
||||||
if (val) m_settings.set_int(settings_pack::allowed_enc_level, val.int_value());
|
if (val) m_settings.set_int(settings_pack::allowed_enc_level, val.int_value());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
settings = e->dict_find_dict("settings");
|
|
||||||
if (settings)
|
|
||||||
{
|
|
||||||
boost::shared_ptr<settings_pack> pack = load_pack_from_dict(settings);
|
|
||||||
apply_settings_pack(pack);
|
|
||||||
}
|
|
||||||
|
|
||||||
// in case we just set a socks proxy, we might have to
|
|
||||||
// open the socks incoming connection
|
|
||||||
if (!m_socks_listen_socket) open_new_incoming_socks_connection();
|
|
||||||
m_udp_socket.set_proxy_settings(proxy());
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
|
||||||
settings = e->dict_find_dict("dht state");
|
|
||||||
if (settings)
|
|
||||||
{
|
|
||||||
// TODO: 2 if the DHT is enabled, it should probably be restarted here.
|
|
||||||
// maybe it should even be deferred to not be started until the client
|
|
||||||
// has had a chance to pass in the dht state
|
|
||||||
m_dht_state = settings;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
settings = e->dict_find_list("feeds");
|
settings = e->dict_find_list("feeds");
|
||||||
if (settings)
|
if (settings)
|
||||||
{
|
{
|
||||||
|
@ -874,6 +859,23 @@ namespace aux {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
settings = e->dict_find_dict("settings");
|
||||||
|
if (settings)
|
||||||
|
{
|
||||||
|
// apply_settings_pack will update dht and proxy
|
||||||
|
boost::shared_ptr<settings_pack> pack = load_pack_from_dict(settings);
|
||||||
|
apply_settings_pack(pack);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
if (need_update_dht) update_dht();
|
||||||
|
#endif
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
if (need_update_proxy) update_proxy();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
|
for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
|
||||||
, end(m_ses_extensions.end()); i != end; ++i)
|
, end(m_ses_extensions.end()); i != end; ++i)
|
||||||
|
|
|
@ -606,7 +606,7 @@ namespace libtorrent
|
||||||
for (std::vector<std::pair<boost::uint16_t, int> >::const_iterator i = pack->m_ints.begin()
|
for (std::vector<std::pair<boost::uint16_t, int> >::const_iterator i = pack->m_ints.begin()
|
||||||
, end(pack->m_ints.end()); i != end; ++i)
|
, end(pack->m_ints.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
// disregard setting indices that are not string types
|
// disregard setting indices that are not int types
|
||||||
if ((i->first & settings_pack::type_mask) != settings_pack::int_type_base)
|
if ((i->first & settings_pack::type_mask) != settings_pack::int_type_base)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ namespace libtorrent
|
||||||
for (std::vector<std::pair<boost::uint16_t, bool> >::const_iterator i = pack->m_bools.begin()
|
for (std::vector<std::pair<boost::uint16_t, bool> >::const_iterator i = pack->m_bools.begin()
|
||||||
, end(pack->m_bools.end()); i != end; ++i)
|
, end(pack->m_bools.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
// disregard setting indices that are not string types
|
// disregard setting indices that are not bool types
|
||||||
if ((i->first & settings_pack::type_mask) != settings_pack::bool_type_base)
|
if ((i->first & settings_pack::type_mask) != settings_pack::bool_type_base)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue