本文整理汇总了C++中libtorrent::session::apply_settings方法的典型用法代码示例。如果您正苦于以下问题:C++ session::apply_settings方法的具体用法?C++ session::apply_settings怎么用?C++ session::apply_settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libtorrent::session
的用法示例。
在下文中一共展示了session::apply_settings方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enable_enc
void enable_enc(lt::session& ses)
{
using namespace libtorrent;
settings_pack p;
p.set_bool(settings_pack::prefer_rc4, true);
p.set_int(settings_pack::in_enc_policy, settings_pack::pe_forced);
p.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
p.set_int(settings_pack::allowed_enc_level, settings_pack::pe_both);
ses.apply_settings(p);
}
示例2: enable_utp
void enable_utp(lt::session& ses)
{
using namespace libtorrent;
settings_pack p;
p.set_bool(settings_pack::enable_outgoing_tcp, false);
p.set_bool(settings_pack::enable_incoming_tcp, false);
p.set_bool(settings_pack::enable_outgoing_utp, true);
p.set_bool(settings_pack::enable_incoming_utp, true);
ses.apply_settings(p);
}
示例3: set_proxy
void set_proxy(lt::session& ses, int proxy_type, int flags = 0, bool proxy_peer_connections = true)
{
// apply the proxy settings to session 0
using namespace libtorrent;
settings_pack p;
p.set_int(settings_pack::proxy_type, proxy_type);
if (proxy_type == settings_pack::socks4)
p.set_int(settings_pack::proxy_port, 4444);
else
p.set_int(settings_pack::proxy_port, 5555);
if (flags & ipv6)
p.set_str(settings_pack::proxy_hostname, "2001::2");
else
p.set_str(settings_pack::proxy_hostname, "50.50.50.50");
p.set_bool(settings_pack::proxy_hostnames, true);
p.set_bool(settings_pack::proxy_peer_connections, proxy_peer_connections);
p.set_bool(settings_pack::proxy_tracker_connections, true);
ses.apply_settings(p);
}
示例4: bootstrap_session
void bootstrap_session(std::vector<dht_network*> networks, lt::session& ses)
{
lt::dht_settings sett;
sett.ignore_dark_internet = false;
ses.set_dht_settings(sett);
lt::entry state;
for (auto dht : networks)
{
// bootstrap off of 8 of the nodes
auto router_nodes = dht->router_nodes();
char const* nodes_key;
if (router_nodes.front().address().is_v6())
nodes_key = "nodes6";
else
nodes_key = "nodes";
lt::entry::list_type& nodes = state["dht state"][nodes_key].list();
for (auto const& n : router_nodes)
{
std::string node;
std::back_insert_iterator<std::string> out(node);
lt::detail::write_endpoint(n, out);
nodes.push_back(lt::entry(node));
}
}
std::vector<char> buf;
lt::bencode(std::back_inserter(buf), state);
lt::bdecode_node e;
lt::error_code ec;
lt::bdecode(&buf[0], &buf[0] + buf.size(), e, ec);
ses.load_state(e);
lt::settings_pack pack;
pack.set_bool(lt::settings_pack::enable_dht, true);
ses.apply_settings(pack);
}
示例5: test_transfer
// proxy: 0=none, 1=socks4, 2=socks5, 3=socks5_pw 4=http 5=http_pw
void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_file
, int proxy, int port, char const* protocol, bool url_seed
, bool chunked_encoding, bool test_ban, bool keepalive, bool proxy_peers)
{
using namespace libtorrent;
TORRENT_ASSERT(torrent_file->web_seeds().size() > 0);
std::string save_path = "tmp2_web_seed";
save_path += proxy_name[proxy];
error_code ec;
remove_all(save_path, ec);
static char const* test_name[] = {"no", "SOCKS4", "SOCKS5", "SOCKS5 password", "HTTP", "HTTP password"};
fprintf(stderr, "\n\n ==== TESTING === proxy: %s ==== protocol: %s "
"==== seed: %s === transfer-encoding: %s === corruption: %s "
"==== keepalive: %s\n\n\n"
, test_name[proxy], protocol, url_seed ? "URL seed" : "HTTP seed"
, chunked_encoding ? "chunked": "none", test_ban ? "yes" : "no"
, keepalive ? "yes" : "no");
int proxy_port = 0;
if (proxy)
{
proxy_port = start_proxy(proxy);
if (proxy_port < 0)
{
fprintf(stderr, "failed to start proxy");
return;
}
settings_pack pack;
pack.set_str(settings_pack::proxy_hostname, "127.0.0.1");
pack.set_str(settings_pack::proxy_username, "testuser");
pack.set_str(settings_pack::proxy_password, "testpass");
pack.set_int(settings_pack::proxy_type, (settings_pack::proxy_type_t)proxy);
pack.set_int(settings_pack::proxy_port, proxy_port);
pack.set_bool(settings_pack::proxy_peer_connections, proxy_peers);
ses.apply_settings(pack);
}
else
{
settings_pack pack;
pack.set_str(settings_pack::proxy_hostname, "");
pack.set_str(settings_pack::proxy_username, "");
pack.set_str(settings_pack::proxy_password, "");
pack.set_int(settings_pack::proxy_type, settings_pack::none);
pack.set_int(settings_pack::proxy_port, 0);
pack.set_bool(settings_pack::proxy_peer_connections, proxy_peers);
ses.apply_settings(pack);
}
add_torrent_params p;
p.flags &= ~add_torrent_params::flag_paused;
p.flags &= ~add_torrent_params::flag_auto_managed;
p.ti = torrent_file;
p.save_path = save_path;
#ifndef TORRENT_NO_DEPRECATE
p.storage_mode = storage_mode_compact;
#endif
torrent_handle th = ses.add_torrent(p, ec);
printf("adding torrent, save_path = \"%s\" cwd = \"%s\" torrent = \"%s\"\n"
, save_path.c_str(), current_working_directory().c_str()
, torrent_file->name().c_str());
std::vector<announce_entry> empty;
th.replace_trackers(empty);
const boost::int64_t total_size = torrent_file->total_size();
file_storage const& fs = torrent_file->files();
int pad_file_size = 0;
for (int i = 0; i < fs.num_files(); ++i)
{
if (fs.file_flags(i) & file_storage::flag_pad_file)
pad_file_size += fs.file_size(i);
}
peer_disconnects = 0;
std::map<std::string, boost::int64_t> cnt = get_counters(ses);
for (int i = 0; i < 40; ++i)
{
torrent_status s = th.status();
cnt = get_counters(ses);
print_ses_rate(i / 10.f, &s, NULL);
print_alerts(ses, " >> ses", test_ban, false, false, &on_alert);
if (test_ban && th.url_seeds().empty() && th.http_seeds().empty())
{
fprintf(stderr, "testing ban: URL seed removed\n");
// when we don't have any web seeds left, we know we successfully banned it
break;
}
if (s.is_seeding)
//.........这里部分代码省略.........