Commit Graph

37 Commits

Author SHA1 Message Date
Xirvik d935e0ffe9 Address review feedback: explicit mark_safe whitelist and rpc trust flow 2026-03-23 15:11:07 +01:00
Xirvik 598914908f Add untrusted connection security infrastructure (v3)
Replace the v2 blacklist approach with a per-command flag system.
Commands must opt in to being available for untrusted connections
via flag_untrusted_safe (0x400), checked in call_command() which
catches all execution paths including nested commands.

Infrastructure changes:
- Add flag_untrusted_safe to CommandMap
- Add untrusted_error exception type for proper error codes
- Enforce trust check in both call_command() overloads
- Add catch blocks in xmlrpc_c, xmlrpc_tinyxml2, and jsonrpc handlers
- Port SCGI trust state management from v2 (thread_local, header parsing)
- Add _U macro variants in command_helpers.h for safe command registration
- Add CMD2_VAR_*_U and CMD2_VAR_*_U_GET variants for variables
2026-03-23 15:11:07 +01:00
Jari Sundell d35a8d68e6 Fixed uninitialized rpc slots when SCGI is not used. 2025-08-25 15:56:15 +09:00
Jari Sundell 2ab7460cbc Fix SCGI threading and added missing header. 2025-04-01 01:26:07 +09:00
kannibalox 9f48226663 Add JSON-RPC capability
Inline nlohmann/json for the JSON parsing itself, and handle requests
with the same SCGI interface as XML-RPC.

Based off the work in https://github.com/jesec/rtorrent
2025-01-20 12:31:04 +01:00
kannibalox 5abcf52e55 Remove unused flag_delete_key 2024-11-13 19:22:34 +09:00
kannibalox 34de2b4ac9 Convert CommandMap to use std::string instead of char*
This allows it to own its keys and clean them up automatically on
destruction.
2024-11-13 19:22:34 +09:00
rakshasa 4d313e6353 Updated copyright information.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1301 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-09 06:30:14 +00:00
rakshasa 49f61eeda3 * Added separate '-I' and '-K' switches, the former is for testing rtorrent code, the latter for webui's.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1178 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-05 23:49:06 +00:00
rakshasa 033e30af04 * Fixed more commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1177 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-05 03:36:14 +00:00
rakshasa 56e126d8a0 * Fixed more redirects to work properly with old webui's.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1175 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-03 10:47:36 +00:00
rakshasa d9f409b223 * Changed command_base stored in CommandMap from a pointer to an instance.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1169 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-30 12:16:45 +00:00
rakshasa 8b03988612 * Added 'rpc/fixed_key.h' header.
* Replaced Command with command_base.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1168 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-30 04:36:02 +00:00
rakshasa d17fa0c684 * Renamed 'check_hash' and added a redirect.
* Added proper torrent::Object stack type in rpc::Command.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1160 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-07 08:49:12 +00:00
rakshasa 90da65f8a1 * Cleanup of old command code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1156 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-04 04:44:45 +00:00
rakshasa 4e4540e60f * Removed old Command classes.
* Redirects can now be made efficiently using rpc::CommandMap::create_redirect or "methods.redirect=new_key,dest_key".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1155 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-28 18:09:09 +00:00
rakshasa 5166253190 * Added 'argument.?' commands that passing of arguments to commands
created with 'system.method.insert'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1077 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-09 12:56:10 +00:00
rakshasa ca9d0b1773 * Added string, value and bool types to 'system.method.insert' for
storing variables.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1076 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-07 16:01:18 +00:00
rakshasa 07b9616ef6 * Use user-modifiable commands instead of slots for the 'on_*' events.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1070 e378c898-3ddf-0310-93e7-cc216c733640
2008-10-01 14:19:51 +00:00
rakshasa d7c2960d1e * Added system.method.{insert,erase} commands that allows
user-specified commands. "system.method.insert=foo,print=Bar"


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1069 e378c898-3ddf-0310-93e7-cc216c733640
2008-09-27 06:28:50 +00:00
rakshasa 6385b995f3 * Cleaned up commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1068 e378c898-3ddf-0310-93e7-cc216c733640
2008-09-24 15:26:15 +00:00
rakshasa 7062935724 * Replaced View sort code with commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1044 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-18 09:11:59 +00:00
rakshasa 8cc7c8430d * Fixed minor bugs in the display of tracker groups. Patch by Josef
Drexler.

* Cleanup of the CommandMap class.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1041 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-13 14:28:17 +00:00
rakshasa 3f644aed8f * Properly handle NULL ptr in target_any commands.
* Enable PEX by default.

* Renamed Download::start2/stop2.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1006 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-10 16:34:37 +00:00
rakshasa 61098513c6 * Cycle the order in which downloads are handled during ticks to
ensure resource usage gets spread out over time.

* Changed element_file_list.cc to use te_command.

* File commands on file list iterators will be called on the File
pointed to.

* Fixed some sigc++ 2.1 compile errors.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@992 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-21 04:27:49 +00:00
rakshasa 1cc1374c7a * Made rpc::CommandSlot into a template class and removed
"command_*_slot.{cc,h}".

* Added 'if' command. 


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@971 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-02 15:07:37 +00:00
rakshasa ac2f5a8882 * Only request from the same tracker more than once if PEX is disabled.
* Added target_any.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@970 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-31 11:44:21 +00:00
rakshasa 73c41074ec * Fix TextElement* to use rpc::target_type.
* Moved most of src/ui/download.cc to use commands for TextElements.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@967 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-30 16:33:52 +00:00
rakshasa 32b74ffc48 * Proper fault handling for bad SCGI requests.
* Cleaned up duplicate code in 'xmlrpc.cc'.

* Cleaned up 'parse_commands.h'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@966 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-27 23:00:48 +00:00
rakshasa f117b9dd16 * Allow loading torrents from https and ftp uri's.
* Added framework for commands on peers, but due to deficiencies in
the libtorrent API it won't be enabled yet.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@955 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-16 20:08:32 +00:00
rakshasa ac92b56f37 * Added 'get_d_ratio', 'view_list', 'get_d_tracker_focus',
'get_d_tracker_size', etc.

* Added tracker commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@945 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-29 16:59:34 +00:00
rakshasa e15aee3f77 * Fix set_f_priority. Will require a call to update priorities.
* CommandMap::call_command(...) now uses a single function for all
calls using an integer id to figure out the object type.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@942 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-21 23:06:19 +00:00
rakshasa 535db16850 * Bumping copyright year to 2007.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@938 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-19 21:29:34 +00:00
rakshasa a8bd405040 * Added support for xmlrpc commands on torrent::File objects. The
xmlrpc command takes the download info-hash and the file index as the
first two parameters.

* Added several file commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@937 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-19 20:50:48 +00:00
rakshasa a492cadf00 * ^X now passes the selected download to the command.
* Added support for writing Objects to generic char* buffers.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@927 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-03 00:33:18 +00:00
rakshasa e9db89e6d6 * Put both global and download specific commands in a single
CommandMap.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@914 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-17 03:14:38 +00:00
rakshasa 297b4b5f1d * Renamed VariableMap to CommandMap.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@913 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-16 17:46:06 +00:00