clean up proxy_settings constructors

This commit is contained in:
arvidn 2018-07-04 16:28:10 +02:00 committed by Arvid Norberg
parent c7e705e158
commit efe3036879
2 changed files with 29 additions and 36 deletions

View File

@ -117,23 +117,23 @@ namespace aux {
// tells libtorrent what kind of proxy server it is. See proxy_type // tells libtorrent what kind of proxy server it is. See proxy_type
// enum for options // enum for options
std::uint8_t type; std::uint8_t type = 0;
// the port the proxy server is running on // the port the proxy server is running on
std::uint16_t port; std::uint16_t port = 0;
// defaults to true. It means that hostnames should be attempted to be // defaults to true. It means that hostnames should be attempted to be
// resolved through the proxy instead of using the local DNS service. // resolved through the proxy instead of using the local DNS service.
// This is only supported by SOCKS5 and HTTP. // This is only supported by SOCKS5 and HTTP.
bool proxy_hostnames; bool proxy_hostnames = true;
// determines whether or not to exempt peer and web seed connections // determines whether or not to exempt peer and web seed connections
// from using the proxy. This defaults to true, i.e. peer connections are // from using the proxy. This defaults to true, i.e. peer connections are
// proxied by default. // proxied by default.
bool proxy_peer_connections; bool proxy_peer_connections = true;
// if true, tracker connections are subject to the proxy settings // if true, tracker connections are subject to the proxy settings
bool proxy_tracker_connections; bool proxy_tracker_connections = true;
}; };

View File

@ -35,41 +35,34 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/aux_/session_settings.hpp"
namespace libtorrent { namespace aux { namespace libtorrent { namespace aux {
proxy_settings::proxy_settings()
: type(0) proxy_settings::proxy_settings() = default;
, port(0)
, proxy_hostnames(true)
, proxy_peer_connections(true)
, proxy_tracker_connections(true)
{}
proxy_settings::proxy_settings(settings_pack const& sett) proxy_settings::proxy_settings(settings_pack const& sett)
{ : hostname(sett.get_str(settings_pack::proxy_hostname))
hostname = sett.get_str(settings_pack::proxy_hostname); , username(sett.get_str(settings_pack::proxy_username))
username = sett.get_str(settings_pack::proxy_username); , password(sett.get_str(settings_pack::proxy_password))
password = sett.get_str(settings_pack::proxy_password); , type(std::uint8_t(sett.get_int(settings_pack::proxy_type)))
type = std::uint8_t(sett.get_int(settings_pack::proxy_type)); , port(std::uint16_t(sett.get_int(settings_pack::proxy_port)))
port = std::uint16_t(sett.get_int(settings_pack::proxy_port)); , proxy_hostnames(sett.get_bool(settings_pack::proxy_hostnames))
proxy_hostnames = sett.get_bool(settings_pack::proxy_hostnames); , proxy_peer_connections(sett.get_bool(
proxy_peer_connections = sett.get_bool( settings_pack::proxy_peer_connections))
settings_pack::proxy_peer_connections); , proxy_tracker_connections(sett.get_bool(
proxy_tracker_connections = sett.get_bool( settings_pack::proxy_tracker_connections))
settings_pack::proxy_tracker_connections); {}
}
proxy_settings::proxy_settings(aux::session_settings const& sett) proxy_settings::proxy_settings(aux::session_settings const& sett)
{ : hostname(sett.get_str(settings_pack::proxy_hostname))
hostname = sett.get_str(settings_pack::proxy_hostname); , username(sett.get_str(settings_pack::proxy_username))
username = sett.get_str(settings_pack::proxy_username); , password(sett.get_str(settings_pack::proxy_password))
password = sett.get_str(settings_pack::proxy_password); , type(std::uint8_t(sett.get_int(settings_pack::proxy_type)))
type = std::uint8_t(sett.get_int(settings_pack::proxy_type)); , port(std::uint16_t(sett.get_int(settings_pack::proxy_port)))
port = std::uint16_t(sett.get_int(settings_pack::proxy_port)); , proxy_hostnames(sett.get_bool(settings_pack::proxy_hostnames))
proxy_hostnames = sett.get_bool(settings_pack::proxy_hostnames); , proxy_peer_connections(sett.get_bool(
proxy_peer_connections = sett.get_bool( settings_pack::proxy_peer_connections))
settings_pack::proxy_peer_connections); , proxy_tracker_connections(sett.get_bool(
proxy_tracker_connections = sett.get_bool( settings_pack::proxy_tracker_connections))
settings_pack::proxy_tracker_connections); {}
}
} // namespace aux } // namespace aux
} // namespace libtorrent } // namespace libtorrent