mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-17 07:32:32 +00:00
Mark safe commands with flag_untrusted_safe for whitelist enforcement
Annotate all commands that web UIs (ruTorrent) need for normal torrent management with _U macro variants, which set flag_untrusted_safe. Commands not marked are blocked by default for untrusted connections. Safe commands include: - d.* download getters, state, priorities, custom fields, start/stop - f.* file getters, priority control - p.* peer getters, disconnect, ban/snub - t.* tracker getters, enable/disable - throttle.* rate getters/setters, peer limits - network.* read-only queries (getters safe, setters blocked) - view.list, view.size, view.filter_all, ui.current_view - load.*, download_list, d.multicall2, d.multicall.filtered - convert.*, branch/if/and/or/not/cat/value/print - system.* version/time/status queries (read-only) - choke_group.* read-only queries - method.has_key, method.const, method.list_keys, method.get, strings.* - group.*.view, group.*.ratio.min/max/upload (dynamic, via flag propagation) Blocked by default (not marked): - execute*, method.insert/set/redirect, schedule*, import - log.*, file.append, network.scgi.open_*, view.filter/sort/event_* - system.shutdown, system.env, group.insert, choke_group.insert - All user-defined commands (via method.insert)
This commit is contained in:
+25
-25
@@ -67,37 +67,37 @@ retrieve_p_completed_percent(torrent::Peer* peer) {
|
||||
|
||||
void
|
||||
initialize_command_peer() {
|
||||
CMD2_PEER("p.id", std::bind(&retrieve_p_id, std::placeholders::_1));
|
||||
CMD2_PEER("p.id_html", std::bind(&retrieve_p_id_html, std::placeholders::_1));
|
||||
CMD2_PEER("p.client_version", std::bind(&retrieve_p_client_version, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.id", std::bind(&retrieve_p_id, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.id_html", std::bind(&retrieve_p_id_html, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.client_version", std::bind(&retrieve_p_client_version, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.options_str", std::bind(&retrieve_p_options_str, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.options_str", std::bind(&retrieve_p_options_str, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.is_encrypted", std::bind(&torrent::Peer::is_encrypted, std::placeholders::_1));
|
||||
CMD2_PEER("p.is_incoming", std::bind(&torrent::Peer::is_incoming, std::placeholders::_1));
|
||||
CMD2_PEER("p.is_obfuscated", std::bind(&torrent::Peer::is_obfuscated, std::placeholders::_1));
|
||||
CMD2_PEER("p.is_snubbed", std::bind(&torrent::Peer::is_snubbed, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.is_encrypted", std::bind(&torrent::Peer::is_encrypted, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.is_incoming", std::bind(&torrent::Peer::is_incoming, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.is_obfuscated", std::bind(&torrent::Peer::is_obfuscated, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.is_snubbed", std::bind(&torrent::Peer::is_snubbed, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.is_unwanted", std::bind(&torrent::PeerInfo::is_unwanted, std::bind(&torrent::Peer::peer_info, std::placeholders::_1)));
|
||||
CMD2_PEER("p.is_preferred", std::bind(&torrent::PeerInfo::is_preferred, std::bind(&torrent::Peer::peer_info, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.is_unwanted", std::bind(&torrent::PeerInfo::is_unwanted, std::bind(&torrent::Peer::peer_info, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.is_preferred", std::bind(&torrent::PeerInfo::is_preferred, std::bind(&torrent::Peer::peer_info, std::placeholders::_1)));
|
||||
|
||||
CMD2_PEER("p.address", std::bind(&retrieve_p_address, std::placeholders::_1));
|
||||
CMD2_PEER("p.port", std::bind(&retrieve_p_port, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.address", std::bind(&retrieve_p_address, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.port", std::bind(&retrieve_p_port, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.completed_percent", std::bind(&retrieve_p_completed_percent, std::placeholders::_1));
|
||||
CMD2_PEER_U("p.completed_percent", std::bind(&retrieve_p_completed_percent, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.up_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::up_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.up_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::up_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.down_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::down_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.down_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::down_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::peer_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::peer_rate, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.up_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::up_rate, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.up_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::up_rate, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.down_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::down_rate, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.down_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::down_rate, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.peer_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::peer_rate, std::placeholders::_1)));
|
||||
CMD2_PEER_U("p.peer_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::peer_rate, std::placeholders::_1)));
|
||||
|
||||
CMD2_PEER ("p.snubbed", std::bind(&torrent::Peer::is_snubbed, std::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V("p.snubbed.set", std::bind(&torrent::Peer::set_snubbed, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_PEER ("p.banned", std::bind(&torrent::Peer::is_banned, std::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V("p.banned.set", std::bind(&torrent::Peer::set_banned, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_PEER_U ("p.snubbed", std::bind(&torrent::Peer::is_snubbed, std::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V_U("p.snubbed.set", std::bind(&torrent::Peer::set_snubbed, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_PEER_U ("p.banned", std::bind(&torrent::Peer::is_banned, std::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V_U("p.banned.set", std::bind(&torrent::Peer::set_banned, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_PEER_V("p.disconnect", std::bind(&torrent::Peer::disconnect, std::placeholders::_1, 0));
|
||||
CMD2_PEER_V("p.disconnect_delayed", std::bind(&torrent::Peer::disconnect, std::placeholders::_1, torrent::ConnectionList::disconnect_delayed));
|
||||
CMD2_PEER_V_U("p.disconnect", std::bind(&torrent::Peer::disconnect, std::placeholders::_1, 0));
|
||||
CMD2_PEER_V_U("p.disconnect_delayed", std::bind(&torrent::Peer::disconnect, std::placeholders::_1, torrent::ConnectionList::disconnect_delayed));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user