mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-11 16:49:22 +00:00
* Allow hex values in the 'tos' option.
* Moved more encryption related code to HandshakeEncryption. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@797 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -279,25 +279,28 @@ apply_enable_trackers(Control* m, __UNUSED const std::string& arg) {
|
||||
|
||||
void
|
||||
apply_tos(const std::string& arg) {
|
||||
utils::Variable::value_type value;
|
||||
torrent::ConnectionManager* cm = torrent::connection_manager();
|
||||
|
||||
if (arg == "default")
|
||||
cm->set_priority(torrent::ConnectionManager::iptos_default);
|
||||
value = torrent::ConnectionManager::iptos_default;
|
||||
|
||||
else if (arg == "lowdelay")
|
||||
cm->set_priority(torrent::ConnectionManager::iptos_lowdelay);
|
||||
value = torrent::ConnectionManager::iptos_lowdelay;
|
||||
|
||||
else if (arg == "throughput")
|
||||
cm->set_priority(torrent::ConnectionManager::iptos_throughput);
|
||||
value = torrent::ConnectionManager::iptos_throughput;
|
||||
|
||||
else if (arg == "reliability")
|
||||
cm->set_priority(torrent::ConnectionManager::iptos_reliability);
|
||||
value = torrent::ConnectionManager::iptos_reliability;
|
||||
|
||||
else if (arg == "mincost")
|
||||
cm->set_priority(torrent::ConnectionManager::iptos_mincost);
|
||||
value = torrent::ConnectionManager::iptos_mincost;
|
||||
|
||||
else
|
||||
else if (!utils::Variable::string_to_value_unit_nothrow(arg.c_str(), &value, 16, 0))
|
||||
throw torrent::input_error("Invalid TOS identifier.");
|
||||
|
||||
cm->set_priority(value);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -94,4 +94,15 @@ Variable::string_to_value_unit(const char* pos, value_type* value, int base, int
|
||||
return last;
|
||||
}
|
||||
|
||||
bool
|
||||
Variable::string_to_value_unit_nothrow(const char* pos, value_type* value, int base, int unit) {
|
||||
try {
|
||||
string_to_value_unit(pos, value, base, unit);
|
||||
|
||||
return true;
|
||||
} catch (const torrent::input_error& e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
virtual void set(const torrent::Object& arg) = 0;
|
||||
|
||||
static const char* string_to_value_unit(const char* pos, value_type* value, int base, int unit);
|
||||
static bool string_to_value_unit_nothrow(const char* pos, value_type* value, int base, int unit);
|
||||
|
||||
protected:
|
||||
Variable(const Variable&);
|
||||
|
||||
Reference in New Issue
Block a user