Compare commits

..

1700 Commits

Author SHA1 Message Date
rakshasa 120fcb0273 Merge branch 'master' into feature/ipc-worker 2026-08-06 11:03:44 +02:00
rakshasa dd3ddf7c39 Tagged release 0.16.20. 2026-08-06 10:12:49 +02:00
rakshasa e56bffff4d Fixed socket category unit test. 2026-08-05 11:18:31 +02:00
xirvik d20c3234da Add system.sockets allocation budget commands.
They report the budget the socket manager enforces, so a client can show the limit.
2026-08-05 11:18:31 +02:00
Maks Verver dda5e4fa04 Fix deprecated command redirects (rtorrent -D) 2026-08-05 10:14:35 +02:00
rakshasa c36956813d Merge branch 'master' into feature/ipc-worker 2026-08-04 18:00:04 +02:00
Jari Sundell 9ab73352e1 Minor fixes to WaitpidQueue. 2026-08-05 00:59:33 +09:00
Jari Sundell f90a96d57a Added WaitpidQueue to handle background process reaping. 2026-08-04 19:03:26 +09:00
rakshasa 247ae7621a Tagged release 0.16.19. 2026-08-02 10:44:30 +02:00
xirvik 05831942a7 commands: don't register min_alloc/max_alloc for the generic socket category
SocketManager throws internal_error for category_generic, aborting rtorrent over RPC.
2026-07-30 12:42:24 +02:00
rakshasa 05563b4c9b Stuff. 2026-07-28 10:56:25 +02:00
rakshasa a544f8ad68 Merge branch 'master' into feature/ipc-worker 2026-07-28 10:33:57 +02:00
rakshasa ee18a1f3fc Added commit message linter. 2026-07-28 10:04:51 +02:00
rakshasa b35413ea71 Merge branch 'master' into feature/ipc-worker 2026-07-26 13:03:33 +02:00
Jari Sundell f52f20f1b6 Cleaned up system headers. 2026-07-26 19:53:18 +09:00
rakshasa f9f19fb041 Stuff. 2026-07-26 09:14:39 +02:00
xirvik 41eef969ea commands: fix group.<name>.ratio.disable calling a removed command
group_insert() builds the disable method as "schedule_remove=...", but that
command no longer exists: the current name is schedule.remove, and the only
old-style aliases registered are schedule2 and schedule_remove2 (and those only
when deprecated commands are enabled at registration time). Every
group.<name>.ratio.disable therefore faults with

  Command "schedule_remove" does not exist.

including the built-in group.seeding.ratio.disable, so a ratio group can be
enabled but never disabled. The enable half already uses the current name.
2026-07-25 10:18:49 +02:00
fffe 1def5e8b36 Add log.print and enum.log_group methods 2026-07-22 11:08:32 +02:00
simonc56 8355870586 Mark 'd.timestamp.started' as safe in command download initialization 2026-07-20 08:21:32 +02:00
Jari Sundell ba2bc7e64d Various release bug fixes. 2026-07-19 18:53:57 +09:00
rakshasa 0c11deac50 Tagged release 0.16.18. 2026-07-17 10:15:28 +02:00
Jari Sundell f6b3ad0efd Minor cleanup of pex and other commands. 2026-07-15 19:40:13 +09:00
Jari Sundell 5d350f0bcc Use new encryption modes. 2026-07-14 17:34:14 +09:00
Jari Sundell 86fa0d195f Changing listen/dht port changes the listening/dht ports. 2026-07-12 17:19:33 +09:00
Jari Sundell 2354c9cdb5 Moved ChunkManager out of public header directory. 2026-07-10 17:54:37 +09:00
Jari Sundell 1b25bc7f56 Moved all sync/diskspace related methods to MemoryManager. 2026-07-10 02:21:08 +09:00
Jari Sundell c6bde213b4 Added runtime::MemoryManager to split out unrelated features from ChunkManager. 2026-07-09 01:56:30 +09:00
Jari Sundell 959448acda Fixed command_base t_pod align static asserts. 2026-07-08 17:15:56 +09:00
Jari Sundell 3b6da6feac Reordered http queue slots to avoid race conditions. 2026-07-07 16:34:19 +09:00
Jari Sundell ea2d22cb87 Removed unused add/remove error-event code. 2026-07-07 03:05:20 +09:00
rakshasa fa351c017d Tagged release 0.16.17. 2026-07-06 14:06:52 +02:00
Pluto Yang 1e1bdd551a Add LoongArch CPU support 2026-07-06 13:38:08 +02:00
Jari Sundell a07f57a703 Fixed fd close order in ExecFile. 2026-07-06 18:06:51 +09:00
Jari Sundell 0494ce70c8 Add http done/failed slots before starting request. 2026-07-06 17:18:39 +09:00
Xeonacid cfad36bf12 Add RISC-V cacheline fallbacks
The Linux cacheline probe first tries <linux/cache.h>, but that header is not part of the installed uapi headers on Arch Linux. When the compile probe fails, configure falls back to a host_cpu mapping and currently aborts for riscv64 with:

  Unrecognized CPU architecture (riscv64) on Linux fallback path.

Handle riscv* in both cacheline fallback maps and use a 64-byte cacheline. That matches the Linux RISC-V kernel default L1_CACHE_SHIFT value of 6 and the value reported on a riscv64 machine through getconf LEVEL1_DCACHE_LINESIZE and sysfs cache coherency_line_size.
2026-07-05 15:40:50 +02:00
rakshasa 123c327a8f Tagged release 0.16.16. 2026-07-03 16:20:27 +02:00
fffe 9884c9dd9b Add support for posix_spawn_file_actions_addclosefrom_np by @fffe 2026-07-03 20:52:26 +09:00
Jari Sundell d99cd5eb73 Added max http request size and limited redirect protocols to http/https. 2026-07-03 19:34:36 +09:00
Jari Sundell 786f1234d2 Fix background task execution. 2026-07-03 17:53:00 +09:00
Jari Sundell 23921cc97c Added new ProxyManager and support for socks5 for peer connections. 2026-06-30 19:55:45 +09:00
Jari Sundell 6558f0ad42 Fixed shutdown handling of stalled http requests. 2026-06-29 16:18:56 +09:00
simonc56 9431dd5acc mark d.complete & d.timestamp.finished as safe in command download 2026-06-28 10:11:06 +02:00
trim21 8598873627 Replace rak::regex with fnmatch from POSIX <fnmatch.h>
rak::regex was a hand-rolled glob matcher supporting only '*'
wildcards. Replace it with the standard POSIX fnmatch() which supports
the same glob patterns plus '?' and '[...]' character classes.

- src/core/manager.cc: use fnmatch for directory entry filtering
- src/command_download.cc: use fnmatch for file path pattern matching
- Makefile.am: remove rak/regex.h from EXTRA_DIST
- rak/regex.h: deleted, no longer needed
2026-06-25 09:47:11 +02:00
rakshasa ce4cd27697 Tagged release 0.16.15. 2026-06-22 10:28:54 +02:00
Jari Sundell 59fe93515e Only enable SIGCHLD on main thread. 2026-06-21 23:05:16 +09:00
Jari Sundell 8249070ff1 Remove shutdown comments for directory watch
Remove commented code regarding directory watch closure during shutdown.
2026-06-19 10:29:43 +02:00
Xirvik Support 517454b413 control: close directory watch on quick shutdown (fix SIGABRT at exit)
Control::handle_shutdown() closes m_directory_events (the inotify directory
watch) only in the normal-shutdown branch (!m_shutdownQuick). On a quick
shutdown (SIGTERM -> receive_quick_shutdown) the m_shutdownQuick branch skips
it, so the watch stays registered in the poll. ~Control() then destroys the
still-open directory_events and Event::~Event()'s assert(m_poll_event == nullptr)
(added with the 0.16.13 poll/event rework) aborts:

    main -> Control::~Control() -> ~directory_events -> ~Event() -> abort

Close it in Control::cleanup() instead, which runs on every shutdown path after
the session is saved; close() is idempotent, so the normal path that already
closed it in handle_shutdown() is unaffected.

Reproducible: configure a directory.watch.added watch, then SIGTERM the client
-> SIGABRT (core in Event::~Event); SIGINT (normal shutdown) is clean. With this
change SIGTERM exits cleanly too.
2026-06-19 10:29:43 +02:00
Jari Sundell a79aaad9ab Clean up comments in InputEvent methods
Removed commented-out code regarding error handling for stdin and event processing.
2026-06-19 09:12:22 +02:00
Xirvik Support c6de871a77 input: survive controlling-terminal/pty hangup on stdin
Since the 0.16.13 callback/poll rework, an EPOLLERR on stdin (controlling
terminal or pty hangup) reaches Poll::process(), which aborts the whole
client with an internal_error because InputEvent never registered for error
events:

    Poll::process() received error event for event not in error: input-fd:0

Register stdin for error events (insert_error) and handle event_error() by
dropping stdin from the poll set with this_thread::poll()->remove_and_close().
rtorrent then keeps running without keyboard input instead of dying.

remove() guards on the fd state (is_open()), mirroring SCgiTask: event_error()
clears the fd after remove_and_close(), and the shutdown path (Control::cleanup)
still calls remove(); without the guard the second remove_and_close() throws
'event not found' via event_mask(). insert()/remove() take the thread poll
implicitly (this_thread::poll()) instead of a Poll* argument.
2026-06-19 09:12:22 +02:00
Jari Sundell acb02379b8 Use a cache for free diskspace when sync'ing all downloads. 2026-06-18 23:45:55 +09:00
trim21 bf74686c29 fix: replace reinterpret_cast UB in command_base with aligned placement new
Replace the union-based reinterpret_cast type erasure in command_base
with an alignas char buffer + typed copy/destroy helper pointers.

set_function<T>() placement-news the correct std::function<T> type
at the buffer address, and stores per-type copy/destroy helpers so
that the copy ctor, assignment, and destructor always operate on the
actual type rather than assuming base_function.

_reinterpret_cast<T&> access of t_pod remains zero-overhead and is
now well-defined because the object was constructed at that address
as T via placement new.

Fixes #1818
2026-06-18 11:05:58 +02:00
Jari Sundell dbe7997131 Use posix_spawn for execute commands. 2026-06-18 01:01:52 +09:00
Jari Sundell d595ebf7d8 Renamed scgi socket manager category to rpc. 2026-06-17 03:43:26 +09:00
Jari Sundell 08828045f5 Added min/max alloc for SocketManager categories. 2026-06-16 22:39:39 +09:00
Jari Sundell 662d67e861 Cleaned up if/branch commands and made branch types stricter. 2026-06-15 18:55:30 +09:00
Jari Sundell d08d7de20d Added "system.sockets.<category>.{size,max_size}" commands. 2026-06-15 18:38:54 +09:00
rakshasa 83bdc271a4 Tagged release 0.16.14. 2026-06-14 09:38:10 +02:00
Jari Sundell 29edda2f15 Removed address based throttling. 2026-06-13 22:53:42 +09:00
Jari Sundell fd69baa2c1 Removed encoding name/path attribute handling. 2026-06-13 18:37:19 +09:00
Jari Sundell 1603ba0573 Use std::chrono::seconds in TrackerState. 2026-06-12 19:50:17 +09:00
trim21 19305ab662 fix: define LUA_OK for Lua 5.1 and LuaJIT compatibility
LUA_OK was introduced in Lua 5.2. Define it as 0 for compatibility
with Lua 5.1 and LuaJIT (which is based on Lua 5.1).
2026-06-12 09:59:42 +02:00
trim21 5b2e202452 fix: scheduler front()->time() -> front()->time after SchedulerHandle change
SchedulerHandle::time is now a data member instead of a method, so
front()->time() must be front()->time (no parentheses).
2026-06-11 18:31:17 +02:00
trim21 c63db9cf97 refactor: use torrent::heuristics_enum instead of choke_queue::heuristics_enum
Update to use the new top-level torrent::heuristics_enum from
torrent/download/types.h, removing the dependency on choke_queue.h
for enum values.
2026-06-10 13:02:06 +02:00
trim21 72f2197add fix: define default_resume_flags sentinel, clearing open_enable_fallocate
Replace the raw ~uint32_t sentinel with a named constant
Download::default_resume_flags that masks out the open_enable_fallocate
bit. This prevents flag_fallocate from being set on all files when
open_throw() reads resume_flags() before explicit flags are configured.

The sentinel value (~uint32_t & ~open_enable_fallocate) retains the
full range as a 'not set' marker while being safe to pass through
Download::open() without unintended fallocate.
2026-06-09 10:50:40 +02:00
fffe e96f594afc Added missing maybe_unuseds attributes and fixed pkg-config check by @fffe 2026-06-09 17:22:11 +09:00
trim21 bc8d0da70f set d.message on hash check failure
Use Download::hash_error_message() to get a descriptive error string when
hash check fails due to I/O error, instead of relying on errno which could
be zero.

Also fix Manager::receive_hashing_changed() where set_hash_failed(true) was
called without setting d.message when catching local_error during hash
check (e.g. 'too many open files').
2026-06-05 15:58:11 +02:00
Jari Sundell 75377817b4 Deprecate commands and set DHT to auto by default. 2026-06-05 21:50:08 +09:00
Jari Sundell 595617c408 Override destructor in ElementLogComplete class. 2026-06-05 10:59:54 +02:00
Jindrich Makovicka 578fe03ad6 Unregister destroyed ElementLogComplete and WindowLog 2026-06-05 10:59:54 +02:00
Xirvik efe258a137 fix(rpc): preserve c_str() stability of stored XMLRPC method names
Commit 6488131 ("Fix RPC/SCGI security and crash bugs by @sirus20x6")
replaced std::vector<std::unique_ptr<const char>> storage with
std::vector<std::string> and returned back().c_str() to the xmlrpc-c
registry as the per-method server_info pointer.

This is unsafe for any method name short enough to be SSO-stored
(<= 15 chars on libstdc++): such a string keeps its buffer inside the
std::string object itself. When a later push_back reallocates the
vector and move-constructs the existing elements into a new buffer,
the previously returned c_str() pointers — captured by xmlrpc-c at
registration time — dangle into freed memory.

Because xmlrpc-c does not dereference server_info until a call
dispatches, the failure surfaces later as nondeterministic garbage
in fault strings, e.g.

  faultString: Command "thod." does not exist.    (load.start, log.xmlrpc, log.execute)
  faultString: Command "in_rate" does not exist.  (log.add_output)
  faultString: Command ""       does not exist.   (log.open_file)
  faultString: Command "+U"     does not exist.   (method.set_key)

Long-named methods (e.g. system.client_version at 21 chars) are
heap-allocated above the SSO threshold and escape the bug because
the heap buffer's address is preserved across the vector move.

Switch the storage to std::deque<std::string>: per [deque.modifiers]
push_back does not invalidate references to existing elements, so
the std::string objects do not move and the c_str() pointers handed
to xmlrpc-c remain valid for the program's lifetime. The body of
store_command_name is unchanged.

Fixes the use-after-free; preserves the std::string-based storage
the original commit aimed for.
2026-06-05 10:55:51 +02:00
Jari Sundell 44d39713d5 Clean out old cruft in autoconf scripts. 2026-06-05 00:46:47 +09:00
Xirvik Support 49625ab5e5 rpc: close SCGI task on EPIPE to stop event_write() busy-loop
When an SCGI client closes the connection before rtorrent finishes sending
the response, send() in SCgiTask::event_write() returns -1 with errno EPIPE.
EPIPE was grouped with EAGAIN/EINTR as a non-fatal retry-later condition, so
the task was not closed and its descriptor stayed registered for EPOLLOUT. A
broken socket is reported writable immediately, so epoll_wait() returns it on
every iteration and the SCGI thread spins at 100% CPU on one core
indefinitely. The dead connection fd is also leaked (stays ESTAB).

EPIPE is terminal here, not retryable: the peer is gone and the response can
never be delivered. Close the task on EPIPE, matching event_read(), which
already closes on any recv() error other than EAGAIN/EINTR.

Reproduction: open the SCGI socket, send a complete RPC request, then
shutdown(SHUT_RDWR)/close before reading the reply. Stock: the rtorrent-scgi
thread goes to 100% CPU and the connection leaks. With this change: CPU stays
at 0% and the descriptor is closed.
2026-06-04 10:41:19 +02:00
Jari Sundell cc15e9308a Fixed xmlrpc-c build errors and added better github workflow for unit-tests. 2026-06-04 17:16:47 +09:00
Jari Sundell a5a96236df Moved base64 transform and validation functions. 2026-06-04 06:37:01 +09:00
Jari Sundell f1cfe8ad72 Added hex to Object and string_utf8. 2026-06-04 04:22:16 +09:00
rakshasa d0fc48cf7b Tagged release 0.16.13. 2026-06-03 10:18:25 +02:00
trim21 5725eb3773 fix: move --without-ncurses logic to scripts/checks.m4 per review
- Add TORRENT_WITHOUT_NCURSES macro in scripts/checks.m4
- Clear CURSES_LIBS/CFLAGS in the macro instead of if/else in configure.ac
- Restore simple LIBS/CFLAGS lines in configure.ac
- Add missing set_escdelay stub
2026-06-01 20:33:39 +02:00
trim21 ca706c21c0 feat: add --without-ncurses option for daemon-only builds
Add a dummy curses stub header that provides all ncurses types, macros,
and no-op function stubs. When configured with --without-ncurses, the
build uses this stub instead of linking to the real ncurses library.

This allows rtorrent to be built for daemon-only usage (e.g. with
ruTorrent or Flood) without requiring ncurses to be installed.

Closes #1613
2026-06-01 20:33:39 +02:00
Jari Sundell 14edd68653 Removed SignalBitfield and replaced it with callbacks. 2026-06-01 22:40:22 +09:00
Jari Sundell 50a609ade9 Fixed cacheline size check. 2026-06-01 20:11:02 +09:00
Jari Sundell 2cf8f2351b Fixed github workflow. 2026-05-31 00:37:22 +09:00
Jari Sundell add305f90c Added support base64 support for non-UTF8 strings. 2026-05-30 00:25:16 +09:00
Jari Sundell 880510073a Updated LUA autoconf script. 2026-05-27 21:37:09 +09:00
rakshasa 0989b2218d Various cleanup and fixes to SocketManager categories. 2026-05-27 12:38:52 +02:00
Trim21 3d7e6cb077 Added per-category allocation limits to SocketManager by @trim21 2026-05-27 18:16:02 +09:00
Jari Sundell 64881317c6 Fix RPC/SCGI security and crash bugs by @sirus20x6 2026-05-26 17:27:10 +09:00
rakshasa a5ecd89a54 Removed unnessesary configure check from PR. 2026-05-25 18:21:31 +02:00
tonimelisma 84229a85be Add directory.watch.ready for safe torrent watch folders 2026-05-25 18:21:31 +02:00
Jari Sundell e03ab27cf0 Added intermediate requesting flag for trackers to prevent premature deletion. 2026-05-26 00:43:15 +09:00
Jari Sundell e41b066555 Converted callbacks to new interface. 2026-05-25 20:13:45 +09:00
Jari Sundell 8318133c79 Added a new callback mechanism and use it for trackers. 2026-05-23 23:43:45 +09:00
rakshasa 088bf40bdf Removed obsolete use of trackers.use_udp. 2026-05-18 16:35:20 +02:00
rakshasa 2f7a984992 Tagged release 0.16.12. 2026-05-18 15:25:56 +02:00
Jari Sundell 840a57915e Deprecate trackers.use_udp as it is no longer needed. 2026-05-17 00:59:03 +09:00
Jari Sundell 5e211c3a28 Allow for quick shutdown after sending the first UDP announce packet. 2026-05-15 20:58:17 +09:00
Jari Sundell 797a194abc Cleaned up torrent header files. 2026-05-14 19:24:38 +09:00
Trim21 501853cfbc Delete repro-scgi-content-type.py 2026-05-11 11:42:36 +02:00
trim21 b0ef95592b fix SCGI parse_headers: defer content-type body peek until body received
detect_content_type() peeked at m_buffer[m_body] to infer JSON vs XML
when no CONTENT_TYPE header was provided.  When the TCP header segment
arrives without any body bytes, m_body equals m_position and the peek
reads the null terminator padding byte — not the actual '{' or '[' —
causing JSON requests to be incorrectly classified as XML and fail.

Fix:
 - Remove the body peek from detect_content_type(); defer it to after
   the full body is confirmed present in event_read().
 - Add a m_content_type_set flag to distinguish header-provided type
   from auto-detected type.
2026-05-11 11:42:36 +02:00
Miroslav Marchev 26a7e9f545 Update to version 11.0.0 2026-05-10 09:25:02 +02:00
Miroslav Marchev 0ed10984b3 Update to version 11.0.0 2026-05-10 09:25:02 +02:00
Miroslav Marchev 5f09bb74de Updated to version 3.12.0 2026-05-10 09:25:02 +02:00
Jari Sundell c368b2de1e Fix SCGI event_read: return on partial header read instead of closing connection @trim21 2026-05-10 16:01:45 +09:00
Jari Sundell 71ac256cb5 Moved socket counter to runtime::SocketManager. 2026-05-10 02:11:35 +09:00
rakshasa b05b65bd65 Enable SCGI compression by default and set min size to 1000. 2026-05-09 12:24:24 +02:00
Jari Sundell f05b48e228 Moved NetworkConfig to runtime. 2026-05-05 16:17:24 +09:00
Xirvik 1279bd9f7a Move d.save_full_session to run after user-registered inserted_new handlers
Previously d.save_full_session was inside the 1_prepare handler for
event.download.inserted_new. Since 0.16.6 moved session saving to a
separate thread, save_full_download() snapshots the bencode synchronously
when called and queues the prebuilt streams for async write.

If user-registered handlers (e.g. seedingtime plugin's addtime setter
running d.set_custom=addtime) sort lexicographically AFTER 1_prepare, they
modify the bencode AFTER the snapshot has already been taken. The first
on-disk .rtorrent then lacks those custom fields. The next periodic
resume save catches up, but if rtorrent restarts before that, the data
is lost — manifesting as blank Finished/SeedingTime columns in ruTorrent.

Fix: split the inserted_new key into two — 1_prepare keeps view
visibility setup, ~_save_full runs d.save_full_session last (~ prefix
is ASCII 0x7E, sorts after all alphanumerics, matching the existing
~_delete_tied precedent on event.download.erased). The snapshot then
includes any custom fields written by user handlers.
2026-05-05 08:40:13 +02:00
Xirvik 981184574d Reset SCgiTask m_trusted on connection reuse
SCgiTask objects are pre-allocated in a pool (scgi.cc) and reused across
SCGI connections. SCgiTask::open() did not reset m_trusted, so when a
task that had handled an untrusted connection (m_trusted=false) was
reused for a new connection, m_trusted stayed false unless the new
connection explicitly sent UNTRUSTED_CONNECTION=1.

The header parser only set m_trusted=false on value 1 and was a no-op
on value 0 (the comment said "default is trusted, so do nothing") —
which is wrong for a reused task that is no longer in default state.

This caused intermittent rejection of trusted commands (e.g. ruTorrent
calling execute.capture for UID detection) with "Command X is not allowed
for untrusted connections", producing cascading plugin failures and
"ruTorrent cannot determine the UID of rTorrent user" in the web UI.

Fix:
- SCgiTask::open() resets m_trusted=true to default.
- parse_headers explicitly sets m_trusted=true on UNTRUSTED_CONNECTION=0,
  so the value sent on the wire is authoritative regardless of pool
  reuse semantics.

Verified on gb4 with rtorrent 0.16.11 + this fix: 30/30 trusted calls
succeed, 30/30 untrusted correctly blocked, 30/30 trusted-after-untrusted
batch all succeed (previously 70%+ would fail in the same scenario).
2026-05-04 10:06:48 +02:00
rakshasa 2700b3141f Tagged release 0.16.11. 2026-05-01 11:29:09 +02:00
fffe 4fec56a243 assert valid read_length 2026-04-24 12:22:34 +02:00
fffe dcf24711ef refactor 2026-04-24 12:22:34 +02:00
fffe 4e3ad1ab62 fix off-by-one in SCgiTask::event_read 2026-04-24 12:22:34 +02:00
rakshasa b5a606649a Tagged release 0.16.10. 2026-04-23 10:31:51 +02:00
Jari Sundell eb96876eb2 Moved Thread header to torrent/system directory. 2026-04-22 23:02:05 +09:00
Jari Sundell a964b0a350 Added special syntax to config files to enable log categories early. 2026-04-20 01:07:38 +09:00
Jari Sundell 1adcf230d2 Fix core subsystem logic and safety bugs @Sirus20x6 2026-04-18 01:54:46 +09:00
rakshasa 4235507292 Fixed path expand when doing a single '~' when expanding directory entries. 2026-04-17 12:13:27 +02:00
Jari Sundell b7a21b1e9d Added support for gzip accepted_encoding in scgi headers. 2026-04-12 22:19:49 +09:00
Jari Sundell bd53959b40 Fixed session save getting stuck. 2026-04-11 16:50:58 +09:00
Jari Sundell 5a4ba8bc32 Removed deprecated rak header files. 2026-04-10 22:04:02 +09:00
Jari Sundell e64ec358fa Removed deprecated rak headers. 2026-04-10 03:49:38 +09:00
rakshasa b78fd9aef5 Tagged release 0.16.9. 2026-04-06 15:19:27 +02:00
rakshasa 21e399d099 Remove unneeded MSG_NOSIGNAL. 2026-04-06 10:48:35 +02:00
Xirvik 08a907b547 Whitelist additional read-only getters for untrusted connections
ruTorrent queries these commands for its settings and status pages.
They are all read-only getters with no side effects, safe to expose
for untrusted SCGI connections.

Tested against ruTorrent with both httprpc and multirpc plugins on
servers with active torrents — all modes (list, settings, totals,
open connections) work with zero blocked commands.
2026-03-30 11:55:24 +02:00
zqmfb a0b8702895 Address additional review feedback 2026-03-27 17:48:13 +01:00
zqmfb ad3c31862e Further clarify systemd socket selection 2026-03-27 17:48:13 +01:00
zqmfb 2711e4c044 Use libtorrent's fd_set_nonblock helper 2026-03-27 17:48:13 +01:00
zqmfb 8d50aee96f Add network.scgi.open_systemd command unconditionally 2026-03-27 17:48:13 +01:00
zqmfb 71bb51c3fd Clarify systemd socket selection logic 2026-03-27 17:48:13 +01:00
zqmfb 63ea08bde6 Add support for SCGI systemd socket activation
Add a new command, `network.scgi.open_systemd`, that binds to a file
descriptor passed in via systemd socket activation.
2026-03-27 17:48:13 +01:00
Xirvik Support a82bdf22ac Review fix: remove method.use_deprecated.set from untrusted whitelist 2026-03-23 15:11:07 +01:00
Xirvik 9f6731b4e2 Address review: tighten untrusted safelist and remove set_trusted 2026-03-23 15:11:07 +01:00
Xirvik d935e0ffe9 Address review feedback: explicit mark_safe whitelist and rpc trust flow 2026-03-23 15:11:07 +01:00
Xirvik ba239bc8c5 Address code review: fix setter exposure and narrow catch blocks
1. network.rpc.use_xmlrpc and network.rpc.use_jsonrpc: change from
   CMD2_VAR_BOOL_U (getter+setter both safe) to CMD2_VAR_BOOL_U_GET
   (getter safe, setter trusted-only). Untrusted callers could
   previously disable RPC transports entirely.

2. Remove broad catch(std::exception&) and catch(...) from xmlrpc_c.cc
   that masked real defects and altered fault semantics.

3. Revert SCGI callback catch-all to re-throw instead of swallowing
   exceptions with a generic error response.
2026-03-23 15:11:07 +01:00
Xirvik ea16276773 Fix crash on untrusted XMLRPC connections
Root cause: network.rpc.use_xmlrpc and network.rpc.use_jsonrpc were not
marked as untrusted-safe, but RpcManager::process() calls them before
dispatching to the protocol handler. When an untrusted request arrived,
call_command() threw untrusted_error for these gatekeepers, which escaped
the callback_interrupt_pollling callback and crashed rtorrent.

Fix: Mark network.rpc.use_xmlrpc/jsonrpc as safe (CMD2_VAR_BOOL_U).

Also harden exception safety:
- SCGI callback catch-all now sends a generic error response instead of
  re-throwing, since the callback infrastructure may not support
  exception propagation.
- xmlrpc_c.cc now has catch(std::exception&) and catch(...) safety nets
  after the specific exception handlers.
2026-03-23 15:11:07 +01:00
Xirvik f767053297 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)
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
rakshasa 38fc815d52 Fix display/UI crash and correctness bugs (@sirus20x6) 2026-03-16 16:08:52 +01:00
Jari Sundell 674ae767aa Validate parsed int pair arguments for positivity 2026-03-16 13:56:43 +01:00
sirus20x6 0aaa470053 Fix resource leaks and minor issues
- Close pipe fds on fork failure in ExecFile::execute
- Add exception-safe fclose in cmd_file_append via try/catch
- Add overflow guards before K/M/G bit shifts in parse_whole_value
- Fix %u format for int* in sscanf (change to %d)
- Fix typo "atter"→"after" in error message
2026-03-16 13:56:43 +01:00
PiloUnk 6f27159627 Refactor full save scheduling with early return 2026-03-16 13:29:33 +01:00
PiloUnk de163293ab Avoid missing save scheduling after full save update 2026-03-16 13:29:33 +01:00
PiloUnk fb4e775689 Fix coalescing resume saves with pending full save 2026-03-16 13:29:33 +01:00
rakshasa 39f186e523 Tagged release 0.16.8. 2026-03-15 15:43:32 +01:00
Jari Sundell 70e6964823 Fixed various SCGI issues. 2026-03-10 23:25:28 +09:00
rakshasa 7ead88448b Removed rak/error_number.h from Makefile.am. 2026-03-04 11:39:25 +01:00
rakshasa 650f0299b5 Tagged release 0.16.7. 2026-03-04 10:47:30 +01:00
rakshasa 5dfb2ae938 Allow dht bootstrap nodes to be added when dht is off. 2026-03-02 09:45:09 +01:00
Jorge Israel Peña f05a2ae520 Re-send smkx on SIGWINCH to fix arrow keys after terminal reattach 2026-02-19 16:06:42 +01:00
Miroslav Marchev ecefdba734 dht_add_peer_node is empty, use dht_add_bootstrap_node instead
After a refactor dht_add_peer_node became empty function. Replace with dht_add_bootstrap_node to make adding bootstrap nodes work.
2026-02-14 14:32:48 +01:00
Jari Sundell 87666199b3 Added SocketManager to handle reuse of uninterested fd's by the kernel. 2026-01-29 04:00:31 +09:00
Jari Sundell 9489793dcb Created torrent/runtime include directory. 2026-01-27 08:21:05 +09:00
Jari Sundell 2fa7568165 Remove obsolete SocketFd class. 2026-01-26 19:13:03 +09:00
fffe f4b718f685 add separate commands for unbuffered logs 2026-01-16 16:10:02 +01:00
Jari Sundell b233e24465 Deprecated rak::path_expand. 2026-01-08 23:27:53 +09:00
Jari Sundell 289ab046bf Expand '~/' to $HOME in session path. 2026-01-06 20:44:40 +09:00
Jari Sundell a8b6a47054 Removed deprecated rak errno and file headers. 2026-01-04 03:22:02 +09:00
Zoltan Celedes 110591d5c1 Fix key/value pairs in Lua
Previously, the keys and values were swapped in d.custom.items()
2026-01-03 12:20:08 +01:00
rakshasa ae14baa357 Tagged release 0.16.6. 2026-01-02 15:22:29 +01:00
rakshasa 0b0c824b4b Changed magnet metadata handling and added 'magnet.path.set'. 2025-12-31 21:57:52 +01:00
Jari Sundell def6551488 Properly propagate errors from download session save. 2025-12-30 22:00:34 +09:00
Jari Sundell 787738e36a Make sure pending builds of session resume get processed. 2025-12-29 09:55:32 +09:00
Jari Sundell 40c2d90c45 Fixed dereferencing of potentially nullptr in SessionManager. 2025-12-25 23:05:08 +09:00
Jari Sundell 4a37fbde0b Session saving of resume data is added to a pre-queue. 2025-12-23 03:04:47 +09:00
Jari Sundell 4bdeb58eb6 Run multiple session save requests in parallel. 2025-12-22 06:26:35 +09:00
Jari Sundell 5dbb0020dc Replace ThreadWorker with scgi::ThreadScgi. 2025-12-18 07:43:43 +09:00
Jari Sundell 8f644e65dd Use separate thread for saving session data. 2025-12-18 06:42:44 +09:00
Jari Sundell 16ff32b88c Added missing Event::type_name() functions. 2025-12-13 19:06:02 +09:00
Jari Sundell 8806c06f9f Added timestamp helper commands. 2025-12-10 22:29:42 +09:00
rakshasa 60cfcd37c4 Release 0.16.5. 2025-12-02 17:51:26 +01:00
rakshasa a526ba58e9 Release 0.16.4. 2025-11-25 10:48:11 +01:00
rakshasa efd9507149 Release 0.16.3. 2025-11-21 14:39:27 +01:00
Jari Sundell 3d91dfdb33 Valgrind suppressions file for macos. 2025-11-20 15:57:30 +09:00
Jari Sundell 30cec98799 Moved Poll to net namespace. 2025-11-20 03:05:16 +09:00
rakshasa b825906034 Store copies of command names added to xmlrpc-c. 2025-11-17 20:30:13 +01:00
rakshasa b05ecb5c5a Push back views explicitly takes a string. 2025-11-17 09:36:32 +01:00
Jari Sundell 900be334dc Cleaned up xmlrpc-c string sanitization. 2025-11-17 02:48:32 +09:00
rakshasa 3a1da2fe34 Check if AF_INET6 is supported, or block IPv6 traffic. 2025-11-15 09:17:56 +01:00
Jari Sundell 70750a2bd3 Cleanup of DHT controller. 2025-11-13 00:01:22 +09:00
Jari Sundell 1d2c424a70 Remove throttle from DHT. 2025-11-08 17:51:00 +09:00
rakshasa 8550facf43 Tagged release 0.16.2. 2025-11-04 15:20:20 +01:00
rakshasa 184ead294a Export 'group2.*' commands. 2025-11-01 14:35:32 +01:00
Jari Sundell 84bfc491ba Added dual listening ports when both IPv4 and IPv6 are bound. 2025-11-01 07:24:31 +09:00
Khem Raj a2e0eca6e3 scripts/common.m4: Insert spaces in shell lists
$1=$(echo "$result" | tr -d '\n')

removes all newlines without inserting spaces
That usually isn’t what we want for shell lists.
It should typically be space-separated output.

Fixes a bug seen with yocto where compiler is not a single word
but a string e.g.

ccache aarch64-yoe-linux-musl-clang++  -mcpu=cortex-a72+crc+nocrypto   --dyld-prefix=/usr -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/libtorrent/0.16.1/recipe-sysroot

It changes it to

ccacheaarch64-yoe-linux-musl-clang++-mcpu=cortex-a72+crc+nocrypto--dyld-prefix=/usr-fstack-protector-strong-O2-D_FORTIFY_SOURCE=2-Wformat-Wformat-security-Werror=format-security--sysroot=/mnt/b/yoe/master/build/tmp/work/cortexa72-yoe-linux-musl/libtorrent/0.16.1/recipe-sysroot

When doing c++17 checks on compiler, resulting in failure

Upstream-Status: Submitted [https://github.com/rakshasa/libtorrent/pull/583]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-10-25 11:30:56 +02:00
rakshasa 92eecdfd52 Updated log group documentation. 2025-10-24 15:38:01 +02:00
Jari Sundell 14219666c5 Fix syntax for appending to log files 2025-10-24 14:08:23 +02:00
Aden a79a844dac Fix typo in 'receiving' 2025-10-24 14:08:23 +02:00
Aden 59b6a013ce Document the log.append_file configuration key
This flag is extremely useful but I couldn't find any documentation
referencing it. I only found it once I started having a poke through the
source code, so hopefully this will save others a little bit of time :)
2025-10-24 14:08:23 +02:00
rakshasa b38f80e597 Release 0.16.1. 2025-10-16 10:54:05 +02:00
Auska 2d2a756a3c fix: replace VLA
Avoids -Wvla-cxx-extension warning by using standard C++ container.
VLA is not part of standard C++ and causes portability issues.
2025-10-14 11:16:35 +02:00
Jari Sundell 891a6ba69d Added local address commands for inet/inet6. 2025-10-13 19:09:20 +09:00
Jari Sundell 2be730e4b3 Reuse HTTP connections and added totale/cached connection limits. 2025-10-09 21:15:24 +09:00
Jari Sundell bf53700f97 Added 'network.bind_address.ipv{4,6}.set' commands. 2025-10-04 20:24:08 +09:00
Jari Sundell 946dc54f9b Fix libtorrent links in README.md
Updated links to point to the GitHub repository for libtorrent.
2025-10-02 16:31:53 +09:00
Jari Sundell ea2347734b Added network.block.outgoing. 2025-09-23 17:56:51 +09:00
Jari Sundell 5206e6cb88 Moved various socket options to NetworkConfig. 2025-09-22 06:01:18 +09:00
Jari Sundell 48f82c17c2 Remove deprecated no-target flags for commands. 2025-09-20 17:27:26 +09:00
rakshasa 675625255d Check if target is null in xmlrpc_to_object(). 2025-09-20 09:22:56 +02:00
Jari Sundell 658e9f7578 Use simplified fd_accept(). 2025-09-18 17:40:56 +09:00
Jari Sundell e7a80c7b18 Remove deprecated rak::socket_address. 2025-09-17 21:44:54 +09:00
Jari Sundell 677f8f45c8 Improved listen/dht port handling and added 'dht.override_port.set' command. 2025-09-13 17:51:04 +09:00
Jari Sundell ba1ba3096a Added NetworkConfig. 2025-09-12 06:09:24 +09:00
Jari Sundell 65906a033a Preparing 0.16.0 release. 2025-09-05 18:32:24 +09:00
rakshasa dd5e0df05c Fixed HttpGet close call. 2025-09-04 13:11:56 +02:00
Bryant Eadon 00ef7d4be2 cleanup of personal information
Given the change to the README I thought it might be a good idea to also update the copyright notices which had an address too.
2025-09-02 20:10:38 +02:00
Jari Sundell e64f9fe324 Include torrent/common.h header. 2025-09-01 20:46:18 +09:00
Jari Sundell 9d3f6645be Fix formatting and capitalization in README.md 2025-09-01 16:45:24 +09:00
Jari Sundell 285827e611 Revise README structure and donation information
Updated sections in README for clarity and formatting.
2025-09-01 09:42:18 +02:00
Bryant Eadon 7fa1166baa README combined
Combined README files to reduce clutter.  However, the build instructions are incomplete ... I've started by modifying these so a build will complete using the instructions once I get a closer look at libtorrent ... additions welcome.
2025-09-01 09:42:18 +02:00
Bryant Eadon 43ba43252e Delete uused file
minor cleanup.
2025-09-01 09:42:18 +02:00
Bryant Eadon 207375c0cc Update README.md
proposing a new message for the release download.  to draw attention to the github repo, instead of the archive.
2025-08-31 12:47:12 +02:00
PRESFIL 4a5bc86643 doc(lua): More examples for insert_lua_method 2025-08-26 20:11:17 +02:00
PRESFIL 1039497a1a feat(lua): Extend insert_lua_method's func_name's arguments
Allows short form with number of arguments and long flexible form with table:

```lua
rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', { '$argument.0=' })
rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', { 0 })
rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', { [1] = 0 })
rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', 1)
rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', 0)
```

Also, there are way to pass no arguments at all:

```lua
rtorrent.insert_lua_method('d.watch_handler', 'watch_handler')
```

Type checking added.
2025-08-26 20:11:17 +02:00
PRESFIL 36a39e91c8 doc(lua): insert_lua_method: Document, that target always passed 2025-08-26 20:11:17 +02:00
Jari Sundell d35a8d68e6 Fixed uninitialized rpc slots when SCGI is not used. 2025-08-25 15:56:15 +09:00
Jari Sundell bb1cdfc0e7 Fixed DHT bind address and converted to using sockaddr. 2025-08-23 02:54:54 +09:00
PRESFIL b0c68aa398 doc(lua): Example: Remove <const> for Lua 5.3 compatibility 2025-08-07 11:03:58 +02:00
PRESFIL 1492d39a3a feat(lua): Make LUA_DATADIR option 2025-08-07 11:03:58 +02:00
PRESFIL 8dcf2bc609 chore(lua): Use PACKAGE_DATADIR and AM_CPPFLAGS 2025-08-07 11:03:58 +02:00
PRESFIL 7022722c64 chore(lua): Make LUA_DATADIR instead of PACKAGE_DATADIR 2025-08-07 11:03:58 +02:00
PRESFIL 2829a73d8b chore(lua): Make AC_DEFINE_UNQUOTED for PACKAGE_DATADIR 2025-08-07 11:03:58 +02:00
PRESFIL 43c36db5fc chore(lua): Add empty newlines for code readability 2025-08-07 11:03:58 +02:00
PRESFIL 9ed8fe8fd8 doc(lua): Add example Lua configuration
Additional step to test in development (non-packaged) mode:

- In packaged mode, rtorrent knows where to search rtorrent.lua, but in
  project mode, rtorrent.lua located in a non-standard location.
  Therefore run rtorrent with following environment variabler set:

  LUA_PATH=<full path to rtorrent project dir>/lua/?.lua
2025-08-07 11:03:58 +02:00
PRESFIL 95cc070ecc feat(lua): Add insert_lua_method for lua-callbacks
Updated @kannibalox's method to pass lua-functions as rtorrent's methods.
2025-08-07 11:03:58 +02:00
PRESFIL d43d08404a feat(lua): Some aliases for Target-commands 2025-08-07 11:03:58 +02:00
PRESFIL c92becbb7c feat(lua): Replace Autocall with Target-object, Autocall_config -> Autocall
Deep-copy `__namestack` decouples all instances of Autocall, previously it
worked as singleton. This allows to store call-chains as variables, aliases.

Target-object allows to avoid duplication of the target-parameter as required
with Autocall by storing them as variables.

Autocall_config renamed to Autocall for brevity.
2025-08-07 11:03:58 +02:00
PRESFIL 20887b1ccb fix(lua): print= shadowed by native Lua print()
Trying `rc.print()` causes redirection to native global Lua `print()`, which
prints to stdout. I don't see any proc of shor-circuiting `autocall_config`
with global environment `_G`.
2025-08-07 11:03:58 +02:00
PRESFIL 3bd111e498 feat(lua): Add autocall_config assignment semantic 2025-08-07 11:03:58 +02:00
PRESFIL f8ec1ca95e fix(lua): Make rtorrent.lua accessible at start 2025-08-07 11:03:58 +02:00
PRESFIL d9976af767 chore(rpc/parse.cc): Fix typo 2025-08-07 11:03:58 +02:00
PRESFIL c649e49a42 fix(lua): Treat VALUE always as integer
rtorrent doesn't have floating point data type
2025-08-07 11:03:58 +02:00
PRESFIL 9b0d74bd68 fix(lua): Execution of commands with empty target 2025-08-07 11:03:58 +02:00
PRESFIL 09dd1ce9c8 fix(lua): Handling of LUA_TNIL 2025-08-07 11:03:58 +02:00
PRESFIL eb45508ab9 chore(lua): Remove unused lua_rtorrent_call() local function 2025-08-07 11:03:58 +02:00
PRESFIL a1ff6f5710 fix(lua): require(rtorrent) cause infinite loop
- missing `pos = end + 1` pos caused infinite loop

- there was no processing of the last element after the last ';', i.e. it was
  assumed that `lua_path` always has ';' in the last character
2025-08-07 11:03:58 +02:00
rakshasa 756e3bd5ae Invert color of focus ui element. 2025-08-05 08:56:22 +02:00
rakshasa ce97bf583d Fixed formating. 2025-08-04 09:52:27 +02:00
rakshasa dd8281204f Update common.m4. 2025-08-04 09:52:27 +02:00
rakshasa 420f03b40b Fixed input key bindings. 2025-08-04 09:52:27 +02:00
mmmsalmon 9ac43c2b40 remove comment 2025-08-04 09:52:27 +02:00
mmmsalmon 25448320aa add vi/emacs keybind for stopping/removing torrent from download list 2025-08-04 09:52:27 +02:00
rakshasa 788442de6a Added test for xmlrpc string reflection. 2025-08-02 15:02:25 +02:00
rakshasa 4492715737 Strict checking of d.views push_back arguments. 2025-08-02 15:02:25 +02:00
Jari Sundell f1a4c13c41 Added network.block.ipv4in6.set command. 2025-07-05 22:31:52 +09:00
Rosen Penev e11ac9abe3 remove downloa_slot_map.h
Unused.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-30 10:14:07 +02:00
Rosen Penev 34aba86d67 remove std::function inheritance
This does nothing but bloat code size.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-30 10:00:23 +02:00
Rosen Penev 5175414333 add chrono header
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-22 17:26:22 +02:00
Rosen Penev 2b15c4a1fa command_ui: use templates instead of function
Less overhead.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-21 11:48:21 +02:00
Rosen Penev 84c0d516ef replace for_each with range loops
No advantage over the latter, which is simpler.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-21 11:23:11 +02:00
Rosen Penev 8b663dd169 add a void cast to get rid of warning
Just copied the file from libtorrent.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-20 13:07:51 +02:00
Rosen Penev c48b7f5b93 replace VERSION with PACKAGE_VERSION
They're both the same. The latter is more descriptive.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-20 13:07:51 +02:00
rakshasa 4c06e7a923 Changed the order in which slots are added in HttpQueue. 2025-06-19 22:50:42 +02:00
Rosen Penev e3918f5d84 remove some get() calls
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-19 10:07:52 +02:00
Rosen Penev 0948b5f86a clang-tidy: convert loops to range based
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-19 09:57:21 +02:00
Phil Rosenthal bb8d677f6e Fix file descriptor leak in session file saving
When system.files.session.fdatasync is set to "no", file descriptors
  were not being closed after writing session files, causing a severe
  resource leak. Each save operation would leak one file descriptor.

  With hundreds of torrents, this leads to tens of thousands of leaked
  file descriptors within hours, mostly pointing to deleted session files.
  This can exhaust the system's file descriptor limit and cause rtorrent
  to fail when opening new files.

  The fix moves the close() call outside the fdatasync conditional block,
  ensuring file descriptors are always properly closed regardless of the
  fdatasync setting.
2025-06-18 19:00:56 +02:00
Rosen Penev dc6208ccc9 add missing header for va_list
Fixes compilation on NetBSD.
2025-06-18 18:20:22 +02:00
Rosen Penev 18d19e3dee initialize in vector directly
No need for std::copy.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-18 16:15:47 +02:00
Rosen Penev f0517e2748 replace various find_if calls
C++11 has shorter equivalents.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-18 14:39:42 +02:00
Rosen Penev 47089bce70 remove some transform calls
for range loop is more readable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-17 17:13:05 +02:00
Jari Sundell 64cb3d11a0 Use shared_ptr for CurlGet stream and improved thread-safety. 2025-06-17 23:15:40 +09:00
Rosen Penev 12347843a9 add file.h header
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-11 20:32:35 +02:00
Jari Sundell 41589f06c2 Converted curl/http to be thread-safe. 2025-06-12 00:04:40 +09:00
Fredrik Lindell a51f367671 Add emacs and vi keymap config logic
* Add emacs and vi keymap config logic
2025-06-05 16:29:12 +02:00
Rosen Penev ac4afeb4bc remove variable fdset check
Doesn't seem to be used.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-05 14:33:28 +02:00
Rosen Penev 8d562d53fc remove disabling ipv6
Doesn't look like it does anything.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-05 14:33:28 +02:00
Rosen Penev 1a79eec876 remove LT_SMP_CACHE_BYTES
This is used by the library, not here.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-05 14:33:28 +02:00
Rosen Penev c803970628 remove posix_memalign check
This was used by the library, not here.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-05 14:33:28 +02:00
Rosen Penev 5f2f046165 remove HAVE_CONFIG_H define
config.h is always included. This is not a library.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-05 14:33:28 +02:00
Rosen Penev ad862f4b44 get rid of fs_stat.h and configure checks
These are used in libtorrent, not here.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-05 14:33:28 +02:00
Jari Sundell 6c25e64c26 Moved curl to libtorrent. 2025-06-05 20:29:43 +09:00
rakshasa 231606afc1 Fix ExecFile waitpid error handling. 2025-06-01 18:41:22 +02:00
rakshasa a9196b43d4 Added missing header to Makefile.am. 2025-06-01 15:40:22 +02:00
rakshasa 8203949259 Removed deprecated headers from Makefile.am. 2025-06-01 15:27:42 +02:00
rakshasa 537c692f47 Tagged release 0.15.4. 2025-06-01 14:44:29 +02:00
Rosen Penev 95b1a19ef1 use _T sizes for curl
The non _T are deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-01 11:21:36 +02:00
Rosen Penev a4ab0112dc convert color_vars to std::array
Fixes:

warning: ‘display::color_vars’ defined but not used

Could also add const to it.

Do the same with color_names.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-01 08:31:16 +02:00
Rosen Penev 897a6face2 clang-tidy: use default member init
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-01 08:16:02 +02:00
Rosen Penev 3ab38583b8 remove __UNUSED
No need since we have C++17.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-01 08:07:37 +02:00
Rosen Penev 1003013f10 remove allocators.h
Unused.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-06-01 08:07:37 +02:00
rakshasa 7bbd9a02a0 Proper handling of DownloadList::clear(). 2025-05-31 23:16:23 +02:00
Jari Sundell f0809ec29d Various pool_event_* and thread API cleanups. 2025-06-01 01:22:14 +09:00
Jari Sundell e8c1f3ed2c Update to use new this_thread::Poll(). 2025-05-31 22:22:31 +09:00
Jari Sundell 3618b9dc4f Added system.files.advise_random.hashing.set command. 2025-05-31 19:19:08 +09:00
rakshasa df8cb53ed2 Properly clear out download list before calling torrent::cleanup(). 2025-05-30 14:31:52 +02:00
rakshasa 2d565d1c80 Do thread cleanup within the same thread context. 2025-05-30 14:31:52 +02:00
Jari Sundell de6c48ca3f Moved TrackerList and TrackerController out of the public API. 2025-05-28 17:11:29 +09:00
rakshasa 5fb61b2857 Removed old poll creation calls. 2025-05-27 12:23:39 +02:00
rakshasa 46e94259e8 Make sure threads are rejoined. 2025-05-26 15:18:59 +02:00
Jari Sundell 9ff373fe58 Related refactoring to updated of ThrottleList to use new Scheduler. 2025-05-12 17:38:07 +09:00
Fredrik Lindell 6d888c008d Align compact display download header labels
* Align compact display download header labels
2025-05-11 09:45:47 +02:00
rakshasa 9fe4d188e9 Cleaned up WindowHttpQueue. 2025-05-08 08:32:45 +02:00
Jari Sundell 9d5b769d78 Removed/replaced deprecated commands (execute/schedule/schedule_remove) and removed global lock in ExecFile. 2025-05-05 16:55:38 +09:00
rakshasa 55615abe9e Use poll interrupting callbacks for SCGI requests. 2025-05-04 11:57:04 +02:00
rakshasa 303edab9ec Detect content type when there's multiple elements. 2025-05-04 11:28:18 +02:00
rakshasa 877c00d54e Fixed missing return statement. 2025-05-03 18:09:28 +02:00
Jari Sundell 4c63cee7a2 Cleaned up Poll code and included missing rtorrent.lua in installer. 2025-05-03 21:07:16 +09:00
Jorge Israel Peña 58a74cee48 Wrap fault struct in value 2025-05-02 12:13:49 +02:00
Jari Sundell 85e74b5542 Removed priority_queue and rak/timer. 2025-05-02 18:03:51 +09:00
rakshasa 6f8c1246dc Tagged release 0.15.3. 2025-05-01 14:34:45 +02:00
Jari Sundell 97415c656b Various scheduler and therad cleanups. 2025-05-01 16:38:49 +09:00
rakshasa 3d9c083032 Fix scheduler access. 2025-04-21 11:09:26 +02:00
Jari Sundell dd221ac66a Replaced Thread::next_timeout_usec(). 2025-04-16 02:39:40 +09:00
Rosen Penev 25f729fab5 use priotity_enum
The _t typedef is only useful with C, not C++.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2025-04-15 10:07:29 +02:00
rakshasa 316b0b51d5 Use new thread event loop method. 2025-04-14 11:15:07 +02:00
rakshasa a8622e5c80 Cleaned up thread-related code. 2025-04-12 23:03:08 +02:00
Abzie d1dd5ac080 Add RPC options to rtorrent.rc-example documentation 2025-04-11 16:16:44 +02:00
Abzie 9f2b81534a Add RPC options to rtorrent.rc documentation 2025-04-11 16:16:44 +02:00
Jari Sundell 2ab7460cbc Fix SCGI threading and added missing header. 2025-04-01 01:26:07 +09:00
rakshasa 2a998df4f1 Fixed LUA compilaition issue. 2025-03-31 06:19:02 +02:00
rakshasa d5b28c30a9 Added default switch cases to RpcManager. 2025-03-30 15:38:07 +02:00
rakshasa a5a1e2fde5 Updated common.m4. 2025-03-30 15:38:07 +02:00
rakshasa 34bc18940a Added missing color_map.h to Makefile.am. 2025-03-28 19:53:52 +01:00
rakshasa cde78f2353 Removed rak/functional.h from Makefile.am. 2025-03-28 19:14:57 +01:00
rakshasa cc59125116 Updated to release 0.15.2. 2025-03-28 19:14:57 +01:00
rakshasa 8ac31afd06 Fixed tinyxml2 compile error. 2025-03-28 16:07:55 +01:00
rakshasa 8d991b4ce5 Added 'system.files.session.fdatasync' config option. 2025-03-28 15:32:57 +01:00
Jari Sundell 3a227c190f Added system.files.advise_random.set command. 2025-03-28 19:21:25 +09:00
Jari Sundell 9a2ce2b231 Changes to support UDNS. 2025-03-27 21:36:10 +09:00
Jari Sundell f33fc331ce Thread-safe improvements to dht/tracker code and reorganized thread objects. 2025-03-13 22:15:12 +09:00
rakshasa 47af28aecd Cleaned up ui/root. 2025-03-11 14:13:05 +01:00
chros c6ebdf876a Fix possible crash with save_input_history (See #26) 2025-03-11 14:13:05 +01:00
rakshasa 5797ed9e7a Added new tracker list commands. 2025-03-11 13:45:18 +01:00
nick black 9465c94b31 Don't recommend obsolete option 'safe_sync'. 2025-03-11 13:24:17 +01:00
Jari Sundell 0adfc17335 Compatibility fixes with thread-safe list tracker changes. 2025-03-11 20:38:04 +09:00
rakshasa 37a5b7bccb Moved torrent::Tracker to torrent::tracker::Tracker. 2025-02-27 19:24:35 +01:00
rakshasa 80ef2e076d Fix trcker command. 2025-02-25 17:25:54 +01:00
rakshasa 4ac7313ff1 Pass tracker key at download creation. 2025-02-23 13:25:48 +01:00
rakshasa 6139217033 Compatibility with new tracker enum. 2025-02-12 14:38:08 +01:00
rakshasa 89b35af7a6 Fixed threaded tracker feature compatibility. 2025-02-11 09:01:52 +01:00
Auska 851ac469c3 Fix xmlrpc namespace 2025-02-03 17:37:01 +01:00
Rakshasa 1811248691 Add checks for liblua-*.so.0 for alpine compatibility. 2025-02-03 16:21:30 +00:00
rakshasa bacf60af89 Call atomic tracker state. 2025-02-02 21:03:26 +01:00
Jari Sundell 1f01b7e94d Fix various macos issues. 2025-01-28 00:18:41 +09:00
rakshasa d514e525ca Minor fixes. 2025-01-20 14:49:18 +01:00
pyroscope b2b723f248 close_low_diskspace.normal: use proper namespace (std) 2025-01-20 14:49:18 +01:00
pyroscope e3ab913f9a new method close_low_diskspace.normal
Skip downloads with prio=3 (high) when checking for disk space
2025-01-20 14:49:18 +01:00
Peter Woodman 787e23a25d clang-tidy: ignore third-party code nlohmann/json.h 2025-01-20 12:31:04 +01: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
stickz 78915746ee Bump c++ standard to 17
This pull request bumps the rTorrent c++ standard from 17. This resolves various undefined behavior which could occur.
2025-01-19 14:59:02 +01:00
stickz e7fc891f11 cleanup: Changes for c++17
This cleanup adjusts the rTorrent code to comply with c++17 standard. It also simplifies various parts of the code.
2025-01-18 20:15:20 +01:00
Jari Sundell 2e0a417367 Add optional Lua scripting capabilties - kannibalox@gmail.com 2025-01-19 04:02:06 +09:00
Jari Sundell b5a6ee33a1 Merge pull request #1375 from rakshasa/fix/github-workflows
Added separate workflow for clang-tidy static analysis.
2025-01-15 08:45:06 +01:00
rakshasa 3378355b64 Added separate workflow for clang-tidy static analysis. 2025-01-15 07:38:30 +00:00
Jari Sundell 6f5d06907b Merge pull request #1374 from stickz/remove-rak-functional
cleanup: Remove rak/functional.h
2025-01-13 10:06:07 +01:00
stickz 712e7e5db0 cleanup: Remove rak/functional.h
This commit replaces the `rak/functional.h` features with lambdas and std functions.

There was one instance with `std::sort` where the comparison operator was always evaluating to false and it wasn't sorting anything. This is removed in favour of the default comparison operator.

`std::sort(transferChunks.begin(), transferChunks.end());`
2025-01-12 14:30:01 -05:00
Jari Sundell 2b73c92a3e Merge pull request #1372 from stickz/remove-rak-mem-fun
cleanup: Remove rak mem_fun
2025-01-12 18:43:15 +01:00
stickz c5563d65c5 cleanup: Remove rak mem_fun
This commit removes rak:mem_fun and replaces it with std::function and lambdas.
2025-01-12 10:18:50 -05:00
Jari Sundell d412caea66 Merge pull request #1370 from stickz/remove-rak-call-delete
cleanup: Replace rak::call_delete with lambdas
2025-01-12 11:40:10 +01:00
stickz 9c92bfc7e2 cleanup: Remove rak::call_delete 2025-01-11 21:22:40 -05:00
Jari Sundell 4a074adc7b Merge pull request #1369 from rakshasa/kannibalox-feature/color
Kannibalox feature/color
2025-01-09 17:12:23 +01:00
rakshasa 3bf494dbc6 Merge branch 'master' into kannibalox-feature/color 2025-01-09 15:55:11 +00:00
rakshasa b193fedc65 Moved inlined functions out of class declaration. 2025-01-09 15:51:04 +00:00
kannibalox 6c5a6a3bb3 Manually include config.h for clang-tidy
Specifically this fixes errors related to undefined macros in headers, since those aren't recorded
in compile_commands.json
2025-01-09 15:28:20 +00:00
kannibalox 7534b02815 Add page up/down and home/end bindings to download list 2025-01-09 15:28:16 +00:00
kannibalox 6d8c214d09 Manually include config.h for clang-tidy
Specifically this fixes errors related to undefined macros in headers, since those aren't recorded
in compile_commands.json
2025-01-08 19:49:59 +01:00
rakshasa 525b038dbb Inline test data instead of using separate text file. 2025-01-08 17:58:09 +00:00
kannibalox 06741a7578 Update XMLRPC unit tests to include <data> for arrays 2025-01-08 17:58:09 +00:00
rakshasa 4cc79590be Release 0.15.1. 2025-01-08 17:58:09 +00:00
simonc56 452397b8af tinyxml2: array with data for dict type 2025-01-08 17:58:09 +00:00
simonc56 c9a8a1e35c tinyxml2: in xmlrpc an array must include values in a data element 2025-01-08 17:58:09 +00:00
stickz 8f77d87994 tinyxml2: Change from i4 to i8
We need to follow the same specification as xmlrpc-c until we deprecate it. It is breaking various software such as sonarr. We can't have xmlrpc using i8 and tinyxml2 using i4, while we allow both to be used.
2025-01-08 17:58:09 +00:00
rakshasa 842edaa201 Added missing base64.h header. 2025-01-08 17:58:09 +00:00
kannibalox 4876301cf4 Add page up/down and home/end bindings to download list 2025-01-08 18:46:09 +01:00
rakshasa c2c6a4be26 Inline test data instead of using separate text file. 2025-01-03 06:04:09 +09:00
kannibalox 350d03ca04 Update XMLRPC unit tests to include <data> for arrays 2025-01-03 05:26:55 +09:00
rakshasa 31602917b7 Release 0.15.1. 2025-01-01 12:59:06 +00:00
rakshasa a9898c6ef6 Merge branch 'master' of github.com:rakshasa/rtorrent 2025-01-01 12:34:15 +00:00
simonc56 2bf81aa8f5 tinyxml2: array with data for dict type 2025-01-01 21:33:30 +09:00
simonc56 a9c0b65b9d tinyxml2: in xmlrpc an array must include values in a data element 2025-01-01 21:33:30 +09:00
stickz 73fed24459 tinyxml2: Change from i4 to i8
We need to follow the same specification as xmlrpc-c until we deprecate it. It is breaking various software such as sonarr. We can't have xmlrpc using i8 and tinyxml2 using i4, while we allow both to be used.
2025-01-01 21:32:23 +09:00
rakshasa f906e9a966 Added missing base64.h header. 2025-01-01 12:15:54 +00:00
kannibalox 090b3889ce Add color support for the TUI
Closes #398
2024-12-26 16:32:42 -05:00
rakshasa 68fdb86c72 Update configure.ac. 2024-12-26 16:50:18 +00:00
rakshasa 6b8a285e75 Release v0.15.0. 2024-12-26 16:29:16 +00:00
kannibalox 8f0331625a Correctly handle commands that are flagged as not using targets
Fixes #1346
2024-12-27 01:00:23 +09:00
stickz 3c65afcf8c tinyxml2: Resolve LTO issues
We can't have two classes with the same name in the rpc namespace. It causes ODR and lto-type-mismatches when compiling rTorrent with LTO.

This pull request addresses the problem by renaming the `xmlrpc_error` error class to `xmlrpc_error_c` in the xmlrpc_c file.
2024-12-27 00:55:29 +09:00
kannibalox cd9948a4a8 Remove/replace functional_fun.h functions 2024-12-22 19:17:36 +09:00
rakshasa 0d1b9e9d55 Removed cppunit ldflags from common flags. 2024-12-21 02:28:46 +09:00
rakshasa 6561c00ae3 Use std::array in partial_queue. 2024-12-21 02:23:58 +09:00
rakshasa b8cb828d96 Replaced depreacted rak/functional calls. 2024-12-15 00:54:20 +09:00
stickz e3be3b2c12 scgi: Fix Apple and Solaris compatibility
This is a follow up to #1310. Apple and Solaris do not support MSG_NOSIGNAL, so disable this flag for these platforms until we find a better solution. Other platforms remain unaffected.
2024-12-14 23:34:48 +09:00
Jari Sundell 0f93fa109c Fixed curl stack shutdown with active downloads. (#1338)
Fixed curl stack shutdown with active downloads.
2024-12-12 22:59:48 +09:00
Jari Sundell 7e1193acab Run unit test in workflow PR. 2024-12-08 01:32:46 +09:00
kannibalox 5792ed1ae2 Apply clang-format 2024-12-07 19:26:29 +09:00
kannibalox 8cfc71b936 Fix system.multicall parameter parsing 2024-12-07 19:26:29 +09:00
kannibalox f2b065a798 Fix typo 2024-12-07 19:26:29 +09:00
kannibalox f33c2560a3 Default to an empty list when not passed explicit <params> 2024-12-07 19:26:29 +09:00
kannibalox db1e78fa9d Update tests to fix typo 2024-12-07 19:26:29 +09:00
kannibalox 48c40ee0c6 Fix typo: methodReponse -> methodResponse 2024-12-07 19:26:29 +09:00
kannibalox 3aeb213dc4 Avoid <int> in tinyxml2 responses
It's part of the XML-RPC spec, but some clients only accept i4/i8, which
should be supported nearly universally.

Fixes #1330
2024-12-07 19:26:29 +09:00
trim21 5a200f5d8f fix: d.group.name should return group name instead of group index 2024-12-06 01:09:18 +09:00
rakshasa 713067ba94 Fixed minor syntax issues. 2024-12-05 04:00:54 +09:00
Jari Sundell fea2cbfac6 Use proper target namespace 2024-12-05 04:00:54 +09:00
kannibalox 6bf1731a1c Ensure compability check actually checks the type for files
Fixes https://github.com/rakshasa/rtorrent/issues/854
2024-12-05 04:00:54 +09:00
Jari Sundell f2caa2651d Added clang-tidy github action. (#1325)
Added clang-tidy github action.
2024-12-05 03:01:11 +09:00
kannibalox 511895a8b6 Add headers to enable compiling without the libtorrent change 2024-12-04 19:19:53 +09:00
kannibalox 4e64fbc78b Properly use compare_exchange_strong
In practice, calling `network.scgi.open_port` again doesn't trigger
this function.
2024-12-04 19:19:53 +09:00
kannibalox 93b3a34f28 Properly lock size check, and remove overall cacheline alignment 2024-12-04 19:19:53 +09:00
kannibalox ea1ca00f31 Remove cacheline alignment from atomic pointer 2024-12-04 19:19:53 +09:00
kannibalox 58b1fc4914 Ensure empty() is properly guarded 2024-12-04 19:19:53 +09:00
kannibalox 577818bde4 Remove cache alignment from atomic members 2024-12-04 19:19:53 +09:00
kannibalox 0ea7615d0a Convert __sync* built-ins to std::atomic
Also converts thread_queue_hack to a simpler reserved vector
2024-12-04 19:19:53 +09:00
PPN-SD 73c1233dc0 Fix calls ar directly
Signed-off-by: Nicolas PARLANT <nicolas.parlant@parhuet.fr>
2024-11-26 01:27:39 +09:00
rakshasa 11ddc35d02 Renamed tinyxml2.cpp file. 2024-11-25 18:44:28 +09:00
kannibalox 036916fd9f Fix typo in method name 2024-11-25 18:44:28 +09:00
kannibalox b3fabd2a2b Align argument name with header definition 2024-11-25 18:44:28 +09:00
kannibalox 4b7c3ffafe Use empty() instead of checking size
Also use a const pointer for a child element
2024-11-25 18:44:28 +09:00
kannibalox 730d43b6c7 Explicitly mark narrowing conversion 2024-11-25 18:44:28 +09:00
kannibalox af2f30c183 Remove unused variable 2024-11-25 18:44:28 +09:00
kannibalox 36fd837d27 Fix unnecessary narrowing with proper return type 2024-11-25 18:44:28 +09:00
kannibalox 8dd8d691c5 Explicitly check result of std::strncmp 2024-11-25 18:44:28 +09:00
kannibalox e367b162ab Share object_to_target between tinyxml2 and xmlrpc-c 2024-11-25 18:44:28 +09:00
kannibalox 49cdfee65a Avoid ambiguous value_* in variable names 2024-11-25 18:44:28 +09:00
kannibalox 5680db3598 Parse out target param first if available 2024-11-25 18:44:28 +09:00
kannibalox 4768eb8356 Fix test to match case change 2024-11-25 18:44:28 +09:00
kannibalox fa2c7d961b Remove unnecessary std::string() and use lowercase for error msgs 2024-11-25 18:44:28 +09:00
kannibalox d6dcbc4a69 Add size limit to XML-RPC documents, defaulting to max SCGI size 2024-11-25 18:44:28 +09:00
kannibalox cadfcb50d2 Print iterator for TYPE_DICT_KEY, not object 2024-11-25 18:44:28 +09:00
kannibalox 71a39cd8a0 Keep as_*() outside of loops 2024-11-25 18:44:28 +09:00
kannibalox 0658486966 Change base64 decoder name, and add util for removing newlines 2024-11-25 18:44:28 +09:00
kannibalox 687fbbb83d Formatting 2024-11-25 18:44:28 +09:00
kannibalox e355eb561f Clean up borrowed base64 code to match repo standards 2024-11-25 18:44:28 +09:00
kannibalox 902de0b258 Add test for empty int text 2024-11-25 18:44:28 +09:00
kannibalox 01e5df4167 Remove title printing from test 2024-11-25 18:44:28 +09:00
kannibalox 8d85ce5857 Add test case for empty integer 2024-11-25 18:44:28 +09:00
kannibalox f9c9fa2e3b Move int element converter to helper function
Also fix strncmp checks
2024-11-25 18:44:28 +09:00
kannibalox 337897784d Change rpc namespace to include static consts 2024-11-25 18:44:28 +09:00
kannibalox 782b1e4ea8 Skip converting value_element_type to std::string 2024-11-25 18:44:28 +09:00
kannibalox 3cfc213053 Fix missing header 2024-11-25 18:44:28 +09:00
kannibalox b789d83b70 Fix system.listMethods inclusion check 2024-11-25 18:44:28 +09:00
kannibalox 67babb65d6 Convert element_access to use initializer lists
Also remove uses element_access for single child accesses
2024-11-25 18:44:28 +09:00
kannibalox e0d5c95821 Use correct terminology in comment 2024-11-25 18:44:28 +09:00
kannibalox 7f4c5df5ee Use single namespace statement 2024-11-25 18:44:28 +09:00
kannibalox dd45684584 Move vendored tinyxml2 files to rpc namespace and directory 2024-11-25 18:44:28 +09:00
kannibalox fb8632e990 Change lingering camelCase to snake_case 2024-11-25 18:44:28 +09:00
kannibalox b043b7b39e Simplify iterator names 2024-11-25 18:44:28 +09:00
kannibalox 168093d256 Remove extra return 2024-11-25 18:44:28 +09:00
kannibalox 0c2f0b7715 Add test case for invalid floats 2024-11-25 18:44:28 +09:00
kannibalox 4a9d9952e1 Be explicit about the desired result 2024-11-25 18:44:28 +09:00
kannibalox fd1d5dbdb2 Add test case for bad boolean value 2024-11-25 18:44:28 +09:00
kannibalox dd0c62c7f7 Uncomment after testing 2024-11-25 18:44:28 +09:00
kannibalox 3a8e462bd3 Throw error if attempting to use both xmlrpc-c and tinyxml2 2024-11-25 18:44:28 +09:00
kannibalox b360a734f1 Use std::strtoll instead of std::stol 2024-11-25 18:44:28 +09:00
kannibalox c18df7a366 Use std::strncmp for string comparison 2024-11-25 18:44:28 +09:00
kannibalox a269f808e1 Fix swapped variable names 2024-11-25 18:44:28 +09:00
kannibalox 4444df2e97 Change internal error to type error 2024-11-25 18:44:28 +09:00
kannibalox 5a194ab037 Remove stack from exception message 2024-11-25 18:44:28 +09:00
kannibalox 1b43f8b591 Use snake case for variable names
Also use `||` instead of `or`, and throw an error if an unknown boolean
string is received
2024-11-25 18:44:28 +09:00
kannibalox d6427203a4 Refactor to only use a position variable 2024-11-25 18:44:28 +09:00
kannibalox 87c6422052 Allow using vendored tinyxml2 for XMLRPC
By default, builds will still not have XMLRPC enabled at all and the
configure flag `--with-xmlrpc-tinyxml2` must be specified. If both
xmlrpc-c and tinyxml2 are specified, xmlrpc-c takes precedence.

Basic benchmarks indicate tinyxml2 is 2x faster for small
requests/responses, and that only increases as response sizes get
larger.
2024-11-25 18:44:28 +09:00
rakshasa 6ab265ecd4 Fixed merge errors. 2024-11-14 00:33:03 +09:00
rakshasa 203c66a287 Merge branch 'kannibalox-feature/clang-format' 2024-11-13 10:53:28 +00:00
Jari Sundell c9fe2facfa Merge branch 'master' into feature/clang-format 2024-11-13 19:51:04 +09:00
kannibalox 5abcf52e55 Remove unused flag_delete_key 2024-11-13 19:22:34 +09:00
kannibalox f2f84dd97a Remove destructor definition entirely 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 ef937863fd Removed unused code. 2024-11-13 18:59:57 +09:00
kannibalox 00fa4127e1 Respect existing line limits 2024-11-11 16:00:28 -05:00
kannibalox 1b0cb722e6 Remove non-naming checks 2024-11-10 09:18:59 -05:00
kannibalox af23ca8032 Convert some representative files 2024-11-10 09:17:12 -05:00
kannibalox c85f9d6318 Add clang tidy/format 2024-11-10 09:08:33 -05:00
Josh Ellithorpe ee120730cc Update README.md to spell Ethereum correctly 2024-10-29 22:44:09 +09:00
stickz b284be6a66 Resolve scgi software crash
This commit resolves a scgi software crash when the scgi socket is closed before the message can be sent. It instructs `::send()` not to send a SIGPIPE termination signal. Instead the value -1 is returned and handled bellow. The SCgiTask is closed and a new one is sent to complete the task.

```
Thread 3 "rtorrent scgi" received signal SIGPIPE, Broken pipe.
                                                             [Switching to Thread 0x7fffe635c6c0 (LWP 2443872)]
0x00007ffff7929a84 in send () from /lib/x86_64-linux-gnu/libc.so.6
```
2024-10-29 22:42:33 +09:00
kannibalox 6e976616a0 Simplify updating queue entries
The erase/insert pattern can be replaced by a single method that
updates an existing entry's timer, or inserting if it doesn't exist.

This has much less impact than the libtorrent change it's based on,
but might as well be consistent.
2024-10-20 18:33:33 +09:00
Adam Sampson 38b39bdafc Add ax_require_defined.m4 to scripts.
This is required now by ax_with_curses.m4, but wasn't added when the
script was updated.
2024-10-07 23:52:20 +09:00
Adam Sampson 48718bdac8 Remove unnecessary +x mode from some m4 files. 2024-10-07 23:52:20 +09:00
Rui Chen 5ce84929e4 fix: use fsync for osx builds
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-10-07 23:43:54 +09:00
stickz c1d076f182 Fixing static building
@rakshasa A major hosting provider with rTorrent has mentioned the following revision is required for static builds to pass.
2024-10-07 23:32:45 +09:00
Jari Sundell f929594763 Update README.md 2024-09-29 23:34:31 +09:00
rakshasa a88cab6d2e Released v0.9.0. 2024-09-29 11:06:14 +00:00
rakshasa 9a93281ded Merge branch 'stickz-session-fix' 2024-09-07 08:29:22 +00:00
rakshasa 133ce36570 Fixed goto warning. 2024-09-07 08:29:00 +00:00
rakshasa a142301d02 Merge branch 'session-fix' of github.com:stickz/rtorrent-rak into stickz-session-fix 2024-09-07 08:17:07 +00:00
rakshasa f04e512887 Merge branch 'stickz-memory-leak' 2024-09-07 08:02:55 +00:00
rakshasa d32d59315d Merge branch 'memory-leak' of github.com:stickz/rtorrent-rak into stickz-memory-leak 2024-09-07 07:54:00 +00:00
rakshasa 86e85ae485 Merge branch 'stickz-lto-fix' 2024-09-07 06:29:21 +00:00
stickz 6e9902c23b Fix critical memory leak
This commit fixes a critical memory leak with the inserting RPC commands. We must initialize the cmd_flags with the delete key, otherwise they hang around in memory forever; potentially leaking significant amounts of resources.
2024-09-06 11:16:47 -04:00
stickz d4427931a2 Fix session file data corruption
From https://github.com/jesec/rtorrent/commit/f9a875b633eb083ec82f89ebeae8678ca424e8b2

This commit ensures session files land on the disk in the event of a system crash or power outage. It prevents data corruption of rTorrent session files, which causes torrent client breakage.

Optimizations from the initial implementation include
1) Skipping unnecessary file metadata updates during the sync process.
2) Skipping variable initialization since open will assign -1 on failure.
2024-09-06 11:05:35 -04:00
stickz ea3828a17e Fix Link Time Optimizations
This commit fixes compiling rTorrent with LTO (Link Time Optimizations). We just need to rename from variables in the directory_entry structure to avoid ODR and ZLIB conflicts.
2024-09-01 08:20:01 -04:00
rakshasa 4e246a401f Remove decision structure for popcount_wrapper
The decision structure is very costly. It's significantly faster to work with long long than to use it.
2024-08-31 12:14:50 +00:00
rakshasa eacf9798e2 commit 30addc1a5e
Author: kannibalox <kannibalox@gmail.com>
Date:   Mon Jun 10 13:09:29 2024 -0400

    Use regular iterators intead of bucket-local ones

    Trying to manually predict which bucket a hashed key will land in does not
    appear to be well-defined behavior.

    Fixes #1285
2024-08-20 17:56:03 +00:00
rakshasa 892e595015 Added PKG_CHECK_EXISTS exception. 2024-08-09 13:06:14 +00:00
Jari Sundell 1da0e3476d Removed stray spaces. 2023-03-16 22:10:38 +01:00
Jari Sundell c0a5a55444 Disable delay tracker scrape on start. 2023-03-16 22:10:38 +01:00
stickz 551712f842 Fix typo in "trackers.delay_scrape" 2023-03-16 22:10:38 +01:00
stickz c7c290a86b Add "trackers.delay_scrape" command 2023-03-16 22:10:38 +01:00
stickz 2e1a499942 Don't delay scraping for newly added torrents 2023-03-16 22:10:38 +01:00
stickz c86f0d0333 Don't force the trackers to scrape when rTorrent first starts
rTorrent will do this gradually, so we can start connecting to peers right away.

This patch shaves approximately 5 minutes off the start time with thousands of torrents.
2023-03-16 22:10:38 +01:00
Aleksa Sarai 92bec88d09 utils: lockfile: avoid stack overflow for lockfile buffer
There appears to have been some change on openSUSE (likely some new
hardening flags for builds, or some glibc hardening) such that incorrect
buffer handling results in a segfault even if the buffer is never
overflowed.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2023-03-10 22:22:36 +01:00
Jari Sundell d067bd802e Create FUNDING.yml 2022-09-08 05:08:17 +09:00
Jari Sundell 50924eeda0 Updated paypal link 2022-09-08 05:04:14 +09:00
Jari Sundell 1e40014482 Added rbedit to README. 2021-12-13 04:07:40 +09:00
Jari Sundell 8cafb55881 Updated ADA address. 2021-11-25 02:12:52 +09:00
Jari Sundell a6bc99bb82 Updated and cleaned up automake. (#1102) 2021-08-07 17:49:23 +09:00
Jari Sundell 52ceb39ca3 Updated release link. 2021-08-04 14:27:15 +09:00
Jari Sundell 926893ee62 Update README.md 2021-08-04 00:18:42 +09:00
Jari Sundell cf13789f8c Update README.md 2021-07-20 10:35:14 +09:00
rakshasa d15d93be88 Added ipv6 options. 2021-06-21 21:14:48 +09:00
rakshasa 582e4e4025 Added '--disable-execinfo' option to configure. 2021-06-16 23:29:01 +09:00
rakshasa 952777d75e Added commands to update choke queue. 2021-05-01 19:45:50 +09:00
rakshasa 19dbaa7442 Added missing ax_execinfo.m4 file. 2021-04-04 14:59:36 +09:00
rakshasa 3f72e27603 Replaced custom execinfo autoconf test. 2021-02-27 22:13:01 +09:00
rakshasa e267e8bc07 Fixed automake required files. 2021-02-25 00:05:27 +09:00
Jari Sundell 79765768ff Update README.md 2019-12-25 23:40:57 +09:00
Jari Sundell 8cc1d8f2c5 Optimize build by using a single makefile file. (#941) 2019-12-06 00:35:47 +09:00
Trog 3798de01a0 few missing sub-commands of network and throttle for the RPC interface (#937) 2019-12-01 14:55:23 +09:00
Jari Sundell 8ac98c6d3a New readme. 2019-10-03 13:25:35 +09:00
rakshasa 81500adc53 Remove obsolete check. 2019-09-11 01:51:47 +09:00
lps-rocks 14d7121185 Increase maximum SCGI request to 16MB (#905) 2019-08-29 00:44:09 +09:00
Jari Sundell 7659cd0ec0 Backport changes from feature-bind. 2019-08-23 23:25:24 +09:00
rakshasa f43f9e430d Merge branch 'chros73-ui_mod_status_mod' 2019-08-02 00:13:41 +09:00
chros f22475d1bf Modify throttle status bar mod to be able to display multiple values (See #6) 2019-07-27 11:22:56 +01:00
Jari Sundell b697a4608b Merge pull request #898 from Nicholi/log_append
Added log.append_file command
2019-07-26 20:08:09 +09:00
nicholi 765665fc28 When opening log files use new append parameter. Also added append_gz_file command. 2019-07-26 01:03:57 -07:00
nicholi 5f70986099 Added log.append_file. 2019-07-24 00:46:17 -07:00
rakshasa 6154d16987 Bumped to version 0.9.8. 2019-07-19 13:38:33 +02:00
rakshasa a5e8631cba Added log.close. 2019-07-17 19:41:23 +02:00
rakshasa 07dcd04357 Revert to only using ax_with_curses.m4, and upgrade it to version 16 which seems to be the last unborked version. 2019-07-13 14:36:05 +02:00
rakshasa 863de44c18 Added d.tracker_announce.force. 2019-07-11 17:46:35 +02:00
Jari Sundell 24135ed48e Merge pull request #763 from MindTooth/travis_path_fix
travis: Fix test in wrong path, and jobs parallelization
2019-07-09 21:24:12 +02:00
rakshasa 83709d28c9 Merge branch 'toff-master' 2019-07-08 21:40:02 +02:00
rakshasa 859d5a9578 Merge branch 'master' of https://github.com/toff/rtorrent into toff-master 2019-07-08 21:39:31 +02:00
rakshasa adc9b1dec5 Merge branch 'zetafunction-autoconf' 2019-07-08 20:30:09 +02:00
rakshasa 285972a20d Fixed configure.ac. (zetafunction) 2019-07-08 20:29:43 +02:00
Jari Sundell 3ec2f52db5 Merge pull request #857 from skangas/view-keys-man
Update change view keys to 0-9 in man page
2019-07-08 19:41:20 +02:00
rakshasa ac64fc3f63 Added _GNU_SOURCE to fallocate test. (neheb) 2019-07-08 19:37:17 +02:00
rakshasa b26dc42f3a Merge branch 'ffontaine-master' 2019-06-10 01:18:32 +09:00
rakshasa 6572088aec Merge branch 'master' of https://github.com/ffontaine/rtorrent into ffontaine-master 2019-06-09 23:51:22 +09:00
rakshasa 31a0ea1a2d Merge branch 'master' of github.com:rakshasa/rtorrent 2019-06-09 17:10:17 +09:00
rakshasa 2d72a0d2c0 Merge branch 'chros73-input_history_with_categories' 2019-06-09 17:09:59 +09:00
rakshasa a3a384b049 Fixed minor issues. 2019-06-09 17:09:35 +09:00
Jari Sundell f37dd0d5c2 Merge pull request #722 from g0tmi1k/config
Update rtorrent.rc
2019-06-09 16:27:53 +09:00
Jari Sundell 78c25011cd Merge pull request #824 from Irishsmurf/patch-1
Fix typo in README
2019-06-09 16:25:07 +09:00
rakshasa 35d98c91e0 Merge branch 'master' of github.com:rakshasa/rtorrent 2019-06-09 16:24:18 +09:00
rakshasa 27811db659 Merge branch 'ss23-749_ncurses_tinfo' 2019-06-09 16:24:00 +09:00
rakshasa 4e73ce6bfd Merge branch '749_ncurses_tinfo' of https://github.com/ss23/rtorrent into ss23-749_ncurses_tinfo 2019-06-09 15:43:54 +09:00
Jari Sundell 8c8e73bb72 Merge pull request #794 from waveletlet/master
Edit getsession() for 0.9 config format
2019-06-09 15:17:18 +09:00
Jari Sundell 0d5b344d2a Switch to C++11 MRT RNG for random bytes
Switching to a better RNG for generating strings will prevent the common peerID collisions the rTorrent client has been seeing for YEARS in #440 and #318.
2019-06-08 16:22:47 +09:00
Fabrice Fontaine 703cac9a42 Fix cross compilation, based on OpenWRT patch.
[Vincent: tweak the patch for version 0.13.6]
[Bernd: tweak the patch for version 0.13.7]

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/libtorrent/0001-Fix-cross-compilation-based-on-OpenWRT-patch.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-04-20 21:37:26 +02:00
Stefan Kangas e6c008b2b7 Update change view keys to 0-9 in man page 2019-04-08 10:03:15 +02:00
Daniel Cheng 81de60e0ae Update global CFLAGS/CXXFLAGS/LIBS at the end of configure.ac
Changes to CFLAGS/CXXFLAGS/LIBS affect following lines in configure.ac.
As originally written, this would cause random libraries, such as
libtorrent, to be linked into the autoconf test program. Occasionally,
this would cause the things like the pkgconfig checks to fail with
mysterious linker errors (e.g. rakshasa/rtorrent#156).

Instead, only populate these global flags with the additional flags for
dependencies at the very end, before the invocation of AC_OUTPUT.
2019-01-13 23:37:36 -08:00
David K c361d6010e Fix typo in README
s/nessesary/necessary
2019-01-03 21:10:09 +00:00
Birger J. Nordølum 724dc088ca travis: Fix test in wrong path, and jobs parallelization 2018-11-14 22:05:19 +01:00
rakshasa c62fa6a756 Merge branch 'pyroscope-cmd-d_multicall_filtered' 2018-10-20 22:00:21 +09:00
rakshasa 656d735de7 Merge branch 'cmd-d_multicall_filtered' of https://github.com/pyroscope/rtorrent into pyroscope-cmd-d_multicall_filtered 2018-10-20 21:47:36 +09:00
rakshasa 408013478c Merge branch 'pyroscope-cmd-compare' 2018-10-20 21:38:39 +09:00
rakshasa fa61b8c11c Merge branch 'cmd-compare' of https://github.com/pyroscope/rtorrent into pyroscope-cmd-compare 2018-10-20 21:38:28 +09:00
rakshasa 1339a3ace9 Merge branch 'chros73-event_system_commands' 2018-10-20 21:35:35 +09:00
rakshasa 4ba128163f Merge branch 'event_system_commands' of https://github.com/chros73/rtorrent into chros73-event_system_commands 2018-10-20 21:30:39 +09:00
rakshasa 908a99751f Merge branch 'chros73-list_type_method_fix' 2018-10-20 21:22:13 +09:00
waveletlet c115640934 Edit getsession() for 0.9 config format 2018-10-18 19:39:32 -03:00
waveletlet 9043c46815 Edit getsession() for 0.9 config format 2018-10-18 19:36:49 -03:00
chros 1f418366d4 Fix 'list' type method (See #25) 2018-10-01 23:27:58 +01:00
toff 30c78c7034 Merge branch 'master' into master 2018-09-29 11:31:06 +02:00
chros 74435f6c40 Add 'event.system.startup_done/shutdown' commands/events (Closes #24) 2018-09-26 15:12:20 +01:00
Jari Sundell a4b281afa4 Merge pull request #753 from ss23/cross_compiling-execinfo
Use AC_COMPILE instead of AC_RUN to check for execinfo.h
2018-06-27 18:36:21 +09:00
Stephen Shkardoon f84670dd63 Use AC_COMPILE instead of AC_RUN to check for execinfo.h
This way enables cross compiling, since we don't need to run anything during the configure script.
2018-06-25 20:14:43 +12:00
rakshasa f0207ce654 Added "try" command that catches input_errors and logs them on rpc_events. 2018-06-23 17:01:34 +09:00
Stephen Shkardoon 9cce5a0bd1 Fix compiling if ncurses was built using --with-terminfo
Resolves #749
Patch from https://bugs.gentoo.org/658390
2018-06-20 01:50:45 +12:00
g0tmi1k 95cff549c6 Removed stop_untied at @pyroscope's request 2018-06-19 10:56:45 +01:00
g0tmi1k 92898a9831 Use session.path for rpc.socket in rtorrent.rc 2018-06-19 10:56:36 +01:00
g0tmi1k fcfbf0e79f Fix typos in rtorrent.rc 2018-06-19 10:51:35 +01:00
g0tmi1k 680b47c197 Add example rtorrent.rc
Source: https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
2018-06-19 10:48:25 +01:00
Jari Sundell 7804ed3009 Merge pull request #748 from pyroscope/d_custom_if_z-empty-val
d.custom.if_z: return default also for existing but empty value
2018-06-19 18:11:00 +09:00
pyroscope d9b39f5ac6 d.custom.if_z: return default also for existing but empty value 2018-06-18 19:41:53 +02:00
Jari Sundell 08aa287cfc Merge pull request #614 from chros73/adjustable_global_throttle_steps
Make global throttle steps adjustable
2018-06-19 00:08:32 +09:00
Jari Sundell 851d1902a0 Merge pull request #738 from pyroscope/d_custom_if_z+keys+items
add d.custom.if_z + d.custom.keys + d.custom.items
2018-06-19 00:06:23 +09:00
Jari Sundell b600ff0c0e Merge pull request #742 from pyroscope/cmd-event-view-change
add 'event.view.hide/show' commands / events
2018-06-16 18:48:10 +09:00
Jari Sundell a639461c4a Merge pull request #743 from pyroscope/fix-log-xmlrpc-close
fix: properly close the XMLRPC log, resetting the handle after close
2018-06-16 18:46:11 +09:00
Jari Sundell c1057d5ac7 Merge pull request #745 from pyroscope/cmd-value
add 'value' command / conversion op
2018-06-16 18:33:39 +09:00
pyroscope 2ac65ad7e1 add 'value' command / conversion op 2018-06-16 06:54:39 +02:00
pyroscope a4939cb9fd add 'compare' command / operator 2018-06-15 22:36:55 +02:00
pyroscope 3d88ac2cc8 fix: properly close the XMLRPC log, resetting the handle after close 2018-06-15 19:38:12 +02:00
pyroscope f37fefcc54 add 'event.view.hide/show' commands / events 2018-06-15 18:36:01 +02:00
pyroscope 885836f68b add 'd.multicall.filtered' command 2018-06-15 00:40:00 +02:00
pyroscope ca4c3bee8d add d.custom.if_z + d.custom.keys + d.custom.items 2018-06-14 20:32:28 +02:00
Jari Sundell 6c278668e4 Merge pull request #587 from pyroscope/add-position-display-in-title
add '[ X of Y ]' to title bar
2018-06-11 23:15:21 +09:00
Jari Sundell 1665437588 Merge pull request #576 from chros73/simple_math_commands
Add support for basic arithmetic operators
2018-06-11 23:06:37 +09:00
rakshasa 327164f9d8 Bumped version to 0.6.7. 2018-06-07 13:18:34 +09:00
rakshasa 5d22fdd4b6 Merge branch 'chros73-ipv4_filter_enhancement' 2018-06-05 18:52:12 +09:00
rakshasa 7455f2eb86 Merge branch 'ipv4_filter_enhancement' of https://github.com/chros73/rtorrent into chros73-ipv4_filter_enhancement 2018-06-05 18:35:05 +09:00
rakshasa 53767cee92 Merge branch 'chros73-throttle_args_fix' 2018-06-05 17:02:33 +09:00
rakshasa aa9e729ca7 Merge branch 'throttle_args_fix' of https://github.com/chros73/rtorrent into chros73-throttle_args_fix 2018-06-05 17:00:04 +09:00
Jari Sundell e43853b782 Merge pull request #677 from ss23/patch-1
Include SCGI/XMLRPC example in rtorrent.rc
2018-06-05 16:58:25 +09:00
rakshasa 81932c0b12 Merge branch 'duraki-patch-1' 2018-06-05 16:56:59 +09:00
rakshasa 61264c4f17 Merge branch 'patch-1' of https://github.com/duraki/rtorrent into duraki-patch-1 2018-06-05 16:55:02 +09:00
rakshasa 244a84dcf5 Merge branch 'chros73-fix_cxxflags_check' 2018-06-05 16:53:03 +09:00
rakshasa c9a5736d5d Merge branch 'fix_cxxflags_check' of https://github.com/chros73/rtorrent into chros73-fix_cxxflags_check 2018-06-05 16:50:47 +09:00
rakshasa 9322acb33d Merge branch 'pyroscope-fix-double-slash-319' 2018-06-05 16:47:57 +09:00
rakshasa a5e722b48f Merge branch 'fix-double-slash-319' of https://github.com/pyroscope/rtorrent into pyroscope-fix-double-slash-319 2018-06-05 16:45:35 +09:00
rakshasa ba4828d226 Merge branch 'pyroscope-handle-sighup-578' 2018-06-05 16:42:40 +09:00
rakshasa dfced79186 Merge branch 'handle-sighup-578' of https://github.com/pyroscope/rtorrent into pyroscope-handle-sighup-578 2018-06-05 16:40:25 +09:00
rakshasa dd2a4cc151 Fixed ncurses.h include bug fix by theirix. 2018-06-05 16:37:48 +09:00
rakshasa fd372b5e48 Cleaned up download list bug fix.. 2018-06-05 16:22:01 +09:00
chros 6dc87e499a Fix bugs in 'math.*' commands (See #14) 2018-06-01 11:51:42 +01:00
chros 6c11a1dbb0 Fix error message in as_vector method (See #14) 2018-03-03 09:08:28 +00:00
chros 3ea47d7acb Fix for missing throttle arguments (See #23) 2018-01-24 18:20:14 +00:00
☃ Stephen Shkardoon ☃ b82f3614c3 Include SCGI/XMLRPC example in rtorrent.rc
Examples are for scgi_port, and scgi_local (with scheduling to change permissions on the file).
2018-01-14 02:09:42 +13:00
devil ❂ tux 2987ba8081 Fix: Missing ranlib in autoconf
On RHEL7 & possibly CentOS configuring using `autogen` does not append RANLIB nor is registered by default, this fixes definition of the library.
2017-12-15 10:45:31 +01:00
chros 33f8fe804b IPv4 filter enhancement (Closes #21) 2017-12-10 18:54:55 +00:00
chros 1a4f6dab1a Modfiy gcc v6.x fix for empty CXXFLAGS (See #20) 2017-08-02 12:51:03 +01:00
chros 943b576e1f Fix compilation issue with gcc v6.x and empty CXXFLAGS (See #20) 2017-07-30 20:37:21 +01:00
chros 29d57e858a Make global throttle steps adjustable (Closes #17) 2017-06-06 09:54:01 +01:00
Toff 7ec9b6685b Merge pyroscope and chros73 suggestion: Command name uniformisation.
ui.console.log.tempfilter => view.temp_filter.log
2017-05-06 11:17:25 +02:00
Toff d5de8a91d1 Merge chros73 suggestions (settings to exclude views and hide info logs)
- Certain views can be excluded from subfiltering via view.temp_filter.excluded config option
    - its default value: "default,started,stopped"
    - example usage in config: view.temp_filter.excluded.set="default,started,stopped,leeching"

- Log messages can be displayed when temp filtering occured
    - disabled by default
    - can be enabled with: ui.console.log.tempfilter.set=1
2017-04-17 14:56:11 +02:00
pyroscope 4d6f6fe335 add '[ X of Y ]' to title bar 2017-04-01 12:30:10 +02:00
pyroscope 2ec90c6892 no // at start of expanded paths (closes #319) 2017-03-17 21:44:08 +01:00
pyroscope 63dfe341a6 handle SIGHUP like SIGINT (closes #578) 2017-03-17 20:25:11 +01:00
chros 13676f06e5 Add median command (See #14) 2017-03-11 11:40:08 +00:00
chros 6cb176ada3 Add more info to throw message in math commands (See #14) 2017-03-07 13:12:18 +00:00
chros 8b6a1ad079 Add count and average commands (See #14) 2017-03-07 12:57:31 +00:00
chros 3002c95b2c Rename couple of arithmetic commands (See #14) 2017-03-06 19:41:49 +00:00
chros 9590949fa7 Add support for basic arithmetic operators (See #14) 2017-03-06 13:06:59 +00:00
Shivaram Lingamneni 321147cdb8 only redraw the download list if the deleted download was onscreen 2017-01-08 14:49:54 -08:00
Toff 6ee61ee6b5 Merge chros73 suggestions (filter indicator, "start/stopped" view case)
- Suffix filtered view name with "(filtered)"
- Add a check to not filter "start" and "stopped" view
2017-01-08 19:45:46 +01:00
Shivaram Lingamneni 2097c9ca3e unfocus_download should always redraw the download list 2016-12-30 09:19:34 -08:00
rakshasa 10ce6864b8 Added non-pkgconfig check for curl as macosx doesn't include the 'pc' file. 2016-11-05 06:58:44 +09:00
Toff e15270271d Add a temporary name filter for the main view.
By using 'F' in the main view you can enter a regex
that will be used to filter the view based on the torrent name.
To remove the filter set the input to empty.
This is adding a 'view.temp_filter' property and a 'match{}' function.
For example with Ctrl+X you could do:
command> view.temp_filter=main,"match={d.name=,.*linux.*iso}"
2016-10-31 12:19:41 +01:00
Jari Sundell 226e670dec Merge pull request #514 from rakshasa/feature-travis
Travis improvements.
2016-10-23 13:33:00 +09:00
rakshasa 74bd0be5d8 Travis improvements. 2016-10-23 12:23:29 +09:00
Jari Sundell e3a5ed9c75 Merge pull request #513 from rakshasa/fix-cppunit
Fix cppunit
2016-10-23 09:32:42 +09:00
rakshasa c7c5a00f66 Cleaned up check for dependencies. 2016-10-23 09:21:40 +09:00
rakshasa 71a52bfac2 Use pkg-config for cppunit test. 2016-10-23 08:53:11 +09:00
Jari Sundell 16e1961636 Merge pull request #512 from rakshasa/fix-dht
Fix dht
2016-10-23 03:10:49 +09:00
rakshasa 2aa130eda9 More work on dht manager. 2016-10-22 14:19:46 +09:00
rakshasa 008561ef47 More dht manager logging. 2016-10-22 12:33:31 +09:00
rakshasa e02c6b29fa More logging stuff. 2016-10-22 11:21:56 +09:00
rakshasa e2c769f459 Improved logging of dht manager. 2016-10-22 10:51:41 +09:00
Jari Sundell c3f6db0384 Merge pull request #507 from rakshasa/ipv6
Ipv6
2016-10-11 06:44:15 +09:00
rakshasa 40a5b63223 Merge branch 'master' into ipv6 2016-10-10 22:11:52 +09:00
rakshasa e6439a173e Merge branch 'master' of github.com:rakshasa/rtorrent 2016-09-23 08:30:55 +09:00
rakshasa 84913766d5 Removed unneeded parameter. 2016-09-23 08:25:40 +09:00
rakshasa 89b02f275e Added "system.shutdown", "system.shutdown.normal" and "system.shutdown.quick". 2016-09-23 08:22:24 +09:00
Jari Sundell ce00085107 Merge pull request #502 from Speeddymon/Speeddymon-doc_fix-2
Speeddymon doc fix 2
2016-09-09 19:41:52 +09:00
Speeddymon d7529d3b84 Correct Download list layout style to 0.9 format.
Blame @rakshasa for using old style.
2016-09-09 01:57:07 -05:00
Speeddymon 23cf6b260c Merge pull request #4 from rakshasa/master
Sync with upstream master
2016-09-09 01:55:25 -05:00
Jari Sundell 06f1c032b0 Merge pull request #496 from chros73/fix_type_of_var
Fix type of m_ssl_verify_host variable
2016-08-30 22:17:17 +09:00
chros bdb0d99c5c Fix type of m_ssl_verify_host variable (See #12) 2016-08-29 11:04:51 +01:00
rakshasa 7c5e42f4b9 Merge branch 'ipv6' of github.com:rakshasa/rtorrent into ipv6 2016-08-29 18:23:08 +09:00
rakshasa e1afe25413 Merge branch 'master' into ipv6 2016-08-29 18:19:45 +09:00
Jari Sundell 0cba9cbf9b Merge pull request #494 from chros73/init_scripts
Add init scripts into doc directory
2016-08-26 18:06:55 +09:00
chros 017cb1bd59 Fixing variables in rtorrentInitTmux.bash script (See #10) 2016-08-25 19:04:11 +01:00
chros dfdbf5e69c Add init scripts into doc directory (See #10) 2016-08-25 18:38:58 +01:00
Jari Sundell 15e64bdade Merge pull request #492 from chros73/fast_resume_fix
Fix fast resume script breaking single file torrents
2016-08-25 21:25:32 +09:00
chros 5838b8e68c Fix fast resume script breaking single file torrents (See #7) 2016-08-25 12:47:14 +01:00
Jari Sundell 13162f98cb Merge pull request #485 from pyroscope/fix-set_kb
scale integer values with given unit, not only converted strings (closes #484)
2016-08-18 08:36:24 +09:00
Jari Sundell b5e4dc0342 Merge pull request #479 from kannibalox/patch-1
Expose the number of current HTTP connections
2016-08-15 06:16:09 +09:00
pyroscope 41a059c999 scale integer values with given unit, not only converted strings (closes #484) 2016-08-13 14:45:00 +02:00
kannibalox 55c61e9099 Expose the number of current HTTP connections 2016-08-12 02:32:26 +00:00
Jari Sundell e1fa392ecb Merge pull request #477 from mvucBmM0/master
Fix Merzlya display (PR #474)
2016-08-10 02:17:32 +09:00
Speeddymon 9d7398d1da Merge pull request #3 from rakshasa/master
Merge mainline master with fork master
2016-08-05 22:57:34 -05:00
mvucBmM0 a194da08b0 Fix Merzlya display (PR #474) 2016-08-06 03:08:13 +01:00
rakshasa 51c5190eb1 Removed commands that were deprecated in version 0.7.0. 2016-08-06 05:24:43 +09:00
rakshasa 66619840d8 Increased max file size to 512GB. 2016-08-06 03:02:14 +09:00
Jari Sundell 63c2b7aef5 Merge pull request #474 from rakshasa/merzlya-display
Merzlya display
2016-08-04 00:08:21 +09:00
rakshasa 2c60226bd2 Cleaned up compact display. 2016-08-03 23:57:02 +09:00
rakshasa d111594d20 Added merzlya's torrent status display changes. 2016-08-03 23:01:28 +09:00
Jari Sundell a0f97e4b06 Merge pull request #459 from chros73/fix_filter_started
Fix scheduled sorting/filtering bug on started and stopped views in rtorrent
2016-08-03 22:04:59 +09:00
Jari Sundell a7079c594e Merge pull request #460 from netpok/master
Fix warning message of deprecated commands
2016-08-03 21:56:32 +09:00
Jari Sundell ed48d586d8 Merge pull request #465 from chros73/expose_meta_property
Expose meta property of downloads
2016-08-03 21:55:50 +09:00
Jari Sundell 8be4e5bbf7 Merge pull request #461 from Speeddymon/Speeddymon-patch-1
Update example rtorrent.rc to 0.9 format
2016-08-02 20:35:45 +09:00
chros 8140c3fe07 Expose meta property of downloads (See #5) 2016-07-21 18:55:21 +01:00
netpok 8385957b06 Fix warning message of deprecated commands 2016-07-15 11:52:33 +02:00
Jari Sundell 1363e50a7b Merge pull request #455 from Speeddymon/Speeddymon-patch-2
Fix travis config
2016-07-13 09:42:25 +09:00
Speeddymon f24154e772 Fix travis config 2016-07-09 14:02:31 -05:00
Speeddymon 3f698b3b39 Update example rtorrent.rc to 0.9 format 2016-07-09 13:59:08 -05:00
chros a8c67b4aab Fix scheduled sorting/filtering bug on started and stopped views in rtorrent (See #3) 2016-07-06 23:15:04 +01:00
Jari Sundell aac0ea48f7 Merge pull request #430 from yate/peer-units
use whatever unit necessary in peer list info
2016-06-29 21:08:42 +09:00
Jari Sundell 1db32f2f63 Merge pull request #444 from jmdevince/master
Show non-preloaded pieces stats
2016-06-29 21:06:22 +09:00
rakshasa efc9097d62 Renamed system.use_daemon to system.daemon. 2016-06-27 01:46:54 +09:00
Jari Sundell 5a56fbd5d1 Merge pull request #446 from zp/daemon
Allow rtorrent to run as a daemon, slightly modified version of #111
2016-06-27 01:40:42 +09:00
zp 7ea5729676 trim modified files 2016-06-19 07:04:23 -05:00
zp c01709fa27 Allow rtorrent to run as a daemon, slightly modified version of the PR provided by sallyswiss 2016-06-19 02:06:30 -05:00
jmdevince 0797d636fb Show non-preloaded pieces stats 2016-06-15 09:46:33 -04:00
yate b68d4c2db9 use whatever unit necessary in peer list info 2016-05-15 22:58:16 -04:00
Jari Sundell 9abcea84c7 Merge pull request #280 from mynamewastaken/patch-1
Partially update outdated documentation
2016-03-10 10:46:27 +09:00
Jari Sundell cc1f7fb2cb Merge pull request #407 from rakshasa/fix-stray-simple
Fix a stray 'simple' method.insert check.
2016-03-10 10:18:32 +09:00
rakshasa 944d304193 Fixed travis config file. 2016-03-10 09:41:16 +09:00
rakshasa 629e421d67 Updated travis file to properly select gcc-4.7. 2016-03-10 09:37:58 +09:00
rakshasa 3e7f9d8b4f Removed make check. 2016-03-10 09:24:08 +09:00
rakshasa a8cb524345 Merge branch 'master' into fix-stray-simple 2016-03-10 09:02:04 +09:00
rakshasa 0510e4db9d Don't run 'make check' in travis as it has linker issues. 2016-03-10 08:59:33 +09:00
rakshasa a975804797 Merge branch 'master' into fix-stray-simple 2016-03-10 08:50:59 +09:00
rakshasa adf4a32097 Fixed name. 2016-03-10 08:50:43 +09:00
rakshasa 3edeb364bc Fix a stray 'simple' method.insert check. 2016-03-10 08:47:14 +09:00
Jari Sundell 73a344711d Merge pull request #406 from rakshasa/test-travis
Adding travis file for testing.
2016-03-10 08:46:13 +09:00
rakshasa 4ba24af463 Adding travis file for testing. 2016-03-10 08:27:27 +09:00
Jari Sundell 44f0ac3447 Merge pull request #379 from krichter722/configure_fix
added checkout URL to action-if-not-found of PKG_CHECK_MODULES for li…
2016-03-10 08:12:46 +09:00
rakshasa a92da121d7 Cleaned up XDG_CONFIG_HOME patch. 2016-03-10 04:21:24 +09:00
rakshasa 4fb036f87d Revert "Merge pull request #317 from jlec/tinfo"
This reverts commit b19cf8b4ff, reversing
changes made to 83d7dc8964.
2016-03-10 04:03:56 +09:00
Jari Sundell 6a8d332b4c Merge pull request #306 from gulafaran/master
add support for the XDG base dir spec for rtorrent.rc
2016-03-10 03:34:27 +09:00
Jari Sundell 911596d65e Merge pull request #263 from lotheac/master
don't depend on dirent DT_DIR
2016-03-10 03:30:14 +09:00
Jari Sundell b19cf8b4ff Merge pull request #317 from jlec/tinfo
Try use pkg-config to detect ncurses libraries
2016-03-10 03:21:41 +09:00
Jari Sundell 83d7dc8964 Merge pull request #366 from RecursiveForest/master
change *dl_rate() to *down_rate()
2016-03-10 02:51:00 +09:00
Jari Sundell b89fa31f37 Merge pull request #405 from pyroscope/cmd-ui-current-view
added ui.current_view command
2016-03-09 07:07:31 +09:00
pyroscope 30d8379391 added ui.current_view command 2016-03-08 13:25:04 +01:00
Jari Sundell 605819ea6c Merge pull request #401 from pyroscope/system-env-command
Added system.env=NAME command
2016-03-08 19:24:35 +09:00
pyroscope 1f5e4d37d5 added system.env=NAME command 2016-03-05 03:12:35 +01:00
Karl-Philipp Richter 33601ddc0c added checkout URL to action-if-not-found of PKG_CHECK_MODULES for libtorrent, fixed #377 2016-01-25 08:33:52 +01:00
Samantha Baldwin e1cc736f11 change *dl_rate() to *down_rate() 2015-12-19 01:28:14 -05:00
Jari Sundell 9647749b01 Merge pull request #351 from Micdu70/master
Save downloaded stat of each torrent
2015-11-17 08:00:25 +09:00
Micdu70 06db5776ae Save downloaded stat of each torrent 2015-11-05 18:41:27 +01:00
rakshasa 62cb5a4605 Bumped master to 0.9.6. 2015-09-08 05:12:40 +09:00
rakshasa d4905d512a Merge branch 'master' of github.com:rakshasa/rtorrent 2015-08-08 22:29:31 +09:00
Justin Lecher 9ba4d1d92e Try use pkg-config to detect ncurses libraries
Modern ncurses version provide a pkg-config interface, so let's try to
use it first. This also helps when ncurses provides functions inside
libtinfo.so and thus needs to be linked against it as well.

Signed-off-by: Justin Lecher <jlec@gentoo.org>
2015-07-29 09:32:37 +02:00
Tom Englund 1c47bf6162 add support for the XDG base dir spec for rtorrent.rc 2015-06-23 14:14:27 +02:00
Jari Sundell 50d6437792 Merge pull request #291 from RSully/patch-1
Add load.raw_start_verbose
2015-05-06 02:23:36 +09:00
Ryan eb5443bbad Add load.raw_start_verbose
Fixes #289.
2015-05-04 19:21:25 -04:00
mynamewastaken 1a728fc683 Partially update outdated documentation 2015-03-10 20:33:47 -05:00
Lauri Tirkkonen 0d1dc8a331 don't depend on dirent DT_DIR 2015-01-03 16:20:57 +02:00
rakshasa b5f2cfe393 Renamed mincore instrumentation plotter. 2014-11-09 23:12:46 +09:00
rakshasa 7343e33a6a Added 'log.open_file_pid' and 'log.open_gz_file_pid' commands that appends the pid automatically. 2014-11-04 23:34:51 +09:00
rakshasa e3cc2c601d Use a generic function for logging and allow output groups to be appended.
log.open_file = "instrumentation_memory.log", "/foo/instrumentation_memory.log", "instrumentation_memory", ...
2014-11-04 22:46:35 +09:00
rakshasa 3cf9cffe68 Moved logging commands to a separate file. 2014-11-04 19:48:55 +09:00
Jari Sundell 0ba4d7d943 Merge pull request #243 from salorium/ipv6
d.timestamp.finished for create torrent
2014-11-04 19:37:33 +09:00
Jari Sundell cc10161c90 Merge pull request #232 from hkjn/master
Also mentions that ^o changes destination dir in -help output, like online docs do
2014-11-04 19:37:22 +09:00
salorium d1e807acc5 d.timestamp.finished for create torrent
English (translate):
Adding initialization d.timestamp.finished at the torrent download but is not set seeding. For example when we create a torrent, it is not downloaded.

French:
Ajout de l'initialisation d.timestamp.finished lors que le torrent n'est pas télécharger mais mis en seeding. Par exemple lors que l'on créer un torrent, celui ci n'est pas télécharger.
2014-10-07 08:20:57 +02:00
rakshasa 0df0a6650d Removed ifdef for ipv6. 2014-09-23 18:56:29 +09:00
rakshasa 6c39da6943 Updated authors and readme. 2014-09-15 16:03:10 +09:00
Henrik Jonsson 089fa765b8 Merge branch 'master' of https://github.com/hkjn/rtorrent 2014-09-05 14:49:02 +02:00
Henrik Jonsson 92197d6286 Merge branch 'master' of https://github.com/hkjn/rtorrent 2014-09-05 14:48:57 +02:00
Henrik Jonsson 9937ea27bc Merge branch 'master' of https://github.com/hkjn/rtorrent 2014-09-05 14:47:20 +02:00
Henrik Jonsson b5bff0cb9c Also mentions that ^o changes destination dir in -help output, like http://libtorrent.rakshasa.no/rtorrent/rtorrent.1.html does 2014-09-05 14:47:16 +02:00
Henrik Jonsson 3d166de175 Also mentions that ^o changes destination dir in -help output, like http://libtorrent.rakshasa.no/rtorrent/rtorrent.1.html does 2014-09-04 12:50:47 +02:00
rakshasa 7007973c76 Added ipv6 patch. 2014-08-14 20:56:20 +09:00
rakshasa 7537a3c2a9 Merge branch 'master' of github.com:rakshasa/rtorrent 2014-07-02 23:11:58 +09:00
rakshasa 81c652292a Added updated autoconf scripts. 2014-07-02 23:11:14 +09:00
Jari Sundell f4c312e2c0 Added command name to exception when it is missing '='. 2014-06-24 03:49:15 +09:00
rakshasa 975d001ea7 Merge branch 'pr/127' 2014-06-18 22:06:37 +09:00
Jari Sundell fe9a4e9714 Updated gitignore. 2014-06-18 03:43:32 +09:00
Jari Sundell 52689695ff Merge branch 'master' of git://github.com/rakshasa/rtorrent 2014-06-18 02:59:09 +09:00
Jari Sundell 2a19c613c1 Merge pull request #213 from rakshasa/c++11
C++11
2014-06-18 00:52:16 +09:00
rakshasa dc8e786d58 Merge branch 'master' into c++11
Conflicts:
	src/command_dynamic.cc
	src/command_events.cc
	src/command_groups.cc
	src/command_ip.cc
	src/command_network.cc
2014-06-18 00:44:36 +09:00
rakshasa b8e24b78cd Added missing option strings commands. 2014-06-13 18:24:03 +09:00
rakshasa 4244921383 Added script to generate option strings wiki page. 2014-06-13 18:23:37 +09:00
Jari Sundell afebadcbdf Added '.dirstamp' to gitignore. 2014-06-13 01:32:45 +09:00
rakshasa d74409c2d7 Merge branch 'master' into old_features 2014-06-12 23:03:54 +09:00
rakshasa 1fefc4720b Forgot to commit changes to how ssl_verify_host/peer parameters are converted. 2014-06-12 22:19:33 +09:00
rakshasa 09f6243c6a Cleaned up how ssl_verify_host/peer is set. 2014-06-12 22:08:40 +09:00
rakshasa 390328ec97 Merge branch 'master' into pr/190 2014-06-12 21:43:31 +09:00
rakshasa bfd1a8da8c Updated migration script to handle rutorrent. 2014-05-31 03:18:26 +09:00
rakshasa 4ac807870e Un-deprecate scgi_port/local. 2014-05-28 17:04:06 +09:00
rakshasa 5acfd592f0 Added sed script for converting gui's to the new 0.9 commands. 2014-05-20 17:55:12 +09:00
rakshasa e4e73aeee9 Set deprecated commands to be off by default. If needed use the '-D' option, however note that they will be removed permanently in the future. 2014-05-16 01:14:47 +09:00
rakshasa 8e69930cc4 Changed thread name to included 'rtorrent'. 2014-05-15 23:42:36 +09:00
rakshasa 3b39f37f49 C++11 compatibility fixes. 2014-05-13 23:36:37 +09:00
rakshasa 4f36c3e49f Merge remote-tracking branch 'origin/master' into xirvik 2014-05-09 18:05:56 +09:00
rakshasa e42ec54920 Bumped scgi listen queue to 100. 2014-05-09 18:05:30 +09:00
rakshasa 6a3234eaa7 Bumped to 0.9.4. 2014-05-09 17:54:04 +09:00
rakshasa ce5d67a9c0 Merge branch 'master' into xirvik 2014-05-03 00:28:14 +09:00
rakshasa d396c8e058 Changed rpc log types. 2014-04-25 19:55:47 +09:00
rakshasa 904a390fba Merge branch 'master' into xirvik 2014-04-25 17:25:04 +09:00
rakshasa 9548e08935 Removed debugging exceptions. 2014-04-25 17:24:42 +09:00
rakshasa 696c2b2b33 Merge branch 'master' into xirvik 2014-04-21 22:34:45 +09:00
rakshasa ce125b1c54 Updated instrumentation plot. 2014-04-21 22:33:47 +09:00
rakshasa 82a68420f4 Fixed non-POSIX conformant included headers. 2014-04-18 22:27:13 +09:00
rakshasa d9f6f5aef4 Cleaned up CurlStack. 2014-04-18 22:16:24 +09:00
Mike Valentine 24f84214c8 Added config parameter network.http.ssl_verify_host to support certificates.
Added config parameter network.http.ssl_verify_host to support certificates
with a mismatched or empty CN. Default is 2 (verify name match). Use 1 to simply
verify the presence of a name or 0 to allow for missing names.
2014-04-12 14:06:22 -04:00
rakshasa 38f39bdb23 Added unordered curve to plot. 2014-04-10 22:32:07 +09:00
rakshasa 906683714b Updated instrumentation transfers plot script. 2014-04-10 22:00:46 +09:00
rakshasa a536fc09a0 Updated autoconf scripts. 2014-04-01 11:49:19 +02:00
rakshasa dea7c80996 Updated instrumenation transfer plot script. 2014-04-01 01:03:44 +02:00
rakshasa 3e3a84b3a0 Added 'network.listen.backlog{,.set}' commands. 2014-03-23 14:46:10 +01:00
rakshasa 866289b38a Updated email address. 2014-01-28 23:29:05 +09:00
rakshasa c9e894982f Merge branch 'master' of github.com:rakshasa/rtorrent 2013-11-28 01:53:41 +09:00
rakshasa 6b7adfd6bd Added scripts for gnuplot. 2013-11-28 01:53:20 +09:00
Jari Sundell fcd1fdb2fe Merge pull request #164 from artagnon/doc
Janitorial documentation work
2013-11-26 09:59:22 -08:00
Ramkumar Ramachandra a5d92cc940 rtorrent.1.xml: nuke deprecated stop_on_ratio
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
Ramkumar Ramachandra 9fcef7fbd6 rtorrent.1.xml: nuke a bunch of deprecated on_* functions
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
Ramkumar Ramachandra effdc5642d rtorrent.1.xml: document (max|min)_(uploads|downloads)
Only max_uploads was documented previously.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
Ramkumar Ramachandra fe5439f6a0 rtorrent.1.xml: document set_* functions for throttle
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
Ramkumar Ramachandra 58fba68aff rtorrent.1.xml: add more DHT variables
Use TODO placeholders for the moment.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
Ramkumar Ramachandra 89dfa3a268 rtorrent.1.xml: clearly demarcate DHT settings
DHT stuff is clearly demarcated in the code, so let the manual also
follow along.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
Ramkumar Ramachandra 0d620e77db rtorrent.1.xml: remove schedule and schedule_remove
They were deprecated a long time ago.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
2013-11-26 23:24:36 +05:30
rakshasa 55b826d6cb Added brackets around configure parameters. 2013-11-22 23:20:50 +09:00
rakshasa 385b342deb Fixed typo in IPv6 option. 2013-11-22 23:03:00 +09:00
rakshasa 2e9baa1635 Added logging of some ui events. 2013-11-06 23:23:20 +09:00
rakshasa 67236d7757 Fixed an issue with input window. 2013-11-06 23:22:54 +09:00
rakshasa 66edb39863 Added 'log.open_gz_file' option. 2013-08-30 00:09:08 +09:00
rakshasa 00a349f68c Added slot_call_list. 2013-08-27 23:18:31 +09:00
rakshasa 370bae4b98 Removed all dependencies on sigc++. 2013-08-27 00:43:23 +09:00
rakshasa 323f0df30c Merge branch 'master' into xirvik 2013-08-26 23:48:23 +09:00
rakshasa aa93404278 Added subdirs option to suppress warnings. 2013-08-26 23:47:31 +09:00
rakshasa 1e4739c862 Merge branch 'master' into xirvik 2013-08-26 23:17:56 +09:00
rakshasa aa2f784ae6 Converted sigc::signals to STL. 2013-08-26 23:15:33 +09:00
rakshasa 529eda5aab Converted sigc++ slots to std::tr1::function. 2013-08-24 00:14:25 +09:00
rakshasa 629ebcbd54 Removed deprecated signals for chunks passed/failed. 2013-08-22 03:48:54 +09:00
rakshasa d8d7861244 Removed old logging signals. 2013-08-22 03:33:48 +09:00
Jari Sundell bc4209e380 Merge pull request #128 from skydrome/automake-1.12
Fix warning on automake-1.12.4
2013-08-21 07:08:34 -07:00
rakshasa e36a0d43a4 Added missing <unistd.h> include. 2013-08-21 22:59:54 +09:00
rakshasa c3ad68156e Adding test output file gitignore. 2013-08-16 22:11:32 +09:00
rakshasa 6697806185 Use pid and ppid to XOR the seed value for random and rand48. 2013-08-16 16:29:59 +09:00
rakshasa 412a2f79b9 Removed obsolete logging facility. 2013-07-31 23:24:02 +09:00
rakshasa 0bf60679e4 Changed file permissions for log_stats.plot. 2013-07-31 06:17:13 +09:00
rakshasa 0329608f69 Merge remote-tracking branch 'origin/master' into xirvik 2013-06-13 23:08:15 +09:00
skydrome b113a02584 Fix warning on automake-1.12.4
warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
2013-05-09 14:00:09 -04:00
Jorge Israel Peña 49d00285c8 added SA_RESTART to automatically restart system calls interrupted by signals (as was already done by signal()) as well as error checking on sigaction() 2013-04-07 21:21:27 -07:00
Jorge Israel Peña 2cd70f4342 replace signal() call with sigaction() for better portability
signal() is known to have portability problems. Some systems such as
old Unix systems and System V employ a behavior in which the signal
disposition is reset to SIG_DFL (default) upon invocation of a signal
handler by the delivery of a signal.

See issue #51 in which Solaris users experience signal-based issues.

Solaris is a system which employs the SIG_DFL reset behavior even in
version 11.1.

See http://docs.oracle.com/cd/E26502_01/html/E29034/signal-3c.html

> If signal() is used, disp is the address of a signal handler, and sig is not SIGILL,
> SIGTRAP, or SIGPWR, the system first sets the signal's disposition to SIG_DFL before
> executing the signal handler.

On Solaris the default signal disposition for SIGUSR1 is to exit the application.

See http://docs.oracle.com/cd/E26502_01/html/E29033/signal.h-3head.html

If I'm correct in assuming this is the problem Solaris users are encountering,
the solution to this (and likely any other portability issues that may arise)
is to use sigaction() which has explicitly defined behavior as per the POSIX standards.

As you can see, it's a pretty drop-in solution. In fact, on some systems such as Linux,
glibc defines signal() as a wrapper around sigaction() to use BSD semantics (i.e. not the
behavior detailed above), which is likely why few others have experienced these problems.

See http://man7.org/linux/man-pages/man2/signal.2.html
2013-04-07 19:41:32 -07:00
rakshasa 7689059dbc Cleaned up thread code. 2013-04-03 21:16:11 +09:00
rakshasa 3b2a47a6d0 Use thread_base::interrupt for all SIGUSR1 interrupt signals and don't set a handler if it's not supported. 2013-03-03 05:00:31 +09:00
rakshasa e28692492b Fixed obsolete macro statements. 2013-02-26 17:44:42 +09:00
rakshasa 2c97841e92 Removed unused member variables. 2013-02-26 17:40:41 +09:00
rakshasa bb27adcfd3 Merge branch 'master' into xirvik 2012-10-31 17:55:44 +09:00
rakshasa 5e6cb5da04 Merge branch 'master' of github.com:rakshasa/rtorrent 2012-10-24 14:35:59 +09:00
rakshasa cd029a67c5 Bumped version to 0.9.3. 2012-10-23 22:39:07 +09:00
Jari Sundell addc323ec8 Merge pull request #89 from ShanaTsunTsunLove/master
Typo in rtorrent.rc
2012-09-05 12:14:54 -07:00
Mateusz Kowalczyk 2217b14095 Typo in default rtorrent.rc comment 2012-08-28 12:35:10 +01:00
rakshasa 6a84facae0 Merge branch 'master' of github.com:rakshasa/rtorrent 2012-08-14 17:56:24 +09:00
rakshasa 66a116841a Removed old options. 2012-08-14 17:55:31 +09:00
rakshasa bacb6c0f72 Removed unused variables. 2012-07-23 23:54:21 +09:00
Jari Sundell 40fc8bbf80 Merge pull request #79 from nullren/master
Restore create_link and delete_link.
2012-07-10 23:21:25 -07:00
nullren 13f672ab4d using lt_log_print
replaced push_log_std with lt_log_print using LOG_TORRENT_WARN.
2012-06-27 00:19:09 -07:00
rakshasa 2967f9a224 Cleaned up old documents and scripts. 2012-06-27 15:43:32 +09:00
nullren eac7536f6a restored create_link
took away empty-body warnings from clang by restoring error messages
using push_log_std.
2012-06-23 20:21:47 -07:00
rakshasa 78f64a3e08 Use internal_error for priority queue exceptions. 2012-05-31 20:16:26 +09:00
rakshasa cf77a17399 Cleaned up command wrappers. 2012-05-22 17:19:19 +09:00
rakshasa 7a2ec0ff86 Merge branch 'master' into xirvik 2012-05-21 16:12:00 +09:00
rakshasa 48733c84ec Added 'catch' command to allow safely calling commands that might fail with input_error. Note that double-brackets are required as the method needs to be called by the 'catch' command, not the parser.
catch = ((foo.bar,"bad input"))
2012-05-21 16:08:49 +09:00
rakshasa b020aa0197 Pass command target when using rpc::call_object with dict_key. 2012-05-21 16:08:18 +09:00
rakshasa e95b66fc51 Merge branch 'master' into xirvik 2012-05-14 20:18:48 +09:00
rakshasa 678049bc09 Fixed brackets in autoconf scripts. 2012-05-14 20:18:29 +09:00
rakshasa 2f102f0fcd Merge branch 'master' into xirvik 2012-05-14 19:41:36 +09:00
rakshasa d0f6bb440a Fixed clang compilation issues. 2012-05-07 02:25:37 +09:00
rakshasa 8f5f383e3c For POSIX threads config script try none first to avoid adding flags when not needed. 2012-05-07 02:19:12 +09:00
rakshasa 2ca49e3485 Removed unused parse command function. 2012-05-07 01:53:39 +09:00
rakshasa 004862850d Allow command function lists for dynamically created functions. 2012-05-04 22:56:58 +09:00
rakshasa d2d09d97f8 Replace old command call functions with the new one taking torrent::Objects. 2012-05-04 22:33:26 +09:00
rakshasa fb75510c0f Allow functions and lists of functions to be passed to view.event_{added,removed}. 2012-05-04 21:31:12 +09:00
rakshasa 8d0f9b3300 Removed old hanshake log signal. 2012-05-04 05:17:11 +09:00
rakshasa 76ed90f514 Removed commented out settings for views. 2012-05-04 05:09:21 +09:00
rakshasa b79dea94b2 Wait for disowned http requests to finish to ensure stopped event gets sent to tracker on client shutdown. 2012-05-04 04:02:59 +09:00
rakshasa cf1c44ef5b Removed sigc++ dependency from ConnectionManager. 2012-05-04 04:02:59 +09:00
rakshasa 6d61cc09c3 Merge branch 'master' into xirvik 2012-05-01 00:56:52 +09:00
rakshasa f1ece0ae12 Wait for disowned http requests to finish to ensure stopped event gets sent to tracker on client shutdown. 2012-05-01 00:29:50 +09:00
Jari Sundell 9df9183a0c Merge pull request #45 from SineSwiper/master
New rtorrent_fast_resume script
2012-04-27 00:41:12 -07:00
rakshasa 75933db69b Merge branch 'master' into xirvik 2012-04-26 21:23:08 +09:00
rakshasa f373b20c1b Removed old handshake logging functions. 2012-04-26 21:22:35 +09:00
rakshasa efa3c670a5 Merge branch 'master' into xirvik 2012-04-25 22:23:38 +09:00
rakshasa 22acdd87c3 Print backtrace for internal_error. 2012-04-25 22:23:15 +09:00
rakshasa c46ee642fe Merge branch 'master' into xirvik 2012-04-25 21:47:12 +09:00
rakshasa cca1f21471 Added logging of segfault/bus signal and backtrace to LOG_CRITICAL. 2012-04-25 21:46:23 +09:00
rakshasa 27888e73bc Changed to latest version. 2012-04-23 16:14:06 +09:00
rakshasa 4dd7582240 Bumped version to 0.9.2. 2012-04-20 16:03:55 +09:00
rakshasa 03c0a4e18c Allow tilde for 'log.open_file' path. 2012-04-18 17:32:12 +09:00
rakshasa c2b768cd6d Minor updates to choke group documentation. 2012-04-18 16:55:30 +09:00
rakshasa 097e3d9056 Merge branch 'master' into xirvik 2012-04-16 17:07:32 +09:00
rakshasa 63cf700593 Updated documentation for choke groups. 2012-04-16 17:06:53 +09:00
rakshasa 0132ce6b81 Merge branch 'master' into xirvik 2012-04-16 00:43:20 +09:00
rakshasa 17201984a6 When 'throttle.max_*.global.*.set' commands are called they will automatically update the libtorrent settings, so it is no longer needed to set the throttle to force this update. 2012-04-16 00:40:47 +09:00
rakshasa a7b7b26d08 Merge branch 'master' into xirvik 2012-04-13 20:54:58 +09:00
rakshasa 0a9e03df57 Added logging of options for created torrents. 2012-04-13 20:53:57 +09:00
rakshasa 90830dc765 Use right function argument for inotify test. 2012-04-12 18:44:42 +09:00
rakshasa 0b39455a4b Merge branch 'master' into xirvik 2012-04-12 15:30:12 +09:00
rakshasa d2dd143d2e Added 'throttle.update' to force 'throttle.max_{up,down}loads.global' setting to take effect. 2012-04-12 15:29:07 +09:00
rakshasa b71b44dbd6 Merge branch 'master' of github.com:rakshasa/rtorrent 2012-04-11 19:27:17 +09:00
Jari Sundell 83294e2198 Merge pull request #53 from taylorchu/master
Sigc++ header cleanup.
2012-04-11 03:26:45 -07:00
rakshasa 46862e23a9 Added ENODEV to "error_number.h". 2012-04-11 19:24:24 +09:00
taylorchu 077288407f fix build after removing sigc++ for download.cc 2012-04-10 15:42:45 -07:00
rakshasa 05d16707d4 Merge branch 'master' into xirvik 2012-04-10 21:46:51 +09:00
rakshasa 3fe1a734ac Differentiate scrape and normal requests in the tracker list. 2012-04-10 15:38:41 +09:00
rakshasa 9c2745ecb3 Added missing return value to watched command. 2012-04-10 15:38:07 +09:00
rakshasa e79b38f907 Merge branch 'master' into xirvik 2012-04-09 15:39:14 +09:00
rakshasa fdc6ee56de Removed sigc++ signal from ConnectionList. 2012-04-07 15:06:25 +09:00
rakshasa 36f8e5d349 Use TR1 slots instead of sigc++ for DownloadInfo events. 2012-04-07 03:37:37 +09:00
rakshasa 5bed4f01ad Added tracker related commands. 2012-04-04 02:49:05 +09:00
rakshasa 020de10f38 Return hex instead of binary for 'd.chunks_seen'. 2012-04-04 02:09:08 +09:00
rakshasa 7343c0d67c Merge branch 'master' into xirvik 2012-04-02 16:05:26 +09:00
rakshasa b28f2ea807 Added 'd.chunks_seen', which is limited to 'Download::peers_accounted()' number of peers for optimization reasons. 2012-04-01 02:22:18 +09:00
rakshasa 9aa54d2344 Added 'directory.watch.added'. 2012-03-29 23:04:17 +09:00
rakshasa 6141a5656f Merge branch 'master' into xirvik 2012-03-29 22:06:11 +09:00
rakshasa dc817e24e4 Added inotify autoconf script. 2012-03-29 22:05:43 +09:00
rakshasa d1ff1fe77c Solaris compatibility fixes. 2012-03-26 23:18:10 +09:00
rakshasa 51fff1fdc5 Fixed version number. 2012-03-26 16:26:56 +09:00
SineSwiper 47d36c0690 Add new version of rtorrent_fast_resume.pl
Add torrent_data script to peek at torrent contents
2012-03-25 16:54:02 -04:00
rakshasa 07d326535d Merge branch 'master' into xirvik 2012-03-21 01:25:05 +09:00
rakshasa bb75f06c6d Replaced std::placeholders with tr1::placholders. 2012-03-21 01:24:35 +09:00
rakshasa 04acc8a0af Converted std::bind calls to tr1::bind. 2012-03-21 01:22:25 +09:00
rakshasa 0514a5c0d1 Merge branch 'master' into xirvik 2012-03-21 00:09:58 +09:00
rakshasa f1cd0f4780 Added 'system.api_version', which will be incremented every time the API changes. (sans brainfarts) 2012-03-21 00:05:37 +09:00
rakshasa ece90f975b Initiate worker thread after initializing libtorrent to ensure logging is properly done. 2012-03-20 23:52:32 +09:00
rakshasa 89611a222c Merge branch 'master' into xirvik 2012-03-19 19:05:01 +09:00
rakshasa 2c72c31e1c Since logs are now thread-safe, allow all threads to push log messages. #43 2012-03-19 15:33:50 +09:00
rakshasa cf3a1674a3 Merge branch 'master' into xirvik
Conflicts:
	configure.ac
2012-03-16 18:02:38 +09:00
rakshasa 64c66c81ae Bumped version to 0.9.1. 2012-03-16 18:01:19 +09:00
rakshasa bc993807d1 Merge branch 'master' into xirvik 2012-03-13 21:10:49 +09:00
rakshasa 3ac22e4bc7 Bumped default max file size to 128Gb. 2012-03-12 21:30:43 +09:00
rakshasa 3d1b0b5971 Cleaned up old log code. 2012-03-12 20:55:29 +09:00
rakshasa 7e0d5956b5 Use new logging buffer for complete log view. 2012-03-12 20:41:19 +09:00
rakshasa a186932c03 Use log_buffer for console logs. 2012-03-12 04:09:18 +09:00
Jari Sundell 79e9990669 Merge pull request #38 from sochotnicky/master
Without this change build will fail when using gold linker
2012-03-08 06:20:45 -08:00
Stanislav Ochotnicky 31ba6341cf Fix build with gold linker
This is needed for certain optimization levels with llvm
2012-03-08 11:00:57 +01:00
rakshasa 6b71d75c33 Test against both libtinfo and libtinfow. 2012-02-27 19:54:53 +09:00
rakshasa 4ff2483f07 Fixed libtinfow detection. 2012-02-27 17:40:08 +09:00
rakshasa d8f41a28fa Added check to see if libinfow is required by ncursesw. 2012-02-27 01:22:47 +09:00
rakshasa 482a9ba09f Used AX_PTHREAD and AX_WITH_CURSES macros. 2012-02-24 16:22:17 +09:00
rakshasa f7403d30e9 Merge branch 'master' into xirvik 2012-02-22 16:50:48 +09:00
rakshasa 639af87e53 Use new logging API. 2012-02-21 15:37:50 +09:00
rakshasa 6a45ca2dd6 Merge branch 'master' into xirvik 2012-02-18 02:22:48 +09:00
rakshasa 78abb7fed1 Reorder libraries for the unit test. 2012-02-18 02:21:17 +09:00
rakshasa 2da20f984e Merge branch 'master' into xirvik 2012-02-17 14:05:28 +09:00
rakshasa 1b4d8f9626 Removed old thread test code. 2012-02-16 15:08:30 +09:00
rakshasa a0ce6c09a6 Merge branch 'master' into xirvik 2012-02-15 13:15:13 +09:00
rakshasa 4bcf7f4f5e Added 'ipv4_filter.dump'. 2012-02-15 13:14:57 +09:00
rakshasa 45d2d0bd49 Added type names to events. 2012-02-14 19:37:21 +09:00
rakshasa 26581c74c1 Merge branch 'master' into xirvik 2012-02-14 13:38:47 +09:00
rakshasa 7fe2fb1584 Properly initialize the main poll object. 2012-02-14 13:38:27 +09:00
rakshasa d4cbe5294d Cleaned up formating. 2012-02-14 00:55:19 +09:00
rakshasa 0cbc11b536 Merge branch 'master' into xirvik 2012-02-13 19:08:14 +09:00
rakshasa d4a3ec0224 Add logging for IP addresses added. 2012-02-13 19:07:53 +09:00
rakshasa f50358b284 Merge branch 'master' into xirvik 2012-02-13 17:17:07 +09:00
rakshasa 4f601fda79 Use intermediate std::string to store the arguments to work around a possible bug. 2012-02-13 17:15:54 +09:00
rakshasa 8ed8ee9f81 Merge branch 'master' of github.com:rakshasa/rtorrent 2012-02-13 11:53:43 +09:00
Jari Sundell 2178422d90 Merge pull request #30 from extravagant/autoconf-2-68
Updated with AC_LANG_SOURCE directives
2012-02-12 18:45:59 -08:00
Extravagant f1852cd222 Updated with AC_LANG_SOURCE directives
Please see this informative thread on bug-autoconf:
http://www.mail-archive.com/bug-autoconf@gnu.org/msg03052.html
2012-02-12 22:23:40 +00:00
rakshasa 47125b9c38 Moved main thread object to libtorrent. 2012-02-12 21:58:16 +09:00
rakshasa 9ad22ab8ff Fixed log syntax. 2012-02-12 15:11:26 +09:00
rakshasa ba30dcd7cf Added names to threads. 2012-02-11 19:14:22 +09:00
rakshasa 4632053301 Added 'ip_tables.size_data'. 2012-02-11 18:52:46 +09:00
rakshasa 309711025b Cleaned up some code. 2012-02-11 16:17:13 +09:00
rakshasa 53edee3e06 Merge branch 'xirvik' of github.com:rakshasa/rtorrent-xirvik into xirvik 2012-02-08 15:16:02 +09:00
rakshasa cfc4984c3a Reverted version to stable. 2012-02-08 15:15:09 +09:00
Jari Sundell 6a399cd927 Merge remote branch 'upstream/master' into xirvik
Conflicts:
	.gitignore
2012-02-05 07:00:27 -05:00
rakshasa be95b82d29 Potential fix to the issue of torrents remaining closed after final hashing. 2012-01-30 00:29:06 +09:00
rakshasa 74ea256036 Updated gitignore files. 2012-01-29 22:31:51 +09:00
Jari Sundell 79517e61aa Merge branch 'master' into xirvik 2012-01-19 01:20:52 +09:00
Jari Sundell 222018e395 Removed obsolete 'system.hash.read_ahead', 'system.hash.interval' and 'system.hash.max_tries'. 2012-01-09 21:49:27 +09:00
Jari Sundell 18d51a60a1 Exit the autogen.sh script if one of the commands fail. 2012-01-05 13:30:47 +09:00
Jari Sundell e58f3975f1 Fixed compiler issues with clang. 2011-12-29 18:58:12 +09:00
Jari Sundell 002833f7b7 Fixed compile issues with C++03. 2011-12-27 17:26:36 +09:00
Jari Sundell 0626dcf783 C++11 fixes. 2011-12-27 16:45:19 +09:00
Jari Sundell f51b280cbf Merge branch 'master' into c++11 2011-12-27 15:50:01 +09:00
Jari Sundell 4c29d3b714 Removed extra semicolon. 2011-12-26 14:32:45 +09:00
Jari Sundell 28634f2c8c Added slot for poll creation. 2011-12-21 01:54:29 +09:00
Jari Sundell 007d83e904 Moved code from ThreadBase to torrent::thread_base. 2011-12-19 03:20:42 +09:00
Jari Sundell 5b7a2b5e95 Moved setting of PTHREAD related variables outside of the macro. 2011-12-19 03:19:54 +09:00
Jari Sundell 1c1993acef Cleaned up code. 2011-12-14 13:38:16 +09:00
Jari Sundell 1fc70a733d Merge branch 'master' into c++11
Conflicts:
	src/core/manager.cc
	src/thread_base.cc
2011-12-13 19:49:10 +09:00
Jari Sundell ee859a6137 Removed deprecated PollManager files. 2011-12-12 03:32:36 +09:00
Jari Sundell 4d1f5dce67 Fixed poll arguments. 2011-12-12 02:58:16 +09:00
Jari Sundell 6dfd2fe0cd Moved polling code to libtorrent. 2011-12-12 01:46:09 +09:00
Jari Sundell 89213982d5 Moving thread code to libtorrent. 2011-12-12 00:03:50 +09:00
Jari Sundell 2d8036e3a8 Use new API call. 2011-12-11 17:52:10 +09:00
Jari Sundell a2ad162fe3 Don't display scrape requests. 2011-12-11 15:41:05 +09:00
Jari Sundell 21944b941a Make sure we don't access freed memory if a download is erased during the erased event. 2011-12-11 12:21:24 +09:00
Jari Sundell 081b5e9cb2 Removed old file entry. 2011-12-10 22:58:02 +09:00
Jari Sundell 1bbb7aa793 Bumped version. 2011-12-09 20:05:49 +09:00
Jari Sundell 4353f1bfa8 Highlight busy trackers in an easier to see way. 2011-12-09 03:01:53 +09:00
Jari Sundell 6a444ab4de Added unittest script to gitignore. 2011-12-07 16:09:13 +09:00
Jari Sundell 41d49b7c18 Merge branch 'master' into c++11
Conflicts:
	src/command_network.cc
2011-12-07 16:08:05 +09:00
Jari Sundell 3c4d21d34c Merge branch 'master' into xirvik 2011-12-07 02:31:56 +09:00
Jari Sundell 0b05196e32 Added a missing header. 2011-12-03 13:06:15 +09:00
Jari Sundell a120b8e9cf Moved some stuff out of command_network.cc to make it compile faster. 2011-12-02 22:54:52 +09:00
Jari Sundell d8aa1cd28b Display promiscuous and failure mode in tracker display. 2011-12-01 02:26:48 +09:00
Jari Sundell b2c1fe2afb Fixed stray comma in script causing invalid LT_SMP_CACHE_BYTES value to be set. 2011-11-30 19:34:29 +09:00
Jari Sundell ae14fcabde Cleaned up tracker list display. 2011-11-30 00:53:07 +09:00
Jari Sundell 79c93762f5 Added display of requesting status. 2011-11-29 02:24:48 +09:00
Jari Sundell 5a2a2e8a68 Show number of peers received from trackers. 2011-11-29 00:38:44 +09:00
Jari Sundell a40b2132fb Added autoconf scripts for pthread. 2011-11-28 18:27:24 +09:00
Jari Sundell 2be9a874c7 Added counter for new peers each tracker received last request. 2011-11-28 02:25:48 +09:00
Jari Sundell 0d648119d2 Merge branch 'master' into xirvik 2011-11-26 01:47:03 +09:00
Jari Sundell 9a9dcb88f7 Merge branch 'master' into c++11 2011-11-26 01:44:52 +09:00
Jari Sundell 6c10f7e05d Use new Http API. 2011-11-26 01:38:47 +09:00
Jari Sundell 7b150ec834 Made d.multicall safe for deletion of downloads. 2011-11-25 02:21:44 +09:00
Jari Sundell e11be5cdbe Fixed some compile issues. 2011-11-22 16:46:59 +09:00
Jari Sundell 58727fe7fd Fixed compiler issues with gcc-4.6 c++0x. 2011-11-18 17:28:50 +09:00
Jari Sundell 9507bd82f4 Use a safe slot list callback function. 2011-11-17 10:13:46 +09:00
Jari Sundell 308d91f817 Replaced sigc++ calles for torrent::Http with tr1::bind. 2011-11-17 01:06:52 +09:00
Jari Sundell f0da99b5c3 Merge branch 'master' into xirvik 2011-11-08 01:10:14 +09:00
Jari Sundell 00a42357d0 Added 'd.tracker.send_scrape = <seconds_to_request>' command for sending scrape requests to all trackers that support it.
Newly inserted downloads send scrape requests after 30 seconds.
2011-11-08 01:03:29 +09:00
Jari Sundell f4c3758dcd Added more scrape information to tracker info. 2011-11-08 01:03:20 +09:00
Jari Sundell 575968b291 Use new function for inserting tracker. 2011-11-08 01:03:10 +09:00
Jari Sundell c55f5611a9 Added 'd.tracker.send_scrape = <seconds_to_request>' command for sending scrape requests to all trackers that support it.
Newly inserted downloads send scrape requests after 30 seconds.
2011-11-08 00:45:11 +09:00
Jari Sundell 52530d5538 Added more scrape information to tracker info. 2011-11-07 21:34:06 +09:00
Jari Sundell 8d4aed7dae Use new function for inserting tracker. 2011-11-06 23:14:06 +09:00
Jari Sundell 7b38cc29aa Merge branch 'master' into xirvik 2011-11-06 03:38:37 +09:00
Jari Sundell eb90b92930 Added 'd.tracker.insert = <tracker_group>, <tracker_url>' for adding trackers to a download. 2011-11-05 22:19:57 +09:00
Jari Sundell a73509a799 Updated use of torrent::Tracker API. 2011-11-05 18:55:01 +09:00
Jari Sundell ed6182589a Removed deprecate tracker focused_index function calls. 2011-11-04 02:24:57 +09:00
Jari Sundell 47c03c8717 Updated rak/timer.h. 2011-11-03 03:36:59 +09:00
Jari Sundell 31495b06be Merge branch 'master' into xirvik 2011-10-27 13:44:32 +09:00
Jari Sundell 682cd56d18 Don't use the old TrackerList focus function when retrieving active tracker. 2011-10-26 22:30:56 +09:00
Jari Sundell 413becea38 Added some autoconf files to '.gitignore'. 2011-10-22 18:47:43 +09:00
Jari Sundell 931b9c848c Added 'network.listen.port'. 2011-10-21 20:24:35 +09:00
Jari Sundell e9a065f9d8 Make rtorrent compatible with the latest HEAD. 2011-10-17 13:09:26 +09:00
Jari Sundell d7fddfe718 Display tracker success/failed counters. 2011-10-10 17:16:53 +09:00
Jari Sundell 9c6aa138fd Merge branch 'master' of github.com:rakshasa/rtorrent 2011-10-09 19:24:30 +09:00
Jari Sundell dcf9c5a0fc Properly detach from background process. 2011-10-09 19:23:30 +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
Jari Sundell fd82d21290 Merge branch 'master' of github.com:rakshasa/rtorrent 2011-10-09 15:03:23 +09:00
Jari Sundell 8a9187796c Updated copyright information. 2011-10-09 15:02:24 +09:00
rakshasa 34d006c492 Adding .gitignore file.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1299 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-09 05:21:19 +00:00
Jari Sundell 1f149b4b3a Merge branch 'tracker_refactoring' 2011-10-09 14:20:52 +09:00
Jari Sundell 77016e4425 Merge branch 'master' of github.com:rakshasa/rtorrent 2011-10-07 10:54:12 +09:00
Jari Sundell 11c107560b Adding .gitignore file. 2011-10-07 10:53:33 +09:00
Jari Sundell 83e898e032 Updated to new API. 2011-10-06 23:44:28 +09:00
rakshasa ba09df1afc Moved the sanity checks for 'd.directory.set' to 'Download::set_root_directory(path)' so that it always gets used.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1297 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-04 15:44:00 +00:00
Jari Sundell a3896f9094 Merge branch 'master' of github.com:rakshasa/rtorrent 2011-10-04 23:05:40 +09:00
Jari Sundell fa5224bf7f Moved the sanity checks for 'd.directory.set' to 'Download::set_root_directory(path)' so that it always gets used. 2011-10-04 22:52:35 +09:00
rakshasa 6a0c82529f Added '__builtin_popcount' check to 'configure.ac' as 'rak/algorithms.h' needs it.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1295 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-03 11:28:42 +00:00
Jari Sundell 670d459300 Merge branch 'master' of github.com:rakshasa/rtorrent 2011-10-03 20:28:07 +09:00
Jari Sundell aaa5586088 Added '__builtin_popcount' check to 'configure.ac' as 'rak/algorithms.h' needs it. 2011-10-03 20:25:02 +09:00
rakshasa 75124f79e1 Removing unneeded TODO file.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1294 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-03 04:21:20 +00:00
Jari Sundell 92b7295303 Removing unneeded TODO file. 2011-10-03 13:20:33 +09:00
rakshasa 3e244f9f93 Added <limits> to 'rak/algorithm.h' headers.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1293 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-03 00:39:23 +00:00
rakshasa 0784d6540f * Switched to using '__builtin_popcount' for counting bits in bitfield.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1292 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-02 15:57:22 +00:00
rakshasa 5f21e207c3 * Unlink the target filename of 'network.scgi.open_local' before opening.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1291 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-02 13:24:59 +00:00
rakshasa 80c97c398b * Clearing out lots of old tickets and small bug reports.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1290 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-02 12:32:28 +00:00
rakshasa 1a3602012e * Added support for Cyrus RC4 to work around an OpenSSL RC4 bug.
* Added manual for logging facilities.

* Fixed bugs in the choking code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1288 e378c898-3ddf-0310-93e7-cc216c733640
2011-10-02 11:50:39 +00:00
rakshasa ecb77ad7bf * Support conversion from Object dict_key type to XMLRPC.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1287 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-26 02:02:35 +00:00
rakshasa 4e3ecc01b2 * Changed tracker logging to use the new logging facilities.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1286 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-25 13:25:36 +00:00
rakshasa 3c75a150db * Added 't.success_time_last' and 't.failed_time_last'.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1285 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-21 08:44:46 +00:00
rakshasa 4914d798f1 * Changing push_log calls to the new logging facility.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1284 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-21 05:07:06 +00:00
rakshasa 156d69c854 * Added 'log.open_file' and 'log.add_output' options for using the new logging facilities.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1283 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-21 02:38:05 +00:00
rakshasa 6faea70de2 * Added options for max_uploads and max_downloads.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1277 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-13 01:42:14 +00:00
rakshasa 1e83c626f8 * Refactoring of choke_queue and how choking is handled.
* Added 'd.{up,down}loads_{max,min}', and the keys 1/2/3/4 and !/@/#/$ control these.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1274 e378c898-3ddf-0310-93e7-cc216c733640
2011-09-07 03:53:38 +00:00
rakshasa 1b49dcb9e0 * More clang warnings fixed.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1273 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-23 16:59:27 +00:00
rakshasa e239b673cf * Properly detect issues with 'd.directory.set' being called after the data files have been moved.
* Added counters for unchoked peers.

* CLang fixes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1272 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-21 15:04:22 +00:00
rakshasa c1eccb4bd7 * Fixed 'log.execute'.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1270 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-17 04:30:23 +00:00
rakshasa 7680277eee * Moving over some cosmetic changes from a patchset.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1269 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-13 09:38:26 +00:00
rakshasa dfc159f67a * Fixed dummy choke groups default heuristics and other minor issues.
* Added 'd.group.name'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1267 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-10 01:39:10 +00:00
rakshasa 847d1ae081 * Fixed strings.choke_heuristics.* typo.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1266 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-08 10:33:27 +00:00
rakshasa c7ad0a90da * Fixed 'network.http.dns_cache_timeout{,.set}'.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1265 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-07 11:06:29 +00:00
rakshasa ea192b342c * Fixed 'd.group.set' for the mainline version.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1264 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-06 08:01:09 +00:00
rakshasa ce16621707 * Fixed a potential issue causing high loads while waiting for main thread to exit polling. #2661
* Added 'strings.choke_heuristics.{upload,download}' and extra dummy upload/download heuristics for testings.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1263 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-06 05:20:18 +00:00
rakshasa 882a64af77 * Bumped the number of incoming connections for SCGI.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1262 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-04 06:21:06 +00:00
rakshasa 3f41f9384d * Added 'network.http.dns_cache_timeout{,.set}' commands to allow for disabling the libcurl dns caching.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1261 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-03 09:29:03 +00:00
rakshasa adef434bc3 * Added 'd.disconnect.seeders' and 'd.accepting_seeders{,.enable,.disable}' commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1260 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-02 06:09:37 +00:00
rakshasa 88260e4989 * Added missing <cstdio> and <string> headers.
* Added 'd.wanted_chunks' command.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1259 e378c898-3ddf-0310-93e7-cc216c733640
2011-08-01 02:51:13 +00:00
rakshasa a6678a4591 * Adding wanted_chunks.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1257 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-30 13:55:34 +00:00
rakshasa f5a141ac5f * Moved bitfields to torrent/utils/download_info.h and made rak/ranges.h part of the API.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1256 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-30 11:40:09 +00:00
rakshasa 7ff232848a * Minor fixes to the choke group implementation.
* Added some documentation.

* Fixed a compiler bug on gcc-4.6.1.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1255 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-29 12:09:29 +00:00
rakshasa b64b975ad4 * Split out parts of command_network.cc to make is easier to compile.
* Moved the iptos and encryption strings to option_strings.cc.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1254 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-27 23:37:10 +00:00
rakshasa ca0e3f66a6 * Trace back SIGBUS errors to the download, file and offset.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1253 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-25 11:00:45 +00:00
rakshasa 520d25a19d * Fixed cg_get_index type.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1251 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-20 13:05:25 +00:00
rakshasa a5ed856f01 * Using sigemptyset.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1250 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-20 12:37:27 +00:00
rakshasa 9b0eb94c09 * Added sigset_t type cast.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1249 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-20 12:03:58 +00:00
rakshasa 86a9c1051b * Fixed a type cast.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1248 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-20 11:37:44 +00:00
rakshasa fa8ef65cd7 * Added better handling of SIGBUS, including the error type and fault address in the dump.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1247 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-20 09:57:29 +00:00
rakshasa f5d4924b22 * Casting printf input to match the format type.
* Properly clear the queued events during closing of a socket by checking for the file descriptor, not the ptr.

* SCGI m_task queue could overflow since the check was not working.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1246 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-19 13:11:28 +00:00
rakshasa dbde781bc5 * Added event name to log printed when a download event fails.
* Made 'log_files.cc' printf statements cast uint64_t to 'long long unsigned int'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1245 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-19 08:46:10 +00:00
rakshasa 4ff2793efb * Added 'd.timestamp.started'.
* Added dummy functions for a new choke group command interface.

* Added 'tracker' logging option for 'logging.libtorrent'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1244 e378c898-3ddf-0310-93e7-cc216c733640
2011-07-10 04:21:34 +00:00
rakshasa d0d52cdda1 * Added 'method.const' and 'method.const.enable' for setting the const flag for objects in object_storage.
* Added '<foo_list>.push_back' to all list objects in object_storage.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1242 e378c898-3ddf-0310-93e7-cc216c733640
2011-06-22 06:13:43 +00:00
rakshasa 90582b58c3 * Tagging release.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1239 e378c898-3ddf-0310-93e7-cc216c733640
2011-06-21 13:39:03 +00:00
rakshasa c31b865046 * Increased the default values for min/max_peers and max_uploads.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1238 e378c898-3ddf-0310-93e7-cc216c733640
2011-06-21 07:05:10 +00:00
rakshasa 1964ba5626 * Moved the default value for 'system.files.max_size' to rtorrent, and set the default in libtorrent to ~0.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1237 e378c898-3ddf-0310-93e7-cc216c733640
2011-06-14 03:12:33 +00:00
rakshasa db4a780893 * Fixed default session name.
* Added a missing inline that would cause linking errors.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1236 e378c898-3ddf-0310-93e7-cc216c733640
2011-06-13 05:30:54 +00:00
rakshasa 1e206cb1c4 * Cleanup of command handling.
* Added 'd.timestamp.finished' that is set when a downloading torrent completes. For torrents that only seed it remains '0'.

* Added 'elapsed.{less,greater}' for checking the time elapsed since a time is less/greater, and it also returns false in all cases where the time is '0'.

* Fixed a bug that would cause hash checking to block exessively in some cases.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1233 e378c898-3ddf-0310-93e7-cc216c733640
2011-06-05 07:11:59 +00:00
rakshasa ff477d3f7a * Using the new rlookup commands for views.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1232 e378c898-3ddf-0310-93e7-cc216c733640
2011-05-26 05:12:47 +00:00
rakshasa d2f328cc8e * Added 'method.rlookup' and 'method.rlookup.clear' commands for looking up the event handlers holding a specified key.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1231 e378c898-3ddf-0310-93e7-cc216c733640
2011-05-26 03:38:45 +00:00
rakshasa 5200454cf7 * Added 'execute.*.bg' commands for non-blocking calls. Always returns 0.
* Added support for prioritizing first/last chunk of files matching specified patterns. Default:

  file.prioritize_toc.set=0
  file.prioritize_toc.first.set = {*.avi,*.mp4,*.mkv,*.gz}
  file.prioritize_toc.last.set  = {*.zip}


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1230 e378c898-3ddf-0310-93e7-cc216c733640
2011-05-21 16:04:05 +00:00
rakshasa 9f738c58fe * Setting 'd.state.set=0' before removing a download from the 'started' view, so it will be properly set when 'event.download.paused' event is triggered.
* Bumped version number.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1227 e378c898-3ddf-0310-93e7-cc216c733640
2011-05-10 01:39:05 +00:00
rakshasa 56a7546f46 * This should fix the leeching and seeding filter.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1226 e378c898-3ddf-0310-93e7-cc216c733640
2011-05-07 14:13:37 +00:00
rakshasa 2f485cdf42 * Fixed 'and' and 'or' commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1225 e378c898-3ddf-0310-93e7-cc216c733640
2011-05-07 04:57:47 +00:00
rakshasa 1f200e7922 * Fixed 'not' command.
* Improved logging.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1224 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-29 15:15:53 +00:00
rakshasa 97f84f2c4d * Cleanup of choke_queue.
* More logging stuff.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1223 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-29 08:52:45 +00:00
rakshasa c845863f30 * Moving ChokeManager to 'torrent/download/choke_queue.h' and cleaning up code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1221 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-24 11:17:33 +00:00
rakshasa 8ae522b729 * More cleanup.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1218 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-23 12:52:46 +00:00
rakshasa 7d41393e5e * Added 'file.append' command for easy writing of stats to a log file.
* Cleaning up and prepearing the download / resource_manager for further improvements.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1214 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-22 09:12:17 +00:00
rakshasa ea9dc35bbe * Optimized view filtering and sorting.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1213 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-20 15:14:02 +00:00
rakshasa 8e15749d0c * Added more logging facilities.
* Ignore logging of alloc/dealloc for chunks during initial hashing.

* Moved torrent::ResourceManager to 'src/torrent/peer/' and removed old functions from 'torrent.h'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1212 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-18 05:07:45 +00:00
rakshasa 83a5213fac * Fixed some bad behavior that caused the hash queue not to empty at high download speeds.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1211 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-17 02:28:47 +00:00
rakshasa 3aa7ed3000 * Added logging for hash queue size.
* Added missing headers for gcc-4.6.0.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1210 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-15 07:28:26 +00:00
rakshasa cb45e30aeb * Be more aggressive about freeing references to downloading / downloaded pieces when a peer connection sends choke or has an empty queue.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1208 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-12 04:08:33 +00:00
rakshasa 63ffc11bbc * Added 'network.http.ssl_verify_peer.set' used to disable checking of self-signed certificates.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1206 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-10 02:54:53 +00:00
rakshasa b6cffa59c9 * Fixed logging of allocated memory.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1205 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-09 14:33:34 +00:00
rakshasa 47efb608ab * Added more instrumentation.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1204 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-09 13:50:30 +00:00
rakshasa d0c853034f * Throw internal error if ncurses 'newwin' fails.
* Cleaned up logging of mincore stats.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1203 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-08 02:56:06 +00:00
rakshasa 6f71a8c1b1 * Added 'p.is_unwanted' and 'p.is_preferred' commands.
* Removed std::tr1:: in favor of std:: using namespace.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1202 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-07 08:41:16 +00:00
rakshasa 18a6c61956 * Fixed a corner-case where initial seeding would end up crashing rtorrent.
* Fixed a bad conditional that would result in write syscall being called with -1 for logging executing external commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1201 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-06 09:59:54 +00:00
rakshasa a3b763aba8 * Catch NULL returned by curl_easy_init() and fail, as there is no way to recover.
* Detect empty 'announce-list' and use 'announce' instead.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1200 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-05 12:31:36 +00:00
rakshasa 8bf3ab6e91 * Added loading of ip filter file and data size query.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1199 e378c898-3ddf-0310-93e7-cc216c733640
2011-04-01 12:32:01 +00:00
rakshasa 86c508e212 * More work on cleaning up code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1198 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-31 11:25:31 +00:00
rakshasa 386250bc87 * Moved some option string stuff to libtorrent.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1197 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-31 09:35:21 +00:00
rakshasa 9ed7596daf * Added framework for introducing different choking algorithms.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1196 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-30 10:39:03 +00:00
rakshasa 143de32dc4 * Added more logging facilities.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1195 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-29 10:49:26 +00:00
rakshasa 18061c20c8 * More work on ip filter framework. Note some critical parts are not at this moment available to the public.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1194 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-29 06:48:38 +00:00
rakshasa 6e9df49912 * Fixed some missing headers.
* Added ip table framework.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1193 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-27 10:23:16 +00:00
rakshasa 5debd6f1be * Added better logging facilities.
* Changed tracker retry timers.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1192 e378c898-3ddf-0310-93e7-cc216c733640
2011-03-10 05:46:08 +00:00
rakshasa 7b2fae35d5 * Allow inlining functions in commands with parantheses, e.g:
print = (convert.time,(system.time))
  schedule2 = test_print_2,2,2,((print,"current ",((convert.time,((system.time))))))

  Multiple parantheses need to be used in schedule to ensure the command doesn't get evaluated at the time of calling schedule.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1191 e378c898-3ddf-0310-93e7-cc216c733640
2011-02-12 12:20:09 +00:00
rakshasa 5691233bf1 * Properly retry connection when non-/encrypted handshakes fail.
* Added test cases for ranges.

* Added a simple utility for torrent files.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1190 e378c898-3ddf-0310-93e7-cc216c733640
2011-01-13 13:13:58 +00:00
rakshasa 7e554e8b1b * Fixed various valgrind warnings.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1189 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-10 11:40:28 +00:00
rakshasa 649248c909 * Reverted to the most portable version.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1188 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-07 08:58:29 +00:00
rakshasa 6985fce321 * Fixed a bug that caused 'execute*' commands to fail when trying to run a program without any arguments.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1187 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-07 08:52:27 +00:00
rakshasa 220f59ee15 * Tweaked the signals.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1186 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-06 20:00:20 +00:00
rakshasa 4013fd6b98 * Properly set ThreadMain::m_thread to pthread_self().
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1185 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-06 11:58:47 +00:00
rakshasa 51db5e64c2 * Fixed inverted check for LT_SLIM_VERSION.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1184 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-04 14:25:14 +00:00
rakshasa 0098b1f0b9 * Fixed a bug where callinging download specific commands through the ui with no torrent selected would cause a crash.
* Added LT_SLIM_VERSION option that will leave out unneeded command redirects from the build.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1183 e378c898-3ddf-0310-93e7-cc216c733640
2010-11-02 11:20:01 +00:00
rakshasa b8d319a2fc * Fixed a race condition where the releasing of the global lock before calling polling would cause problems. Now a thread that acquires the global lock and wants to remove or change fd's from the main thread.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1182 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-22 11:31:11 +00:00
rakshasa 0e69677dbc * Added xmlrpc calls for peer snubbed, banned and disconnect.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1180 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-08 08:10:08 +00:00
rakshasa a0f3e95d20 * Fixed group commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1179 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-06 12:08:44 +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 c12f698c95 * Fixed 'view_*' commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1176 e378c898-3ddf-0310-93e7-cc216c733640
2010-10-03 12:14:57 +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 9bc5470243 * Renamed old 'load*' commands to 'load.*' in order to allow deprecated generic command redirects to be defined.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1174 e378c898-3ddf-0310-93e7-cc216c733640
2010-09-18 11:32:33 +00:00
rakshasa e0068a3f42 * Incore debugging fixes.
* Fixed max uploads and connected peers settings.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1173 e378c898-3ddf-0310-93e7-cc216c733640
2010-09-18 10:26:25 +00:00
rakshasa e1f0ee86b7 * Some debugging tools added.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1172 e378c898-3ddf-0310-93e7-cc216c733640
2010-08-25 07:14:19 +00:00
rakshasa 01738fd357 * Added some memory debugging utils.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1171 e378c898-3ddf-0310-93e7-cc216c733640
2010-08-19 10:30:42 +00:00
rakshasa 493843f223 * More commands fixed.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1170 e378c898-3ddf-0310-93e7-cc216c733640
2010-05-06 07:04:23 +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 7dad6d34f3 * Don't try to resume after finished if the download was deleted. Patch by sirjaren.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1167 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-29 11:16:56 +00:00
rakshasa c8fc6402bb * Finished the move over to object_storage, removing command_function.*.
* Added redirects for several commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1166 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-29 10:59:41 +00:00
rakshasa b530d35d94 * More work on rpc::object_storage and moving simple functions over to it.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1165 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-28 15:19:18 +00:00
rakshasa 9362453391 * Added a missing READ_PORT case to a switch in handshake.cc.
* Stuff.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1164 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-19 19:52:42 +00:00
rakshasa 575cafc7a8 * Old file/tracker related xmlrpc commands now work as before.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1163 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-12 03:37:07 +00:00
rakshasa 74bae32243 * Fixed more redirected commands.
* Cleaned up the Command stack implementation.

* Added framework for object_storage class that will hold variables and user-defined command lists.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1162 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-11 14:19:27 +00:00
rakshasa 856228da3d * Don't throw an exception on 'download->resume_flags() != ~uint32_t()' as there seems to be a race condition where a torrent doing the final hashing might get some flags set. Instead just clear it and hope nothing bad happens. See #1292.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1161 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-10 07:05:39 +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 4b9c4d5bbe * More cleanups of commands.
* Don't install the out-of-date man page.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1159 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-04 19:15:01 +00:00
rakshasa 8da449f666 * Handle XMLRPC commands with no arguments as if the target is empty.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1158 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-04 08:13:44 +00:00
rakshasa 4c6c943669 * Added missing file.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1157 e378c898-3ddf-0310-93e7-cc216c733640
2010-04-04 04:47:19 +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 10f665e9c6 * Last of the commands converted, cleanup remaining.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1154 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-27 16:35:15 +00:00
rakshasa bc96dbfa2d * Modified the fallocate configure check so it will fail if 'fallocate' can't be found.
* Changed more commands to the new format.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1153 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-24 20:23:48 +00:00
rakshasa db2b813fc4 * Finished refactoring command_network.cc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1152 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-23 18:24:18 +00:00
rakshasa 28aabb7874 * Reordered Makefile.am entries to fix linking errors.
* Changed more commands to std::tr1::bind.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1151 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-23 11:24:27 +00:00
rakshasa 83e993a1eb * Added missing command_new_slot.{cc,h} files.
* Converted more commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1150 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-21 09:45:45 +00:00
rakshasa 8622100e09 * Added a new Command type based on std::tr1::function aimed at replacing the current ones.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1149 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-19 09:33:25 +00:00
rakshasa ee5b0819a1 * Added 'system.files.{opened,closed,failed}_counter' commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1148 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-17 06:45:00 +00:00
rakshasa 589c8c147b * Cleaned up torrent/download.h.
* Removed raw_value as it is redundant.

* Fixed 'greater' command and added 'equal'. Patch by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1146 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-15 23:31:58 +00:00
rakshasa c5e839287d * Cleaned up torrent/download.h.
* Removed raw_value as it is redundant.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1145 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-15 18:31:50 +00:00
rakshasa 19be810642 * Added '-D' flag which turns of redirects for deprecated commands. Use this to ensure your scripts/webui.
* Moved DownloadInfo to src/torrent.

* Applied the magnet-uri patch.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1144 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-15 16:42:05 +00:00
rakshasa ded689d3ff * Fixed the linux fallocate detection script.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1143 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-12 10:29:11 +00:00
rakshasa df4c0ce67b * Optimized bencode read skip function.
* Fixed various bugs in the new dht/static map implementation.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1140 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-04 17:35:46 +00:00
rakshasa 44e77016a9 * Renamed 'system.method.*' to 'method.*'.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1139 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-03 13:45:34 +00:00
rakshasa db8f217569 * Commited the DHT changes from dht-pex-static_map.diff with changes so it works with the modified static_map implementation.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1138 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-03 11:52:01 +00:00
rakshasa 806941b6c7 * Added a static_map implementation based on Josef's patches.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1136 e378c898-3ddf-0310-93e7-cc216c733640
2010-03-01 07:45:54 +00:00
rakshasa 6fe6dcd8d8 * Fixed session file loading.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1135 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-19 15:05:33 +00:00
rakshasa 49cbbad5d7 * Make the torrent::Object immediately after loading a file to lower memory footprint.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1133 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-18 06:26:06 +00:00
rakshasa 0a76faa427 * Copy a torrent to std::stringstream instead of keeping a fstream open. This ensures rtorrent doesn't run out of file descriptors during launch.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1132 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-17 17:18:54 +00:00
rakshasa 3cae3d37be * Cleaning up command names. The deprecated commands will be redirected.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1131 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-16 17:29:53 +00:00
rakshasa 31abf85846 * Added support for Linux's fallocate and Darwin's fcntl(...,F_PREALLOCATE,...) to preallocate files by default. The 'system.file_allocate' setting will now only be used to indicate you want posix_fallocate called, which may block while it zeros out the file manually.
* Added 'event.download.hash_failed' and 'event.download.hash_final_failed'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1130 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-14 01:20:20 +00:00
rakshasa 8954393e52 * Don't recheck hashes of from 'uncertain_pieces' resume data when closing/resuming a torrent within the same session.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1129 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-11 15:45:56 +00:00
rakshasa 6796e9ad34 * Added missing <sys/types.h> includes. Patch by Artifex Maximus.
* Changed torrent::Object to use placement new instead of a pointer to std::string/list/map.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1128 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-11 03:39:13 +00:00
rakshasa 222bf7ae8f * Better handling of resume after crash/reboot. Sponsored by anonymous source.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1126 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-08 19:41:46 +00:00
rakshasa 2d3e12387d * Check if the thread is active before sending a signal.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1124 e378c898-3ddf-0310-93e7-cc216c733640
2010-02-02 23:17:49 +00:00
rakshasa 588f9e80c7 * Threaded XMLRPC support. Sponsored by Xirvik.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1123 e378c898-3ddf-0310-93e7-cc216c733640
2010-01-25 13:14:09 +00:00
rakshasa 83ea813245 * Fixed system.method.{set,find}_key commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1122 e378c898-3ddf-0310-93e7-cc216c733640
2010-01-20 18:11:58 +00:00
rakshasa 5ad2eff8c9 * Allow interrupting a thread's polling through SIGUSR1. Used to signal events across threads.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1121 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-30 07:27:43 +00:00
rakshasa 027edf9dcd * Discard dht cache if it is corrupt, instead of killing rtorrent.
* Minor fixes to the configure script.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1120 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-30 01:29:20 +00:00
rakshasa 8987be3001 * Fixed some minor compiler warnings/errors.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1119 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-26 11:16:21 +00:00
rakshasa 6188d110c5 * Added a flag to torrent::Poll that lets us set which Poll objects should waive the global lock.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1118 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-24 10:53:52 +00:00
rakshasa 2c7563825c * Added shutdown for worker thread.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1117 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-22 03:29:47 +00:00
rakshasa 5a1d0be323 * Use the safe default cacheline settings for all platforms for now.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1116 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-19 21:36:44 +00:00
rakshasa 5470e50ffb * Added autoconf support for cacheline_aligned and SMP_CACHE_BYTES.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1115 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-18 21:56:14 +00:00
rakshasa 2304983f4f * Finished the foundation of threading.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1114 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-15 21:39:35 +00:00
rakshasa 6a94909647 * More work on the threading stuff.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1113 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-14 21:18:51 +00:00
rakshasa b635f8c852 * More work on threading.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1112 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-12 21:30:52 +00:00
rakshasa ef6e4deca9 * Foundation for multi-threaded support.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1111 e378c898-3ddf-0310-93e7-cc216c733640
2009-12-12 15:32:04 +00:00
rakshasa d71e0ccf9a * Bumped version to 0.8.6/0.12.6.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1106 e378c898-3ddf-0310-93e7-cc216c733640
2009-11-30 15:08:17 +00:00
rakshasa 76fd429f89 * Changed the ctor for rt_triple to a non-template version.
* Made torrent::Rate::rate_type uint64_t and added sanity checks due to reports of bad download/upload values being reported to some trackers.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1103 e378c898-3ddf-0310-93e7-cc216c733640
2009-11-16 14:02:24 +00:00
rakshasa 3359c2bbb0 * Some commands were not using the new "log.tracker" name. Ticket #1888.
* Fixed crash on empty bitfield in 'd.bitfield'.

* Fixes a file handle leak in the execute_capture functions. Patch by Josef Drexler.

* Moved ThreadBase to ./src as ./src/utils caused linker problems due to core::PollManager::create_poll_manager().


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1102 e378c898-3ddf-0310-93e7-cc216c733640
2009-11-15 06:36:01 +00:00
rakshasa 667c4c3562 * Created ThreadBase holding poll manager, etc, and added a this_thread global object.
* Cleaned up main initialization, SCGI and polling code.

* Fixed a bug that would cause reading of a piece to hang if the incoming data contains only data up to the file boundary, but not the next file's data. The bug did not trigger if the file boundary and piece boundaries were the same.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1101 e378c898-3ddf-0310-93e7-cc216c733640
2009-11-12 09:28:35 +00:00
rakshasa a60c330d3b * Logging for scgi calls.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1100 e378c898-3ddf-0310-93e7-cc216c733640
2009-10-27 15:11:32 +00:00
rakshasa f11c48d454 * Fixed handling of errors when writing out session torrents, it should no longer hit an infinite loop.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1099 e378c898-3ddf-0310-93e7-cc216c733640
2009-10-23 15:45:45 +00:00
rakshasa 6c3a80636a * Fixed warnings in snprintf statements.
* Don't send numwant in tracker STOPPED requests.

* Reintroudced clearing of epoll event list when a socket is closed as it might cause race conditions.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1097 e378c898-3ddf-0310-93e7-cc216c733640
2009-10-22 07:01:53 +00:00
rakshasa abcb2cea48 * Added simple scheduler.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1096 e378c898-3ddf-0310-93e7-cc216c733640
2009-08-06 16:21:36 +00:00
rakshasa 134ae81ae3 * Fixes to xmlrpc's int64_t type, etc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1095 e378c898-3ddf-0310-93e7-cc216c733640
2009-06-18 19:01:20 +00:00
rakshasa b19bc576c4 * Fix crashes/errors due to rtorrent attempting to pass non-utf-8 strings to xmlrpc. Patch by Josef Drexler.
* Disabled strict ordering check for the bencode decoder added 2 revisions ago, as it might be messing up PEX, etc.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1093 e378c898-3ddf-0310-93e7-cc216c733640
2009-05-16 12:59:54 +00:00
rakshasa 63af7078a3 * Include locally available chunks in the "chunks seen" statistics for completed/distributed copies. Patch by Josef Drexler.
* Added 'd.get_bitfield' command for retrieving the bitfield in hex format. Patch by Thomas Rosner. (PD)

* Fixed include headers for gcc-4.4.0. Patch by 'kloeri'.

* Switched a 'long long' with 'int64_t' in xmlrpc.cc to avoid incompatible types for some systems.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1092 e378c898-3ddf-0310-93e7-cc216c733640
2009-05-14 13:07:47 +00:00
rakshasa 855bf9a781 * Enable custom throttles, both per-download or per-IP. See http://libtorrent.rakshasa.no/ticket/20 for info and instructions. Patch by Josef Drexler.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1091 e378c898-3ddf-0310-93e7-cc216c733640
2009-05-14 09:49:18 +00:00
rakshasa 05d7028f61 * Added support for using posix_fallocate on newly resized files.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1090 e378c898-3ddf-0310-93e7-cc216c733640
2009-05-13 17:25:19 +00:00
rakshasa 69d1c9700a * Fixes the code that detects which peer was sending bad data. Peers are then automatically banned after sending three bad chunks.
* Fixes a crash when parsing a malformed get_peers (or find_node) response throws an exception and fails to remove the corresponding transaction. Ticket #1622.

* Fix automatic unchoking of new peers exceeding the max upload slots of the download.

* Stops rtorrent from always creating and resizing ALL files, even those set to "off". Files will still be created, but with a size of zero, until a part of them is getting downloaded. This helps with filesystems that don't support sparse files (such as FAT, HFS+, and others).

* Fix inefficient piece distribution due to linear chunk request strategy by randomizing position every few (on average 32) chunks, see ticket #190.

* Fixes lack of return values for user-defined commands (using system.method.insert). When there are multiple commands, returns the result of the last one.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1089 e378c898-3ddf-0310-93e7-cc216c733640
2009-05-13 13:15:33 +00:00
rakshasa 3c670a7add * Add support for any number of custom download values identified by string keys.
d.set_custom=key,value
  d.get_custom=key (returns "" if not set)
  d.get_custom_throw=key (returns error if not set)

* With this patch, rtorrent will detect and complain about .torrent files with broken bencode representation (e.g. where the order of dictionary keys is not lexicographic).

* Choose a different poll type using the RTORRENT_POLL env. variable (if it's implemented), probably only useful as RTORRENT_POLL=select.

* Add the commands execute_capture and execute_capture_nothrow that work like their other counterparts but return the OUTPUT (stdout) of the given command.

  Note that the output is not modified in any way, in particular a trailing newline is NOT removed. To work around this, have the command write its output without it e.g. using echo -n. Also note that with execute_capture_nothrow there is no way to check if the command failed.

  Example usage: d.set_custom4=$execute_capture=handler.sh

* When logging peer communication errors, show IP and peer ID to help debugging.

All patches above by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1088 e378c898-3ddf-0310-93e7-cc216c733640
2009-05-13 09:39:00 +00:00
rakshasa 6753b45627 * Bumped version numbers.
* Fixed inconsistent handling of d.get_base_path for single and
multi-torrents. Now both return the cached path even though the
torrent is closed and a new root directory set.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1085 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-19 17:25:52 +00:00
rakshasa 15ae43a5ea * Make 'seeding' view trigger filtering on 'event.download.finished'.
* Fixed a potential buffer overflow in displaying of non-UTF8
filenames.

* Changed torrent::DownloadList::close_directly() so doesn't save the
session if the underlying file/directory has been moved or
removed. This change, in addition to calling 'd.set_directory=' before
'execute=mv,...', as previously shown in the examples, will make
rtorrent behave correctly when 'check_hash=no' is set.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1084 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-18 15:11:49 +00:00
rakshasa d05e889317 * Fixed a minor buffer-overflow.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1083 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-16 14:51:27 +00:00
rakshasa eb74609cdc * More compiler error fixes.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1082 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-16 10:06:29 +00:00
rakshasa 97b97261fd * Fixed a minor compile error.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1081 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-16 09:55:58 +00:00
rakshasa 7600a51039 * Fix potential buffer overflows in case snprintf buffer is too
small. Patch by Josef Drexler.

* Added 'view.persistance' command that makes downloads inserted into
that view persist across sessions. Only call on user-created views.

* Added 'ratio.*' commands that call the 'group.seeding.ratio.*'
equivalents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1080 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-16 07:54:45 +00:00
rakshasa de8a11c4fd * Added 'system.method.get', 'ui.current_view.set' and 'group.insert'
commands.

* Enabled different ratio settings for different groups of
downloads.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1079 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-10 18:52:36 +00:00
rakshasa 66a2af991a * Added groups and started reworking the ratio handling.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1078 e378c898-3ddf-0310-93e7-cc216c733640
2008-11-09 16:20:57 +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 5648cf7dd0 * Added 'event.download.inserted_{new,session}' that are triggered
when a new or a session torrent is added. Ticket #1516.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1075 e378c898-3ddf-0310-93e7-cc216c733640
2008-10-28 17:59:40 +00:00
rakshasa 29ba4ff4bc * Enforce an http transfer timeout when libcurl fails to honor
it. Also set a 5-minute timeout for (previously unlimited) torrent
transfers and fixes the argument type for curl_easy_setopt values.

* Allows bandwidth throttles to work without floating point support.

* Adds a d.add_peer=host[:port] command to manually add a peer (not
for torrents marked "private"), port is 6881 by default.

* Allows banning the selected peer with "B". No unbanning is possible
yet.

All the above patches were written by Josef Drexler.

* Differentiate between commands that have no target, and those that
take generic targets, when using XMLRPC.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1073 e378c898-3ddf-0310-93e7-cc216c733640
2008-10-22 13:23:48 +00:00
rakshasa 85f5b7dc46 * Fixed two instances of string includes where <strings.h> was used
instead of <string.h>.

* Fixes {stop,close}_on_ratio calling further commands even when the
"ignore commands" flag is set.

* Work-around for OpenBSD's broken sys/event.h, which fails to compile
if it's the first (or only) included header. (Ticket #1470)

* Fixes compilation with old libcurl versions. (Ticket #1471)

* Fix compile error on systems that lack mincore(2).

* Fixes a crash in epoll due to libcurl/c-ares bug:
PollEPoll::modify(...) epoll_ctl call failed.

All patches by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1072 e378c898-3ddf-0310-93e7-cc216c733640
2008-10-07 13:14:59 +00:00
rakshasa db4ba9fe68 * Cleaned up obsolete scheduler framework.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1071 e378c898-3ddf-0310-93e7-cc216c733640
2008-10-04 10:06:47 +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 879a019757 * Various fixes to the new polling code to handle bad libcurl/cares
behavior. Patch by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1067 e378c898-3ddf-0310-93e7-cc216c733640
2008-08-31 20:49:55 +00:00
rakshasa 854d119ff2 * Added missing files.
* Inserted more error-checking in kqueue and fixed some potential bugs.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1066 e378c898-3ddf-0310-93e7-cc216c733640
2008-08-31 19:01:19 +00:00
rakshasa be8b59b00b * Use curl's new polling interface so we don't have to switch to
select() while http transfers are active.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1065 e378c898-3ddf-0310-93e7-cc216c733640
2008-08-27 08:41:08 +00:00
rakshasa c627d6dc0c All patches in this commit were from Josef Drexler.
* Fixes a segfault when configure finds execinfo.h.

* Fix compile errors and warnings with g++ 4.3.x.

* Fixes an interoperability issue in the get_peers handling, now it
behaves according to the clarified BEP-0005. Also fixes a minor issue
of not being able to generate error packets.

* Fix a crash in scgi_local or scgi_port when calling freeaddrinfo
with a NULL pointer.

* Only check the filename cache for loading tied torrents (e.g. from
watch dirs) but not manually loaded ones via <enter>/<bs>, to allow
loading those again (ticket #1227).

* Fix display of multi-byte characters with attributes (i.e. utf-8
filenames in the file list), and make the list aware of characters
occupying two screen positions.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1064 e378c898-3ddf-0310-93e7-cc216c733640
2008-08-26 20:42:57 +00:00
rakshasa 5a700f34d9 * Fix a slight memory leak in peer exchanges. Patch by Josef Drexler.
* Fixed mix-up in version numbers causing an incompatibility for .so
libraries. Patch by Josef Drexler for ticket #1333.

* Fix excessive HAVE messages being sent after handshake when download
has been active for a while. Patch by Josef Drexler for ticket #1372.

* Make --enable-ipv6 not break DHT on Mac OS X. Patch by Josef Drexler
for ticket #1359.
 
* Fix crash when contacting tracker. Patch by Josef Drexler for ticket
#1272.

* Fix stopping downloads not working properly. Patch by Josef Drexler
for ticket #1335.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1062 e378c898-3ddf-0310-93e7-cc216c733640
2008-07-05 12:13:12 +00:00
rakshasa bfa7523677 * Fix a crash in DHT due to returning a reference to a temporary
variable. Patch by Josef Drexler for ticket #1221.

* Fix an off-by-one error that causes a crash if a DHT node advertises
an ID of "FFFFFFFF...". Patch by Josef Drexler.

* Fix a crash in initial seeding to due a typo not passing the right
flag. Patch by Josef Drexler.

* Fix d.connection_seed being set to "leech" when download wasn't set
to initial_seed. Patch by Josef Drexler for ticket #1376.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1061 e378c898-3ddf-0310-93e7-cc216c733640
2008-07-05 12:01:00 +00:00
rakshasa 108ec969f7 * Minor fixes to configure scripts, updated man page and bumped the version.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1060 e378c898-3ddf-0310-93e7-cc216c733640
2008-05-07 12:18:36 +00:00
rakshasa e3fa31b6df * Initial seeding support added. Patch by Josef Drexler.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1058 e378c898-3ddf-0310-93e7-cc216c733640
2008-05-05 19:16:26 +00:00
rakshasa 3f64e8b1fa * Fixed EINTR handling in execute command. Patch by anonymous.
* Fixed a couple of memory leaks in xmlrpc.cc. Reported by Novik.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1057 e378c898-3ddf-0310-93e7-cc216c733640
2008-05-01 17:14:43 +00:00
rakshasa fcbad61577 * Revision bump.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1054 e378c898-3ddf-0310-93e7-cc216c733640
2008-04-20 13:46:39 +00:00
rakshasa 3ddd04a9a5 * Fixed another bug in scgi_tast.cc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1053 e378c898-3ddf-0310-93e7-cc216c733640
2008-04-16 10:58:04 +00:00
rakshasa 12b43d78a3 * Fixed a potential leak in scgi_task.cc.
* Removed std:: from snprintf in window_file_list.cc.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1052 e378c898-3ddf-0310-93e7-cc216c733640
2008-04-15 11:50:14 +00:00
rakshasa 41088740bd * Added dummy scheduler commands.
* Add/remove downloads from the 'active' view on resume/pause.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1051 e378c898-3ddf-0310-93e7-cc216c733640
2008-04-11 18:03:27 +00:00
rakshasa aab493caad * Used different ncurses calls in the file list so that UTF8 filenames
should show up properly.

* More cleanup of Views.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1050 e378c898-3ddf-0310-93e7-cc216c733640
2008-04-02 17:11:44 +00:00
rakshasa 03c544d07d * Added some more download commands that replace some of the
start/stop/close wrapper functions in DownloadList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1049 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-28 16:47:17 +00:00
rakshasa a6045c9ea5 * Made the signal in View trigger using a task, thus avoiding bad
recursions and wrongly orderer commands. This should fix some problems
with hash checking returning errno 0.

* More changes to View usage.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1048 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-27 15:41:11 +00:00
rakshasa e8e5ef337b * Made pause/resume trigger on insertion into the started queue.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1047 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-24 19:30:56 +00:00
rakshasa 8fbaca61b1 * Refactoring to change the DownloadList events to commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1046 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-23 12:16:18 +00:00
rakshasa 199bd1985c * Added view_event_{added,removed} commands that sets a command to be
triggered when a download is added/removed from the specified view.

* Minor compiler errors fixed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1045 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-20 11:50:57 +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 d22e1ae30e * Bug fixes to the previous rev's View code.
* Fixed dht alignment issues. Patch by Josef Drexler.

* Removed duplicate code in PeerConnection{Leech,Seed}. Patch by Josef
Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1043 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-16 15:31:11 +00:00
rakshasa f9ff1cf5ac * Changed view_filter to use boolean commands instead of custom
functors.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1042 e378c898-3ddf-0310-93e7-cc216c733640
2008-03-16 13:55:40 +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 b21f465969 * Added {get/set}_xmlrpc_size_limit to allow the user to specify
larger buffer size for handling direct loading of torrents through
xmlrpc.

* Allow file and tracker targets with the compact xmlrpc syntax,
e.g. "<infohash>:f<id>".

* Fixed an alignment bug in the DHT code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1040 e378c898-3ddf-0310-93e7-cc216c733640
2008-02-28 19:54:36 +00:00
rakshasa 49bb643cf3 * Added system.time{,_seconds,_usec} commands.
* Cleaned up XMLRPC handling and added support for empty targets so it
will handle print and cat properly.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1039 e378c898-3ddf-0310-93e7-cc216c733640
2008-02-22 14:11:40 +00:00
rakshasa afe1312eb6 * Added some missing includes.
* Changed more key bindings in ElementDownloadList to commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1038 e378c898-3ddf-0310-93e7-cc216c733640
2008-02-03 14:30:58 +00:00
rakshasa 1b96bd6016 * Bumped to version 0.12.0/0.8.0.
* Removed Download::disconnect_peer as it can call ConnectionList
directly.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1035 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-28 18:21:36 +00:00
rakshasa 805689c3af * Preliminary API changes for the throttle groups. Patch by Josef
Drexler with some changes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1034 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-28 16:56:01 +00:00
rakshasa 0fdb72b05b * Made Peer virtual so casting between PCB and Peer will work properly.
* Updated the man page.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1033 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-27 15:58:26 +00:00
rakshasa 259cb77799 * Made PCB inherit from Peer.
* Added man page entry for ^E.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1032 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-27 14:01:10 +00:00
rakshasa 728c6ac9bd * Added ^E for setting 'create/resize queued' on files in a torrent.
* Minor cleanup of the API.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1030 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-22 15:50:48 +00:00
rakshasa c19af8f389 * Cleanup of the Object api.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1028 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-20 07:48:52 +00:00
rakshasa 9e8b4add9d * Fixed a race condition in the handshake read/write code. Patch by
Josef Drexler.

* Fixed the --with-xmlrpc-c autoconf check so that you can pass an
alternative path to an xmlrpc-c-config script.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1027 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-12 18:39:19 +00:00
rakshasa 87e02737ce * Removed the Object ctor taking an Object::type_type.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1026 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-06 15:41:30 +00:00
rakshasa 77a7d13b39 * Automatically prune the file status cache every day.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1025 e378c898-3ddf-0310-93e7-cc216c733640
2008-01-01 14:13:14 +00:00
rakshasa 7abc459d74 * Keep a cache listing all, including failed, torrent loads and the
mtimes of those files. This is used to ensure that e.g. the watch dir
does not try to load bad/duplicate torrents, in addition to optimizing
the pruning of those already loaded.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1024 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-31 10:12:17 +00:00
rakshasa ce64ea89b1 * Properly use d.set_directory_base when
* Added get_{up,down}_{rate,total}.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1023 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-30 04:43:05 +00:00
rakshasa 7b053b969e * Refactoring utils::Directory.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1022 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-23 19:12:23 +00:00
rakshasa ccb3713a57 * Added "d.set_directory_base" command that handles single and multi
file torrent equally.

* Fixed man page entry on 'umask', it should be 0022 not 0664.

* Cleaned up File and FileList classes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1021 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-23 08:05:00 +00:00
rakshasa 51e27e29c8 * Properly clean up SCGI on exceptions so it deletes the socket
file. Found by Josef Drexler.

* Handle mtime properly in resume_save.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1020 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-16 08:25:57 +00:00
rakshasa 71ac2cc8e1 * Partial implementation of better detection and handling of deleted
files in a torrent.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1017 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-10 17:17:40 +00:00
rakshasa 6db7ada26c * Allow opening a torrent without creating any files. Still requires
modification of the client to work.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1016 e378c898-3ddf-0310-93e7-cc216c733640
2007-12-02 15:39:58 +00:00
rakshasa 4704c91a8f * Fixed a crash in apply_on_ratio when an iterator got invalidated by
erasing the download currently pointed to.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1015 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-30 14:33:20 +00:00
rakshasa f05dd5b152 * Added support for DHT. Patch by Josef Drexler, public domain as per
prior agreement.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1013 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-28 15:00:13 +00:00
rakshasa 4e3a867257 * Added 'p.multicall' command, though it lacks sorting atm.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1012 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-27 01:56:20 +00:00
rakshasa 66037a7ae2 * Fixed use of old max/min_peers commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1011 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-17 06:03:41 +00:00
rakshasa d86505924b * Moved ConnectionList into the API and made rtorrent use it.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1010 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-15 14:26:12 +00:00
rakshasa 2fe964059f * torrent::Peer now is used as a pointer, instead of an instance
containing a pointer.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1007 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-13 11:33:39 +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 04e6575e5d * Replaced the old TrackerList API with the cleaned up
TrackerContainer code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1005 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-08 16:33:51 +00:00
rakshasa 4a2ae4d339 * New Tracker API.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1002 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-02 10:47:12 +00:00
rakshasa c326c7f43a * Added insert_preserve helper functions to torrent::Object.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1000 e378c898-3ddf-0310-93e7-cc216c733640
2007-11-01 08:32:08 +00:00
rakshasa ff2c25bdeb * Bumped version to 0.7.9/0.11.9.
* Fixed more sigc++ header includes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@995 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-25 11:00:24 +00:00
rakshasa d13e502ee4 * Print to the log when close_on_diskspace gets triggered.
* Cleared out unused TextElement code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@994 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-25 09:13:30 +00:00
rakshasa 4038e78665 * Changed element_peer_list.cc to te_command.
* Added several Peer commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@993 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-23 15:56:58 +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 78f8b19aa4 * Limited the number of addresses in the outgoing pex list to 200.
* Show private flag in download info.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@988 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-12 14:46:41 +00:00
rakshasa aad01906d3 * Bugfixes to the PEX changes.
* Minor changes to statvfs detection.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@987 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-09 16:03:30 +00:00
rakshasa 099ec98210 * Require the caller to push data to ProtocolExtension's buffer
directly.

* Don't allow extension messages larger than 2^15.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@986 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-08 15:18:50 +00:00
rakshasa 9cb48a9f66 * Disable PEX when we are connected to enough peers.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@983 e378c898-3ddf-0310-93e7-cc216c733640
2007-10-04 14:54:31 +00:00
rakshasa 166e8e1357 * Display size of pex for each download.
* Limit the number of PEX connections to 5 per download.

* Fixed minor bugs in the new PEX code. Patch by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@981 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-28 08:50:59 +00:00
rakshasa b32c07a638 * Optimized AvailableList::erase.
* Moved PeerInfo and DownloadMain into Extensions.

* Added a flag for if we've received the initial handshake and moved
setting of flag_received_ext to Extension.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@980 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-26 07:45:44 +00:00
rakshasa 81782e2e9f * Set "encryption=allow_incoming,prefer_plaintext,enable_retry" by
default.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@977 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-07 21:02:15 +00:00
rakshasa 804eb769a0 * Added "close_on_ratio".
* Allow commands to be appended to "{stop,close}_on_ratio".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@976 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-06 22:39:43 +00:00
rakshasa 3b82216a1b * Renamed 't.get_enabled' to 't.is_enabled'.
* The torrent is no longer closed on finished for on_finished
commands, instead d.set_directory causes the download to call
close_directly.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@974 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-05 17:52:16 +00:00
rakshasa 48f13fb7a3 * Don't skip the last line in rc files missing the final
newline. Patch by Jussi Judin under Public Domain.

* Added warnings on usage of scgi_port.

* Include a file's completed chunks count in the resume data.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@973 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-04 21:32:42 +00:00
rakshasa 95516fe3b5 * Renamed pex_{enabled,active} to is_pex_*.
* Changed the download info screen to only use commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@972 e378c898-3ddf-0310-93e7-cc216c733640
2007-09-03 00:59:34 +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 332b4a303f * Added Peer Exchange support, enable with the "peer_exchange"
option. Patch by Josef Drexler, public domain as per earlier
agreement.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@968 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-30 20:35:23 +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 02b790c0bf * Added torrent::Download::{start2,stop2}(int flags) that will replace
the old start/stop functions. The old functions are now just wrappers
for the new.

* Fixed the tracker requests when finishing a torrent.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@965 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-26 02:31:32 +00:00
rakshasa c6a43429a2 * Added support for XMLRPC_TYPE_BASE64.
* Added 'load_raw*' commands for loading torrents directly from the
data passed through the first argument.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@964 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-24 12:30:29 +00:00
rakshasa 85d14f0e96 * Cleaned up the 'umask' command and renamed 'working_directory' to
'cwd'.

* Added 'd.{get,set}_custom[1-5]' for user scripts.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@963 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-23 21:21:11 +00:00
rakshasa 38f8a00c0c * Moved PF_LOCAL to rak/socket_address.h and made it portable.
* Added "d." to '{create,delete}_link', and marked the old names as
obsolete.

* Added "d.{get,set}_message'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@962 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-22 07:16:29 +00:00
rakshasa 0390b7ec00 * Added 'f.multicall' and 't.multicall', and renamed 'call_download'
to 'd.multicall'.

* Cleanup of 'rpc/parse_commands.h'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@961 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-20 21:29:59 +00:00
rakshasa bac7d0ba3b * Client address resolver support. Patch by Josef Drexler.
* Added 'get_name' to the download list window title.

* Bumped version numbers.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@960 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-20 13:40:09 +00:00
rakshasa ded9e12ff1 * Added 'get_pid', 'get/set_name' and 'cat' command.
* SocketFd::open_local() should use SOCK_STREAM, not SOCK_DGRAM.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@959 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-20 01:38:38 +00:00
rakshasa 5ec7790aa9 * Added 'd.get_hash' and 'get_hostname' commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@958 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-18 23:44:59 +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 11976871ac * Dynamically sized SCGI read buffer.
* Added 'call_command' that takes a view as the first parameter and
then a list of commands. It will return a list of lists containing the
results from those commands.

* Fixed the xmlrpc-c-config usage.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@954 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-15 21:38:44 +00:00
rakshasa 6ca373d293 * Renamed all commands to from e.g "get_d_*" to "d.get_*". Remember to
update your rc file.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@953 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-12 18:41:09 +00:00
rakshasa 788b496241 * Fix the use of strlcpy.
* Allow lists as arguments in commands by using '{' and '}'. The list
will be recursed and all '$' will be called, while '~' will only be
expanded when in the first element in the list. E.g "execute =
touch,{~/tmp/,$get_client_version=}"

* Added rak::path_expand that works on char buffers.

* Fixed RequestList::calculate_pipe_size so it doesn't request too
many pieces from fast peers.

* Added 'execute_log' for logging the result of calls to 'execute'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@952 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-12 13:41:50 +00:00
rakshasa 781e1ca7dc * Add alternate execute_ commands.
* Fixed the queue size calculations.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@951 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-07 23:56:58 +00:00
rakshasa ef794b8eda * Added a default low_diskspace check for 500MB.
* Properly catch the exceptions being thrown by the 'in_*' events.

* Expand ~ in ExecFile.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@950 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-07 15:14:57 +00:00
rakshasa 37bc4c85c4 * Enabled 'max_downloads_div' by default.
* Added 'get_{client,library}_version' commands.

* Removed support for appending more than one command to 'schedule'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@949 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-03 11:56:18 +00:00
rakshasa ba634e7d62 * Bumped rtorrent's required libtorrent version.
* *BSD requires <unistd.h> for symlink(...).


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@946 e378c898-3ddf-0310-93e7-cc216c733640
2007-08-01 23:03:40 +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 1232cd44cb * Properly catch exceptions from commands called from DownloadFactory.
* The print command was not properly adding the final nul char to the
buffer.

* Added 'get_d_name' command.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@944 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-24 23:12:42 +00:00
rakshasa 8617e205ea * Added file commands for retrieving path and it's components.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@943 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-22 20:05:04 +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 465625692f * Allow a list of commands to be called on a newly created download
before it is started.

* The "load_*" commands now allow a list of commands to be appended.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@941 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-20 23:54:31 +00:00
rakshasa 7d0be56c83 * Set the content type to text/xml in XMLRPC replies.
* Fixed a compile error when using xmlrpc-c >= 1.07.

* Added various download commands for getting torrent sizes, peers,
etc.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@940 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-20 18:05:17 +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 350bdfde7e * Allow ';' as a separator for multi-command lines. Not recognized by
the string parser, so it must be preceeded by whitespace.

* Allow escaping of newlines in the resource file.

* Cleanup of the parse_command_* commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@936 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-17 16:24:57 +00:00
rakshasa 3c7144092e * Added more download related commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@935 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-11 23:39:40 +00:00
rakshasa 3570602a08 * Allow "print" command to take a list of parameters.
* Added "d_{start,stop,open,close,erase}" commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@934 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-11 19:22:34 +00:00
rakshasa 36251a46bf * Allow returning torrent::Object map type's with XMLRPC. Patch by Josef Drexler.
* Commands that pass through rpc::parse_command_* now support inline
commands that start with a '$'. E.g 'print="$get_ip="'.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@933 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-10 13:14:42 +00:00
rakshasa 2eaa34d989 * Moved reannounce intervals into each tracker and use that to decide
the reannounce interval.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@932 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-09 10:48:43 +00:00
rakshasa 17ebbf1b92 * Fixed a race-condition in Handshake::event_read() that would cause a
closed Handshake to be inserted into SocketSet.

* Converted torrent::object_write_bencode(...) to use
torrent::object_write_bencode_c(...).


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@931 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-07 23:16:10 +00:00
rakshasa d04ef5406b * Removed the FastCGI code.
* Cleaned up XmlRpc and fixed some compile errors. 


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@930 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-06 21:33:26 +00:00
rakshasa 0c3038783e * Allow i8 and apache style 64bit integer support in XMLRPC. Use
"xmlrpc_dialect" command to change.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@929 e378c898-3ddf-0310-93e7-cc216c733640
2007-07-05 13:10:13 +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 c8e74a78ad * Bumped version.
* Fixed a crash when XMLRPC download commands were called without any
arguments.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@926 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-28 19:14:44 +00:00
rakshasa 9b95b51410 * torrent::FileList::is_multi_file() now indicates whether the torrent
loaded was a multi-file torrent, not whether it contains more than one
file.

* Ignore attempts to load an empty URI in the client.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@925 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-24 22:32:44 +00:00
rakshasa e6e7e8a384 * Added "d_delete_tied" command.
* Moved CommandScheduler into src/rpc.

* Fixed a bug in the "download_list" command.

* Partial cleanup of the tracker list.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@924 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-24 20:25:44 +00:00
rakshasa 9f11a5ad92 * Added "http_ca{path/cert}" to the man page.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@919 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-20 22:35:45 +00:00
rakshasa 93f1e349ff * Fixed xmlrpc dummy functions.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@918 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-19 23:07:36 +00:00
rakshasa 750ba89129 * Added direct support for download commands in XMLRPC. Now the first
parameter of the get_d/set_d commands is the info-hash.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@917 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-19 18:04:49 +00:00
rakshasa 507ba5a7a0 * Added "download_list" and "download_call" options. The latter is
just a prototype, and will be changed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@916 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-18 22:57:04 +00:00
rakshasa 8096b4f4ca * Added "download_list" option for getting a list of torrents.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@915 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-17 23:28:13 +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
rakshasa f8f2f80960 * Moved the rest of the helper functions from VariableMap to
parse_commands.h.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@912 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-16 17:22:39 +00:00
rakshasa 0de4bbea7a * Re-enabled the umask option.
* Moved around command related classes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@911 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-16 00:14:09 +00:00
rakshasa 64e1d1f440 * Was using wide char std::isspace version by mistake.
* More cleanup of old option code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@910 e378c898-3ddf-0310-93e7-cc216c733640
2007-06-09 21:48:13 +00:00
rakshasa 8a1220fd5b * Cleanup of old Variable stuff.
* Fixed a bug that would cause ^O to make an extra call to
"set_directory" for the log, instead of "get_directory".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@909 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-31 16:40:34 +00:00
rakshasa 13dc0c942a * Allow binding of the SCGI socket to a specific address, and added
"scgi_dont_route" variable.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@908 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-23 21:47:11 +00:00
rakshasa bebce18368 * Added "http_ca{path/cert}" options. Patch by Johan Gunnarsson,
public domain.

* Minor bugfixes to SCgi.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@907 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-23 14:03:02 +00:00
rakshasa 2db205a89d * Added support for named pipes and proper parseing of arguments for
SCGI.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@906 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-21 01:51:52 +00:00
rakshasa 5f274b2619 * Added support for SCGI rpc calls.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@905 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-20 17:30:00 +00:00
rakshasa bc7d485391 * Fixed xmlrpc so it registers all the commands.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@904 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-18 22:01:29 +00:00
rakshasa d33d283293 * Last of the old commands moved.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@903 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-18 20:34:31 +00:00
rakshasa 7d1bb524ba * Moving download variables into command_download.cc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@902 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-18 14:24:57 +00:00
rakshasa 9fe72cb3b5 * Replaced DownloadFactory's m_variables with a torrent::Object map.
* Starting work on moving the download commands to the new command
framework.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@901 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-16 14:39:03 +00:00
rakshasa 032bae7030 * Removed old non-download set/get functions from VariableMap.
* Added forgotten command_download.cc file.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@900 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-11 22:47:15 +00:00
rakshasa 0182bfbfba * Finished moving the normal commands to the new system.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@899 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-04 20:29:07 +00:00
rakshasa c986357bab * Automatically add variables to XMLRPC unless added as private.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@898 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-04 16:15:16 +00:00
rakshasa a864d5938d * More commands moved to the new system.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@897 e378c898-3ddf-0310-93e7-cc216c733640
2007-05-01 19:00:17 +00:00
rakshasa 2ede6f03ab * Continuing conversion to the new command infrastructure.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@896 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-29 18:46:55 +00:00
rakshasa 43fd2c92ec * Return torrent::Object instead of reference from
utils::VariableMap::call_command(...).

* More cleanup of the command calls.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@895 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-28 02:37:08 +00:00
rakshasa c5beb24d6c * Fixed XMLRPC-C header.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@894 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-22 16:11:31 +00:00
rakshasa 7077aba019 * More cleanup of commands, including some optimization by avoiding
some heap allocations.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@893 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-18 15:15:06 +00:00
rakshasa d0ae367dca * Adding missing files.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@892 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-17 20:22:24 +00:00
rakshasa 81637ff5a0 * Converting various variables to the new command version.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@891 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-17 14:57:56 +00:00
rakshasa 7c121ac049 * Starting work on merging get/set variable. Moved the bool and value
variables, still might have missed some prior uses that might cause
exceptions to be thrown.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@890 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-14 12:43:19 +00:00
rakshasa 4a449bae67 * Added configure options that allow building universal binaries.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@889 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-10 22:36:43 +00:00
rakshasa 8501832788 * Bumped to 0.11.5/0.7.5.
* Added "call.set_upload_rate", "call.get_upload_rate" and
"call.get_directory" XMLRPC calls.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@888 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-09 21:09:53 +00:00
rakshasa 6691298fb4 * Added XMLRPC-C support and hooked it up to FastCGI. Calling a test
function is now possible.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@887 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-09 17:28:54 +00:00
rakshasa d6fd8f08dc * Added FastCGI support for RPC. This will be hooked up with XMLRPC-C.
* Experimenting with move semantics for Object.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@886 e378c898-3ddf-0310-93e7-cc216c733640
2007-04-06 22:12:52 +00:00
rakshasa 93afd05e18 * Updating to 0.7.4/0.11.4.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@884 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-30 07:13:44 +00:00
rakshasa 3bd0d6fb27 * Allow certain commands, like schedule and on_* to take unquoted
multi-arg commands. So "on_start = link1,create_link=tied,,.started"
now works again.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@879 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-27 15:45:18 +00:00
rakshasa ee6eae6c84 * Working on new infrastructure for parseing commands. It now passes a
list instead of a string when calling a multi-parameter command, which
handles escaped spaces, commas and quotes correctly.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@877 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-25 18:03:07 +00:00
rakshasa 0ab5bae22e * Generated man page.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@874 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-24 15:05:09 +00:00
rakshasa 5450971273 * Fixed an incorrect exception check in
ResourceManager::receive_upload_unchoke(...).

* Allow the client to manually cancel tracker requests so that quick
shutdown works correctly after moving the TrackerManager::close() call
to DownloadWrapper::~DownloadWrapper().


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@873 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-24 00:22:23 +00:00
rakshasa b009734d5c * Added support for dvorak keyboard layout. Patch by matled@gmx.net.
* Moved TrackerManager::close() call to the DownloadWrapper dtor so
that tracker STOPPED request will be sent when closing a torrent.

* Fixed some portability issues with Solaris, but still some remain.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@872 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-23 00:00:15 +00:00
rakshasa 59c6f97cb9 * Added "max_{up,down}loads_{div,global}" options and man page entries.
* PCB::should_request() didn't check if m_downUnchoked was true, just
m_downChoke.choked(). This would cause requests to be sent while we
were still choked by remote.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@871 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-20 16:13:20 +00:00
rakshasa 3b13fc7f05 * Send uninterested to peer when no download slots are available, and
various other stuff to make it work properly.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@870 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-18 01:56:29 +00:00
rakshasa 3ef8384c38 * Set allowed encodings for tracker and http requests.
* Fixed two valgrind errors in the ChokeManager code.

* Added 'seeding' view on key 8. Remeber to fix the man page.

* Fixed an exception being thrown in ChokeManager::cycle(...) due to a
missing range check on the number of unchokes we do.

* Moved choke/queued state to a new ChokeManagerNode class.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@869 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-16 23:22:51 +00:00
rakshasa f43cdad650 * Added global download slots. The "max_downloads_hack" option may be
used to test this feature. Note that there seems to be a bug in the
code causing exceptions.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@866 e378c898-3ddf-0310-93e7-cc216c733640
2007-03-03 20:32:18 +00:00
rakshasa b46caac088 * Added "max_uploads_div" option to set fewer global upload
slots. Currently just intended for testing purposes.

* Renamed and changed the use of ProtocolBase variables within
ChokeManager.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@864 e378c898-3ddf-0310-93e7-cc216c733640
2007-02-24 13:54:48 +00:00
rakshasa de3ab556e5 * Added missing includes of <algorithm> required by newer gcc
versions. Patch by falk@debian.org.

* Swapped the use of PCB::m_up.interested() with
PCB::m_down.interested(). This means that m_up.interested()/choked()
says if the remote peer is interested and if upload to it is choked,
while m_down.interested()/choked() says if local is interested and if
download from the remote peer is choked.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@862 e378c898-3ddf-0310-93e7-cc216c733640
2007-02-23 16:33:26 +00:00
rakshasa ef3ecb0b97 * The "tos" option was parsing the hex value with unit == 0, which
caused it to always zero it.

* Split the chunks in the transfer list to fit the display. Patch by
Josef Drexler.

* Forgot to check if there were any torrents hashing before starting
new non-fast-resume checks, which would cause multiple torrents to be
hashed at once.

* File progress is now updated when hash_check is called, and no
longer cleared on close. This fixes a bug with >100% file progress
being reported and optimizes file progress updating for completed
torrents.

* Disabled IPv6 http requests so the trackers won't think we support
it.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@857 e378c898-3ddf-0310-93e7-cc216c733640
2007-02-09 16:39:51 +00:00
rakshasa cdd2da8df5 * Replaced the single container in ChokeManager which used to contain
all connections, with an unchoked and an interested container. The
semantics of the code should be the same.

* Bump version number to 0.11.3/0.7.3.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@855 e378c898-3ddf-0310-93e7-cc216c733640
2007-02-02 11:18:53 +00:00
rakshasa ecdfaed06f * Updated the man page, probably still needs some cleanup, but meh.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@852 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-26 08:48:12 +00:00
rakshasa 5a9fa2fdcd * Fixed a bug that cause the hash checker not to start.
* Added "base_path" and "base_filename" types to the
"create/delete_link" command.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@851 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-22 14:45:18 +00:00
rakshasa 81921ba9a4 * Added "base" type to the "*_link" commands.
* Added a bunch of client id's from solsTiCe.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@850 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-21 16:10:27 +00:00
rakshasa 1d1b5710fa * Added "create_link" and "delete_link" options for creating and
deleting symbolic links to downloads.

* Added "on_*" options for calling commands on state changes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@849 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-20 19:42:22 +00:00
rakshasa b301faf3ca * Fixed a leaking rak::address_info in TrackerUdp. Patch by Josef
Drexler.

* Finished converting the variables in core::Download to use the new
get/set_d(core::Download, ...) functions.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@848 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-20 12:42:14 +00:00
rakshasa e59b5bf7b6 * Make VariableMap handle both global and core::Download
variables. Variable now has functions for both void and
core::Download*, where the core::Download* is discarded if necessary.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@847 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-17 15:18:33 +00:00
rakshasa d030c5401e * Cleanup of the auto* scripts, curl and openssl checks are now done
with pkg-config.

* Minor changes to included headers and autoconf scripts required by
Solaris.

* Added const char* to VariableMap::has.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@846 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-16 17:30:13 +00:00
rakshasa e122cc928a * Removed the SocketFile dtor which contained an obsolete check of
is_open().

* Added multi-line parser to VariableMap and replaced the various
calls to process_command in main.cc with a single call.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@845 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-13 12:20:22 +00:00
rakshasa c1ac4a2319 * Cleaned up and moved FileManager to the API. It now only keeps track
of open files, which makes the dynamic opening/closing of files much
more efficient if very many large torrents are open.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@843 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-09 11:52:59 +00:00
rakshasa 2be918261e * Bump to version 0.11.2/0.7.2.
* Allow the user to collapse the directories with the '/' key.

* Cleanup of core::Manager::receive_hashing_changed().


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@841 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-05 13:27:56 +00:00
rakshasa 3b38c4ab9c * Limit the number of simultanious http connections.
* Added max_open_http to the man page.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@840 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-02 17:06:08 +00:00
rakshasa de744ad11d * Converted VariableMap and ViewManager to using const char* as the
key, since they are never changed nor added from outside. This cut the
stripped binary size by 50KB.

* Use a shared have piece queue for each download. Each connection has
a time-stamp for the last have message they sent, which is checked
against the queue. This also avoids the race condition where some
peers would get incomplete views of our bitfield due to lost have
messages during handshake.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@839 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-01 14:57:10 +00:00
rakshasa fe7adfc999 * Cleanup of TextElement.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@838 e378c898-3ddf-0310-93e7-cc216c733640
2007-01-01 06:52:56 +00:00
rakshasa 0854e65775 * Changing priority of a directory changes the priority for all files
within that directory.

* Removed a buggy hack in FileListIterator::operator++().

* Cleaned up display of file sizes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@835 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-27 15:11:41 +00:00
rakshasa 06dad41ff8 * Cleanup of the file list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@834 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-26 10:05:44 +00:00
rakshasa eabbf33a76 * Added an info screen to the file list and added more information to
the list.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@833 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-25 18:26:40 +00:00
rakshasa 25702ea4b7 * Finished FileListIterator and basic navigation of the file list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@832 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-25 13:19:45 +00:00
rakshasa c453565e8f * Added FileListIterator to the API, which allows the client to
iterate through FileList as if it consisted of directories.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@831 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-25 10:54:31 +00:00
rakshasa c65b6aa9ff * Added file_path_iterator that allows the client to iterate through
FileList in a structured manner. Messed up the file list view to test
it.

* Added operator[] and at(...) to torrent::FileList and torrent::Path.

* Fixed Handshake::fill_read_buffer(...) that was throwing due to a
bad error check. Patch by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@830 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-22 10:54:39 +00:00
rakshasa aab31e5ea5 * Added path match depth to torrent::File which can be used to quickly
determine the common root directory of two adjecent files.

* Cleaned up RC4 class.

* Fixed --with-openssl so it accepts user-supplied paths.

* Call abort instead of exit when receiving a SIGSEGV or SIGBUS.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@829 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-21 16:27:48 +00:00
rakshasa fbf1a8b8a6 * Fixed a bug caused by gcc-3.3.5 miscompiling the exception thrown in
rtorrent/src/core/download_list.cc:100.

* Disable encryption support when compiling libtorrent with
--without-openssl. Patch by Josef Drexler, public domain as per
earlier agreement.

* Converted torrent::HashQueue from std::list into a std::deque for
better cache locality.

* Fixed a bug that would cause storage errors to trigger an
internal_error being wrongly thrown.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@828 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-18 15:32:31 +00:00
rakshasa cc44fb175d * Cleaned up hash checking, and allow resuming stopped checks.
* Fixed setting of TOS so it doesn't always set it to throughput.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@827 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-18 08:24:01 +00:00
rakshasa d8e5a59b92 * Fixed a bug in download_factory.cc that was setting the chunks done
to 0.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@824 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-13 08:06:16 +00:00
rakshasa 16bb9a87c8 * Cleaned up error.h and HandshakeMessage.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@823 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-12 14:31:39 +00:00
rakshasa fcb8154188 * Cleaned up the exception classes so they require less space. This
reduced the size of the stripped libtorrent by 1/7.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@822 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-11 10:33:09 +00:00
rakshasa 460aac5df0 * Check for duplicate filenames when opening a torrent.
* Removed unnessesary functions from torrent.h.

* Cleanup of Handshake.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@820 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-09 16:51:34 +00:00
rakshasa 407d570de3 * Cleaned up the destruction of Handshake objects, and fixed a use of
a free'ed rak::socket_address.

* Updated rtorrent.1.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@817 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-07 08:04:52 +00:00
rakshasa 59b6ed61ce * Added helper functions for splitting files in FileList.
* Added "split_file_size" and "split_suffix" options.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@815 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-05 09:50:59 +00:00
rakshasa e4db1cacc2 * Removed Content and moved stuff to DownloadWrapper and FileList.
* Using a char buffer instead of std::string in
Handshake::prepare_key_plus_pad().


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@813 e378c898-3ddf-0310-93e7-cc216c733640
2006-12-02 09:16:36 +00:00
rakshasa c992fa60df * Moved some stuff from Content into FileList.
* Resume data was not being used as it was comparing the number of
entries with size_bytes, not size_files.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@812 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-30 15:14:26 +00:00
rakshasa 8b759a5c6e * Moved torrent/file*.{cc,h} to torrent/data/.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@811 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-23 13:54:49 +00:00
rakshasa 281f924556 * Set Content::m_chunkSize before adding files.
* Removed the old FileList and replaced it with the cleaned up
EntryList code. The API now gives a FileList* instead of FileList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@810 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-22 12:57:38 +00:00
rakshasa e3f59ee9e4 * Replaced the old File with the EntryListNode code, and cleaned it
up. The user now uses File* instead of File.

* Changed apply_low_diskspace to use
torrent::Download::free_diskspace() instead of the old file path hack.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@809 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-21 14:05:36 +00:00
rakshasa 4819162ffa * Remove the PeerInfo header dependency inside torrent/data.
* Cleaned up BlockTransfer.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@807 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-19 08:27:20 +00:00
rakshasa f9916b574f * Added a torrent::ClientInfo object to torrent::PeerInfo.
* Removed the old display::ClientInfo code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@806 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-17 14:50:45 +00:00
rakshasa a5e7acc61b * Added all the clients to the new ClientList and fixed it so that it
prints the version number.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@805 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-16 18:33:45 +00:00
rakshasa cafd4c6090 * Added new API for client type and version info, which will replace
the code currently in the client.

* Fixed rtorrent.rc to show the right name for the encryption option.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@804 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-15 14:05:34 +00:00
rakshasa 1982429b8c * Moving some API headers torrent/data and torrent/peer.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@803 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-08 14:57:30 +00:00
rakshasa 6935c97e8f * Removed some global operator == for HashString, made them explicit.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@802 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-08 11:33:12 +00:00
rakshasa b5cc7cff44 * Check if a file in the torrent is a directory when calling
EntryList::open.

* Removed preload_min_pipelined option and added preload_type, which
disables preload on 0, uses madvise willneed on 1 and does direct
touching of the pages on 2.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@801 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-05 13:38:50 +00:00
rakshasa 0c393e1cdb * Properly nul-terminate the info hash and client id in the tracker
request.

* Implemented options for read-ahead of
chunks. 'preload_min_pipelined', 'preload_min_size' and
'preload_required_rate' are used to decide when to read-ahead a chunk.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@800 e378c898-3ddf-0310-93e7-cc216c733640
2006-11-04 16:05:28 +00:00
rakshasa 9d465de7e1 * Use HashString for hash and id which contains the 20 byte array
directly, instead of using std::string.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@799 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-31 11:20:31 +00:00
rakshasa c9d8a2406d * Added symbol export attributes to the API and made the rest hidden
by default.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@798 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-27 13:07:36 +00:00
rakshasa 5dfc986658 * 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
2006-10-25 08:24:20 +00:00
rakshasa 2781ce9698 * Added preliminary support for tunneling peer connections through a
http proxy. Doesn't currently support error checking or such. Use the
'connection_proxy' option to enable.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@796 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-22 10:32:49 +00:00
rakshasa a72054d018 * Removed reset from ProtocolBuffer::consume.
* Added Download::skip_rate that tells us how many downloaded bytes
were skipped.

* Append '&' instead of '?' to the tracker url when the url already
has '?'.

* Added 'tracker_numwant' to the man page and moved tracker related
options to a seperate section.

* Removed Handshake::generate_hash and replaced it with sha1_salt
function in utils/sha1.h.

* Changed various encryption keys to use c_str.

* Set the handshake buffer size to the minimum required and moved them
to the end of Handshake.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@795 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-21 15:13:10 +00:00
rakshasa 44a782e962 * Cleanp of the encryption patch, minor changes.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@793 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-18 07:25:06 +00:00
rakshasa dda5d0783d * Bump version to 0.11.0/0.7.0.
* Shortened the encryption option name to just "encryption".

* Added handshake_encryption.* and moved various stuff from Handshake.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@791 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-15 08:40:29 +00:00
rakshasa 1736c8eaf7 * Encrypted (obfuscated) handshake and connection support. Patch by
Josef Drexler, public domain as per earlier agreement.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@790 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-14 16:46:43 +00:00
rakshasa eb7c0b5874 * Made FileManager::close_least_active() work when cachedTime is
before any of the open file's last touched timer.

* Display upload total, not download for both, in the download info
screen.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@787 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-13 12:59:51 +00:00
rakshasa 29ef815d0e * Added "tracker_numwant" option for setting the numwant field sent to
the tracker.

* Added display for the up/down rate total in download info.

* Use completed bytes from Content for download progress reported to
the tracker, rather than download rate total.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@786 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-11 11:46:33 +00:00
rakshasa 8f311cda47 * Bumping version to 0.10.3/0.6.3.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@783 e378c898-3ddf-0310-93e7-cc216c733640
2006-10-05 12:17:10 +00:00
rakshasa 3084847508 * Bindings::pressed didn't use a temporary to store the result of "itr
!= end()" test.

* Properly clean up trailing '/' in EntryList::set_root_dir(...) and
fixed EntryList::make_directory so it actually makes them.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@776 e378c898-3ddf-0310-93e7-cc216c733640
2006-09-11 13:50:28 +00:00
rakshasa 407824c9c8 * Switch the order rak::advance_bidirectional iterates.
* When testing for mincore, cast the address pointer to (char*).

* Failure during syncing causes the download to stop, unless
flag_ignore_error is set.

* Trigger storage error signal for HashTorrent in
DownloadWrapper::receive_initial_hash.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@774 e378c898-3ddf-0310-93e7-cc216c733640
2006-09-10 03:28:09 +00:00
rakshasa b90a220e15 * Check if individual files are symlinks.
* Use the list of indirect links in EntryList when checking for
available free diskspace.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@773 e378c898-3ddf-0310-93e7-cc216c733640
2006-09-07 14:35:43 +00:00
rakshasa 66dd9a3304 * Use random, not rand, in rak::generate_random as the latter wasn't
being seeded.

* Added a flag to PeerInfo for those that are in handshake, which is
used by PeerList::connect_keep_handshake flag to decide if that
address is to be re-added to the available list when there is already
a connection in progress. This ensures that multiple ports on the same
address don't end up discarded prematurely.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@770 e378c898-3ddf-0310-93e7-cc216c733640
2006-09-01 16:33:21 +00:00
rakshasa af6eb493a9 * Changed RequestList so that it clears m_canceled when a non-canceled
piece is downloaded, and it no longer checks the whole dequeue for
invalid transfers.

* Fixed a bad exception in
PeerConnectionBase::down_chunk_from_buffer(), it is supposed to check
the buffer was used up only when the transfer is unfinished, not when
finished.

* Added --with-address-space to allow the user to change the address
space size. Defaults to 1024 MB on 32 bit, 4096 MB on 64 bit archs.

* Added a parameter to display::Manager::schedule_update that sets the
minimum update interval. Normal updates use 50 msec, adjust_layout
uses 0 msec.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@769 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-31 00:01:12 +00:00
rakshasa ab3a0fead2 * Bumped version number to 0.10.2/0.5.2.
* Support for qwertz keyboard layout.

* Added support for preloading chunks which will be
uploaded. Currently just loads the whole chunk, so it needs to be
improved or disabled before release.

* Added PeerInfo::transfer_counter which keeps track of the number of
BlockTransfers referring to this object.

* Added PeerList::cull_peers that is called every hour to remove
unnessesary PeerInfo from the list..

* In PollKQueue and PollEPoll check that the event we received is
still wanted.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@768 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-29 21:41:49 +00:00
rakshasa bb0f13144b * Fixed the man page to include the latest modifications.
* Bound ^F and ^B for navigating and swapped ^P and ^N in some windows
to get correct behavior.

* Sanitized and added PeerInfo and PeerList to the API.

* HashTorrent now waits for the last outstanding chunks finish before
allowing a chunk mapping error to bork the hashing.

* Lowered the default hash_interval to 5 msec and hash_max_tries to 5.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@765 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-24 23:55:33 +00:00
rakshasa a3f7be3278 * Rebound ^P for commands to ^X.
* Map page entry about max_memory_usage and note about units.

* Quick hash checking changes borked the logic for handling FS errors,
etc.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@764 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-22 11:10:11 +00:00
rakshasa 8fe8fbbb31 * Added kqueue support, enable with "--with-kqueue". Currently
keyboard input is disabled due to bugs in MacOSX 10.4.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@763 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-20 22:01:33 +00:00
rakshasa dbfb9f1165 * Fixed leaking of ViewFilters.
* Messed up the patch, now properly sets min/max_peers on incomplete
downloads.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@760 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-16 17:50:24 +00:00
rakshasa 708e89ebad * Fixed memory leaks in Control, ElementMenu and TextElementBranch.
* Check if RLIMIT_AS is present, else use RLIMIT_DATA.

* Don't add one to the timeout in display::Window::mark_dirty() so
that it updates the display immediately upon reorganizing the layout.

* Updated doc/rtorrent.1.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@759 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-15 23:15:47 +00:00
rakshasa ee7016f547 * Show "Hashing:" for torrents that are queued for hashing.
* Allow different min/max peers setting for seeding. Patch by Josef
Drexler.

* Man page entry for "safe_sync" and "max/min_peers_seed".

* The p,o,i,u keys are now bound so they change ElementMenu directly.

* Bound ^P and ^N for moving up/down.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@758 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-15 19:35:43 +00:00
rakshasa 4d988fccb9 * Added TextElementBranch that uses a slot as the conditional.
* Added timeout to WindowText and updated download and peer info.

* Moved default http agent string to rtorrent/configure.ac.

* Periodic syncing of chunks now tries to only sync tightly packed
  ranges of chunks unless timeout_sync has been reached.

* ChunkManager now checks if max memory is set to RLIM_INFINITY, if so
  use 2^32.

* Added safe_sync option that forces MS_SYNC to be used before
  unmapping chunks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@757 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-13 23:02:13 +00:00
rakshasa 34258bcfb2 * Added various TextElement flags and replaced WindowPeerInfo with a
WindowText.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@756 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-12 18:35:19 +00:00
rakshasa da0d5dbf22 * Added formatting to TextElementValue.
* Finished the download information screen, removed the redunant
entries in WindowPeerInfo.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@755 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-11 15:32:49 +00:00
rakshasa 3c634730c4 * Added TextElementValue*.
* The curl perform loop wasn't properly checking the returned pointer,
which caused a segfault with libcurl 7.15.5.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@754 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-10 21:24:10 +00:00
rakshasa ca58b43d8b * Starting work on ElementText for displaying generic information.
* If a storage error was thrown from make_directory in
EntryList::open, it would try to erase a FileMeta that wasn't inserted.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@753 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-09 19:55:34 +00:00
rakshasa ba28df3ff2 * Fixed download menu.
* Use bold when ElementMenu loses focus.

* Added an exit slot to ElementBase and bind to that from withing the
subclasses.

* Moved peer info to ElementPeerList, accessed by the right
arrow. Download info will be moved to a seperate Element.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@752 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-07 16:31:55 +00:00
rakshasa 0b45062eb3 * Use varargs in Canvas::print.
* Added min/max size to display::Window. Added flags for windows that
should be on located at the left/bottom side of a Frame.

* Reversed print order in WindowLog*.

* Added display::TextElement and subclasses for flexible printing to a
char buffer with associated attributes. Added display::Attributes and
display::Canvas::print_attributes.

* Added display::WindowText for use with display::TextElement's.

* Added ui::ElementMenu for generic menus, and started work adding
this to ui::Download.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@751 e378c898-3ddf-0310-93e7-cc216c733640
2006-08-06 18:20:56 +00:00
rakshasa 62beb9d9ed * Moved handling of events from DownloadList into ElementDownloadList
and WindowLog.

* Added bindings to input::TextInput and disabled other bindings while
it is active.

* ^K now sets ignore_commands.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@750 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-31 00:26:58 +00:00
rakshasa fa5ff92e24 * Moved all remaining classes to use the new display::Frame.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@749 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-29 00:22:26 +00:00
rakshasa 4c9fc671be * Allow Frame's to be located in both rows and columns. Improved min
height/width for windows.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@748 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-28 00:17:54 +00:00
rakshasa fc76a11d71 * UI refactoring, added display::Frame and started cleaning up the
code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@747 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-26 21:41:09 +00:00
rakshasa ef90f0f51e * Added resume functions for saving/loading tracker state.
* Added parameter to torrent::resume_save_progress to indicate that
only completed files are to be saved. This is used when the torrent is
active.

* Update the display when priority is changed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@746 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-22 20:41:47 +00:00
rakshasa 652fd25c07 * Detect the amount of address space available for mapping chunks and
use that to decide when syncing is needed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@745 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-21 20:19:55 +00:00
rakshasa 345c57e9bc * Replaced syncing chunks with ChunkList::sync_chunks which allows the
caller greater control through the use of flags. MS_SYNC is only used
if the caller either requires it or asks for remaining free diskspace
to be checked.

* Moved various flags from DownloadMain to DownloadInfo.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@744 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-19 21:09:19 +00:00
rakshasa b3fc488e5f * Initial work on a global chunk manager for controlling memory usage,
and checking if enough disk space is available for MS_ASYNC to be safe.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@743 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-19 00:42:23 +00:00
rakshasa e8a8fc7e1a * Minor fixes before release.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@740 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-08 22:04:12 +00:00
rakshasa 52bf80d704 * 'I' key set the download to ignore the start/stop_try commands.
* Added options for timeout_sync/safe_sync and max_chunks_queued.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@739 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-07 22:19:20 +00:00
rakshasa 63311270c9 * Adding the compiled man page.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@738 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-05 21:09:36 +00:00
rakshasa 082cbb6cc5 * Added "key_layout" option with support for azerty.
* Delayed the hash done signal.

* Allow quick hash checks that only handles invalid chunks.

* Show failed counter for peers.

* Updated the man page.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@737 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-05 20:12:01 +00:00
rakshasa 66bb95a26c * Select the proper encoding for a torrent's name so that multi-file
torrents get the right root directory.

* Properly clean up after catching a storage_error in
EntryList::open().

* Added a funtion to torrent::Download for syncing chunks to disk, and
made torrent::resume_save_progress(...) use it.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@736 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-04 22:48:43 +00:00
rakshasa c957d1b4d1 * Properly invalidate BlockTransfer's in Block so they get deleted.
* Added is_active flag to TrackerManager and don't reset the
up/download baseline in Download::start() when a request is queued.

* Remove the "started" filter in hashing view, so it starts hashing
stopped torrents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@735 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-03 00:18:48 +00:00
rakshasa 26ffe74744 * Moved the resume code out of DownloadWrapper and made it use the
public API. The client can now use the various calls provided or
implement its own.

* 'U' now deletes the tied file in addition to clearing 'tied_to_file.

* Bound left arrow in chunks seen to return to peer list. Patch by
Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@734 e378c898-3ddf-0310-93e7-cc216c733640
2006-07-01 20:31:07 +00:00
rakshasa 9f2f427e9d * Fixed the transitions between skipping and downloading pieces.
* Added Object::merge_recursive.

* Save and set the chunks done count for closed torrents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@733 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-30 01:02:41 +00:00
rakshasa 4b79a7c47f * Fixed the hashing so it properly starts and stops. When
DownloadList::pause is called it clears the "hashing" variable.

* Added convenience functions for retriving torrent::Object key's of
specific types.

* Iterate to the first visible transfer in the chunks seen view. Patch
by Josef Drexler.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@732 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-28 22:50:58 +00:00
rakshasa ee353bfc9f * Bound 'U' for clearing "tied_to_file".
* Fixed transfer list to mark peers that sent bad data once the chunk
has successfully passed the hash check.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@731 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-26 23:55:54 +00:00
rakshasa d35bef6791 * Expand the path when unlinking the tied file.
* Use DownloadWrapper* to identify hashing chunks, rather than the
info hash.

* When hashing fails, retry the most common blocks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@729 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-24 23:48:26 +00:00
rakshasa 8be667e935 * When a chunk hash fails, copy the data to buffers and try again.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@728 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-23 00:14:44 +00:00
rakshasa 70eacfe738 * Reworked how hashing is queued, state must 1 and removed the
set_hash_failed hacks when closing, etc.

* Changed the attributes of blocks in transfer view.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@727 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-21 22:14:10 +00:00
rakshasa d2fc993514 * Changed the usage of rand() to random() as we only seed the latter.
* Added corrupt_file, an utility to corrupt files to test chunk
hashing.

* Added "start_tied" option, and don't clear "tied_to_file" when
*_untied are called.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@725 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-19 13:01:24 +00:00
rakshasa f1c9188d55 * Compare the block data downloaded by a non-leader with the current
and mark the block transfer if they do not match.

* Erase handshakes in DownloadMain::stop() rather than
Manager::cleanup_download(). This was causing exceptions in PeerList.

* Add 1000ns to the timeout when polling to avoid rounding errors
messing up scheduling.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@724 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-17 23:46:00 +00:00
rakshasa c95eb62802 * Second part of reworking how multiple downloads of the same chunk is
handled.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@721 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-15 00:46:13 +00:00
rakshasa b3b4acaad8 * Added view of blocks in transfer list view.
* Show chunks with only queued transfers with an underscore in chunks
seen view. Patch by Josef Drexler, public domain.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@719 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-12 22:34:41 +00:00
rakshasa 38f0cdbce2 * Added blocks to transfer list view.
* Minor modifications to the Block API.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@718 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-12 19:20:51 +00:00
rakshasa 1e54882da4 * Reverse the color of currently downloading chunks in chunks
seen. Patch by Josef Drexler, public domain.

* Moving various stuff from Delegator to TransferList.

* Added checks in HandshakeManager::receive_* to check for invalid
handshakes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@716 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-11 18:22:30 +00:00
rakshasa f0d94bc938 * Added TransferList to the API.
* Added transfer list view, bound to the 'u' key.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@715 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-09 22:59:47 +00:00
rakshasa ffb820f536 * Moved PeerConnectionBase::m_downTransfer into RequestList.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@714 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-08 18:45:51 +00:00
rakshasa beeea9fd3e * Handshake was setting wrong bitfield size.
* Cleanup of Block classes.

* Added brackets to error message from the OpenSSL test.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@713 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-06 21:16:55 +00:00
rakshasa d0f6719e50 * Added pageup/down to chunks seen and file list. Patch by Josef
Drexler, all future patches to lib/rtorrent will be under public
domain.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@712 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-04 23:37:39 +00:00
rakshasa 46dd41e956 * Moved defininiton of priority enum to torrent/common.h.
* Properly return the size of the Block.

* Bumped to 0.10.0/0.6.0.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@711 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-04 20:53:04 +00:00
rakshasa 18cd5342df * Moved Delegator over to using the new Block classes.
* Fixed alignment of the ratio display.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@710 e378c898-3ddf-0310-93e7-cc216c733640
2006-06-04 14:17:23 +00:00
rakshasa c573c8a9bc * Starting work on persitant storage of peer info.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@707 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-31 16:05:09 +00:00
rakshasa 146c104eb3 * Added "stop_on_ratio" option and display the ratio. Patch by Josef
Drexler, public domain.

* Made autogen.sh detect glibtoolize.

* Don't resume torrents that are marked as completed yet the initial
hash check returns failed chunks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@704 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-27 23:35:20 +00:00
rakshasa 932296ce52 * Added "close_low_diskspace" option that closes active downloads on
filesystems with less space left than what was passed as the
argument. Patch by Josef Drexler, public domain.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@703 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-25 19:44:13 +00:00
rakshasa aaaf5d9a5d * core::DownloadList::receive_hash_done(...) now handles failed
initial hash checks properly, rather than throwing an exception.

* Explicitly allocate Bitfield::m_data and dis-associate it from the
size. This will allow us to store m_size and m_set without the
underlying bitfield.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@700 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-23 17:26:38 +00:00
rakshasa e4c5c80688 * Bumping version to 0.9.3/0.5.3.
* Ignore wrong type for "peers" in tracker requests as some trackers
send a dictionary when empty.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@697 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-23 07:36:58 +00:00
rakshasa 770d205b9a * Some views were using uninitialized bool for reversing.
* Possibly hash_done gets called while a download is closed.

* Consider putting chunk release before receive_chunkdone.

* Don't use getopt to check for flags as that re-orders the left-over
arguments.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@696 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-21 00:11:07 +00:00
rakshasa 271e8e6ccf * Bumping the version numbers.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@693 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-19 16:54:42 +00:00
rakshasa 14418244fb * Reordered the ChunkList::sync_* code to work around a gcc-3.3 bug.
* torrent::TrackerList::send_completed() was being called before the
download was resumed, thus it never got sent.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@692 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-18 19:35:27 +00:00
rakshasa ba4a1927ff * Set the hash failed flag before DownloadList::hash_clear closes the
torrent, so the hashing queue doesn't re-open it.

* Randomized the starting position in chunk selector.

* Added man page entry for send/receive buffer size.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@689 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-15 17:55:11 +00:00
rakshasa d4706da4d5 * Removed core::HashQueue, using the "hashing" view and a function in
core::Manager instead.

* Added a new :rtorrent:hashing state so we can distinguish between
initial hashing and manual rehashes. The former is cleared if the
download is paused.

* Added a hash failed flag to core::Download. This is used to skip
entries in the hashing view that either failed to open or are in the
process of being erased from DownloadList.

* torrent::Bitfield::unset was incrementing, rather than decrementing,
the m_set counter.

* Replaced all torrent::internal_error's in rtorrent with
torrent::client_error.

* ^D now checks :rtorrent:state to decide whetever to stop or erase a
download. Downloads queued for hashing will now stop rather than be
deleted.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@688 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-13 00:18:50 +00:00
rakshasa 65f3dda9ab * Added 'close_untied' option.
* Remove redundant BitField::update calls now that updating
Bitfield::m_set gets handled properly in hash_resume_load.

* Fixed the error message when trying to lock non-existant session
directories.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@687 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-12 01:07:21 +00:00
rakshasa a851264787 * Added '-n' flag that disables loading of ~/.rtorrent.rc.
* Re-added priority change when a download finishes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@686 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-09 20:50:07 +00:00
rakshasa 6d07bf3540 * Added 'view_filter_on' option that triggers filtering of a download
after an event.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@685 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-08 23:42:03 +00:00
rakshasa 8387dbde6f * Clear the resume bitfield when resuming an incomplete download. This
will force rehashing if the program dies in a messy way.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@682 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-04 13:43:59 +00:00
rakshasa 0620ea88a7 * Added man page entries for view_* and session_save.
* Moved around resume save so it doesn't bork on completed last hash
check.

* torrent::Download::hash_resume_clear() no longer removes priority
and mtime information, only the bitfield.

* Added a quick hack that allows libtorrent to split large files. The
parameter needs to be set in the source, no API available yet.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@681 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-03 18:59:07 +00:00
rakshasa f01289ef12 * Do session save on exit from the main loop, and moved around
hash_resume_save.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@680 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-02 19:57:35 +00:00
rakshasa 2b420e95a0 * A seperate variable for hashing state, now properly restarts hashing
after restart.

* Stop a torrent and show a message when it finishes the final
hash-check and finds some chunks incomplete. This prevents full disk
from causing a torrent to go into an infinit loop of re-downloading
the data.

* Moved various slots from core::Manager to core::DownloadList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@679 e378c898-3ddf-0310-93e7-cc216c733640
2006-05-01 18:53:21 +00:00
rakshasa fff7838f13 * Moved various Download related stuff from core::Manager to
core::DownloadList.

* SVN didn't properly commit changes to view.h, fixed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@678 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-29 20:27:04 +00:00
rakshasa 236f689efc * Moved various download related calls from core::Manager to
core::DownloadList, added a slot map for hash done.

* Enabled the complete/incomplete views.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@677 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-28 23:21:32 +00:00
rakshasa 02a0510439 * Changed ViewSort::less(...) to operator().
* Added a "last changed" paramter to ViewManager::sort(...) which is
checked, if the ViewDownloads's last_changed timer was poked withing
that timeframe it won't update.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@676 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-27 21:38:02 +00:00
rakshasa 8ae5e51a0f * Change :rtorrent:state to an integer.
* Split up DownloadList::insert to get proper ordering of slot map
calls and variable initialization.

* Added filtering to ViewDownloads.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@675 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-26 21:23:37 +00:00
rakshasa c5c9a1ddae * Added the framework for a download scheduler.
* Added "state_changed" variable to downloads that returns the last
time the download called DownloadList::pause/resume.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@674 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-25 19:33:53 +00:00
rakshasa 19179bd160 * Fixed mismatched delete/delete[] in torrent::Bitfield::resize.
* Added 'view_sort_current', changed 'view_sort' to sort according to
what was defined by the former option.

* 'view_sort_*' now takes a list of sorting options which are applied
in order.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@673 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-24 23:22:57 +00:00
rakshasa 598455a5df * The curl bind address was being set by set_local_address(...), urgh.
* Made IPv6 stuff configurable.

* Improved the view stuff.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@672 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-23 23:17:05 +00:00
rakshasa 11c842308a * Added VariableBool.
* Added views for downloads, that can be sorted.

* Added options "view_add", "view_sort" and "view_new".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@671 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-22 23:16:08 +00:00
rakshasa c4256079ae * New non-template VariableStringSlot and VariableValueSlot.
* Support B, K, M and G in options.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@670 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-20 20:03:03 +00:00
rakshasa 2f6b5affd1 * Disconnect incoming connections early if the download is full. Patch
by Josef Drexler, public domain.

* Check if bitfield or have messages has been received before when
getting a bitfield message. This fixes an exception on
PC::using_counter() not begin false.

* Added a switch to disable the use of ncursesw, instead using ncurses.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@669 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-13 21:11:42 +00:00
rakshasa 7ad18cdac2 * Added missing files in rtorrent/Makefile.am.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@666 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-06 17:51:17 +00:00
rakshasa dc1f6d4f23 * Minor BSD portability fixes.
* Added torrent::TrackerList::{set_,}key() and made rtorrent save the
key between sessions.

* Added import option to the man page.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@665 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-06 16:40:25 +00:00
rakshasa 8a8cfe5e3d * Made torrent::Piece part of the api.
* Made libtorrent locale agnostic.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@664 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-05 21:09:15 +00:00
rakshasa 3fa08503bb * Clear the DelegatorChunk's when clearing Delegator, so it doesn't
throw on some obscure bug. Not going to be looking for this one anyway
as there is a rewrite scheduled.

* Added "tos = default|lowdelay|throughput|reliability|mincost" option.

* Made EntryList::value_type a pointer, fixed so FileMeta is
initialized and path set before Download::open().


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@662 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-03 20:58:10 +00:00
rakshasa f0d31900b7 * Added combined Object::has_key and Object::is_* functions.
* Re-added 'tracker_dump' option which takes a filename.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@661 e378c898-3ddf-0310-93e7-cc216c733640
2006-04-01 22:06:57 +00:00
rakshasa d9d27139d1 * Fixed an overflow in rak::partial_queue, and added some exceptions.
* Changed to configure script so --disable-mincore must be called
explicitly to disable it.

* API and core::Download cleanup.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@660 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-31 23:02:39 +00:00
rakshasa 59a23ea9ed * Added torrent::FileList to the API.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@659 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-30 17:57:57 +00:00
rakshasa 8ea6f78e21 * Cache the current ceiling in rak::partial_queue.
* Added "enable_trackers=yes|no" option that can turn on/off the use
of trackers on all torrents.

* Cleanup of the API, including a new TrackerList class.

* When requesting from seeders, either continue a chunk another seeder
started or try a new one. This means seeders don't end up downloading
non-rare chunks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@658 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-28 21:04:07 +00:00
rakshasa a811f53301 * Applied a patch from josef that cleand up the chunks seen window.
* More work on rarity-first chunk selection.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@657 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-25 20:20:52 +00:00
rakshasa b3051db2b2 * Used the peer's option field when writing the handshake header
causing some peers to disconnect.

* Added rak::partial_priority class for efficient caching of chunks
indices based on rarity.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@656 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-24 21:24:24 +00:00
rakshasa f953c8935e * Added the rarity of chunks to ChunkStatistics, only non-complete
peers. This will be even more lazy and only do this when needed.

* 'i' key in the download view will show rarity of pieces.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@655 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-22 21:13:34 +00:00
rakshasa 14475fd4c1 * Moved Listen to ConnectionManager and use a single port rather than
cache it in each download.

* Set classic locale on various streams.

* Added ChunkStatistic class that will keep track of the number of
each chunk, and how many seeders there are.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@654 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-21 20:37:00 +00:00
rakshasa 17d66c4a2f * Moved Bencode stream functions to object_stream.h and the Bencode
class to object.h.

* torrent::download_add(...) now takes an torrent::Object*.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@653 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-20 21:03:42 +00:00
rakshasa 86a3f868df * Added "send_buffer_size" and "receive_buffer_size" options that set
the socket SND/RCBBUF sizes.

* Added slot for connection filtering.

* Added closing torrents with ^K and did some cleanup of the torrent
state code.

* Moved various socket setup to HandshakeManager.

* Added a baseline for the uploaded amount that resets every time the
torrent restarts, thereby sending only the amount uploaded since the
last restart.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@652 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-18 00:55:50 +00:00
rakshasa 1c55348d45 * Moved {bind,local}_address() to ConnectionManager.
* Various other API cleanups.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@651 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-15 23:25:19 +00:00
rakshasa 571fe8b2f4 * Changed to using sockaddr* in libtorrent's api.
* Prepared SocketManager for inclusion in the api.

* From <nornagon@gmail.com>: bound some control keys in text input.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@650 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-15 16:22:40 +00:00
rakshasa 2863c10389 * Removed duplicate portions of some rak/ headers.
* Properly set uninterested when the peer doesn't have any more pieces
we're interested in.

* #180, the ResourceManager didn't iterate over downloads with weight
0, causing those with priority off to not to perform choking nor get
counted in the total.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@649 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-10 15:51:25 +00:00
rakshasa 6822261199 * Piece request messages didn't get read when they were the only
message in the buffer, it required an additional byte beyond the size
of the request body.

* More work on ClientInfo.

* Bound 'k' to disconnecting a peer. Consider a better key.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@647 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-06 20:43:44 +00:00
rakshasa b00d083ac2 * Renamed TrackerInfo to DownloadInfo, moved it to DownloadMain and
cleaned up DownloadWrapper etc.

* Resume total upload from the client rather than
torrent::Download::hash_resume_load(...).

* Show client names and versions. (incomplete)


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@646 e378c898-3ddf-0310-93e7-cc216c733640
2006-03-01 20:48:54 +00:00
rakshasa c77ecb034f * Added API for getting the complete, incomplete and downloaded stats
received from trackers. Display them in the tracker list.

* Fixed a bug introduced by the TrackerInfo* id change that caused
handshakes to hold old pointer. They now get removed when a download
is erased.

* Some cleanup of DownloadWrapper initialization.

* Moved bind and local address to from Manager to SocketManager.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@645 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-28 13:20:52 +00:00
rakshasa a6a0c25fbc * More rak::socket_address cleanup, made listening port seperate from
local address and use port 0 when listening port is closed.

* Added "port_open" option which allows the user to not open any
listening port.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@644 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-24 21:32:36 +00:00
rakshasa e3571f249c * Added "upload_total_clear" option that clears the total upload
counter when loading session torrents.

* Use the TrackerInfo pointer (to be renamed) as an identifier for
downloads, rather than the hash.

* Partially converted to using a new wrapper for sockaddr, which will
allow IPv6.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@642 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-21 20:58:47 +00:00
rakshasa 1f769cc138 * Use TrackerInfo pointer as unique id for torrents internally.
* Make the fake mincore call use the right length parameter.

* Added new rak::socket_address class.



git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@641 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-20 17:20:26 +00:00
rakshasa 1a7fccf2d9 * Minor portability fixes.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@638 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-16 18:14:52 +00:00
rakshasa 1e5146121e * Added "-O" flag that takes a single option, allowing ','.
* Added the errno message when a file in a torrent could not be opened.

* Added torrent::Object class which will be replacing torrent::Bencode.

* Ported to Cygwin, patch supplied by Jussi Kivilinna
<jussi.kivilinna@mbnet.fi>.

* Update display before entering the main loop, so it won't seem to be
blocking when loading torrents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@637 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-16 14:57:41 +00:00
rakshasa 4dea195340 * Expand ~ in paths, all uses should be covered.
* Moved option file parsing to VariableMap and added "import" and
"try_import" options for loading option files.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@636 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-11 15:34:53 +00:00
rakshasa e5c5f7ecb1 * Remove stale lock files if it is held by the same hostname and the
pid is not running.

* Added rak::timer::from_seconds(uint32_t) and converted all uses to
this to avoid overflows etc.

* For each cycle through the tracker list without any successfull
connections, increase the timeout by 20 seconds.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@635 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-09 19:18:26 +00:00
rakshasa 126bb511b8 * Applied patch from Diego 'Flameeyes' Petteno <flameeyes@gentoo.org>
that adds the "unused" attribute to some function parameters and minor
cleanups of configure.ac.

* Added inttypes.h to command_scheduler.h.

* Bumped to version 0.8.5/0.4.5.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@634 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-05 01:43:38 +00:00
rakshasa 8b934623d4 * Minor *BSD compatibility fixes.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@631 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-04 20:00:54 +00:00
rakshasa 68502367ec * Don't show ETA on finished and stopped torrents.
* Added percentage completed to active unfinished torrents.

* Re-enabled different seeding and leeching priorities.

* Make a temporary container in AvailableList::insert(AddressList*)
when doing std::set_differernce. AvailableList's std::vector would
resize and cause invalidated iterators to be used.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@630 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-04 19:18:41 +00:00
rakshasa d06ecda46a * Added "working_directory" option that calls chdir.
* Added "session_on_completion" option which saves the session torrent
when a download finishes.

* Handle SIGTERM gracefully, saving session torrents etc.

* Implemented session directory lockfile, use "session_lock" option to
disable.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@629 e378c898-3ddf-0310-93e7-cc216c733640
2006-02-01 12:11:09 +00:00
rakshasa 6f44f8f920 * Make DownloadStore::save(...) validate the new file by loading the
bencoded data.

* Make it safe to remove torrents that are selected.

* Delete the rtorrent and libtorrent sections when loading non-session
torrents.

* Added ^O to change a torrent's root dir, ^P to set a variable.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@628 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-27 20:16:52 +00:00
rakshasa c89ae513ef * Allow clock time for command scheduler interval and start time using
the format "hh:mm:ss".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@627 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-25 21:23:46 +00:00
rakshasa 305e3bdf2b * ChunkSelector selected from outside the priority ranges due to
~(char)0 giving an inverted integer rather than char.

* Fixed a segfault due to too small screen size, snprintf returns the
number of bytes that could have been written rather than how much
actually was.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@626 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-24 20:05:36 +00:00
rakshasa 825985b8ef * Bind udp and http tracker requests to the bind address.
* Allow the torrent's priority to be changed with '+'.

* More work on the variables thing.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@625 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-23 19:24:45 +00:00
rakshasa 52636178d1 * Moved hash and torrent size checking to initialize so it will be
caught when loading a torrent.

* Added VariableMap to core::Download and started moving various
settings.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@624 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-19 17:13:25 +00:00
rakshasa e8cd37ea3a * Set SO_REUSEADDR for the listening socket.
* Moved several settings to use the new variables and made the parser
better.

* Use "-O2" rather than "-O3".


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@623 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-17 17:23:32 +00:00
rakshasa 4028ab2295 * New code for handling options/variables which used bencode and can
redirect get/set operations.

* Fixed(?) a bug in RequestList::downloading(...) that could cause a
segfault when pieces in the canceled list start downloading.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@622 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-13 03:26:46 +00:00
rakshasa b25af84ee8 * Bumping the copyright year to 2006.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@621 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-10 00:46:50 +00:00
rakshasa 310589c4bf * Unlink the tied file when a torrent is erased.
* Remove torrents that are already tied from the expanded paths.

* Move the loop counter to Control.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@618 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-09 18:54:57 +00:00
rakshasa f32c15878a * Fixed the log redraw which didn't happen as the display's scheduler
didn't get re-added to the task scheduler until a new event happened.

* Added redraw delay interval of 100ms, consider 50ms.

* Removed exceptions from core::DownloadStore::save.

* Added load, load_run, tied_stop and tied_remove to man-page.

* Cleaned up the command/option instances, move them to Control.

* PCB::load_up_chunk grabbed the errno from m_downChunk, not m_upChunk.

* Various string operations were moved to rak/string_manip.h.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@617 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-06 21:14:49 +00:00
rakshasa 4431fd1652 * Fixed a regression that threw an exception for torrents with
empty directories.

* When receiving zero length pieces, remove them from the request list.

* Send the interested state before any requests as some clients,
BitTornado 0.7.14 and uTorrent 0.3.0, disconnect if a request has been
received while uninterested.

* WITH_POSIX_FALLOCATE configure macro should check against "yes", not
"no".

* The new priority queue would cause arg torrents to load before
session torrents in some cases. Fixed to perform the session torrent
tasks before loading arg torrents.

* Allow '*' wildcard in filenames when loading torrents.

* Added load, load_run, stop_tied and remove_tied settings which can
be used to scan a directory for new/removed torrents. These torrents
are tied to the lifetime of the torrent file.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@616 e378c898-3ddf-0310-93e7-cc216c733640
2006-01-03 21:43:01 +00:00
rakshasa 5a8a402745 * Minor cleanup in rtorrent.
* Changing priorities of closed torrents caused a crash due to empty
ChunkSelector, fixed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@615 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-22 03:55:43 +00:00
rakshasa 2c5151def5 * Checked and fixed calls to priority_queue_insert to make sure they
don't end up in an infinite loop.

* Fixed a bug that caused failed chunk downloads to result in
ChunkSelector's forgetting to download them again.

* Added note to the man page about the schedule and schedule_remove
setting.

* Display the number of failed chunks in the client.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@612 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-20 19:12:15 +00:00
rakshasa 3989ae8975 * Disabled setting of uninterested when no more chunks can be
requested, this needs to be fixed.

* Minor adjustments to the usage of rak::priority_queue_insert.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@611 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-19 20:58:13 +00:00
rakshasa 4e8e5a18df * Clear the download rate when finishing a torrent.
* Fixed torrent::set_{bind,local}_address(...) so they update
correctly.

* Tweaked the time left display, show minutes instead of seconds.

* Add earlier check on validity of the socket address of
incoming/outgoing connection.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@610 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-18 23:49:00 +00:00
rakshasa e45f05ee98 * Added command scheduler, currently it only calls option handler.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@609 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-17 02:50:10 +00:00
rakshasa ca5b5e05ec * Removed ticks for downloads, use the global tick instead.
* Fixed rak::priority_queue.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@608 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-15 22:56:03 +00:00
rakshasa 7cc377b550 * Cleaned up rak::priority_queue.
* Added download time left display, need to tweak it.

* Removed libtorrent/src/download/download_setup.cc.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@607 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-09 05:22:36 +00:00
rakshasa 12ef47da3c * Replaced TaskScheduler with rak::priority_queue.
* Fixed an exception caused by initial hash check not properly
cleaning up HashQueue when canceling.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@606 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-08 21:19:53 +00:00
rakshasa ba7d61b532 * Fixed a buffer overflow when writting to the output buffer. This
would in some rare occasions cause memory to be corrupted. leading to
a crash.

* Added option for setting the http proxy and proccess's umask.

* Save the total uploaded for downloads between sessions.

* Moved from sigc++ to my own lightweight slot class for the task
scheduler. This saves some 5-600kb when compiled with debugging
symbols, 1-200kb without.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@605 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-05 07:59:29 +00:00
rakshasa 32a3619cd8 * Moved Timer to rak/timer.h.
* Added position affinity to ChunkSelector, still needs more work to
make it move forward without needing to finish all pieces.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@604 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-04 21:08:17 +00:00
rakshasa a1a07c47aa * Bumped version number to 0.8.1.
* Implemented ChunkSelector.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@603 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-04 00:20:47 +00:00
rakshasa f9614c405d * Added a workaround for the vfat truncate bug. This blocks for a
while, so either it needs some additional hack or make it a configure
option.

* Trigger a storage_error when files fail to resize.

* Fixed a bug in the priority code that caused it to skip some ranges.

* Added a check to make sure a CurlGet object is closed once it is
finished.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@602 e378c898-3ddf-0310-93e7-cc216c733640
2005-12-02 20:07:50 +00:00
rakshasa 98a8fc8638 * Improved error handling for settings. LibTorrent now consistently
throws torrent::input_error and rtorrent catches those and prints good
error messages.

* torrent::set_{bind,local}_address now accepts dns addresses.

* Fixed bug that caused multiple instances of the setting
up/download_rate to change the relative rate, rather than constant.

* Minor change to the way PCB decides to not request more pieces.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@601 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-24 17:21:32 +00:00
rakshasa 93c6369b69 * Added the ability to set the timeout in torrent::Http. Torrent
downloads now have longer timeout than tracker requests.

* Bound the '*' key in tracker list to disable a tracker.

* Added PollKQueue placeholder, implementation will come later.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@598 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-21 19:19:43 +00:00
rakshasa cbbad78b6a * Set "stopped" stated to newly added torrents, so they stay stopped
when restarting the client.

* Renamed Bencode::operator[] to Bencode::get_key.

* Added progress percentage for hash checking.

* Correctly update the delegator priority when loading resume data
with file priorities.

* Don't allow file names with '\0' in them.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@597 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-16 20:46:13 +00:00
rakshasa e8deac9f79 * Made ThrottleNode an object held by PCB, rather than ThrottleList
which now holds ThrottleNode*. Moved Rate from PCB to ThrottleNode.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@596 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-14 15:42:13 +00:00
rakshasa a97408328a * Cleanup of the API, got rid of "get_" prefix for alot of the calls.
* Tweaked the http get timeout, now it has a 60 second connect timeout
and a 360 second download timeout.

* Moved libtorrent/src/parse/download_constructor to src/download.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@595 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-12 15:31:12 +00:00
rakshasa 3db8179274 * Moved http get's user agent stuff to the client. It now uses
"rtorrent/CLIENT_VERSION/LIBRARY_VERSION".

* Using libcurl's timeout, set to 60 seconds, rather than in
TrackerHttp. This should make libcurl try different IP's.

* Minor cleanup of how file priorities are updated.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@594 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-08 21:14:32 +00:00
rakshasa b28621f839 * Dynamically changes the throttle interval depending on the current
rate and chunk size.

* Changed torrent::download_remove to take a torrent::Download, rather
than the info hash.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@592 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-03 16:26:08 +00:00
rakshasa 89e69adb7a * Added interface for changing download priority.
* More throttle fiddling.

* Pop the currently uploaded piece from the send list.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@591 e378c898-3ddf-0310-93e7-cc216c733640
2005-11-01 19:42:07 +00:00
rakshasa 1a68177eca * More fiddling of the throttle code.
* Fixed a bug that caused idle looping due to epoll_wait timeout using
msecs rather than usecs resolution.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@590 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-31 15:40:50 +00:00
rakshasa ce411252ac * More work on the new throttle code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@589 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-29 22:54:08 +00:00
rakshasa 5137aade10 * New throttle implementation, works to a certain degree but still
needs some work.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@588 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-29 00:55:21 +00:00
rakshasa da67bdfff1 * Added prefered encoding list using the "encoding_list = <enc>"
option.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@587 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-26 13:25:10 +00:00
rakshasa 7e861cf9f2 * Store and display the encoding for the currently used filename.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@586 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-25 20:15:26 +00:00
rakshasa eb8fecbc34 * Fixed various compiler warnings.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@585 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-24 10:40:55 +00:00
rakshasa dc2b1aa5d8 * Making a DownloadConstructor to replace src/parse/* stuff.
* Enabled throttle dependent global upload limit and added some stats
display to the client.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@584 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-22 19:36:38 +00:00
rakshasa 45781e8dbf * Got rid of some additional internal sigc++ calls.
* Changed print_hhmmss/ddmmyyyy to use a char buffer.

* Added error messages for failed torrent http/file downloads which
includes the url/filename.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@581 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-17 19:19:48 +00:00
rakshasa c99cc03d19 * Replaced most of the internal sigc++ slots and signals with a
lightweight version. This cut the size of the library w/debug by more
than 300kb. All (almost) the signals the client connects to are now in
DownloadWrapper.

* Fixed off-by-one error in the month displayed.

* Moved tracker url cleanup to src/parse and improved it.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@580 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-14 21:50:45 +00:00
rakshasa ad80247ba6 * Improved hash checking, it now stops a torrent if some chunk
mappings fail even though a file has been allocated.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@578 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-10 19:36:12 +00:00
rakshasa 881f515d03 * Scheduled tasks, like hash checking, didn't get called when
downloading with curl on epoll unless sockets triggered events.

* Checking whetever we're interested in a peer's pieces wasn't
finished, doh.

* Don't use shorter timeout for "stopped" tracker request, the client
now makes sure it shuts down within 5 seconds.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@577 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-07 20:01:38 +00:00
rakshasa 65573ec1ee * Converted some internal sigc++ calls to lightweight function
wrappers.

* Some client code cleanup.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@576 e378c898-3ddf-0310-93e7-cc216c733640
2005-10-04 11:06:06 +00:00
rakshasa 33b7217627 * Working resource manager.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@570 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-23 23:49:53 +00:00
rakshasa 88b8afe025 * Replaced some sigc++ slots with lightweight callback classes.
* Almost done with global choke management, only need to sort and
debug. The API to change the setting will be added after the next
release.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@569 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-22 12:09:55 +00:00
rakshasa 108ad78d30 * Starting work on resource manager.
* Modified rak::accumulate to require accessing ::result instead of
using a reference.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@568 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-20 13:53:45 +00:00
rakshasa 94d31cc681 * Fixed various memory leaks/errors.
* Don't increment beyond end when incrementing a entry's completed
counter.

* Don't allow ChokeManager::try_unchoke to succeed when it has been
less than 10 seconds since the last unchoke.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@562 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-17 01:31:30 +00:00
rakshasa 5ada857c3e * Added lazy syncing of chunks.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@557 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-10 15:38:34 +00:00
rakshasa c347ccc439 * Use ChunkHandle instead of ChunkListNode*, this will include write
reference counter.

* Get errno message when chunks can't be allocated.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@556 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-09 16:12:29 +00:00
rakshasa 8732e457fa * Cleaned up socket read/write error handling.
* Fixed a bug where PeerConnectionSeed was reading the wrong type of
message.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@554 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-05 18:50:48 +00:00
rakshasa 3bd99aee50 * Fixed some bugs and cleaned up the code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@550 e378c898-3ddf-0310-93e7-cc216c733640
2005-09-01 17:12:31 +00:00
rakshasa c568306a5a * Finished keep-alive in PeerConnectionSeed.
* Display the connection types for a download.

* Fixed HashTorrent so it properly erases the Chunks it holds.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@549 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-31 18:40:18 +00:00
rakshasa a1bffb4526 * Almost completed PeerConnectionSeed, only missing the keep-alive
message.

* Set "connection_seed = seed" by default.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@548 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-30 22:54:16 +00:00
rakshasa 2a1f3e12cc * Renamed read/write stuff to down/up.
* Adding incomplete PeerConnectionSeed.

* For every new peer connection it would traverse the local bitfield
to check if it was zero'ed, instead of using a cached value. Forgot to
change over when changing it from the BitFieldExt to the normal class.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@547 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-29 18:39:34 +00:00
rakshasa a28ed1c96b * File progress wasn't being updated as the index range iterator was
off by one.

* Removed ProtocolChunk, moved the functions to PeerConnectionBase,
remains to clean it up.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@546 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-27 15:44:56 +00:00
rakshasa abbe4dd675 * Changed the TaskScheduler so new tasks are inserted beyond the last
due task when executing.

* Moved stuff from torrent/torrent.cc to torrent::Manager.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@535 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-18 00:46:54 +00:00
rakshasa b0ac469262 * Removed PeerConnection::m_taskStall, use the keepalive task instead.
* Fixed typo in USE_ALIGNED check.

* Added checks to Tracker* to make sure m_taskTimeout isn't already
inserted.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@534 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-17 19:20:38 +00:00
rakshasa 7f2b66d601 * Add includes of headers for select.
* Make initialization and cleanup of display::Canvast safer.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@533 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-17 16:58:07 +00:00
rakshasa 4eb18663f5 * Use a common task item to trigger keepalive for all connections.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@532 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-16 22:26:59 +00:00
rakshasa 8b1afe2485 * Added byte alignment check, if required use a different means of
reading ints from ProtocolBuffer.

* Don't round the task for ThrottleScheduler to the nearest second
since it has a sub-second timeout. Change the other timeouts to first
add cached and timespan, then round to the nearest seconds.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@529 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-16 18:13:43 +00:00
rakshasa 52214aa992 * Properly close tracker requests when closing a download.
* When sending stopped state to a tracker, use 5 second timeout.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@525 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-13 20:15:42 +00:00
rakshasa 407f3383f0 * Automagically set the max open sockets and files to resonable values
according to sysconf(_SC_OPEN_MAX).

* Added timeout to torrent::TrackerHttp so connections that are left
open, but with no data being transmitted get closed after a resonable
time.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@524 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-12 16:05:54 +00:00
rakshasa 202ed7928b * Fixed a compiler warning.
* Tell libcurl to follow redirects.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@521 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-10 12:20:17 +00:00
rakshasa 6590f5608f * Added tracker re-requesting when connected to less than minimum
peers, currently doesn't handle multi-trackers nor do various safety
checks.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@520 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-09 14:49:00 +00:00
rakshasa 65d940484a * Adding TrackerManager class that implements a simpler interface for
tracker control. It will support different modes like f.ex trying to
request more peers from the trackers.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@519 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-08 15:59:12 +00:00
rakshasa 287dfbf334 * Fixed an un-initialized pointer bug in ui::ElementStringList.
* Properly hide epoll stuff inside an USE_EPOLL if/else macro.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@518 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-07 17:57:58 +00:00
rakshasa dc5476e3f4 * Moved Hanshake* to protocol/, moved peer/* to protocol/*.
* Show in client which tracker has the focus.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@516 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-04 15:41:15 +00:00
rakshasa e5aad7ed6a * Using SocketAddress instead of PeerInfo in Tracker*, unconnected
peers and HandshakeManager. Some other address releated code was
cleaned up.

* Made a seperate AvailableList class for unconnected peers. Using the
tracker success signal to call a function in ConnectionList that
removes already connected peers from the list.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@514 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-03 18:50:36 +00:00
rakshasa 91a6950c01 * Added information about which side initiates a connection.
* Cleaned up torrent::DownloadNet and created torrent::ConnectionList
that handles the connections in a download.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@513 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-02 14:59:04 +00:00
rakshasa 89a090111d * Added support for variable sized fd_set's, this should remove the FD_SETSIZE limit.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@512 e378c898-3ddf-0310-93e7-cc216c733640
2005-08-01 16:20:34 +00:00
rakshasa 00e0da7aa5 * Fixed torrent::PollSelect::perform(...) so it checks if the Event*
is NULL, which happens if another event removes it.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@511 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-28 01:47:35 +00:00
rakshasa 3df7567ddf * Rewrote 'select' based polling in the client and finished the
'epoll' code. The client selects whichever is available on the current
platform.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@510 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-27 18:39:57 +00:00
rakshasa 91f4f022a9 * Finished implementing epoll support in the library. The client side
is abit hacky and normal select based polling is temporarily disabled.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@509 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-26 16:38:15 +00:00
rakshasa 424a20b3f5 * Changed the API to support different Poll objects and made
PollSelect available. Started work on PollEPoll.

* Fixed a bug that caused blank characters to be inserted into the
tracker request url.

* Added display of the options field in the peer info view.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@508 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-25 15:28:03 +00:00
rakshasa a3521e974d * Minor bug fixes and cleanup.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@507 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-25 00:33:00 +00:00
rakshasa e877d3487b * Adding framework for a modular polling class.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@505 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-24 16:47:30 +00:00
rakshasa 10ff3141d9 * Added posix_fallocate to File::reserve, though it is disabled by
default.

* Added some checks to the keyboard input code in the client, perhaps
it'll fix the bug some OpenBSD people are encountering.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@501 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-19 14:00:20 +00:00
rakshasa 81c36a7d96 * Using SocketAddress instead of std::string/uint16_t for peer
addresses.

* Tracker key is now an uint32_t instead of std::string.

* Added client address to UDP tracker requests.

* Added a check for FD_SETSIZE and _SC_OPEN_MAX in the client. A
warning is issued if max open files and sockets exceed either of these.

* Cleaned up the API, propably quite close to what will be in the
slush'ed API.

* Swapped emit and close order in TrackerHttp.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@499 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-18 17:22:17 +00:00
rakshasa 7a9010445b * Cleaned up torrent::ProtocolBuffer.
* Added enums to torrent::Tracker to allow the client to check
whetever the tracker is an UDP or HTTP tracker.

* Added "enable_udp_trackers" setting for disabling the use of UDP
trackers, enabled by default.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@498 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-13 18:51:19 +00:00
rakshasa d02ded1d4c * Changed function calls in torrent::Download to be const.
* Cleaned up the code that handles printing of download stats, uses a
char* for buffer for output more flexible concatenation. Closed
torrents are displayed correctly now.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@497 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-13 13:05:08 +00:00
rakshasa 568dcc0b91 * More work on support for UDP tracker.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@493 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-11 17:44:28 +00:00
rakshasa 8ca61a79ac * Saves file priorities along with fast-resume data.
* Cleaned up the shutdown code, moved some unnessesary stuff out of
the main loop.

* Made a TrackerBase and an empty TrackerUdp class. The proper
Tracker* class is selected based on the url.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@492 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-09 18:28:57 +00:00
rakshasa 26a7907f0a * Cleaned up torrent::Rate and moved it to the API. Changed various
parts of the API to return torrent::Rate instead of specific functions
for each stat.

* Use 600 second time span for peer rates.

* Added core::DownloadFactory which allows for an async http get and
changing of settings. This will allow the implementation of a
configuration screen when pressing "return", while the client is
downloading or finished downloading a torrent file.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@491 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-09 15:28:56 +00:00
rakshasa a195933a2a Fixing wrong return type.
Adding entry in faq.xml about -fomit-frame-pointer.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@488 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-07 10:53:40 +00:00
rakshasa 0a56ce6fff Fixed bug that caused negative quotas and cleaned up the quota code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@486 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-05 18:10:37 +00:00
rakshasa fc8ca7df20 Fixed bug that cause exception to be thrown when erasing a download.
Moved to using SocketAddress within src/net.

Enabled SocketManager.

Changed API to use uint32_t instead of int.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@485 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-04 16:14:13 +00:00
rakshasa 0588e66eaf Added license exception for linking toward OpenSSL.
Disabled Mozilla's NSS SHA1 code and added OpenSSL SHA1, use NSS if
you need Debian-strict GPL compliance. Added note in README.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@484 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-01 22:41:16 +00:00
rakshasa 758bbc9faf Fixed memory leak of PeerConnection::m_read and
PeerConnection::m_write.

Moved src/net/protocol_* to src/peer/.

Moved over to using PeerConnectionBase and created factory class and
setting for seeder/leecher.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@483 e378c898-3ddf-0310-93e7-cc216c733640
2005-07-01 15:38:39 +00:00
rakshasa 98ad8e8791 Cleaned up ui::Root, fixed updating and hiding status bar.
Using displayScheduler for updating windows, much more efficient.

Added saving of some parts of the state of torrents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@482 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-30 16:42:22 +00:00
rakshasa 52884c3c39 Added throttle_interval option and backend.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@481 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-29 01:30:59 +00:00
rakshasa d04adf81ae The client is now responsible for sending completed to tracker, fixes
the problem where doing hash checking of completed torrents would
cause wrong messages to be sent.

Added option to the client for opening a random port in the supplied
port range.

Cleaned up ui::Download and ui::DownloadList handling of throttle keys
and status bar.

Added 60s timeout for handshakes.

Added ignore key function to input::Bindings.

Made the time span of torrent::Rate configurable.

Seperate torrent::Rate object for quick and slow time span in
torrent::ThrottleControl. Also limited the amount the throttle could
over-allocate per tick, not completely fixed.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@480 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-28 20:57:01 +00:00
rakshasa 2c5ce1989a Added setting for session directory.
Added support for quotation in settings.

Added key for changing the priority of all files in a torrent.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@477 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-26 19:51:20 +00:00
rakshasa 28b369dc83 Added man pages.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@475 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-25 21:50:32 +00:00
rakshasa 088398d6d6 Converted to new TaskScheduler.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@474 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-23 19:23:36 +00:00
rakshasa bc27fd19cb Cleaned up option_handler_rules.*, it now uses the slot_map_* properly.
Erases the screen upon quit.

Added option for checking the hash for completed downloads.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@471 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-21 16:23:34 +00:00
rakshasa 7e77635353 * Added slot map's for insert/erase, open/close, start/stop and
finished downloads in DownloadList, moved stuff from core::Manager to
the slot maps.

* Added check hash key ^r, though triggering check hash on finished
signals currently borks.

* Made tracker dump into an option.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@470 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-20 19:14:41 +00:00
rakshasa 9a3d75490f Adding tracker group cycle.
Adding creation date display.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@468 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-19 20:44:56 +00:00
rakshasa 7b1e0ec085 Bumped version.
Moved around include order.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@465 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-15 20:09:15 +00:00
rakshasa 2e83af28ac Fixed freebsd compile errors.
Added global rate display.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@463 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-15 09:28:52 +00:00
rakshasa fdc56e8f09 Added resource for max open files.
Fixed bug that could cause infinit looping on SIGBUS.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@460 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-10 21:37:06 +00:00
rakshasa 693ce38317 Cleaned up the API.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@456 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-07 22:20:03 +00:00
rakshasa 2e7333792f Changed api for listen ip and bind.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@454 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-07 01:19:18 +00:00
rakshasa 3092a583ca Adding a bunch of options.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@450 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-02 18:31:02 +00:00
rakshasa 0206ee066d Working option file, doesn't yet load from a sane place.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@449 e378c898-3ddf-0310-93e7-cc216c733640
2005-06-01 13:33:44 +00:00
rakshasa 74930f86b3 Adding framework for an option parser.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@448 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-31 19:05:55 +00:00
rakshasa a2248f584f Cleaned up configure.ac and fixed it to properly handles CXXFLAGS.
Ignore SIGPIPE.

Fixed(?) bug in hash queue code when a queued torrent got
deleted. Also reorganized core::Manager to catch all
torrent::local_error's.

Fixed display bug in display::FileList which hid the last element.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@441 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-26 03:25:55 +00:00
rakshasa 528646cc02 Adding more faq entries.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@439 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-15 02:19:20 +00:00
rakshasa d8398eae5f Added FAQ entries.
Fixed bug that caused single file torrent to be saved in a seperate
directory when -d is used.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@437 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-11 18:40:26 +00:00
rakshasa d96173453d Fixed minor bugs in the resume save and start torrent code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@434 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-07 00:15:54 +00:00
rakshasa 11bc3a9f80 Adding faq.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@432 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-05 16:31:46 +00:00
rakshasa d898b9db01 Adding controls for download throttle.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@426 e378c898-3ddf-0310-93e7-cc216c733640
2005-05-02 01:20:51 +00:00
rakshasa 98676e5531 Removed choke delay in the peer list window.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@421 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-28 01:15:39 +00:00
rakshasa 2f77d1bafa Todo etc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@412 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-24 14:25:50 +00:00
rakshasa f139621c4c Switched from tracker dump in bencode to std::istream*.
Various *BSD port fixes.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@406 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-20 14:20:09 +00:00
rakshasa 70a73ea441 Minor bugfixes to find-file interface etc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@403 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-17 17:54:19 +00:00
rakshasa f8bbf8bfad Added "-d" to change the default root dir.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@388 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-09 21:48:59 +00:00
rakshasa 472c19fe67 Added errno.h.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@387 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-09 18:59:19 +00:00
rakshasa 8bf6a42048 Added "-b" for binding the listening ip addresse.
Throw an error if no listening port is opened.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@386 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-09 18:19:14 +00:00
rakshasa 874e46fc64 Proper '/' on the end of directories in the find-file window.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@381 e378c898-3ddf-0310-93e7-cc216c733640
2005-04-03 16:36:19 +00:00
rakshasa fe11d1936d Fixed some *BSD compatibility bugs.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@371 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-26 17:44:22 +00:00
rakshasa 2f49249378 Minor fixes to autoconf.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@365 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-19 02:07:43 +00:00
rakshasa 74e3b4fc1c Minor tweak to file list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@364 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-19 00:05:49 +00:00
rakshasa 072a38c8fc Find file now shows a directory listing.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@362 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-18 21:20:46 +00:00
rakshasa a16a88ebeb Added changed signal to list_focus and connected it to
WindowDownloadList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@361 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-18 16:09:49 +00:00
rakshasa 2eb534e423 Made log complete an element.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@360 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-17 23:16:43 +00:00
rakshasa 73fb55ae42 Prefixed ui element classes with Element.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@359 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-17 18:53:15 +00:00
rakshasa 2ded36e38e Removed algorithms from path_input.cc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@358 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-17 16:11:31 +00:00
rakshasa cefa2b584d Tab completion functional.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@357 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-17 01:07:54 +00:00
rakshasa 8090d4db26 Cleaned up download ui code.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@356 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-15 20:04:11 +00:00
rakshasa b5f218ffd9 Refactored peer info screen out into its own ui class.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@355 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-15 15:58:45 +00:00
rakshasa dfa6c9cd05 Added our id to the peer info screen.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@354 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-14 20:37:57 +00:00
rakshasa 3efadf69ec Minor cleanup of the interface.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@352 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-13 03:08:13 +00:00
rakshasa da764db3b9 Adding copyright claim to source files.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@348 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-12 23:30:11 +00:00
rakshasa 010d5cfbe3 Cleanup of log time display.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@346 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-12 23:22:28 +00:00
rakshasa c36ee96550 New log window available through 'l'.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@343 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-12 19:16:30 +00:00
rakshasa ab69ae3fe6 Cleanup.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@341 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-11 01:01:39 +00:00
rakshasa f664e1ce0c Adding view of tracker list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@338 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-10 18:59:24 +00:00
rakshasa a4dbdffcb8 Seperated out my template algorithms and stuff.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@334 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-08 18:25:34 +00:00
rakshasa f379abb200 Fixed a mispelled name in utils::for_each_pre(...).
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@333 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-07 20:49:16 +00:00
rakshasa 209581bd3f Fixed configure's debug flag.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@330 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-07 18:49:03 +00:00
rakshasa c378ab638c Update libtorrent's interal file priorities when changing them in the client.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@328 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-07 14:53:23 +00:00
rakshasa 1dc51a1b13 Refactored code for positioning the focus and the start of iteration.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@327 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-05 22:16:12 +00:00
rakshasa ddf619f934 Added changing of the file priorities.
Seperated the algorithm extensions from functional.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@326 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-05 20:56:12 +00:00
rakshasa 2dc7ffdb8f Fixed bug in display code for peer percentage progress.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@325 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-05 02:20:45 +00:00
rakshasa c15d840962 Fixing bad backspace handling for some remote shells.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@324 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-05 02:05:12 +00:00
rakshasa 9e0db66b58 Added file view.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@322 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-04 22:00:39 +00:00
rakshasa 8d36f7c374 Created a root ui.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@321 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-03 21:27:27 +00:00
rakshasa fd0c10d962 Moved over to a next time based display update.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@320 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-03 20:09:04 +00:00
rakshasa b840476527 Added -t for dumping tracker requests.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@315 e378c898-3ddf-0310-93e7-cc216c733640
2005-03-01 19:21:49 +00:00
rakshasa ef3a8fcd83 Task Scheduler, log viewer pops up and disapperes. good good
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@308 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-26 21:58:59 +00:00
rakshasa 9fe97ee490 Added logging, currently shows failed torrent creations but does not
time out the log messages.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@307 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-25 22:05:15 +00:00
rakshasa f66424f642 Added the -i switch.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@306 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-25 16:23:45 +00:00
rakshasa 5ef6be4912 Added <errno.h> to src/core/poll.h.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@299 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-22 16:29:59 +00:00
rakshasa 75ef138118 Cleaning up main.cc and adding help text.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@296 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-20 18:02:32 +00:00
rakshasa c4d548bafd Loads correctly formated torrents from session dir when starting.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@294 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-20 17:21:23 +00:00
rakshasa fa9a2d7e86 Deletes torrents in the session directory when they are removed.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@293 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-20 15:40:01 +00:00
rakshasa 91da0475e4 Saves to a session directory, but does not delete.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@292 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-19 23:25:28 +00:00
rakshasa 5b050b594b Working on sessions.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@291 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-19 21:45:36 +00:00
rakshasa a5f23adc7b Reorganized, moing stuff to src/utils subdir.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@290 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-19 17:27:29 +00:00
rakshasa aa405810db Added help text and port range option.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@288 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-18 21:51:13 +00:00
rakshasa e0f21cce78 Added option and flag parseing, now supports -p for port range.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@287 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-18 19:08:17 +00:00
rakshasa 78d3d78ef3 Improved the http progress display, includes truncated names, download
progress and 10 second delay on hiding.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@286 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-17 21:20:18 +00:00
rakshasa f9975ae9f2 Adding active/disabled status on windows so it's easier to show/hide
them while keeping the order.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@284 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-16 20:34:20 +00:00
rakshasa e3a0730b33 Hide/show input and status bar depending on whetever input has focus.
Added removal of downloads. 


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@283 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-16 20:03:40 +00:00
rakshasa ab065e598b Fixed various memory problems.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@282 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-15 23:55:46 +00:00
rakshasa 46120cbb30 Added start/stop keys.
Added more extensive download status information where only tracker
status used to be.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@279 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-15 21:59:35 +00:00
rakshasa f348196f2e Adding hash check queue.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@278 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-15 15:37:06 +00:00
rakshasa ce4c09c143 Various minor fixes to the 0.0.1 release.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@277 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-15 01:00:53 +00:00
rakshasa 1f58b0074b Hooked the input to the torrent loader.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@274 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-14 18:24:21 +00:00
rakshasa 73b1c58f4c Work on an input field.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@272 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-13 21:47:26 +00:00
rakshasa aec27deaeb Starting work on core::Manager, working for file/http inserts.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@267 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-11 19:42:25 +00:00
rakshasa 8ec38be77e HttpQueue finishing touches.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@266 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-10 20:00:00 +00:00
rakshasa deb1244d8c Half done the http queue.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@264 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-09 23:36:27 +00:00
rakshasa f7144a333f Adding some tracker msg related stuff, download status bar.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@262 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-08 22:06:57 +00:00
rakshasa b01cd17a72 Peer info properly displays data, added parse.* with escape_string(...).
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@261 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-08 17:07:22 +00:00
rakshasa b657554236 Work on peer info display.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@260 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-07 23:40:48 +00:00
rakshasa 45404b7473 Added configure check for execinfo.h.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@259 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-06 20:41:19 +00:00
rakshasa fc903274ae Commited a possible fix to the screen update bug.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@258 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-06 18:17:13 +00:00
rakshasa c2a0fd90dc Adding stack dump on SIGSEGV and SIGBUS.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@257 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-06 16:18:54 +00:00
rakshasa 11506c5a61 Proper handling of resize events.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@256 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-06 00:09:47 +00:00
rakshasa ecb2fc7d57 Focus iterators moved out of Window*.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@254 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-05 20:36:22 +00:00
rakshasa e02974571a Alot of UI work, resize fixed.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@253 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-04 19:50:59 +00:00
rakshasa bd7849199c Listing peers.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@252 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-02 21:51:40 +00:00
rakshasa 5f102a5dcf git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@251 e378c898-3ddf-0310-93e7-cc216c733640 2005-02-02 15:19:36 +00:00
rakshasa 0ff36babee Up and down on the download list working.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@250 e378c898-3ddf-0310-93e7-cc216c733640
2005-02-01 15:26:24 +00:00
rakshasa cd9b014eb6 Renamed engine to core.
Added focus to WindowDownloadList.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@249 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-31 17:59:16 +00:00
rakshasa c3a4a7d554 Signal handler with cleaner shutdown.
Window title and stuff.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@248 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-30 23:10:25 +00:00
rakshasa 3357b5caab rtorrent: Polling http and torrent. Improved the download list.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@247 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-30 17:14:53 +00:00
rakshasa b17dc37a3b rtorrent: Moving towards working torrents.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@246 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-29 22:42:52 +00:00
rakshasa 53f32e74a1 Client work.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@244 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-29 21:06:53 +00:00
rakshasa 96a28a78bb rtorrent: Moving rtorrent.cc to main.cc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@243 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-29 17:47:36 +00:00
rakshasa 27109b542c rtorrent: Layout dynamically resizes vertically.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@240 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-28 23:45:57 +00:00
rakshasa b994517819 rtorrent: Initial key handler implemented.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@239 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-28 18:43:39 +00:00
rakshasa f9b95c6255 Moving from algo back to std.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@238 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-27 20:52:59 +00:00
rakshasa 74b154f07e rtorrent: Working on display.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@237 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-27 20:14:21 +00:00
rakshasa f622f45f0b Renamed display::Manager to display::Layers.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@236 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-27 13:55:31 +00:00
rakshasa 914c7c1aeb Commiting rtorrent display stuff.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@235 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-26 22:04:16 +00:00
rakshasa 1c10f620f8 rtorrent/display: Initial ncurses canvas implementation.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@234 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-26 15:29:29 +00:00
rakshasa 68788e904c Commiting basic files for rtorrent.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@233 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-25 18:47:10 +00:00
rakshasa ca6a7e2d16 Adding rtorrent directory.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@232 e378c898-3ddf-0310-93e7-cc216c733640
2005-01-25 15:01:02 +00:00
307 changed files with 73111 additions and 948 deletions
+33
View File
@@ -0,0 +1,33 @@
---
BasedOnStyle: LLVM
Standard: c++14
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AlwaysBreakAfterReturnType: TopLevelDefinitions
BinPackArguments: false
BinPackParameters: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 0
ContinuationIndentWidth: 2
IndentCaseLabels: false
IndentWidth: 2
PenaltyReturnTypeOnItsOwnLine: 130
PointerAlignment: Left
AlignEscapedNewlines: Right
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
AlignConsecutiveMacros:
Enabled: true
AlignConsecutiveAssignments:
Enabled: true
IncludeCategories:
- Regex: "^(config|globals)\\.h"
Priority: -1
- Regex: "^torrent/.*"
Priority: 1
+16
View File
@@ -0,0 +1,16 @@
---
Checks: '-*,readability-identifier-naming'
FormatStyle: 'file'
CheckOptions:
- key: readability-identifier-naming.LocalVariableCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberPrefix
value: m_
- key: readability-identifier-naming.PrivateMemberCase
value: lower_case
- key: readability-identifier-naming.ClassConstantCase
value: lower_case
+7
View File
@@ -0,0 +1,7 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((c++-mode
(flycheck-clang-language-standard . "c++11")
(flycheck-gcc-language-standard . "c++11")))
+13
View File
@@ -0,0 +1,13 @@
# These are supported funding model platforms
github: [rakshasa]
patreon: rtorrent
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://rakshasa.github.io/rtorrent/donate.html']
+65
View File
@@ -0,0 +1,65 @@
name: "Lint Commit Message Size"
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
check-commit-bounds:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate Line Count, Width, and Spacing
run: |
# Fetch commit hashes unique to this PR branch
COMMITS=$(git log --no-merges --pretty=format:"%H" origin/${{ github.base_ref }}..HEAD)
MAX_LINES=3
MAX_CHARS=90
FAILED=0
for commit in $COMMITS; do
SUBJECT=$(git log --format="%s" -n 1 $commit)
# Extract clean commit message, trimming trailing blank lines
RAW_MSG=$(git log --format="%B" -n 1 $commit)
CLEAN_MSG=$(echo "$RAW_MSG" | awk '{msg[NR]=$0} END {while(NR>0 && msg[NR]=="") NR--; for(i=1;i<=NR;i++) print msg[i]}')
# 1. Check total line count
LINE_COUNT=$(echo "$CLEAN_MSG" | wc -l)
if [ "$LINE_COUNT" -gt "$MAX_LINES" ]; then
echo "❌ Error: Commit message has too many lines ($LINE_COUNT/$MAX_LINES)."
echo " Commit: '$SUBJECT'"
FAILED=1
fi
# 2. Check for multiple consecutive blank lines
# This regex looks for 2 or more empty lines anywhere in the message
if echo "$CLEAN_MSG" | grep -Pz '(\r?\n){3,}'; then
echo "❌ Error: Commit message contains multiple consecutive line breaks."
echo " Commit: '$SUBJECT'"
FAILED=1
fi
# 3. Check maximum width of any individual line
while IFS= read -r line; do
LINE_LENGTH=${#line}
if [ "$LINE_LENGTH" -gt "$MAX_CHARS" ]; then
echo "❌ Error: Line length exceeds limit ($LINE_LENGTH / $MAX_CHARS chars)."
echo " Offending line: '$line'"
FAILED=1
fi
done <<< "$CLEAN_MSG"
done
# Fail the job if any check failed
if [ "$FAILED" -ne 0 ]; then
exit 1
fi
echo "✅ All commit messages passed style rules!"
@@ -0,0 +1,96 @@
# Secure workflow with access to repository secrets and GitHub token for posting analysis results
name: Post the static analysis results
on:
workflow_run:
workflows: [ "Static analysis" ]
types: [ completed ]
jobs:
clang-tidy-results:
# Trigger the job only if the previous (insecure) workflow completed successfully
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
permissions:
pull-requests: write
# OPTIONAL: auto-closing conversations requires the `contents` permission
contents: read
steps:
- name: Sleep for 30 seconds
run: sleep 30s
shell: bash
- name: Download analysis results
uses: actions/github-script@v7
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "clang-tidy-result"
})[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: "zip",
});
const fs = require("fs");
fs.writeFileSync("${{ github.workspace }}/clang-tidy-result.zip", Buffer.from(download.data));
- name: Extract analysis results
run: |
mkdir clang-tidy-result
unzip -j clang-tidy-result.zip -d clang-tidy-result
- name: Set environment variables
uses: actions/github-script@v7
with:
script: |
const assert = require("node:assert").strict;
const fs = require("fs");
function exportVar(varName, fileName, regEx) {
const val = fs.readFileSync("${{ github.workspace }}/clang-tidy-result/" + fileName, {
encoding: "ascii"
}).trimEnd();
assert.ok(regEx.test(val), "Invalid value format for " + varName);
core.exportVariable(varName, val);
}
exportVar("PR_ID", "pr-id.txt", /^[0-9]+$/);
exportVar("PR_HEAD_REPO", "pr-head-repo.txt", /^[-./0-9A-Z_a-z]+$/);
exportVar("PR_HEAD_SHA", "pr-head-sha.txt", /^[0-9A-Fa-f]+$/);
- uses: actions/checkout@v4
with:
repository: ${{ env.PR_HEAD_REPO }}
ref: ${{ env.PR_HEAD_SHA }}
persist-credentials: false
- name: Redownload analysis results
uses: actions/github-script@v7
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "clang-tidy-result"
})[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: "zip",
});
const fs = require("fs");
fs.writeFileSync("${{ github.workspace }}/clang-tidy-result.zip", Buffer.from(download.data));
- name: Extract analysis results
run: |
mkdir clang-tidy-result
unzip -j clang-tidy-result.zip -d clang-tidy-result
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clang_tidy_fixes: clang-tidy-result/fixes.yml
pull_request_id: ${{ env.PR_ID }}
+84
View File
@@ -0,0 +1,84 @@
name: Static analysis
on: pull_request
jobs:
clang-tidy:
runs-on: ubuntu-22.04
steps:
- name: Update Packages
run: |
sudo apt-get update
- name: Install Dependencies
run: |
sudo apt-get install -y \
bear \
clang-tidy \
libcurl4-openssl-dev \
zlib1g-dev
- name: Fetch libtorrent
run: |
git clone https://github.com/rakshasa/libtorrent
- name: Build libtorrent
run: |
cd libtorrent
libtoolize
aclocal -I scripts
autoconf -i
autoheader
automake --add-missing
./configure
make
sudo make install
cd ..
rm -rf libtorrent
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fetch base branch
run: |
git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}"
git fetch --no-tags --no-recurse-submodules upstream "${{ github.event.pull_request.base.ref }}"
- name: Configure Project
run: |
libtoolize
aclocal -I scripts
autoconf -i
autoheader
automake --add-missing
./configure
- name: Prepare compile_commands.json
run: |
bear -- make
- name: Create results directory
run: |
mkdir clang-tidy-result
- name: Analyze
run: |
git diff -U0 "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml "-extra-arg=-include/${PWD}/config.h"
- name: Save PR metadata
run: |
echo "${{ github.event.number }}" > clang-tidy-result/pr-id.txt
echo "${{ github.event.pull_request.head.repo.full_name }}" > clang-tidy-result/pr-head-repo.txt
echo "${{ github.event.pull_request.head.sha }}" > clang-tidy-result/pr-head-sha.txt
- uses: actions/upload-artifact@v4
with:
name: clang-tidy-result
path: clang-tidy-result/
# - name: Run clang-tidy-pr-comments action
# uses: platisd/clang-tidy-pr-comments@v1
# with:
# # The GitHub token (or a personal access token)
# github_token: ${{ secrets.GITHUB_TOKEN }}
# # The path to the clang-tidy fixes generated previously
# clang_tidy_fixes: clang-tidy-result/fixes.yml
# # Optionally set to true if you want the Action to request
# # changes in case warnings are found
# request_changes: true
# # Optionally set the number of comments per review
# # to avoid GitHub API timeouts for heavily loaded
# # pull requests
# suggestions_per_comment: 10
+107
View File
@@ -0,0 +1,107 @@
name: Static analysis
on: pull_request
jobs:
ubuntu-base:
runs-on: ubuntu-22.04
steps:
- name: Update Packages
run: |
sudo apt-get update
- name: Install Dependencies
run: |
sudo apt-get install -y \
libcppunit-dev \
zlib1g-dev \
libcurl4-openssl-dev
- name: Fetch libtorrent
run: |
git clone https://github.com/rakshasa/libtorrent
- name: Build libtorrent
run: |
cd libtorrent
autoreconf -fiv
./configure
make
sudo make install DESTDIR=$GITHUB_WORKSPACE/libtorrent-dist
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: installed-libtorrent
path: libtorrent-dist/
unit-tests-default:
runs-on: ubuntu-22.04
needs: ubuntu-base
steps:
- name: Update Packages
run: |
sudo apt-get update
- name: Install Dependencies
run: |
sudo apt-get install -y \
libcppunit-dev \
zlib1g-dev \
libcurl4-openssl-dev
- name: Download Libtorrent Artifacts
uses: actions/download-artifact@v4
with:
name: installed-libtorrent
path: ./libtorrent-dist
- name: Move Artifacts to System Path
run: |
# Elevate permissions with sudo to safely place the files
sudo cp -r ./libtorrent-dist/usr/local/* /usr/local/
rm -rf ./libtorrent-dist
- uses: actions/checkout@v4
- name: Configure Project
run: |
autoreconf -fiv
./configure
make
ls /usr/local/lib/
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" make check
- name: Archive test/test-suite.log
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: test-suite.log
path: test/test-suite.log
unit-tests-variants:
runs-on: ubuntu-22.04
needs: unit-tests-default
strategy:
matrix:
config_flag: ["--with-xmlrpc-c", "--with-xmlrpc-tinyxml2"]
steps:
- name: Update Packages
run: |
sudo apt-get update
- name: Install Dependencies
run: |
sudo apt-get install -y \
libcppunit-dev \
zlib1g-dev \
libcurl4-openssl-dev \
libxmlrpc-c++8-dev
- name: Download Libtorrent Artifacts
uses: actions/download-artifact@v4
with:
name: installed-libtorrent
path: ./libtorrent-dist
- name: Move Artifacts to System Path
run: |
sudo cp -r ./libtorrent-dist/usr/local/* /usr/local/
rm -rf ./libtorrent-dist
- uses: actions/checkout@v4
- name: Configure Project
run: |
autoreconf -fiv
./configure ${{ matrix.config_flag }}
make
ls /usr/local/lib/
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" make check
+74
View File
@@ -0,0 +1,74 @@
# Compiled source #
###################
*.o
*.lo
*.a
*.la
*.so
*.in
*.sub
*.pc
*.orig
*.rej
# Autoconf files #
##################
.deps
.libs
Makefile
aclocal.m4
actmp.*
ar-lib
autom4te.cache
compile
config.h
config.guess
config.status
confdefs.h
conftest.dir
configure
depcomp
install-sh
libtool
ltmain.sh
missing
stamp-h1
src/rtorrent
scripts/libtool.m4
scripts/lt*.m4
# Editor poo #
##############
.#*
\#*#
*~
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.gz
*.tar
*.zip
# Logs and databases #
######################
*.log
# OS generated files #
######################
.DS_Store?
.dirstamp
ehthumbs.db
Icon?
Thumbs.db
TAGS
# rTorrent specific files
###########################
src/rtorrent
test/rtorrent_Test*
test/test-suite.log.tmp
test-driver
+1
View File
@@ -0,0 +1 @@
Jari Sundell <sundell.software@gmail.com>
-1
View File
@@ -1 +0,0 @@
rtorrent.net
+340
View File
@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+368
View File
@@ -0,0 +1,368 @@
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell command './configure && make && make install'
should configure, build, and install this package. The following
more-detailed instructions are generic; see the 'README' file for
instructions specific to this package. Some packages provide this
'INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The 'configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a 'Makefile' in each directory of the package.
It may also create one or more '.h' files containing system-dependent
definitions. Finally, it creates a shell script 'config.status' that
you can run in the future to recreate the current configuration, and a
file 'config.log' containing compiler output (useful mainly for
debugging 'configure').
It can also use an optional file (typically called 'config.cache' and
enabled with '--cache-file=config.cache' or simply '-C') that saves the
results of its tests to speed up reconfiguring. Caching is disabled by
default to prevent problems with accidental use of stale cache files.
If you need to do unusual things to compile the package, please try
to figure out how 'configure' could check whether to do them, and mail
diffs or instructions to the address given in the 'README' so they can
be considered for the next release. If you are using the cache, and at
some point 'config.cache' contains results you don't want to keep, you
may remove or edit it.
The file 'configure.ac' (or 'configure.in') is used to create
'configure' by a program called 'autoconf'. You need 'configure.ac' if
you want to change it or regenerate 'configure' using a newer version of
'autoconf'.
The simplest way to compile this package is:
1. 'cd' to the directory containing the package's source code and type
'./configure' to configure the package for your system.
Running 'configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type 'make' to compile the package.
3. Optionally, type 'make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type 'make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the 'make install' phase executed with root
privileges.
5. Optionally, type 'make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior 'make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing 'make clean'. To also remove the
files that 'configure' created (so you can compile the package for
a different kind of computer), type 'make distclean'. There is
also a 'make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type 'make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide 'make
distcheck', which can by used by developers to test that all other
targets like 'make install' and 'make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the 'configure' script does not know about. Run './configure --help'
for details on some of the pertinent environment variables.
You can give 'configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here is
an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU 'make'. 'cd' to the
directory where you want the object files and executables to go and run
the 'configure' script. 'configure' automatically checks for the source
code in the directory that 'configure' is in and in '..'. This is known
as a "VPATH" build.
With a non-GNU 'make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use 'make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple '-arch' options to the
compiler but only a single '-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the 'lipo' tool if you have problems.
Installation Names
==================
By default, 'make install' installs the package's commands under
'/usr/local/bin', include files under '/usr/local/include', etc. You
can specify an installation prefix other than '/usr/local' by giving
'configure' the option '--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like '--bindir=DIR' to specify different values for particular
kinds of files. Run 'configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the default
for these options is expressed in terms of '${prefix}', so that
specifying just '--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to 'configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
'make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, 'make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
'${prefix}'. Any directories that were specified during 'configure',
but not in terms of '${prefix}', must each be overridden at install time
for the entire installation to be relocated. The approach of makefile
variable overrides for each directory variable is required by the GNU
Coding Standards, and ideally causes no recompilation. However, some
platforms have known limitations with the semantics of shared libraries
that end up requiring recompilation when using this method, particularly
noticeable in packages that use GNU Libtool.
The second method involves providing the 'DESTDIR' variable. For
example, 'make install DESTDIR=/alternate/directory' will prepend
'/alternate/directory' before all installation names. The approach of
'DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of '${prefix}'
at 'configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving 'configure' the
option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
Some packages pay attention to '--enable-FEATURE' options to
'configure', where FEATURE indicates an optional part of the package.
They may also pay attention to '--with-PACKAGE' options, where PACKAGE
is something like 'gnu-as' or 'x' (for the X Window System). The
'README' should mention any '--enable-' and '--with-' options that the
package recognizes.
For packages that use the X Window System, 'configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the 'configure' options '--x-includes=DIR' and
'--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of 'make' will be. For these packages, running './configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with 'make V=1'; while running './configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with 'make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC
is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX 'make' updates targets which have the same time stamps as their
prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its '<wchar.h>' header file. The option '-nodtk' can be used as a
workaround. If GNU CC is not installed, it is therefore recommended to
try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
in your 'PATH', put it _after_ '/usr/bin'.
On Haiku, software installed for all users goes in '/boot/common',
not '/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features 'configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, 'configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
'--build=TYPE' option. TYPE can either be a short name for the system
type, such as 'sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file 'config.sub' for the possible values of each field. If
'config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option '--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with '--host=TYPE'.
Sharing Defaults
================
If you want to set default values for 'configure' scripts to share,
you can create a site shell script called 'config.site' that gives
default values for variables like 'CC', 'cache_file', and 'prefix'.
'configure' looks for 'PREFIX/share/config.site' if it exists, then
'PREFIX/etc/config.site' if it exists. Or, you can set the
'CONFIG_SITE' environment variable to the location of the site script.
A warning: not all 'configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to 'configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the 'configure' command line, using 'VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified 'gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
Autoconf limitation. Until the limitation is lifted, you can use this
workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
'configure' Invocation
======================
'configure' recognizes the following options to control how it
operates.
'--help'
'-h'
Print a summary of all of the options to 'configure', and exit.
'--help=short'
'--help=recursive'
Print a summary of the options unique to this package's
'configure', and exit. The 'short' variant lists options used only
in the top level, while the 'recursive' variant lists options also
present in any nested packages.
'--version'
'-V'
Print the version of Autoconf used to generate the 'configure'
script, and exit.
'--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally 'config.cache'. FILE defaults to '/dev/null' to
disable caching.
'--config-cache'
'-C'
Alias for '--cache-file=config.cache'.
'--quiet'
'--silent'
'-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to '/dev/null' (any error
messages will still be shown).
'--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
'configure' can determine that directory automatically.
'--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names:: for
more details, including other options available for fine-tuning the
installation locations.
'--no-create'
'-n'
Run the configure checks, but stop before creating any output
files.
'configure' also accepts some other, not widely useful, options. Run
'configure --help' for more details.
+14
View File
@@ -0,0 +1,14 @@
SUBDIRS = \
doc \
src \
test
nobase_dist_pkgdata_DATA = \
lua/rtorrent.lua
EXTRA_DIST= \
scripts/checks.m4 \
scripts/common.m4 \
scripts/attributes.m4
ACLOCAL_AMFLAGS = -I scripts
+88
View File
@@ -0,0 +1,88 @@
RTorrent BitTorrent Client
========
Introduction
------------
A ncurses-based command line torrent client for high performance.
To learn how to use rTorrent visit the [Wiki](https://github.com/rakshasa/rtorrent/wiki).
Download the [latest stable release](https://github.com/rakshasa/rtorrent/releases/latest)
Related Projects
----------------
* [https://github.com/rakshasa/rbedit](https://github.com/rakshasa/rbedit): A dependency-free bencode editor.
Donate to rTorrent development
------------------------------
* [Paypal](https://paypal.me/jarisundellno)
* [Patreon](https://www.patreon.com/rtorrent)
* [SubscribeStar](https://www.subscribestar.com/rtorrent)
* Bitcoin: 1MpmXm5AHtdBoDaLZstJw8nupJJaeKu8V8
* Ethereum: 0x9AB1e3C3d8a875e870f161b3e9287Db0E6DAfF78
* Litecoin: LdyaVR67LBnTf6mAT4QJnjSG2Zk67qxmfQ
* Cardano: addr1qytaslmqmk6dspltw06sp0zf83dh09u79j49ceh5y26zdcccgq4ph7nmx6kgmzeldauj43254ey97f3x4xw49d86aguqwfhlte
Help keep rTorrent development going by donating to its creator.
BUILDING
--------
Jump into the github cloned directory
```
cd rtorrent
```
## Install build dependencies
Install [libtorrent](https://github.com/rakshasa/libtorrent) with the same version rTorrent.
Generate configure scripts:
```
autoreconf -ivf
```
Optionally, generate man pages:
```
docbook2man rtorrent.1.xml
```
Man pages output to "doc/rtorrent.1".
RTorrent follows the development of [libtorrent](https://github.com/rakshasa/libtorrent) closely, and thus the versions must be in sync.
## USAGE
Refer to User Guide: https://github.com/rakshasa/rtorrent/wiki/User-Guide
## LICENSE
GNU GPL, see COPYING. "libtorrent/src/utils/sha_fast.{cc,h}" is
originally from the Mozilla NSS and is under a triple license; MPL,
LGPL and GPL. An exception to non-NSS code has been added for linking to OpenSSL as requested by Debian, though the author considers that library to be part of the Operative System and thus linking is allowed according to the GPL.
Use whatever fits your purpose, the code required to compile with
Mozilla's NSS implementation of SHA1 has been retained and can be
compiled if the user wishes to avoid using OpenSSL.
## DEPENDENCIES
* libcurl >= 7.12.0
* libtorrent = (same version)
* ncurses
## BUILD DEPENDENCIES
* libtoolize
* aclocal
* autoconf
* autoheader
* automake
-8
View File
@@ -1,8 +0,0 @@
title: Rtorrent
description: rTorrent BitTorrent client
google_analytics:
show_downloads: true
theme: jekyll-theme-minimal
gems:
- jekyll-mentions
+85
View File
@@ -0,0 +1,85 @@
m4_pattern_allow([PKG_CHECK_EXISTS])
AC_INIT([rtorrent],[0.16.20],[sundell.software@gmail.com])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([scripts])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_PROG_AR
LT_INIT
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX(20, noext, mandatory)
PKG_PROG_PKG_CONFIG
AC_DEFINE([API_VERSION], [25], [api version])
RAK_CHECK_CFLAGS
RAK_CHECK_CXXFLAGS
RAK_ENABLE_DEBUG
RAK_ENABLE_EXTRA_DEBUG
RAK_ENABLE_WERROR
AC_ARG_ENABLE(execinfo,
AS_HELP_STRING([--disable-execinfo],
[disable libexecinfo [[default=enable]]]),
[
if test "$enableval" = "yes"; then
AX_EXECINFO
fi
],[
AX_EXECINFO
])
AX_PTHREAD([], AC_MSG_ERROR([requires pthread]))
TORRENT_WITHOUT_NCURSES
if test "x$with_ncurses" != xno; then
AX_WITH_CURSES
if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
AC_MSG_ERROR([requires either NcursesW or Ncurses library])
fi
fi
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
PKG_CHECK_MODULES([ZLIB], [zlib])
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.20])
AC_LANG_PUSH(C++)
TORRENT_WITH_XMLRPC_C
AC_LANG_POP(C++)
dnl We don't have LuaJIT support, and the script breaks if not disabled.
AM_CONDITIONAL([LUAJIT], [false])
TORRENT_WITH_LUA
TORRENT_WITH_TINYXML2
TORRENT_WITH_SYSTEMD
if test ${with_xmlrpc_c+y} && test ${with_xmlrpc_tinyxml2+y}; then
AC_MSG_ERROR([--with-xmlrpc-c and --with-xmlrpc-tinyxml2 cannot be used together. Please choose only one])
fi
AC_DEFINE(USER_AGENT, [std::string(PACKAGE "/" VERSION)], Http user agent)
dnl Only update global build variables immediately before generating the output,
dnl to avoid affecting the global build environment for other autoconf checks.
LIBS="$PTHREAD_LIBS $CURSES_LIB $CURSES_LIBS $ZLIB_LIBS $DEPENDENCIES_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS $ZLIB_CFLAGS $DEPENDENCIES_CFLAGS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS $ZLIB_CFLAGS $DEPENDENCIES_CFLAGS"
TORRENT_CHECK_CACHELINE
TORRENT_CHECK_POSIX_SPAWN_ADDCLOSEFROM_NP
AC_CONFIG_FILES([
Makefile
doc/Makefile
src/Makefile
test/Makefile
])
AC_OUTPUT
-4
View File
@@ -1,4 +0,0 @@
Reddit
======
Yes, I'm 'rasatsu'.
+2
View File
@@ -0,0 +1,2 @@
EXTRA_DIST= \
rtorrent.rc
+11
View File
@@ -0,0 +1,11 @@
=== Dumping core files on mac ==
ulimit -c unlimited
sysctl kern.corefile
schedule = log_vmmap,5,600,"execute_nothrow=/Users/rakshasa/trunk/rtorrent/doc/log_vmmap.sh,\"$cat=/Users/rakshasa/Downloads/session/vmmap.system.,$system.pid="; log.vmmap.dump=\"$cat=/Users/rakshasa/Downloads/session/vmmap.rtorrent.,$system.pid=\""
log.vmmap.dump="$cat=/Users/rakshasa/Downloads/session/vmmap.rtorrent.,$system.pid="
print="$cat=/Users/rakshasa/Downloads/session/vmmap.rtorrent.,$system.pid="
+106
View File
@@ -0,0 +1,106 @@
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<article>
<title>rTorrent Frequently Asked Questions</title>
<para>
This is the user FAQ for Rakshasa's BitTorrent client. RTorrent is
an ncurses based client that uses libTorrent and is written in
C++. Efficiency and good code is the main goal of both projects.
</para>
<qandaset>
<qandaentry>
<question><para>
How do I add new torrents while the client is running?
</para></question>
<answer><para>
Use the backspace key to enter file input mode. The bottom
line will change into a prompt which allows you to enter URL's
or file paths to torrents. File name completion and directory
listing is supported with the tab key.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
I got the message "Could not create download, failed to parse the bencoded data" when adding a torrent, what does it mean?
</para></question>
<answer><para>
The torrent data the library received was not a valid torrent
file. If this was a direct http download, try downloading the
torrent file and add it manually. This usually happens when
the torrent link uses some form of redirection that libcurl
does not automatically redirect. If the failure still happens,
make sure the file is infact an uncorrupted torrent.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
How does the session feature work?
</para></question>
<answer><para>
When you start the client you can use the "-s" switch to
specify a session directory. The client will save all
currently running torrents in the session directory and fast
resume data will be written when the client exits. Upon
restarting the client it will resume all the torrents in the
session directory.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
How do i query the tracker for more peers?
</para></question>
<answer><para>
Go into the download view screen and press 't' to initiate a
new tracker request. If the tracker requires a minimum timeout
between requests you can override this by using the capital
'T'. Don't abuse this feature.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
Why do I sometimes need to press ctrl-Q twice to exit the client?
</para></question>
<answer><para>
The first time you press ctrl-q you initiate the
shutdown. This causes rTorrent to send a stop message to the
trackers of each torrent, and if the tracker is slow it might
take more than a few seconds or until the requests time
out. The second time ctrl-q is pressed forces the client to
shutdown.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
It doesn't help how much i press ctrl-q, it still won't quit.
</para></question>
<answer><para>
Perhaps your terminal sends a different key-code to the
application. There's no configuration files for keys yet, so
modify rtorrent/src/ui/root.cc:56 to use whatever key you want
for quitting.
</para></answer>
</qandaentry>
<qandaentry>
<question><para>
When I try downloading a torrent the client aborts (SIGABRT), what should I do?
</para></question>
<answer><para>
Make sure you arn't using "-fomit-frame-pointer" when
compiling libtorrent and rtorrent, this is known to produce
bad code for C++ exception handling. If this doesn't help, run
the client in gdb and use "bt -20" to get a backtrace. Send
this with a bug report.
</para></answer>
</qandaentry>
</qandaset>
</article>
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
cat /proc/$PPID/maps > $1
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
args=($@)
echo "${args[@]:1}" >> $1
+149
View File
@@ -0,0 +1,149 @@
#/bin/bash
gnuplot << EOF
# 1) system.time_seconds=
#
# 2) throttle.global_up.rate
# 3) throttle.global_up.total
# 4) throttle.global_down.rate
# 5) throttle.global_down.total
#
# 6) pieces.memory.current
# 7) pieces.memory.sync_queue
# 8) pieces.memory.block_count
# 9) pieces.stats.total_size
# 10) pieces.hash.queue_size
#
# file.append = (cat,/foo/bandwidth_stats.,(system.pid)),"timestamp","\"upload rate\"","\"upload total\"","\"download rate\"","\"download total\"","\"memory usage\"","\"sync queue\"","\"block count\"","\"total size\"","\"hash queue size\""
# schedule = log_bandwidth_stats,5,10,((file.append,((cat,/foo/bandwidth_stats.,((system.pid)))),((system.time_seconds)),((throttle.global_up.rate)),((throttle.global_up.total)),((throttle.global_down.rate)),((throttle.global_down.total)),((pieces.memory.current)),((pieces.memory.sync_queue)),((pieces.memory.block_count)),((pieces.stats.total_size)),((pieces.hash.queue_size))))
#
# 1) system.time_seconds
#
# 2) throttle.unchoked_uploads
# 3) throttle.unchoked_downloads
# 4) network.open_sockets
#
# 5) view.size,leeching
# 6) view.size,seeding
# 7) view.size,active
#
# file.append = (cat,/foo/peer_stats.,(system.pid)),"timestamp","\"upload unchoked\"","\"download unchoked\"","\"open sockets\"","leeching","seeding","active"
# schedule = log_peer_stats,5,10,((file.append,((cat,/foo/peer_stats.,((system.pid)))),((system.time_seconds)),((throttle.unchoked_uploads)),((throttle.unchoked_downloads)),((network.open_sockets)),((view.size,leeching)),((view.size,seeding)),((view.size,active))))
#
# Choke groups:
#
# file.append = (cat,/foo/choke_group_stats.,(system.pid)),"timestamp",\
# "\"default up unchoked\"","\"default up queued\"","\"default up rate\"",\
# "\"default down unchoked\"","\"default down queued\"","\"default down rate\"","\"default torrents\"",\
# "\"leech up unchoked\"","\"leech up queued\"","\"leech up rate\"",\
# "\"leech down unchoked\"","\"leech down queued\"","\"leech down rate\"","\"leech torrents\"",\
# "\"seed boost up unchoked\"","\"seed boost up queued\"","\"seed boost up rate\"",\
# "\"seed boost down unchoked\"","\"seed boost down queued\"","\"seed boost down rate\"","\"seed boost torrents\"",\
# "\"seed up unchoked\"","\"seed up queued\"","\"seed up rate\"",\
# "\"seed down unchoked\"","\"seed down queued\"","\"seed down rate\"","\"seed torrents\""
#
# schedule = log_choke_group_stats,5,10,((file.append,((cat,/foo/choke_group_stats.,((system.pid)))),((system.time_seconds)),\
# ((choke_group.up.unchoked,0)),((choke_group.up.queued,0)),((choke_group.up.rate,0)),((choke_group.down.unchoked,0)),((choke_group.down.queued,0)),((choke_group.down.rate,0)),((choke_group.size,0)),\
# ((choke_group.up.unchoked,1)),((choke_group.up.queued,1)),((choke_group.up.rate,1)),((choke_group.down.unchoked,1)),((choke_group.down.queued,1)),((choke_group.down.rate,1)),((choke_group.size,1)),\
# ((choke_group.up.unchoked,2)),((choke_group.up.queued,2)),((choke_group.up.rate,2)),((choke_group.down.unchoked,2)),((choke_group.down.queued,2)),((choke_group.down.rate,2)),((choke_group.size,2)),\
# ((choke_group.up.unchoked,3)),((choke_group.up.queued,3)),((choke_group.up.rate,3)),((choke_group.down.unchoked,3)),((choke_group.down.queued,3)),((choke_group.down.rate,3)),((choke_group.size,3)) ))
#
# Mincore stats:
#
# file.append = (cat,/foo/mincore_stats.,(system.pid)),"timestamp","\"incore cont. /10s\"","\"not incore cont. /10s\"","\"incore new /10s\"","\"not incore new /10s\"","\"incore break /10s\"","\"sync success /10s\"","\"sync failed /10s\"","\"sync not synced /10s\"","\"sync not deallocated /10s\"","\"alloc failed /10s\"","\"allocate velocity /10s\"","\"deallocate velocity /10s\""
# log.libtorrent = mincore_stats,(cat,"/foo/mincore_stats.",(system.pid))
set terminal png size 1024,768 enhanced
#set terminal png size 2*1024,768 enhanced
set xdata time
set timefmt "%s"
set format x "%H:%M"
set format y2 "%.0f"
set y2tics
set autoscale xfix
set key autotitle columnhead
set output "output_$1_sockets.png"
plot "peer_stats.$1" using 1:7 smooth sbezier with lines lw 4,\
"peer_stats.$1" using 1:5 smooth sbezier with lines lw 4,\
"peer_stats.$1" using 1:6 smooth sbezier with lines lw 4,\
"<awk '{x=1000; if (\$4 < 1000) x=\$4; print \$1,x}' peer_stats.$1" using 1:2 smooth sbezier with lines title "open sockets" lw 2 axis x1y2,\
"peer_stats.$1" using 1:2 smooth sbezier with lines lw 2 axis x1y2,\
"peer_stats.$1" using 1:3 smooth sbezier with lines lw 2 axis x1y2
set output "output_$1_groups.png"
plot "choke_group_stats.$1" \
using 1:8 smooth sbezier with lines lw 4,\
"" using 1:8+7*1 smooth sbezier with lines lw 4,\
"" using 1:8+7*2 smooth sbezier with lines lw 4,\
"" using 1:8+7*3 smooth sbezier with lines lw 4\
set format y "%.0s %cb"
set output "output_$1_bandwidth.png"
plot "bandwidth_stats.$1" using 1:2 smooth sbezier with lines lw 4,\
"bandwidth_stats.$1" using 1:4 smooth sbezier with lines lw 4,\
"choke_group_stats.$1" using 1:4+7*1 smooth sbezier with lines lw 3,\
"choke_group_stats.$1" using 1:7+7*1 smooth sbezier with lines lw 3,\
"choke_group_stats.$1" using 1:4+7*2 smooth sbezier with lines lw 3,\
"choke_group_stats.$1" using 1:4+7*3 smooth sbezier with lines lw 3,\
"peer_stats.$1" using 1:2 smooth sbezier with lines lw 2 axis x1y2,\
"peer_stats.$1" using 1:3 smooth sbezier with lines lw 2 axis x1y2
set output "output_$1_memory.png"
plot "bandwidth_stats.$1" using 1:6 smooth sbezier with lines lw 4 axis x1y1,\
"peer_stats.$1" using 1:2 smooth sbezier with lines lw 2 axis x1y2,\
"peer_stats.$1" using 1:3 smooth sbezier with lines lw 2 axis x1y2
#set yrange [0:3900000000.0]
#set y2range [0:2000]
set output "output_$1_pieces.png"
plot "bandwidth_stats.$1" using 1:6 smooth sbezier with lines lw 4 axis x1y1,\
"bandwidth_stats.$1" using 1:7 smooth sbezier with lines lw 4 axis x1y1,\
"<awk '{x=\$12*10; print \$1,x}' mincore_stats.$1" using 1:2 smooth sbezier with lines lw 4 title 'alloc /100s' axis x1y1,\
"<awk '{x=\$13*10; print \$1,x}' mincore_stats.$1" using 1:2 smooth sbezier with lines lw 4 title 'dealloc /100s' axis x1y1,\
"mincore_stats.$1" using 1:7 smooth sbezier with lines lw 2 axis x1y2,\
"mincore_stats.$1" using 1:8 smooth sbezier with lines lw 2 axis x1y2,\
"mincore_stats.$1" using 1:11 smooth sbezier with lines lw 2 axis x1y2,\
"<awk '{x=\$8/10; print \$1,x}' bandwidth_stats.$1" using 1:2 smooth sbezier with lines lw 2 title 'block count /10' axis x1y2,\
"bandwidth_stats.$1" using 1:10 smooth sbezier with lines lw 2 axis x1y2
#set yrange [*:*]
#set y2range [*:*]
set format y2 "%.0s %cb"
set output "output_$1_torrents.png"
plot "bandwidth_stats.$1" using 1:6 smooth sbezier with lines lw 4 axis x1y1,\
"bandwidth_stats.$1" using 1:9 smooth sbezier with lines lw 2 axis x1y2
set format y "%.0f"
set format y2 "%.0f"
set output "output_$1_incore.png"
#plot "bandwidth_stats.$1" using 1:(0) smooth sbezier with lines,
plot \
"mincore_stats.$1" using 1:2 smooth sbezier with lines lw 2 axis x1y1,\
"mincore_stats.$1" using 1:3 smooth sbezier with lines lw 4 axis x1y2,\
"mincore_stats.$1" using 1:4 smooth sbezier with lines lw 2 axis x1y1,\
"mincore_stats.$1" using 1:5 smooth sbezier with lines lw 4 axis x1y2
#
# Updated:
#
set output "output_$1_choke.png"
set style histogram columnstacked
plot "choke_group_stats.$1" \
using 1:2+7*1 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:3+7*1 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:5+7*1 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:6+7*1 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:2+7*2 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:3+7*2 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:2+7*3 smooth sbezier with lines lw 2 axis x1y2,\
"" using 1:3+7*3 smooth sbezier with lines lw 2 axis x1y2
EOF
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
vmmap -interleaved $PPID > $1
+28
View File
@@ -0,0 +1,28 @@
# Choke Groups
## Settings
choke_group.insert = "leech_fast"
Create a new group named "leech_fast", accessible by the string or
index / reverse index according to order of insertion. E.g. '-1'
refers to the last inserted choke group, while 0 refers to the first.
All commands that applies to a group requires the first argument to be
the index, reverse index or the group name.
choke_group.tracker.mode.set = -1,"aggressive"
Set the tracker mode for torrents in this group.
choke_group.up.heuristics.set = -1,"upload_leech_experimental"
choke_group.down.heuristics.set = -1,"download_leech"
Set the heuristics used when deciding on which peers to choke and
unchoke. Use "strings.choke_heuristics{,.upload,.download}" to get a
list of the available heuristics.
choke_group.up.max.set = -1,250
choke_group.down.max.set = -1,500
Set the max total number of unchoked peers for all torrents in this choke group.
+64
View File
@@ -0,0 +1,64 @@
# IP filtering
## Introduction
## Make a new ip table
ip_tables.insert_table = <table_name>
Create a new empty table with the name table\_name, with the default
value returned being $0$.
There is currently no use of the generic ip tables commands.
## Add a new address block
ip_tables.add_address = <table_name>, 10.0.0.0/8, <value>
Set <value\> for all addresses in the address block, overwriting prior
values.
## Add a new address block
ip_tables.load = <table_name>, ~/foo.txt, <value>
Set <value\> for all addresses in the file foo.txt separated by
newline, similar to add\_address.
## Get value for address
ip_tables.get = <table_name>, 10.10.10.10
Returns the value set for an address, or the address block it belongs
to. The default is $0$.
## Size of data structures
ip_tables.size_data = <table_name>
Returns the size in bytes of all data structures for this table,
excluding the root class object itself. Note that the in-memory table is
dynamically consolidated, as such memory use will always be based on
actual fragmentation.
The table is a b-tree with 1024 nodes per branch.
## IPv4 filtering table
ipv4_filter.add_address = 10.0.0.0/8, unwanted
ipv4_filter.add_address = 11.0.0.0/8, preferred
ipv4_filter.load = ~/filters.txt, unwanted
ipv4_filter.get = 10.10.10.10
ipv4_filter.size_data =
The main ip filter, currently supporting unwanted (do not allow
connections) and preferred (currently used only in private code).
## Constants
strings.ip_filter =
=>
{ "unwanted", PeerInfo::flag_unwanted },
{ "preferred", PeerInfo::flag_preferred },
Constants used by ipv4\_filter values.
+85
View File
@@ -0,0 +1,85 @@
\section{IP filtering}
\subsection{Introduction}
\subsection{Make a new ip table}
\begin{verbatim}
ip_tables.insert_table = <table_name>
\end{verbatim}
Create a new empty table with the name 'table\_name', with the default
value returned being $0$.
There is currently no use of the generic ip tables commands.
\subsection{Add a new address block}
\begin{verbatim}
ip_tables.add_address = <table_name>, 10.0.0.0/8, <value>
\end{verbatim}
Set <value> for all addresses in the address block, overwriting prior
values.
\subsection{Add a new address block}
\begin{verbatim}
ip_tables.load = <table_name>, ~/foo.txt, <value>
\end{verbatim}
Set <value> for all addresses in the file 'foo.txt' separated by
newline, similar to 'add\_address'.
\subsection{Get value for address}
\begin{verbatim}
ip_tables.get = <table_name>, 10.10.10.10
\end{verbatim}
Returns the value set for an address, or the address block it belongs
to. The default is $0$.
\subsection{Size of data structures}
\begin{verbatim}
ip_tables.size_data = <table_name>
\end{verbatim}
Returns the size in bytes of all data structures for this table,
excluding the root class object itself. Note that the in-memory table
is dynamically consolidated, as such memory use will always be based
on actual fragmentation.
The table is a b-tree with 1024 nodes per branch.
\subsection{IPv4 filtering table}
\begin{verbatim}
ipv4_filter.add_address = 10.0.0.0/8, unwanted
ipv4_filter.add_address = 11.0.0.0/8, preferred
ipv4_filter.load = ~/filters.txt, unwanted
ipv4_filter.get = 10.10.10.10
ipv4_filter.size_data =
\end{verbatim}
The main ip filter, currently supporting 'unwanted' (do not allow
connections) and 'preferred' (currently used only in private code).
\subsection{Constants}
\begin{verbatim}
strings.ip_filter =
=>
{ "unwanted", PeerInfo::flag_unwanted },
{ "preferred", PeerInfo::flag_preferred },
\end{verbatim}
Constants used by ipv4_filter values.
+60
View File
@@ -0,0 +1,60 @@
# Logging
## Opening log files
# log.open_file = "log name", "file path"
log.open_file = "rtorrent.log", (cat,/tmp/rtorrent.log.,(system.pid))
A newly opened log file is not connected to any logging events.
Some control over formatting will be provided at a later date.
## Appending to log files
log.append_file = "rtorrent.log", "/tmp/rtorrent.log"
The `log.open_file` clears any existing contents of the file. If you'd
prefer to have a single log file that persists across application
restarts, you can use the `log.append_file` in place of the
`log.open_file` configuration key.
## Adding outputs to events
# log.add_output = "logging event", "log name"
log.add_output = "info", "rtorrent.log"
log.add_output = "dht_all", "tracker.log"
log.add_output = "tracker_events", "tracker.log"
log.add_output = "tracker_requests", "tracker.log"
Each log handle can be added to multiple different logging events.
## Logging events
"critical"
"error"
"warn"
"notice"
"info"
"debug"
The above events receive logging events from all the sub-groups
displayed below, and each event also receiving events from the event
above in importance.
Thus some high-volume sub-group events such as “tracker\_debug” are not
part of “debug” and every “warn” event will receive events from “error”,
“critical”.
"connection_*"
"dht_*"
"peer_*"
"rpc_*"
"storage_*"
"thread_*"
"tracker_*"
"torrent_*"
All sub-groups have events from “critical” to “debug” defined.
+62
View File
@@ -0,0 +1,62 @@
\section{Logging}
\subsection{Opening log files}
\begin{verbatim}
# log.open_file = "log name", "file path"
log.open_file = "rtorrent.log", (cat,/tmp/rtorrent.log.,(system.pid))
\end{verbatim}
A newly opened log file is not connected to any logging events.
Some control over formatting will be provided at a later date.
\subsection{Adding outputs to events}
\begin{verbatim}
# log.add_output = "logging event", "log name"
log.add_output = "info", "rtorrent.log"
log.add_output = "dht_all", "tracker.log"
log.add_output = "tracker_events", "tracker.log"
log.add_output = "tracker_requests", "tracker.log"
\end{verbatim}
Each log handle can be added to multiple different logging events.
\subsection{Logging events}
\begin{verbatim}
"critical"
"error"
"warn"
"notice"
"info"
"debug"
\end{verbatim}
The above events receive logging events from all the sub-groups
displayed below, and each event also reciving events from the event
above in importance.
Thus some high-volume sub-group events such as ``tracker\_debug'' are
not part of ``debug'' and every ``warn'' event will receive events
from ``error'', ``critical''.
\begin{verbatim}
"connection_*"
"dht_*"
"peer_*"
"rpc_*"
"storage_*"
"thread_*"
"tracker_*"
"torrent_*"
\end{verbatim}
All sub-groups have events from ``critical'' to ``debug'' defined.
+559
View File
@@ -0,0 +1,559 @@
.\" This manpage has been automatically generated by docbook2man
.\" from a DocBook document. This tool can be found at:
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
.\" Please send any bug reports, improvements, comments, patches,
.\" etc. to Steve Cheng <steve@ggi-project.org>.
.TH "RTORRENT" "1" "14 May 2009" "BitTorrent client for ncurses" ""
.SH NAME
rtorrent \- a BitTorrent client for ncurses
.SH SYNOPSIS
\fBrtorrent\fR [ \fB-h\fR ] [ \fB-n\fR ] [ \fB-o key1=opt1,...\fR ] [ \fB-O key=opt\fR ] [ \fBURL | FILE\fR\fI ...\fR ]
.SH "DESCRIPTION"
.PP
\fBrtorrent\fR is a BitTorrent client for ncurses, using
the \fBlibtorrent\fR library. The client and library is
written in C++ with emphasis on speed and efficiency, while delivering
equivalent features to those found in GUI based clients in an ncurses
client.
.PP
Most of the options below have their own default unit in addition to
supporting B, K, M and G suffixes.
.SH "KEYBOARD CONTROL"
.PP
.SS "GLOBAL KEYS"
.TP
\fB^q\fR
Initiate shutdown, press again to force the shutdown and
skip sending the stop signal to trackers.
.TP
\fBup | down | left | right arrow keys\fR
.TP
\fB^P | ^N | ^B | ^F\fR
Select entries or change windows. The right arrow key or ^F is often
used for viewing details about the selected entry, while the left
arrow key or ^B often returns to the previous screen.
.TP
\fBa | s | d\fR
Increase the upload throttle by 1/5/50 KB.
.TP
\fBA | S | D\fR
Increase the download throttle by 1/5/50 KB.
.TP
\fBz | x | c\fR
Decrease the upload throttle by 1/5/50 KB.
.TP
\fBZ | X | C\fR
Decrease the download throttle by 1/5/50 KB.
.SS "MAIN VIEW KEYS"
.TP
\fB->\fR
View download.
.TP
\fB0 - 9\fR
Change view.
.TP
\fB^S\fR
Start download.
.TP
\fB^D\fR
Stop an active download, or remove a stopped download.
.TP
\fB^K\fR
Close a torrent and its files.
.TP
\fB^E\fR
Set the 'create/resize queued' flags on all files in a torrent. This
is necessary if the underlying files in a torrent have been deleted or
truncated, and thus rtorrent must recreate them.
.TP
\fB^R\fR
Initiate hash check of torrent.
.TP
\fB^O\fR
Change the destination directory of the download. The torrent must be
closed.
.TP
\fB^X\fR
Call commands or change settings.
.TP
\fB^B\fR
Set download to perform initial seeding. Only use when
you are the first and only seeder so far for the download.
.TP
\fB+ | -\fR
Change the priority of the download.
.TP
\fBbackspace\fR
Add torrent using an URL or file path. Use
\fBtab\fR to view directory content and do
auto-complete.
.TP
\fBl\fR
View log. Exit by pressing the space-bar.
.TP
\fBU\fR
Delete the file the torrent is tied to, and clear the association.
.TP
\fBI\fR
Toggle whether torrent ignores ratio settings.
.TP
\fBF\fR
Add a temporary name based regex filter to the current view.
.SS "DOWNLOAD VIEW KEYS"
.TP
\fB->\fR
View torrent file list. Use the space-bar to change the file priority
and \fB*\fR to change the priority of all
files. Use \fB/\fR to collapse the directories. OUTDATED
.TP
\fB1 | 2\fR
Adjust max uploads.
.TP
\fB3 | 4\fR
Adjust min peers.
.TP
\fB5 | 6\fR
Adjust max peers.
.TP
\fBu\fR
Display transfering blocks.
.TP
\fBi\fR
Display chunk rarity.
.TP
\fBo\fR
Display the tracker list. Cycle the trackers in a group with the
space-bar.
.TP
\fBp\fR
View peer and torrent information.
.TP
\fBt | T\fR
Initiate tracker request. Use capital T to force the request, ignoring
the "min interval" set by the tracker.
.TP
\fBk\fR
Disconnect peer.
.TP
\fB*\fR
Choke/Snub peer.
.SH "OPTIONS"
.TP
\fB-b \fIa.b.c.d\fB\fR
Bind listening socket and outgoing connections to this network
interface address.
.TP
\fB-d \fIdirectory\fB\fR
Set the default download directory. Defaults to "./".
.TP
\fB-h\fR
Display help and exit.
.TP
\fB-i \fIa.b.c.d\fB\fR
Set the address reported to the tracker.
.TP
\fB-n\fR
Don't load ~/.rtorrent.rc on startup.
.TP
\fB-o key1=opt1,...\fR
.TP
\fB-O key=opt\fR
Set any number of options, see the SETTINGS section. The options given
here override the resource files. Use capital \fB-O\fR
to allow comma in the option.
.TP
\fB-p \fIa-b\fB\fR
Try to open a listening port in the range \fBa\fR up to
and including \fBb\fR\&.
.TP
\fB-s \fIdirectory\fB\fR
Session management will be enabled and the torrent files for all open
downloads will be stored in this directory. Only one instance of
rtorrent should be used with each session directory, though at the
moment no locking is done. An empty string will disable the session
directory.
.SH "GENERAL SETTINGS"
.PP
.TP
\fBbind = \fIa.b.c.d\fB\fR
Bind listening socket and outgoing connections to this network
interface address.
.TP
\fBip = \fIa.b.c.d\fB\fR
.TP
\fBip = \fIhostname\fB\fR
Set the address reported to the tracker.
.TP
\fBport_range = \fIa-b\fB\fR
Try to open a listening port in the range \fBa\fR up to
and including \fBb\fR\&.
.TP
\fBport_random = \fIyes | no\fB\fR
Open the listening port at a random position in the port range.
.TP
\fBcheck_hash = \fIyes | no\fB\fR
Perform hash check on torrents that have finished downloading.
.TP
\fBdirectory = \fIdirectory\fB\fR
Set the default download directory. Defaults to "./".
.TP
\fBsession = \fIdirectory\fB\fR
Session management will be enabled and the torrent files for all open
downloads will be stored in this directory. Only one instance of
rtorrent can be used per session directory. An empty string will
disable the session directory.
.TP
\fBhttp_proxy = \fIurl\fB\fR
Use a http proxy. Use an empty string to disable.
.TP
\fBencoding_list = \fIencoding\fB\fR
Add a preferred filename encoding to the list. The encodings are
attempted in the order they are inserted, if none match the torrent
default is used.
.TP
\fBencryption = \fIoption\fB,\fI\&...\fB\fR
Set how rtorrent should deal with encrypted Bittorrent connections. By
default, encryption is disabled, equivalent to specifying the option
\fBnone\fR\&. Alternatively, any number of the following
options may be specified:
\fBallow_incoming\fR (allow incoming encrypted connections),
\fBtry_outgoing\fR (use encryption for outgoing connections),
\fBrequire\fR (disable unencrypted handshakes),
\fBrequire_RC4\fR (also disable plaintext transmission after the
initial encrypted handshake),
\fBenable_retry\fR (if the initial outgoing connection fails, retry
with encryption turned on if it was off or off if it was on),
\fBprefer_plaintext\fR (choose plaintext when peer offers a choice
between plaintext transmission and RC4 encryption, otherwise RC4 will be used).
.TP
\fBpeer_exchange = \fIyes | no\fB\fR
Enable/disable peer exchange for torrents that aren't marked private. Disabled by default.
.TP
\fBschedule = \fIid\fB,\fIstart\fB,\fIinterval\fB,\fIcommand\fB\fR
Call \fBcommand\fR every \fBinterval\fR
seconds, starting from \fBstart\fR\&. An
\fBinterval\fR of zero calls the task once, while a
\fBstart\fR of zero calls it immediately. Currently
\fBcommand\fR is forwarded to the option handler.
\fBstart\fR and \fBinterval\fR may
optionally use a time format, \fBdd:hh:mm:ss\fR\&. F.ex to
start a task every day at \fB18:00\fR, use
\fB18:00:00,24:00:00\fR\&.
.TP
\fBschedule_remove = \fIid\fB\fR
Delete \fBid\fR from the scheduler.
.TP
\fBstart_tied =\fR
Start torrents that are tied to filenames that have been re-added.
.TP
\fBstop_untied =\fR
.TP
\fBclose_untied =\fR
.TP
\fBremove_untied =\fR
Stop, close or remove the torrents that are tied to filenames that
have been deleted. Clear the association with the 'U' key.
.TP
\fBclose_low_diskspace = \fIspace\fB\fR
Close any active torrents on filesystems with less than
\fBspace\fR diskspace left. Use with
the \fBschedule\fR option. A default scheduled event
with id \fBlow_diskspace\fR is set to 500Mb.
.TP
\fBload = \fIfile\fB\fR
.TP
\fBload_verbose = \fIfile\fB\fR
.TP
\fBload_start = \fIfile\fB\fR
.TP
\fBload_start_verbose = \fIfile\fB\fR
Load and possibly start a file, or possibly multiple files by using the
wild-card "*". This is meant for use with
\fBschedule\fR, though ensure that the
\fBstart\fR is non-zero. The loaded file will be tied
to the filename provided.
.TP
\fBimport = \fIfile\fB\fR
.TP
\fBtry_import = \fIfile\fB\fR
Load a resource file. \fBtry_import\fR does not throw
torrent::input_error exception on bad input.
.TP
\fBstop_on_ratio = \fImin_ratio\fB\fR
.TP
\fBstop_on_ratio = \fImin_ratio\fB,\fImin_upload\fB\fR
.TP
\fBstop_on_ratio = \fImin_ratio\fB,\fImin_upload\fB,\fImax_ratio\fB\fR
Stop torrents when they reach the given upload ratio
\fBmin_ratio\fR in percent. If the optional
\fBmin_upload\fR is given, require a total
upload amount of this many bytes as well. If the optional
\fBmax_ratio\fR is given, stop the torrent
when reaching this ratio regardless of the total upload
amount. Exclude certain torrent by pressing
\fBShift+I\fR in the downlist list.
Use with the \fBschedule\fR option.
.TP
\fBon_insert = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_erase = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_open = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_close = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_start = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_stop = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_hash_queued = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_hash_removed = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_hash_done = \fIid\fB,\fIcommand\fB\fR
.TP
\fBon_finished = \fIid\fB,\fIcommand\fB\fR
Call a command on a download when its state changes. Only a subset of
commands are available.
.SH "THROTTLE SETTINGS"
.TP
\fBupload_rate = \fIKB\fB\fR
.TP
\fBdownload_rate = \fIKB\fB\fR
Set the maximum global uploand and download rates.
.TP
\fBmin_peers = \fIvalue\fB\fR
.TP
\fBmax_peers = \fIvalue\fB\fR
Set the minimum and maximum number of peers to allow in each download.
.TP
\fBmin_peers_seed = \fIvalue\fB\fR
.TP
\fBmax_peers_seed = \fIvalue\fB\fR
Set the minimum nad maximum number of peers to allow while seeding, or
-1 (default) to use max_peers.
.TP
\fBmax_uploads = \fIvalue\fB\fR
Set the maximum number of simultaneous uploads per download.
.TP
\fBmax_uploads_div = \fIvalue\fB\fR
.TP
\fBmax_downloads_div = \fIvalue\fB\fR
Change the divider used to calculate the max upload and download slots
to use when the throttle is changed. Disable by
setting \fB0\fR\&.
.TP
\fBmax_uploads_global = \fIvalue\fB\fR
.TP
\fBmax_downloads_global = \fIvalue\fB\fR
Max upload and download slots allowed. Disable by
setting \fB0\fR\&.
.TP
\fBthrottle_up = \fIname\fB, \fIupload_rate\fB\fR
.TP
\fBthrottle_down = \fIname\fB, \fIdownload_rate\fB\fR
Define secondary throttle and/or set the given upload or download rate. Attach to a download with the d.set_throttle_name=name command
or switch throttles with Ctrl-T. Download must be stopped when changing throttles. Note that secondary throttles only work if the
global upload/download is throttled. Setting a download to use the \fBNULL\fR throttle makes the download unthrottled
even when there is a global throttle. Note that this special case bypasses the global throttle entirely, and as such its rate and
transfer amounts are not included in the global statistics.
.TP
\fBthrottle_ip = \fIname\fB, \fIhost\fB\fR
.TP
\fBthrottle_ip = \fIname\fB, \fInetwork/prefix\fB\fR
.TP
\fBthrottle_ip = \fIname\fB, \fIstart\fB, \fIend\fB\fR
Use the given secondary throttle for a host, CIDR network or IP range. All peers with a matching IP will use this throttle instead
of the global throttle or a custom download throttle. The name may be \fBNULL\fR to make these peers unthrottled, with
the same caveats as explained above.
.SH "TRACKER RELATED SETTINGS"
.PP
Tracker related settings.
.TP
\fBenable_trackers = \fIyes\fB\fR
Set to \fBno\fR to disable all tracker requests. Useful
for disabling rtorrent with the \fBschedule\fR command.
.TP
\fBtracker_dump = \fIfilename\fB\fR
Dump tracker requests to \fBfilename\fR, disable by
supplying an empty string. Only torrents loaded while
\fBtracker_dump\fR contains a non-empty string will be
logged at the moment, although disabling it will work as expected.
.TP
\fBtracker_numwant = \fInumber\fB\fR
Set the numwant field sent to the tracker, which indicates how many
peers we want. A negative value disables this feature.
.TP
\fBuse_udp_trackers = \fIyes\fB\fR
Use UDP trackers. Disable if you are behind a firewall, etc, that does
not allow connections to UDP trackers.
.TP
\fBdht = \fIdisabled|off|auto|on\fB\fR
Support for querying the distributed hash table (DHT) to find peers for trackerless
torrents or when all trackers are down. Set to \fBdisable\fR to completely
disable DHT, \fBoff\fR (default) to enable DHT but to not start the
DHT server, \fBauto\fR to automatically start and stop the DHT server
as needed or \fBon\fR for permanently keeping the DHT server running.
When set to automatic, the DHT server will start up when the first non-private torrent
is started, and will stop 15-30 minutes after the last non-private torrent is
stopped (or when rTorrent quits). For DHT to work, a session directory must be set (for
saving the DHT cache).
.TP
\fBdht_port = \fInumber\fB\fR
Set the UDP listen port for DHT. Defaults to 6881.
.TP
\fBdht_add_node = \fIhost[:port]\fB\fR
Not intended for use in the configuration file but as one-time option in the
client or on the command line to bootstrap an empty DHT node table. Contacts
the given node and attempts to bootstrap from it if it replies.
The port is optional, with port 6881 being used by default.
.TP
\fBhttp_capath = \fIpath\fB\fR
.TP
\fBhttp_cacert = \fIfilename\fB\fR
Set the certificates to use in http requests. See Curl's
CURLOPT_CAPATH and CURLOPT_CAINFO options for further information.
.SH "USER-INTERFACE SETTINGS"
.PP
Display related settings.
.TP
\fBview_add = \fIname\fB\fR
Create a new view.
.TP
\fBview_sort = \fIname\fB\fR
.TP
\fBview_sort = \fIname\fB,\fIseconds\fB\fR
Sort a view according the the criteria set by
\fBview_sort_current\fR\&. If the optional argument is
supplied, the view is not sorted if a change happened during the last
\fBseconds\fR\&. This command is meant to be used with
\fBschedule\fR\&.
.TP
\fBview_sort_new = \fIname\fB,\fI\&...\fB\fR
.TP
\fBview_sort_current = \fIname\fB,\fI\&...\fB\fR
Set the sorting criteria for when new elements inserted or
\fBview_sort\fR is called. The list can contain any
number of criteria, including zero, from the following:
\fBname\fR, \fBname_reverse\fR,
\fBstopped\fR, \fBstarted\fR,
\fBcomplete\fR, \fBincomplete\fR,
\fBstate_changed\fR,
\fBstate_changed_reverse\fR
.TP
\fBkey_layout = \fIqwerty|azerty|qwertz|dvorak\fB\fR
Change the key-bindings.
.SH "FILE-SYSTEM SETTINGS"
.PP
File-system related settings.
.TP
\fBmax_file_size = \fIsize\fB\fR
Set the maximum size a file can have. Disable by
passing \fB-1\fR\&.
.TP
\fBsplit_file_size = \fIsize\fB\fR
Split files in a torrent larger than \fBsize\fR into
seperate files. Disable by passing \fB-1\fR\&.
.TP
\fBsplit_suffix = \fIstring\fB\fR
Set the suffix used on split files. Defaults
to \fB\&.part\fR\&.
.SH "DOWNLOAD SETTINGS"
.PP
Settings that require a download as a target, the options need to be
called through f.ex \fBon_finished\fR\&.
.TP
\fBcreate_link = \fItype\fB,\fIpath\fB,\fIsuffix\fB\fR
.TP
\fBdelete_link = \fItype\fB,\fIpath\fB,\fIsuffix\fB\fR
Create or delete a symbolic link. The link path is the concatenation
of \fBpath\fR, the result of
the \fBtype\fR on the download,
and \fBsuffix\fR\&.
Available types are; \fBbase_path\fR uses the base path
of the download, \fBbase_filename\fR uses the base
filename of the download, \fBtied\fR uses the path of
the file the download is tied to, see \fBstart_tied\fR\&.
.SH "ADVANCED SETTINGS"
.PP
This list contains settings users shouldn't need to touch, some may
even cause crashes or similar if incorrectly set.
.TP
\fBhash_read_ahead = \fIMB\fB\fR
Configure how far ahead we ask the kernel to read when doing hash
checking. The hash checker uses madvise(..., MADV_WILLNEED) for the
requests.
.TP
\fBhash_interval = \fIms\fB\fR
Interval between attempts to check the hash when the chunk is not in
memory, in milliseconds.
.TP
\fBhash_max_tries = \fItries\fB\fR
Number of attempts to check the hash while using the mincore status,
before forcing. Overworked systems might need lower values to get a
decent hash checking rate.
.TP
\fBmax_open_files = \fIvalue\fB\fR
Number of files to simultaneously keep open. LibTorrent dynamically
opens and closes files as necessary when mapping files to
memory. Default is based on sysconf(_SC_OPEN_MAX).
You probably only think you know what this option does, so don't touch
it.
.TP
\fBmax_open_sockets = \fIvalue\fB\fR
Number of network sockets to simultaneously keep open. This value is
set to a reasonable value based on \fBsysconf(_SC_OPEN_MAX)\fR\&.
.TP
\fBmax_open_http = \fIvalue\fB\fR
Number of sockets to simultaneously keep open. This value is set
to \fB32\fR by default.
.TP
\fBmax_memory_usage = \fIbytes\fB\fR
Set the max amount of memory space used to mapping file chunks. This
may also be set using \fBulimit -m\fR where 3/4 will be
allocated to file chunks.
.TP
\fBsend_buffer_size = \fIvalue\fB\fR
.TP
\fBreceive_buffer_size = \fIvalue\fB\fR
Adjust the send and receive buffer size for socket.
.TP
\fBumask = \fI0022\fB\fR
Set the umask for this process, which is applied to all files created
by the program.
.TP
\fBcwd = \fIdirectory\fB\fR
Changes the working directory of the process using
\fBchdir\fR\&.
.TP
\fBsession_on_completion = \fIyes\fB\fR
Controls if the session torrent is saved when a torrent finishes. By
default on.
.TP
\fBsession_lock = \fIyes\fB\fR
Controls if a lock file is created in the session directory on startup.
.TP
\fBsession_save = \fR
Save the session files for all downloads.
.TP
\fBtos = \fIdefault|lowdelay|throughput|reliability|mincost\fB\fR
.TP
\fBtos = \fIhex\fB\fR
Change the TOS of peer connections, by default set to
\fBthroughput\fR\&. If the option is set to
\fBdefault\fR then the system default TOS is used. A
hex value may be used for non-standard settings.
.TP
\fBhandshake_log = \fIyes\fB\fR
Enable logging of the peer handshake. This generates a large number of
log messages, but may be useful to debug connection problems.
.SH "AUTHORS"
.PP
Jari "Rakshasa" Sundell
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
#/bin/bash
gnuplot << EOF
set terminal png size 1024 * 1, 768 enhanced
set xdata time
set timefmt "%s"
set format x "%H:%M"
set y2tics
set autoscale xfix
set key autotitle columnhead
set format y "%.0f"
set format y2 "%.0f"
set output "output_$1_incore_sync.png"
plot \
"instrumentation_mincore.log.$1" using 1:6 title 'success' with lines lw 4 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:7 title 'failed' with lines lw 4 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:8 title 'not synced' with lines lw 4 axis x1y2,\
"instrumentation_mincore.log.$1" using 1:9 title 'not deallocated' with lines lw 4 axis x1y2
set format y "%.0g"
set output "output_$1_incore_alloc.png"
plot \
"instrumentation_mincore.log.$1" using 1:12 title 'allocations' with lines lw 2 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:13 title 'deallocations' with lines lw 4 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:10 title 'alloc failed' with lines lw 2 axis x1y2
EOF
+49
View File
@@ -0,0 +1,49 @@
#/bin/bash
gnuplot << EOF
set terminal png size 1024,768 enhanced
set xdata time
set timefmt "%s"
set format x "%H:%M"
set y2tics
set autoscale xfix
set key autotitle columnhead
# set datafile missing '0'
set format y "%.0f"
set format y2 "%.0f"
set yrange [0:]
set y2range [0:]
set output "output_$1_transfer_requests.png"
plot \
"instrumentation_transfers.log.$1" using 1:2 title 'delegated' with lines lw 4 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:3 title 'downloading' with lines lw 4 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:4 title 'finished' with lines lw 4 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:5 title 'skipped' with lines lw 2 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:6 title 'unknown' with lines lw 2 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:7 title 'unordered' with lines lw 2 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:19 title 'unaccounted' with lines lw 2 axis x1y2
set output "output_$1_transfer_queues.png"
plot \
"instrumentation_transfers.log.$1" using 1:8 title 'queue added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:9 title 'queue moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:10 title 'queue removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:11 title 'queue total' with lines lw 4 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:12 title 'unordered added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:13 title 'unordered moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:14 title 'unordered removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:15 title 'unordered total' with lines lw 4 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:16 title 'stalled added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:17 title 'stalled moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:18 title 'stalled removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:19 title 'stalled total' with lines lw 4 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:20 title 'choked added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:21 title 'choked moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:22 title 'choked removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:23 title 'choked total' with lines lw 4 axis x1y2
EOF
+140
View File
@@ -0,0 +1,140 @@
#############################################################################
# This is an (old) example resource file for rTorrent.
# Copy to ~/.rtorrent.rc and enable/modify the options as needed.
# Remember to uncomment the options you wish to enable.
#
# See 'rtorrent.rc-example' for a newer, basic configuration.
#
# Sample: https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
# Complete: https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html
# Useful: https://rtorrent-docs.readthedocs.io/en/latest/use-cases.html
# Manual: https://rtorrent-docs.readthedocs.io/en/latest/
# Convert: https://github.com/rakshasa/rtorrent/wiki/rTorrent-0.9-Comprehensive-Command-list-(WIP)
# Handbook: https://media.readthedocs.org/pdf/rtorrent-docs/latest/rtorrent-docs.pdf
# File: https://github.com/rakshasa/rtorrent/blob/master/doc/rtorrent.rc
#############################################################################
# Maximum and minimum number of peers to connect to per torrent.
#
#throttle.min_peers.normal.set = 40
#throttle.max_peers.normal.set = 100
# Same as above but for seeding completed torrents.
# "-1" = same as downloading.
#
#throttle.min_peers.seed.set = 10
#throttle.max_peers.seed.set = 50
# Maximum number of simultaneous uploads per torrent.
#
#throttle.max_uploads.set = 15
# Global upload and download rate in KiB.
# "0" for unlimited.
#
#throttle.global_down.max_rate.set_kb = 0
#throttle.global_up.max_rate.set_kb = 0
# Default directory to save the downloaded torrents.
#
#directory.default.set = ./
# Default session directory. Make sure you don't run multiple instance
# of rTorrent using the same session directory. Perhaps using a
# relative path?
#
#session.path.set = ./session
# Watch a directory for new torrents, and stop those that have been
# deleted. Use directory.watch.ready for network shares or other watch
# directories where files may be copied or written directly into place.
# Do not mix directory.watch.ready and directory.watch.added on the same
# watch directory.
#
#directory.watch.ready = ./watch, load.start
#schedule2 = watch_directory,5,5,load.start=./watch/*.torrent
# Close torrents when disk-space is low.
#
#schedule2 = low_diskspace,5,60,close_low_diskspace=100M
# The IP address reported to the tracker.
#
#network.local_address.set = 127.0.0.1
#network.local_address.set = rakshasa.no
# The IP address the listening socket and outgoing connections is
# bound to.
#
#network.bind_address.set = 127.0.0.1
#network.bind_address.set = rakshasa.no
# Port range to use for listening.
#
#network.port_range.set = 6890-6999
# Start opening ports at a random position within the port range.
#
#network.port_random.set = no
# Set RPC type
#network.rpc.use_xmlrpc.set = true
#network.rpc.use_jsonrpc.set = true
# Check hash for finished torrents. Might be useful until the bug is
# fixed that causes lack of disk-space not to be properly reported.
#
#pieces.hash.on_completion.set = no
# Set whether the client should try to connect to UDP trackers.
#
#trackers.use_udp.set = yes
# Alternative calls to bind and IP that should handle dynamic IP's.
#
#schedule2 = ip_tick,0,1800,ip=rakshasa
#schedule2 = bind_tick,0,1800,bind=rakshasa
# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plain-text to RC4 encryption after the encrypted handshake.
#
# protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext
# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
# dht.mode.set = auto
# UDP port to use for DHT.
#
#dht.port.set = 6881
# Enable peer exchange (for torrents not marked private).
#
#protocol.pex.set = yes
# Set download list layout style ("full", "compact").
#
#ui.torrent_list.layout.set = "full"
# Set navigation keymap style ("vi", "emacs"). Default is "emacs".
#
#ui.keymap.style.set = "emacs"
# Run rTorrent as a daemon, controlled via XMLRPC.
#
#system.daemon.set = false
# SCGI Connectivity (for alternative rtorrent interfaces, XMLRPC)
# Use a IP socket with scgi_port, or a Unix socket with scgi_local.
# schedule can be used to set permissions on the unix socket.
#
#network.scgi.open_port = "127.0.0.1:5000"
#network.scgi.open_local = (cat,(session.path),/rpc.sock)
#schedule2 = socket_chmod, 0, 0, "execute.nothrow=chmod,770,(cat,(session.path),/rpc.sock)"
+111
View File
@@ -0,0 +1,111 @@
#############################################################################
# A minimal rTorrent configuration that provides the basic features
# you want to have in addition to the built-in defaults.
#
# See https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
# for an up-to-date version.
#############################################################################
# Instance layout (base paths)
method.insert = cfg.basedir, private|const|string, (cat,"/home/USERNAME/rtorrent/")
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/")
method.insert = cfg.logs, private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile, private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session, private|const|string, (cat,(cfg.basedir),".session/")
method.insert = cfg.watch, private|const|string, (cat,(cfg.basedir),"watch/")
# Create instance directories
execute.throw = sh, -c, (cat,\
"mkdir -p \"",(cfg.download),"\" ",\
"\"",(cfg.logs),"\" ",\
"\"",(cfg.session),"\" ",\
"\"",(cfg.watch),"/load\" ",\
"\"",(cfg.watch),"/start\" ")
# Listening port for incoming peer traffic (fixed; you can also randomize it)
network.port_range.set = 50000-50000
network.port_random.set = no
# Tracker-less torrent and UDP tracker support
# (conservative settings for 'private' trackers, change for 'public')
dht.mode.set = disable
protocol.pex.set = no
trackers.use_udp.set = no
# Peer settings
throttle.max_uploads.set = 100
throttle.max_uploads.global.set = 250
throttle.min_peers.normal.set = 20
throttle.max_peers.normal.set = 60
throttle.min_peers.seed.set = 30
throttle.max_peers.seed.set = 80
trackers.numwant.set = 80
protocol.encryption.set = allow_incoming,try_outgoing,enable_retry
# Limits for file handle resources, this is optimized for
# an `ulimit` of 1024 (a common default). You MUST leave
# a ceiling of handles reserved for rTorrent's internal needs!
network.http.max_open.set = 50
network.max_open_files.set = 600
network.max_open_sockets.set = 300
# Memory resource usage (increase if you have a large number of items loaded,
# and/or the available resources to spend)
pieces.memory.max.set = 1800M
network.xmlrpc.size_limit.set = 4M
# Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
##log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
(session.path), "rtorrent.pid", " ", (system.pid))
# Other operational settings (check & adapt)
encoding.add = utf8
system.umask.set = 0027
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
##pieces.hash.on_completion.set = no
##view.sort_current = seeding, greater=d.ratio=
##keys.layout.set = qwerty
##network.http.capath.set = "/etc/ssl/certs"
##network.http.ssl_verify_peer.set = 0
##network.http.ssl_verify_host.set = 0
#network.rpc.use_xmlrpc.set = true
#network.rpc.use_jsonrpc.set = true
# Some additional values and commands
method.insert = system.startup_time, value|const, (system.time)
method.insert = d.data_path, simple,\
"if=(d.is_multi_file),\
(cat, (d.directory), /),\
(cat, (d.directory), /, (d.name))"
method.insert = d.session_file, simple, "cat=(session.path), (d.hash), .torrent"
# Watch directories (add more as you like, but use unique schedule names)
schedule2 = watch_start, 10, 10, ((load.start_verbose, (cat, (cfg.watch), "start/*.torrent")))
schedule2 = watch_load, 11, 10, ((load.verbose, (cat, (cfg.watch), "load/*.torrent")))
# Run the rTorrent process as a daemon in the background
# (and control via XMLRPC sockets)
#system.daemon.set = true
#network.scgi.open_local = (cat,(session.path),rtorrent.sock)
#execute.nothrow = chmod,770,(cat,(session.path),rtorrent.sock)
# Logging:
# Levels = critical error warn notice info debug
# Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "info", "log"
#log.add_output = "tracker_events", "log"
#log.add_output = "tracker_requests", "log"
### END of rtorrent.rc ###
+142
View File
@@ -0,0 +1,142 @@
--[[
A minimal rTorrent configuration that provides the basic features
you want to have in addition to the built-in defaults.
See https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
for an up-to-date version.
How to use this file:
1. Copy to destination, remove '-example' suffix
2. Create rtorrent.rc, containing single command, which executes THIS file.
For example:
lua.execute = (cat, (system.env, HOME), "/.config/rtorrent/rtorrent.rc.lua")
]]--
--[[ Bootstrap START ]]--
local rtorrent = require('rtorrent')
rc = rtorrent.autocall
--[[ Helper functions ]]--
local function makeArgs(cmdline)
return 'sh', '-c', "'"..table.concat(cmdline, "' '").."'"
end
-- Instance layout (base paths)
local home = os.getenv('HOME')
local cfg = {}
cfg.basedir = home..'/rtorrent/'
cfg.download = cfg.basedir..'download/'
cfg.logs = cfg.basedir..'log/'
cfg.logfile = cfg.logs..'rtorrent-'..rc.system.time()..'.log'
cfg.session = cfg.basedir..'.session/'
cfg.watch = cfg.basedir..'watch/'
rc.method.insert('cfg.download', 'private|const|string', cfg.download)
rc.method.insert('cfg.logs', 'private|const|string', cfg.logs)
rc.method.insert('cfg.logfile', 'private|const|string', cfg.logfile)
rc.method.insert('cfg.session', 'private|const|string', cfg.session)
rc.method.insert('cfg.watch', 'private|const|string', cfg.watch)
-- Create instance directories
rc.execute.throw(
makeArgs({'mkdir', '-p',
cfg.download,
cfg.logs,
cfg.session,
cfg.watch..'/load',
cfg.watch..'/start'}))
-- Listening port for incoming peer traffic (fixed; you can also randomize it)
rc.network.port_range = '50000-50000'
rc.network.port_random = false
-- Tracker-less torrent and UDP tracker support
-- (conservative settings for 'private' trackers, change for 'public')
rc.dht.mode = 'disable'
rc.protocol.pex = false
rc.trackers.use_udp = false
-- Peer settings
rc.throttle.max_uploads = 100
rc.throttle.max_uploads.global = 250
rc.throttle.min_peers.normal = 20
rc.throttle.max_peers.normal = 60
rc.throttle.min_peers.seed = 30
rc.throttle.max_peers.seed = 80
rc.trackers.numwant = 80
rc.protocol.encryption.set('allow_incoming', 'try_outgoing', 'enable_retry')
-- Limits for file handle resources, this is optimized for
-- an `ulimit` of 1024 (a common default). You MUST leave
-- a ceiling of handles reserved for rTorrent's internal needs!
rc.network.http.max_open = 50
rc.network.max_open_files = 600
rc.network.max_open_sockets = 300
-- Memory resource usage (increase if you have a large number of items loaded,
-- and/or the available resources to spend)
rc.pieces.memory.max = '1800M'
rc.network.xmlrpc.size_limit = '4M'
-- Basic operational settings (no need to change these)
rc.session.path = cfg.session
rc.directory.default = cfg.download
rc.log.execute(cfg.logs.."execute.log")
--rc.log.xmlrpc(cfg.logs.."xmlrpc.log")
rc.execute.nothrow(
"sh", "-c", table.concat(
{"echo >", rc.session.path(), "rtorrent.pid", " ", rc.system.pid()
}))
-- Other operational settings (check & adapt)
rc.encoding.add('utf8')
rc.system.umask = 0027
rc.system.cwd = rc.directory.default()
rc.network.http.dns_cache_timeout = 25
rc.schedule2('monitor_diskspace', '15', '60', 'close_low_diskspace=1000M')
--rc.pieces.hash.on_completion = false
--rc.view.sort_current('seeding', 'greater=d.ratio=')
--rc.keys.layout = 'qwerty'
--rc.network.http.capath = '/etc/ssl/certs'
--rc.network.http.ssl_verify_peer = 0
--rc.network.http.ssl_verify_host = 0
--rc.network.rpc.use_xmlrpc = true
--rc.network.rpc.use_jsonrpc = true
-- Some additional values and commands
-- NOTE: just common names, not commands
rc.method.insert('system.startup_time', 'value|const', rc.system.time())
rc.method.insert('d.data_path', 'simple',
[[if=(d.is_multi_file),
(cat, (d.directory), /),
(cat, (d.directory), /, (d.name))]])
rc.method.insert('d.session_file', 'simple', 'cat=(session.path), (d.hash), .torrent')
-- Watch directories (add more as you like, but use unique schedule names)
rc.schedule2('watch_start', '10', '10', 'load.start_verbose=(cat, (cfg.watch), "start/*.torrent")')
rc.schedule2('watch_load', '11', '10', 'load.verbose=(cat, (cfg.watch), "load/*.torrent")')
-- Run the rTorrent process as a daemon in the background
-- (and control via XMLRPC sockets)
--rc.system.daemon = true
--rc.network.scgi.open_local(cfg.session..'rtorrent.sock')
--rc.execute.nothrow('chmod', '770', cfg.session..'rtorrent.sock')
-- Logging:
-- Levels = critical error warn notice info debug
-- Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
rc.print('Logging to '..rc.cfg.logfile())
rc.log.open_file('log', rc.cfg.logfile())
rc.log.add_output('info', 'log')
--rc.log.add_output('tracker_events', 'log')
--rc.log.add_output('tracker_requests', 'log')
--[[ END of rtorrent.rc.lua ]]--
+131
View File
@@ -0,0 +1,131 @@
#!/usr/bin/perl
# Perl script to add rTorrent fast resume data to torrent files.
#
# Usage:
# rtorrent_fast_resume.pl [base-directory] < plain.torrent > with_fast_resume.torrent
# -OR-
# rtorrent_fast_resume.pl [base-directory] plain.torrent [with_fast_resume.torrent]
use strict;
use warnings;
use Convert::Bencode_XS qw(bencode bdecode);
use File::Spec; # core module
use POSIX; # core module
$/ = undef;
$| = 1;
# Process ARGV
my $d = $ARGV[0];
if ($d and not -d $d) {
if (-f $d and -s $d and not $ARGV[2]) { # missing directory, but has file
$ARGV[2] = $ARGV[1];
$ARGV[1] = $ARGV[0];
$d = '';
}
else { die "$d is not a directory\n"; }
}
$d ||= ".";
$d .= "/" unless $d =~ m#/$#;
my ($in, $out, $msg);
my ($in_file, $out_file) = ('', '');
if ($ARGV[1]) {
$in_file = $ARGV[1];
open($in, ($ARGV[2] ? '<' : '+<'), $in_file) || die "Cannot open $in_file for input!\n";
unless ($ARGV[2]) {
$out = $in;
$out_file = $in_file;
}
}
else { $in = *STDIN; }
if ($ARGV[2]) {
$out_file = $ARGV[2];
open($out, '>', $out_file) || die "Cannot open $out_file for output!\n";
$msg = *STDOUT;
}
elsif (!$ARGV[1]) { $out = *STDOUT; }
$msg //= *STDERR;
print {$msg} "Total input torrent size: ".sprintf('%.2f', (-s $in_file) / 1024)." KB\n" if $in_file;
print {$msg} "Decoding ".($in_file || 'torrent from standard input')."...";
my $t = bdecode(scalar <$in>);
die "No info key.\n" unless ref $t eq "HASH" and exists $t->{info};
my $psize = $t->{info}{"piece length"} or die "No piece length key.\n";
print {$msg} "done\n\n";
my @files;
my $tsize = 0;
if (exists $t->{info}{files}) {
print {$msg} "Multi file torrent: $t->{info}{name}\n";
for (@{$t->{info}{files}}) {
push @files, join "/", $t->{info}{name},@{$_->{path}};
$tsize += $_->{length};
}
}
else {
print {$msg} "Single file torrent: $t->{info}{name}\n";
@files = ($t->{info}{name});
$tsize = $t->{info}{length};
}
my $chunks = int(($tsize + $psize - 1) / $psize);
print {$msg} "Total size: ".sprintf('%.2f', $tsize / 1024**2)." MB; $chunks chunks; ", scalar @files, " files.\n\n";
die "Inconsistent piece information!\n" if $chunks*20 != length $t->{info}{pieces};
print {$msg} "Adding fast resume information...";
# flags => 1+16+
my $pmod = 0;
$t->{libtorrent_resume}{bitfield} = $chunks;
foreach my $f (0..$#files) {
die "$d$files[$f] not found.\n" unless -e "$d$files[$f]";
my $mtime = (stat "$d$files[$f]")[9];
# Compute number of chunks per file
my $fsize = (exists $t->{info}{files}) ? $t->{info}{files}[$f]{length} : 1;
my $fchunks = ($pmod ? 1 : 0);
if ($pmod >= $fsize) { ($fsize, $pmod ) = (0, $pmod-$fsize); }
else { ($pmod, $fsize) = (0, $fsize-$pmod); }
$fchunks += ceil($fsize / $psize);
$pmod ||= $psize - ($fsize % $psize);
$t->{libtorrent_resume}{files}[$f] = {
priority => 0, # Don't download; we already have the file, so don't clobber it!
mtime => $mtime,
completed => $fchunks,
};
};
$t->{libtorrent_resume}{'uncertain_pieces.timestamp'} = time;
# Some extra information to re-enforce the fact that this is a finished torrent
if (exists $t->{info}{files}) {
$d .= $t->{info}{name};
}
$t->{rtorrent} = {
state => 1, # started
state_changed => time,
state_counter => 1,
chunks_wanted => 0,
chunks_done => $chunks,
complete => 1,
hashing => 0, # Not hashing
directory => File::Spec->file_name_is_absolute($d) ? $d : File::Spec->rel2abs($d),
((tied_to_file => File::Spec->file_name_is_absolute($out_file) ? $out_file : File::Spec->rel2abs($out_file)) x!! $out_file),
'timestamp.finished' => 0,
'timestamp.started' => time,
};
print {$msg} "done\n";
print {$msg} "Encoding ".($out_file || 'torrent from standard output')."...";
seek($out, 0, 0); # just in case files are the same
print {$out} bencode($t);
close($in);
close($out);
print {$msg} "done\n";
exit;
+164
View File
@@ -0,0 +1,164 @@
#!/bin/bash
#############
###<Notes>###
#############
# This script depends on screen.
# For the stop function to work, you must set an
# explicit session directory using absolute paths (no, ~ is not absolute) in your rtorrent.rc.
# If you typically just start rtorrent with just "rtorrent" on the
# command line, all you need to change is the "user" option.
# Attach to the screen session as your user with
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
##############
###</Notes>###
##############
#######################
##Start Configuration##
#######################
# You can specify your configuration in a different file
# (so that it is saved with upgrades, saved in your home directory,
# or whatever reason you want to)
# by commenting out/deleting the configuration lines and placing them
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
# have written them here (you can leave the comments if you desire
# and then uncommenting the following line correcting the path/filename
# for the one you used. note the space after the ".".
# . /etc/rtorrent.init.conf
#Do not put a space on either side of the equal signs e.g.
# user = user
# will not work
# system user to run as (can only use one)
user="user"
# system user to run as # not implemented, see d_start for beginning implementation
# group=$(id -ng "$user")
# the full path to the filename where you store your rtorrent configuration
# must keep parentheses around the entire statement, quotations around each config file
config=("$(su -c 'echo $HOME' $user)/.rtorrent.rc")
# Examples:
# config=("/home/user/.rtorrent.rc")
# config=("/home/user/.rtorrent.rc" "/mnt/some/drive/.rtorrent2.rc")
# config=("/home/user/.rtorrent.rc"
# "/mnt/some/drive/.rtorrent2.rc"
# "/mnt/another/drive/.rtorrent3.rc")
# set of options to run with each instance, separated by a new line
# must keep parentheses around the entire statement
#if no special options, specify with: ""
options=("")
# Examples:
# starts one instance, sourcing both .rtorrent.rc and .rtorrent2.rc
# options=("-o import=~/.rtorrent2.rc")
# starts two instances, ignoring .rtorrent.rc for both, and using
# .rtorrent2.rc for the first, and .rtorrent3.rc for the second
# we do not check for valid options
# options=("-n -o import=~/.rtorrent2.rc" "-n -o import=~/rtorrent3.rc")
# default directory for screen, needs to be an absolute path
base=$(su -c 'echo $HOME' $user)
# name of screen session
srnname="rtorrent"
# file to log to (makes for easier debugging if something goes wrong)
logfile="/var/log/rtorrentInit.log"
#######################
###END CONFIGURATION###
#######################
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
DESC="rtorrent"
NAME=rtorrent
DAEMON=$NAME
SCRIPTNAME=/etc/init.d/$NAME
checkcnfg() {
exists=0
for i in `echo "$PATH" | tr ':' '\n'` ; do
if [ -f $i/$NAME ] ; then
exists=1
break
fi
done
if [ $exists -eq 0 ] ; then
echo "cannot find $NAME binary in PATH: $PATH" | tee -a "$logfile" >&2
exit 3
fi
for (( i=0 ; i < ${#config[@]} ; i++ )) ; do
if ! [ -r "${config[i]}" ] ; then
echo "cannot find readable config ${config[i]}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2
exit 3
fi
session=$(getsession "${config[i]}")
if ! [ -d "${session}" ] ; then
echo "cannot find readable session directory ${session} from config ${config[i]}. check permissions" | tee -a "$logfile" >&2
exit 3
fi
done
}
d_start() {
[ -d "${base}" ] && cd "${base}"
stty stop undef && stty start undef
su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
# this works for the screen command, but starting rtorrent below adopts screen session gid
# even if it is not the screen session we started (e.g. running under an undesirable gid
#su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "sg \"$group\" -c \"screen -fn -dm -S ${srnname} 2>&1 1>/dev/null\"" ${user} | tee -a "$logfile" >&2
for (( i=0 ; i < ${#options[@]} ; i++ )) ; do
sleep 3
su -c "screen -S "${srnname}" -X screen rtorrent ${options[i]} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
done
}
d_stop() {
for (( i=0 ; i < ${#config[@]} ; i++ )) ; do
session=$(getsession "${config[i]}")
if ! [ -s ${session}/rtorrent.lock ] ; then
return
fi
pid=$(cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g")
# make sure the pid doesn't belong to another process
if ps -A | grep -sq ${pid}.*rtorrent ; then
kill -s INT ${pid}
fi
done
}
getsession() {
session=$(cat "$1" | grep "^[[:space:]]*session.path.set[[:space:]]*=" | sed "s/^[[:space:]]*session.path.set[[:space:]]*=[[:space:]]*//" )
#session=${session/#~/`getent passwd ${user}|cut -d: -f6`}
echo $session
}
checkcnfg
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
+137
View File
@@ -0,0 +1,137 @@
#!/bin/sh
#############
###<Notes>###
#############
# This script depends on screen.
# For the stop function to work, you must set an
# explicit session directory using ABSOLUTE paths (no, ~ is not absolute) in your rtorrent.rc.
# If you typically just start rtorrent with just "rtorrent" on the
# command line, all you need to change is the "user" option.
# Attach to the screen session as your user with
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
##############
###</Notes>###
##############
#######################
##Start Configuration##
#######################
# You can specify your configuration in a different file
# (so that it is saved with upgrades, saved in your home directory,
# or whateve reason you want to)
# by commenting out/deleting the configuration lines and placing them
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
# have written them here (you can leave the comments if you desire
# and then uncommenting the following line correcting the path/filename
# for the one you used. note the space after the ".".
# . /etc/rtorrent.init.conf
#Do not put a space on either side of the equal signs e.g.
# user = user
# will not work
# system user to run as
user="user"
# the system group to run as, not implemented, see d_start for beginning implementation
# group=`id -ng "$user"`
# the full path to the filename where you store your rtorrent configuration
config="`su -c 'echo $HOME' $user`/.rtorrent.rc"
# set of options to run with
options=""
# default directory for screen, needs to be an absolute path
base="`su -c 'echo $HOME' $user`"
# name of screen session
srnname="rtorrent"
# file to log to (makes for easier debugging if something goes wrong)
logfile="/var/log/rtorrentInit.log"
#######################
###END CONFIGURATION###
#######################
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
DESC="rtorrent"
NAME=rtorrent
DAEMON=$NAME
SCRIPTNAME=/etc/init.d/$NAME
checkcnfg() {
exists=0
for i in `echo "$PATH" | tr ':' '\n'` ; do
if [ -f $i/$NAME ] ; then
exists=1
break
fi
done
if [ $exists -eq 0 ] ; then
echo "cannot find rtorrent binary in PATH $PATH" | tee -a "$logfile" >&2
exit 3
fi
if ! [ -r "${config}" ] ; then
echo "cannot find readable config ${config}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2
exit 3
fi
session=`getsession "$config"`
if ! [ -d "${session}" ] ; then
echo "cannot find readable session directory ${session} from config ${config}. check permissions" | tee -a "$logfile" >&2
exit 3
fi
}
d_start() {
[ -d "${base}" ] && cd "${base}"
stty stop undef && stty start undef
su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "screen -dm -S ${srnname} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
# this works for the screen command, but starting rtorrent below adopts screen session gid
# even if it is not the screen session we started (e.g. running under an undesirable gid
#su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "sg \"$group\" -c \"screen -fn -dm -S ${srnname} 2>&1 1>/dev/null\"" ${user} | tee -a "$logfile" >&2
su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
}
d_stop() {
session=`getsession "$config"`
if ! [ -s ${session}/rtorrent.lock ] ; then
return
fi
pid=`cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
if ps -A | grep -sq ${pid}.*rtorrent ; then # make sure the pid doesn't belong to another process
kill -s INT ${pid}
fi
}
getsession() {
session=`cat "$1" | grep "^[[:space:]]*session.path.set[[:space:]]*=" | sed "s/^[[:space:]]*session.path.set[[:space:]]*=[[:space:]]*//" `
echo $session
}
checkcnfg
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
+166
View File
@@ -0,0 +1,166 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: rtorrent_autostart
# Required-Start: $local_fs $remote_fs $network $syslog $netdaemons
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: rtorrent script using tmux
# Description: rtorrent script using tmux
### END INIT INFO
#############
###<Notes>###
#############
# This script depends on tmux and is based on 'rtorrentInitScreen.sh' script
# with the following enhancements:
# - init script 'start' option can be called without breaking anything
# - init script 'status' option can be used in scripts to determine whether rtorrent is running or not
# - auto removes damaged/stuck 'rtorrent.lock' file if necessary
# - saves session (just in case) before stopping with 'rtxmlrp' if it exists
# - provides examples how to script tmux windows
#
# For the stop function to work, you must set an explicit session directory
# using ABSOLUTE paths (no, ~ is not absolute) in your rtorrent.rc and with
# "sessiondir" option.
# If you typically just start rtorrent with just "rtorrent" on the
# command line, all you need to change is the "user" and "sessiondir" option.
# Attach to the tmux session as your user with
# "tmux -2u new-session -A -s rtorrent". Change "rtorrent" with "tmuxname" option.
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
##############
###</Notes>###
##############
#######################
##Start Configuration##
#######################
# You can specify your configuration in a different file.
# (so that it is saved with upgrades, saved in your home directory,
# or whatever reason you want to)
# by commenting out/deleting the configuration lines and placing them
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
# have written them here (you can leave the comments if you desire
# and then uncommenting the following line correcting the path/filename.
# for the one you used. note the space after the ".".
# . /etc/rtorrent.init.conf
# system user to run as
user="username"
# default directory for tmux, needs to be an absolute path
base=$(su -c 'echo $HOME' $user)
# the full path to the filename where you store your rtorrent configuration
config="$base/.rtorrent.rc"
# the full path to the session directory of rtorrent
sessiondir="/mnt/Torrents/.rtorrent/.session"
# options to pass to rtorrent; e.g. don't read config from $HOME but load alternate
#options="-n -O import=$config"
options=""
# name of tmux session
tmuxname="rtorrent"
# name of window in tmux session
tmuxwindowname="rT"
#######################
###END CONFIGURATION###
#######################
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
NAME=rtorrent
DAEMON=$NAME
SCRIPTNAME=/etc/init.d/$NAME
RTXMLRPCBIN="$base/bin/rtxmlrpc"
checkcnfg() {
if [ -z "$(which $DAEMON)" ] ; then
echo "Cannot find $DAEMON binary in PATH: $PATH"
exit 3
fi
if ! [ -r "$config" ] ; then
echo "Cannot find readable config $config. Check that it is there and permissions are appropriate"
exit 3
fi
if ! [ -d "$sessiondir" ] ; then
echo "Cannot find readable session directory $sessiondir from config $config. Check permissions"
exit 3
fi
}
status() {
if [ -e "${sessiondir}/rtorrent.lock" ] ; then
pid=`cat ${sessiondir}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
# make sure the pid isn't empty and doesn't belong to another process : this will match lines containing rtorrent, which grep '[r]torrent' does not!
# if there is no process as the 'pid' suggests then delete the stuck "rtorrent.lock" file (to be able to start rtorrent)
[[ -n "$pid" ]] && ps aux | grep -sq ${pid}.*[r]torrent && echo -e ${pid} || rm -f "${sessiondir}/rtorrent.lock"
fi
}
d_start() {
[ -d "$base" ] && cd "$base"
# if STDIN is a terminal (we are using interactive mode)
[ -t 0 ] && stty stop undef && stty start undef
# start the default 2 tmux window (bash and mc) if there isn't tmux session called "tmuxname" option (rtorrent)
if ! su -c "tmux ls | grep -sq ${tmuxname}: " $user ; then
# 1st window (0): split it into 3 panes, display 'date' in the last one
su -c "tmux -2u new-session -d -s ${tmuxname} -n 'shell1'" $user
su -c "tmux -2u split-window -v -t ${tmuxname}:0 'bash'" $user
su -c "tmux -2u split-window -h -t ${tmuxname}:0 'date; bash'" $user
# 2nd window (1): start 'mc' if it exists
su -c "tmux -2u new-window -t ${tmuxname}:1 -n 'mc1' 'command which mc && mc ~/; bash'" $user
fi
# start rtorrent always in the 3rd tmux window (2) if it's not running and leave shell behind to be able to see reason of a crash
if [ "$(status)" == "" ]; then
su -c "tmux -2u list-panes -t ${tmuxname}:2 &>/dev/null && tmux -2u respawn-pane -t ${tmuxname}:2 -k \"${DAEMON} ${options}; bash\" || tmux -2u new-window -t ${tmuxname}:2 -n ${tmuxwindowname} \"${DAEMON} ${options}; bash\"" $user
fi
}
d_stop() {
pid=$(status)
if [ "$pid" != "" ]; then
# save session before stopping explicitly (just in case) if rtxmlrpc util exists then wait for 5 seconds to be able to complete it
[ -L "$RTXMLRPCBIN" ] && "$RTXMLRPCBIN" session.save &>/dev/null && sleep 5
# INT (2, Interrupt from keyboard): normal shutdown
kill -s INT $pid
fi
}
checkcnfg
case "$1" in
start)
echo -n "Starting $tmuxwindowname: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $tmuxwindowname: $NAME"
d_stop
echo "."
;;
restart|force-reload)
echo -n "Restarting $tmuxwindowname: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
status)
status
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
PORT_NUMBER=${1:-5001}
echo "Option Strings"
echo "=============="
echo
echo "Introduction"
echo "------------"
echo
echo "Client version: " `xmlrpc2scgi.py -p scgi://127.0.0.1:${PORT_NUMBER} system.client_version`
echo
echo "Generated by 'rtorrent/doc/scripts/print_option_string.sh' on `date -u`."
for i in strings.choke_heuristics strings.choke_heuristics.upload strings.choke_heuristics.download strings.connection_type strings.encryption strings.ip_filter strings.ip_tos strings.log_group strings.tracker_event strings.tracker_mode; do
echo
echo $i
echo `echo $i | tr 'a-z_.' '-'`
echo
echo '```'
xmlrpc2scgi.py -p scgi://127.0.0.1:${PORT_NUMBER} $i | tr , '\n' | tr '[' ' ' | tr ']' ' '
echo '```'
done
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/perl
# Perl script to read torrent data
use strict;
use warnings;
use Convert::Bencode_XS qw(bdecode);
use Data::Dumper;
$/ = undef;
$| = 1;
my $in;
my $in_file = $ARGV[0];
if ($in_file) { open($in, '<', $in_file) || die "Cannot open $in_file for input!\n"; }
else { $in = *STDIN; }
print "Total input torrent size: ".sprintf('%.2f', (-s $in_file) / 1024)." KB\n" if $in_file;
print "Decoding ".($in_file || 'torrent from standard input')."...";
my $t = bdecode(scalar <$in>);
print "done\n\n";
print Data::Dumper->new([$t], ['*Torrent'])->Indent(1)->Useqq(1)->Quotekeys(0)->Sortkeys(1)->Dump;
+1
View File
@@ -0,0 +1 @@
valgrind --leak-check=full --track-origins=yes --show-reachable=yes --suppressions=/Users/rakshasa/projects/rtorrent/doc/valgrind.suppression --gen-suppressions=all --log-file=valgrind.log /usr/local/bin/rtorrent
+343
View File
@@ -0,0 +1,343 @@
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:__76-*
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:__76-*
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:__80-*
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:__93-*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:__93-*
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:__108-*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:__108-*
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:__108-*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[CFPrefsPlistSource setDomainIdentifier:]
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:-[CFPrefsSearchListSource alreadylocked_copyValueForKey:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[CFPrefsSearchListSource alreadylocked_copyValueForKey:]
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:-[CFPrefsSearchListSource alreadylocked_copyValueForKey:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[CFPrefsSearchListSource addNamedVolatileSourceForIdentifier:]
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:-[CFPrefsSearchListSource handleReply:toRequestNewDataMessage:onConnection:retryCount:error:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[CFPrefsSearchListSource addSourceForIdentifier:user:byHost:container:]
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:-[CFPrefsSearchListSource handleReply:toRequestNewDataMessage:onConnection:retryCount:error:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[CFPrefsSearchListSource handleReply:toRequestNewDataMessage:onConnection:retryCount:error:]
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:-[CFPrefsSearchListSource handleReply:toRequestNewDataMessage:onConnection:retryCount:error:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[_CFXPreferences withSearchLists:]
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:-[CFPrefsSource copyValueForKey:]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:-[OS_xpc_object dealloc]
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_CF*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:__CF*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_NS*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:getSuperclassMetadata
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_ZN5dyld*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_ZNK5dyld*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:___ZNK5dyld*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_dyld_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:*_dyld_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:___SC_getApplicationBundleID_block_invoke
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:xpc_*
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:xpc_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_xpc_*
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:_xpc_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_libxpc_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:si_module_with_name
}
{
<insert_a_suppression_name_here>
Memcheck:Cond
...
fun:_dispatch_*
}
{
<insert_a_suppression_name_here>
Memcheck:Value8
...
fun:_dispatch_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_dispatch_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:*_swift_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:libdispatch_init
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_os_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_od_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_objc_init
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_notify_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:bootstrap_*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:$ss*
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:loadlocale
fun:setlocale
fun:main
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:initscr
fun:_ZN7display6Canvas10initializeEv
fun:_ZN7Control10initializeEv
fun:main
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:assume_default_colors_sp
fun:_ZN7display6Canvas10initializeEv
fun:_ZN7Control10initializeEv
fun:main
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:start_color_sp
fun:_ZN7display6Canvas10initializeEv
fun:_ZN7Control10initializeEv
fun:main
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
...
fun:_ZN7display6Canvas10initializeEv
}
-14
View File
@@ -1,14 +0,0 @@
Donate to rTorrent development
==============================
* [Paypal](https://paypal.me/jarisundellno)
* [Patreon](https://www.patreon.com/rtorrent)
* [SubscribeStar](https://www.subscribestar.com/rtorrent)
* Bitcoin: 1MpmXm5AHtdBoDaLZstJw8nupJJaeKu8V8
* Ethereum: 0x9AB1e3C3d8a875e870f161b3e9287Db0E6DAfF78
* Litecoin: LdyaVR67LBnTf6mAT4QJnjSG2Zk67qxmfQ
* Cardano: addr1qytaslmqmk6dspltw06sp0zf83dh09u79j49ceh5y26zdcccgq4ph7nmx6kgmzeldauj43254ey97f3x4xw49d86aguqwfhlte
Help keep rTorrent development going by donating to its creator.
(Note the old paypal account is defunct, please use the new one when sending donations)
-1
View File
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h49v20H0z"/><path fill="#97ca00" d="M49 0h47v20H49z"/><path fill="url(#b)" d="M0 0h96v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="255" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="390">Donate</text><text x="255" y="140" transform="scale(.1)" textLength="390">Donate</text><text x="715" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="370">PayPal</text><text x="715" y="140" transform="scale(.1)" textLength="370">PayPal</text></g> </svg>

Before

Width:  |  Height:  |  Size: 954 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

-39
View File
@@ -1,39 +0,0 @@
RTorrent
========
Introduction
------------
To learn how to use rTorrent visit the [Wiki](https://github.com/rakshasa/rtorrent/wiki).
[Donate](https://rakshasa.github.io/rtorrent/donate.html) to help fund the development of this client.
Stable
------
* [libtorrent-0.16.11.tar.gz](https://github.com/rakshasa/rtorrent-archive/raw/master/libtorrent-0.16.11.tar.gz)
* [rtorrent-0.16.11.tar.gz](https://github.com/rakshasa/rtorrent-archive/raw/master/rtorrent-0.16.11.tar.gz)
Development
-----------
* [libtorrent-0.16.13.tar.gz](https://github.com/rakshasa/rtorrent-archive/raw/master/libtorrent-0.16.13.tar.gz)
* [rtorrent-0.16.13.tar.gz](https://github.com/rakshasa/rtorrent-archive/raw/master/rtorrent-0.16.13.tar.gz)
Related Projects
----------------
* [https://github.com/rakshasa/rbedit](https://github.com/rakshasa/rbedit): A dependency-free bencode editor.
Donate to rTorrent development
------------------------------
* [Paypal](https://paypal.me/jarisundellno)
* [Patreon](https://www.patreon.com/rtorrent)
* [SubscribeStar](https://www.subscribestar.com/rtorrent)
* Bitcoin: 1MpmXm5AHtdBoDaLZstJw8nupJJaeKu8V8
* Ethereum: 0x9AB1e3C3d8a875e870f161b3e9287Db0E6DAfF78
* Litecoin: LdyaVR67LBnTf6mAT4QJnjSG2Zk67qxmfQ
* Cardano: addr1qytaslmqmk6dspltw06sp0zf83dh09u79j49ceh5y26zdcccgq4ph7nmx6kgmzeldauj43254ey97f3x4xw49d86aguqwfhlte
Help keep rTorrent development going by donating to its creator.
-1
View File
@@ -1 +0,0 @@
console.log('This would be the main JS file.');
-17
View File
@@ -1,17 +0,0 @@
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
document.addEventListener("gesturestart", gestureStart, false);
}
function gestureStart() {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
}
}
}
+127
View File
@@ -0,0 +1,127 @@
-- The "rtorrent" table is passed in by the C++ code, modify and
-- return it for loading.
local args = {...}
local rtorrent = args[1]
local math = require('math')
-- Autocall
-- Passes an empty first argument implicitly, as "".
-- Allows syntax like:
-- - `rtorrent.autocall.system.hostname()` or
-- - `rtorrent.autocall.session.directory.set("/tmp/")`
-- Has assignment operator, syntax sugar for `.set()` with single argument
-- - `rtorrent.autocall.session.directory = "/tmp/"`
-- Autocall-chains can be reused as aliases:
-- ```lua
-- a = rtorrent.autocall.system
-- a.hostname() -- same as `rtorrent.autocall.system.hostname()`
-- a.pid() -- same as `rtorrent.autocall.system.pid()`
local mt = {}
function mt.__call (t, ...)
name = table.concat(rawget(t, "__namestack"), ".")
tg = rawget(t, "__target") or ""
success, ret = pcall(rtorrent.call, name, tg, ...)
if not success then error(name..": "..ret, 2) end
return ret
end
function mt.__index (t, key)
ns = {table.unpack(rawget(t, "__namestack") or {})}
tg = rawget(t, "__target") or nil
table.insert(ns, key)
return setmetatable({__namestack=ns, __target=tg}, mt)
end
function mt.__newindex (t, key, value)
t[key].set(value)
end
rtorrent["autocall"] = setmetatable({}, mt)
-- Target-object
-- Sets first argment for Autocall, for commands that require target.
-- Second argument allows to add prefix to command.
-- Allows syntax like:
-- - `rtorrent.Target("some_infohash").d.name()` or
-- - `rtorrent.Target:new("some_infohash").d.name()`
-- Also can be stored as variable
local Target = setmetatable({
new = function (self, target, prefix)
return self(target, prefix)
end;
}, {
__call = function (self, target, prefix)
return setmetatable(
{__namestack={prefix}, __target=target}, mt)
end
})
rtorrent["Target"] = Target
-- Some aliases for Target-commands
for i, p in ipairs({ "d", "f", "p", "t", "load" }) do
rtorrent[p] = function (target) return Target(target, p) end
end
-- Insert Lua method
-- Allow insert global lua-finction `func_name` at rtorrent slot `name`
-- @param name string rtorrent's slot
-- @param func_name string name of global lua-function
-- @param method_args number|string[]|number[]
-- rtorrent's arguments like `(d.name)` to be passed to lua-function when it be
-- called by rtorrent:
--
-- 1) non-negative integer - number of first arguments to be passed
--
-- example:
-- rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', 1)
--
-- gives following rtorrent event handler:
-- d.watch_handler=$argument.0
--
-- 2) table (array) of strings - concrete rtorrent strings, passed in specified
-- order
--
-- example:
-- rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', { '$argument.0=' })
--
-- gives following rtorrent event handler:
-- d.watch_handler=$argument.0
--
-- 3) table (array) of non-negative integer - indexes, converted to
-- $argument.0, $argument.1 ..., passed in specified order
--
-- example:
-- rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', { 1, 0 })
-- or:
-- rtorrent.insert_lua_method('d.watch_handler', 'watch_handler', { [1]=1, [2]=0 })
--
-- gives following rtorrent event handler:
-- d.watch_handler=$argument.1,$argument.0
--
-- NOTE: first argement of func_name is always target, may be empty string
rtorrent["insert_lua_method"] = function (name, func_name, method_args)
local args = {}
if method_args == nil then method_args = 0 end
if math.type(method_args) == 'integer' and method_args >= 0 then
for i = 1, method_args do
args[i] = "$argument." .. i-1 .. "="
end
elseif type(method_args) == 'table' then
for i, v in ipairs(method_args) do
if type(v) == 'string' then
args[i] = v
elseif math.type(v) == 'integer' and v >= 0 then
args[i] = "$argument." .. v .. "="
else
error("Incorrect arguments")
end
end
else
error("Incorrect arguments")
end
local arg_str = table.concat(args, ",")
if #arg_str > 0 then arg_str = ","..arg_str end
rtorrent.autocall.method.insert(name, "simple", 'lua.execute.str="return '..func_name..'(...)"'..arg_str)
end
return rtorrent
+131
View File
@@ -0,0 +1,131 @@
# Functions to check for attributes support in compiler
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
AC_CACHE_CHECK([if compiler supports __attribute__((constructor))],
[cc_cv_attribute_constructor],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
void ctor() __attribute__((constructor));
void ctor() { };
])],
[cc_cv_attribute_constructor=yes],
[cc_cv_attribute_constructor=no])
])
if test "x$cc_cv_attribute_constructor" = "xyes"; then
AC_DEFINE([SUPPORT_ATTRIBUTE_CONSTRUCTOR], 1, [Define this if the compiler supports the constructor attribute])
$1
else
true
$2
fi
])
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))],
[cc_cv_attribute_format],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { }
])],
[cc_cv_attribute_format=yes],
[cc_cv_attribute_format=no])
])
if test "x$cc_cv_attribute_format" = "xyes"; then
AC_DEFINE([SUPPORT_ATTRIBUTE_FORMAT], 1, [Define this if the compiler supports the format attribute])
$1
else
true
$2
fi
])
AC_DEFUN([CC_ATTRIBUTE_INTERNAL], [
AC_CACHE_CHECK([if compiler supports __attribute__((visibility("internal")))],
[cc_cv_attribute_internal],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
void __attribute__((visibility("internal"))) internal_function() { }
])],
[cc_cv_attribute_internal=yes],
[cc_cv_attribute_internal=no])
])
if test "x$cc_cv_attribute_internal" = "xyes"; then
AC_DEFINE([SUPPORT_ATTRIBUTE_INTERNAL], 1, [Define this if the compiler supports the internal visibility attribute])
$1
else
true
$2
fi
])
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
AC_LANG_PUSH(C++)
tmp_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))],
[cc_cv_attribute_visibility],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
void __attribute__((visibility("default"))) visibility_function() { }
])],
[cc_cv_attribute_visibility=yes],
[cc_cv_attribute_visibility=no])
])
CXXFLAGS=$tmp_CXXFLAGS
AC_LANG_POP(C++)
if test "x$cc_cv_attribute_visibility" = "xyes"; then
AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.])
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
$1
else
true
$2
fi
])
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))],
[cc_cv_attribute_nonnull],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
void some_function(void *foo, void *bar) __attribute__((nonnull()));
void some_function(void *foo, void *bar) { }
])],
[cc_cv_attribute_nonnull=yes],
[cc_cv_attribute_nonnull=no])
])
if test "x$cc_cv_attribute_nonnull" = "xyes"; then
AC_DEFINE([SUPPORT_ATTRIBUTE_NONNULL], 1, [Define this if the compiler supports the nonnull attribute])
$1
else
true
$2
fi
])
AC_DEFUN([CC_FUNC_EXPECT], [
AC_CACHE_CHECK([if compiler has __builtin_expect function],
[cc_cv_func_expect],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
int some_function()
{
int a = 3;
return (int)__builtin_expect(a, 3);
}
])],
[cc_cv_func_expect=yes],
[cc_cv_func_expect=no])
])
if test "x$cc_cv_func_expect" = "xyes"; then
AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function])
$1
else
true
$2
fi
])
+141
View File
@@ -0,0 +1,141 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
#
# DESCRIPTION
#
# This macro searches for an installed zlib library. If nothing was
# specified when calling configure, it searches first in /usr/local and
# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
# --without-zlib is specified, the library is not searched at all.
#
# If either the header file (zlib.h) or the library (libz) is not found,
# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
# not specified, the configuration exits on error, asking for a valid zlib
# installation directory or --without-zlib.
#
# If both header file and library are found, shell commands
# 'action-if-found' is run. If 'action-if-found' is not specified, the
# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
# for this symbol in a config.h file. Sample usage in a C/C++ source is as
# follows:
#
# #ifdef HAVE_LIBZ
# #include <zlib.h>
# #endif /* HAVE_LIBZ */
#
# LICENSE
#
# Copyright (c) 2008 Loic Dachary <loic@senga.org>
# Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 16
AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
AC_DEFUN([AX_CHECK_ZLIB],
#
# Handle user hints
#
[AC_MSG_CHECKING(if zlib is wanted)
zlib_places="/usr/local /usr /opt/local /sw"
AC_ARG_WITH([zlib],
[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to
/usr/local or /usr if not found in /usr/local@:>@
--without-zlib to disable zlib usage completely],
[if test "$withval" != no ; then
AC_MSG_RESULT(yes)
if test -d "$withval"
then
zlib_places="$withval $zlib_places"
else
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
fi
else
zlib_places=
AC_MSG_RESULT(no)
fi],
[AC_MSG_RESULT(yes)])
#
# Locate zlib, if wanted
#
if test -n "${zlib_places}"
then
# check the user supplied or any other more or less 'standard' place:
# Most UNIX systems : /usr/local and /usr
# MacPorts / Fink on OSX : /opt/local respectively /sw
for ZLIB_HOME in ${zlib_places} ; do
if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
ZLIB_HOME=""
done
ZLIB_OLD_LDFLAGS=$LDFLAGS
ZLIB_OLD_CPPFLAGS=$CPPFLAGS
if test -n "${ZLIB_HOME}"; then
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
fi
AC_LANG_PUSH([C])
AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
AC_LANG_POP([C])
if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
then
#
# If both library and header were found, action-if-found
#
m4_ifblank([$1],[
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
LIBS="-lz $LIBS"
AC_DEFINE([HAVE_LIBZ], [1],
[Define to 1 if you have `z' library (-lz)])
],[
# Restore variables
LDFLAGS="$ZLIB_OLD_LDFLAGS"
CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
$1
])
else
#
# If either header or library was not found, action-if-not-found
#
m4_default([$2],[
AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
])
fi
fi
])
File diff suppressed because it is too large Load Diff
+67
View File
@@ -0,0 +1,67 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_execinfo.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_EXECINFO([ACTION-IF-EXECINFO-H-IS-FOUND], [ACTION-IF-EXECINFO-H-IS-NOT-FOUND], [ADDITIONAL-TYPES-LIST])
#
# DESCRIPTION
#
# Checks for execinfo.h header and if the len parameter/return type can be
# found from a list, also define backtrace_size_t to that type.
#
# By default the list of types to try contains int and size_t, but should
# some yet undiscovered system use e.g. unsigned, the 3rd argument can be
# used for extensions. I'd like to hear of further suggestions.
#
# Executes ACTION-IF-EXECINFO-H-IS-FOUND when present and the execinfo.h
# header is found or ACTION-IF-EXECINFO-H-IS-NOT-FOUND in case the header
# seems unavailable.
#
# Also adds -lexecinfo to LIBS on BSD if needed.
#
# LICENSE
#
# Copyright (c) 2014 Thomas Jahns <jahns@dkrz.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 2
AC_DEFUN([AX_EXECINFO],
[AC_CHECK_HEADERS([execinfo.h])
AS_IF([test x"$ac_cv_header_execinfo_h" = xyes],
[AC_CACHE_CHECK([size parameter type for backtrace()],
[ax_cv_proto_backtrace_type],
[AC_LANG_PUSH([C])
for ax_cv_proto_backtrace_type in size_t int m4_ifnblank([$3],[$3 ])none; do
AS_IF([test "${ax_cv_proto_backtrace_type}" = none],
[ax_cv_proto_backtrace_type= ; break])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <execinfo.h>
extern
${ax_cv_proto_backtrace_type} backtrace(void **addrlist, ${ax_cv_proto_backtrace_type} len);
char **backtrace_symbols(void *const *buffer, ${ax_cv_proto_backtrace_type} size);
])],
[break])
done
AC_LANG_POP([C])])])
AS_IF([test x${ax_cv_proto_backtrace_type} != x],
[AC_DEFINE_UNQUOTED([backtrace_size_t], [$ax_cv_proto_backtrace_type],
[Defined to return type of backtrace().])])
AC_SEARCH_LIBS([backtrace],[execinfo])
AS_IF([test x"${ax_cv_proto_backtrace_type}" != x -a x"$ac_cv_header_execinfo_h" = xyes -a x"$ac_cv_search_backtrace" != xno],
[AC_DEFINE([HAVE_BACKTRACE],[1],
[Defined if backtrace() could be fully identified.])
]m4_ifnblank([$1],[$1
]),m4_ifnblank([$2],[$2
]))])
dnl
dnl Local Variables:
dnl mode: autoconf
dnl End:
dnl
+710
View File
@@ -0,0 +1,710 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_lua.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
# AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
# AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
# AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])]
#
# DESCRIPTION
#
# Detect a Lua interpreter, optionally specifying a minimum and maximum
# version number. Set up important Lua paths, such as the directories in
# which to install scripts and modules (shared libraries).
#
# Also detect Lua headers and libraries. The Lua version contained in the
# header is checked to match the Lua interpreter version exactly. When
# searching for Lua libraries, the version number is used as a suffix.
# This is done with the goal of supporting multiple Lua installs (5.1,
# 5.2, 5.3, and 5.4 side-by-side).
#
# A note on compatibility with previous versions: This file has been
# mostly rewritten for serial 18. Most developers should be able to use
# these macros without needing to modify configure.ac. Care has been taken
# to preserve each macro's behavior, but there are some differences:
#
# 1) AX_WITH_LUA is deprecated; it now expands to the exact same thing as
# AX_PROG_LUA with no arguments.
#
# 2) AX_LUA_HEADERS now checks that the version number defined in lua.h
# matches the interpreter version. AX_LUA_HEADERS_VERSION is therefore
# unnecessary, so it is deprecated and does not expand to anything.
#
# 3) The configure flag --with-lua-suffix no longer exists; the user
# should instead specify the LUA precious variable on the command line.
# See the AX_PROG_LUA description for details.
#
# Please read the macro descriptions below for more information.
#
# This file was inspired by Andrew Dalke's and James Henstridge's
# python.m4 and Tom Payne's, Matthieu Moy's, and Reuben Thomas's ax_lua.m4
# (serial 17). Basically, this file is a mash-up of those two files. I
# like to think it combines the best of the two!
#
# AX_PROG_LUA: Search for the Lua interpreter, and set up important Lua
# paths. Adds precious variable LUA, which may contain the path of the Lua
# interpreter. If LUA is blank, the user's path is searched for an
# suitable interpreter.
#
# Optionally a LUAJIT option may be set ahead of time to look for and
# validate a LuaJIT install instead of PUC Lua. Usage might look like:
#
# AC_ARG_WITH(luajit, [AS_HELP_STRING([--with-luajit],
# [Prefer LuaJIT over PUC Lua, even if the latter is newer. Default: no])
# ])
# AM_CONDITIONAL([LUAJIT], [test "x$with_luajit" != 'xno'])
#
# If MINIMUM-VERSION is supplied, then only Lua interpreters with a
# version number greater or equal to MINIMUM-VERSION will be accepted. If
# TOO-BIG-VERSION is also supplied, then only Lua interpreters with a
# version number greater or equal to MINIMUM-VERSION and less than
# TOO-BIG-VERSION will be accepted.
#
# The Lua version number, LUA_VERSION, is found from the interpreter, and
# substituted. LUA_PLATFORM is also found, but not currently supported (no
# standard representation).
#
# Finally, the macro finds four paths:
#
# luadir Directory to install Lua scripts.
# pkgluadir $luadir/$PACKAGE
# luaexecdir Directory to install Lua modules.
# pkgluaexecdir $luaexecdir/$PACKAGE
#
# These paths are found based on $prefix, $exec_prefix, Lua's
# package.path, and package.cpath. The first path of package.path
# beginning with $prefix is selected as luadir. The first path of
# package.cpath beginning with $exec_prefix is used as luaexecdir. This
# should work on all reasonable Lua installations. If a path cannot be
# determined, a default path is used. Of course, the user can override
# these later when invoking make.
#
# luadir Default: $prefix/share/lua/$LUA_VERSION
# luaexecdir Default: $exec_prefix/lib/lua/$LUA_VERSION
#
# These directories can be used by Automake as install destinations. The
# variable name minus 'dir' needs to be used as a prefix to the
# appropriate Automake primary, e.g. lua_SCRIPS or luaexec_LIBRARIES.
#
# If an acceptable Lua interpreter is found, then ACTION-IF-FOUND is
# performed, otherwise ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-
# FOUND is blank, then it will default to printing an error. To prevent
# the default behavior, give ':' as an action.
#
# AX_LUA_HEADERS: Search for Lua headers. Requires that AX_PROG_LUA be
# expanded before this macro. Adds precious variable LUA_INCLUDE, which
# may contain Lua specific include flags, e.g. -I/usr/include/lua5.1. If
# LUA_INCLUDE is blank, then this macro will attempt to find suitable
# flags.
#
# LUA_INCLUDE can be used by Automake to compile Lua modules or
# executables with embedded interpreters. The *_CPPFLAGS variables should
# be used for this purpose, e.g. myprog_CPPFLAGS = $(LUA_INCLUDE).
#
# This macro searches for the header lua.h (and others). The search is
# performed with a combination of CPPFLAGS, CPATH, etc, and LUA_INCLUDE.
# If the search is unsuccessful, then some common directories are tried.
# If the headers are then found, then LUA_INCLUDE is set accordingly.
#
# The paths automatically searched are:
#
# * /usr/include/luaX.Y
# * /usr/include/lua/X.Y
# * /usr/include/luaXY
# * /usr/local/include/luaX.Y
# * /usr/local/include/lua-X.Y
# * /usr/local/include/lua/X.Y
# * /usr/local/include/luaXY
#
# (Where X.Y is the Lua version number, e.g. 5.1.)
#
# The Lua version number found in the headers is always checked to match
# the Lua interpreter's version number. Lua headers with mismatched
# version numbers are not accepted.
#
# If headers are found, then ACTION-IF-FOUND is performed, otherwise
# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then
# it will default to printing an error. To prevent the default behavior,
# set the action to ':'.
#
# AX_LUA_LIBS: Search for Lua libraries. Requires that AX_PROG_LUA be
# expanded before this macro. Adds precious variable LUA_LIB, which may
# contain Lua specific linker flags, e.g. -llua5.1. If LUA_LIB is blank,
# then this macro will attempt to find suitable flags.
#
# LUA_LIB can be used by Automake to link Lua modules or executables with
# embedded interpreters. The *_LIBADD and *_LDADD variables should be used
# for this purpose, e.g. mymod_LIBADD = $(LUA_LIB).
#
# This macro searches for the Lua library. More technically, it searches
# for a library containing the function lua_load. The search is performed
# with a combination of LIBS, LIBRARY_PATH, and LUA_LIB.
#
# If the search determines that some linker flags are missing, then those
# flags will be added to LUA_LIB.
#
# If libraries are found, then ACTION-IF-FOUND is performed, otherwise
# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then
# it will default to printing an error. To prevent the default behavior,
# set the action to ':'.
#
# AX_LUA_READLINE: Search for readline headers and libraries. Requires the
# AX_LIB_READLINE macro, which is provided by ax_lib_readline.m4 from the
# Autoconf Archive.
#
# If a readline compatible library is found, then ACTION-IF-FOUND is
# performed, otherwise ACTION-IF-NOT-FOUND is performed.
#
# LICENSE
#
# Copyright (c) 2023 Caleb Maclennan <caleb@alerque.com>
# Copyright (c) 2015 Reuben Thomas <rrt@sc3d.org>
# Copyright (c) 2014 Tim Perkins <tprk77@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 47
dnl =========================================================================
dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION],
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl =========================================================================
AC_DEFUN([AX_PROG_LUA],
[
dnl Check for required tools.
AC_REQUIRE([AC_PROG_GREP])
AC_REQUIRE([AC_PROG_SED])
dnl Make LUA a precious variable.
AC_ARG_VAR([LUA], [The Lua interpreter, e.g. /usr/bin/lua5.1])
dnl Find a Lua interpreter.
AM_COND_IF([LUAJIT],
[_ax_lua_interpreter_list='luajit luajit-2.1.0-beta3 luajit-2.0.5 luajit-2.0.4 luajit-2.0.3'],
[_ax_lua_interpreter_list='lua lua5.4 lua54 lua5.3 lua53 lua5.2 lua52 lua5.1 lua51 lua5.0 lua50'])
m4_if([$1], [],
[ dnl No version check is needed. Find any Lua interpreter.
AS_IF([test "x$LUA" = 'x'],
[AC_PATH_PROGS([LUA], [$_ax_lua_interpreter_list], [:])])
ax_display_LUA='lua'
AS_IF([test "x$LUA" != 'x:'],
[ dnl At least check if this is a Lua interpreter.
AC_MSG_CHECKING([if $LUA is a Lua interpreter])
_AX_LUA_CHK_IS_INTRP([$LUA],
[AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
AC_MSG_ERROR([not a Lua interpreter])
])
])
],
[ dnl A version check is needed.
AS_IF([test "x$LUA" != 'x'],
[ dnl Check if this is a Lua interpreter.
AC_MSG_CHECKING([if $LUA is a Lua interpreter])
_AX_LUA_CHK_IS_INTRP([$LUA],
[AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
AC_MSG_ERROR([not a Lua interpreter])
])
dnl Check the version.
m4_if([$2], [],
[_ax_check_text="whether $LUA version >= $1"],
[_ax_check_text="whether $LUA version >= $1, < $2"])
AC_MSG_CHECKING([$_ax_check_text])
_AX_LUA_CHK_VER([$LUA], [$1], [$2],
[AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
AC_MSG_ERROR([version is out of range for specified LUA])])
ax_display_LUA=$LUA
],
[ dnl Try each interpreter until we find one that satisfies VERSION.
m4_if([$2], [],
[_ax_check_text="for a Lua interpreter with version >= $1"],
[_ax_check_text="for a Lua interpreter with version >= $1, < $2"])
AC_CACHE_CHECK([$_ax_check_text],
[ax_cv_pathless_LUA],
[ for ax_cv_pathless_LUA in $_ax_lua_interpreter_list none; do
test "x$ax_cv_pathless_LUA" = 'xnone' && break
_AX_LUA_CHK_IS_INTRP([$ax_cv_pathless_LUA], [], [continue])
_AX_LUA_CHK_VER([$ax_cv_pathless_LUA], [$1], [$2], [break])
done
])
dnl Set $LUA to the absolute path of $ax_cv_pathless_LUA.
AS_IF([test "x$ax_cv_pathless_LUA" = 'xnone'],
[LUA=':'],
[AC_PATH_PROG([LUA], [$ax_cv_pathless_LUA])])
ax_display_LUA=$ax_cv_pathless_LUA
])
])
AS_IF([test "x$LUA" = 'x:'],
[ dnl Run any user-specified action, or abort.
m4_default([$4], [AC_MSG_ERROR([cannot find suitable Lua interpreter])])
],
[ dnl Query Lua for its version number.
AC_CACHE_CHECK([for $ax_display_LUA version],
[ax_cv_lua_version],
[ dnl Get the interpreter version in X.Y format. This should work for
dnl interpreters version 5.0 and beyond.
ax_cv_lua_version=[`$LUA -e '
-- return a version number in X.Y format
local _, _, ver = string.find(_VERSION, "^Lua (%d+%.%d+)")
print(ver or "")'`]
])
AS_IF([test "x$ax_cv_lua_version" = 'x'],
[AC_MSG_ERROR([invalid Lua version number])])
AC_SUBST([LUA_VERSION], [$ax_cv_lua_version])
AC_SUBST([LUA_SHORT_VERSION], [`echo "$LUA_VERSION" | $SED 's|\.||'`])
AM_COND_IF([LUAJIT], [
AC_CACHE_CHECK([for $ax_display_LUA jit version], [ax_cv_luajit_version],
[ ax_cv_luajit_version=[`$LUA -e '
local _, _, ver = string.find(jit and jit.version, "(%d+%..+)")
print(ver or "")'`]
])
AS_IF([test "x$ax_cv_luajit_version" = 'x'],
[AC_MSG_ERROR([invalid Lua jit version number])])
AC_SUBST([LUAJIT_VERSION], [$ax_cv_luajit_version])
AC_SUBST([LUAJIT_SHORT_VERSION], [$(echo "$LUAJIT_VERSION" | $SED 's|\.|§|;s|\..*||;s|§|.|')])
])
dnl The following check is not supported:
dnl At times (like when building shared libraries) you may want to know
dnl which OS platform Lua thinks this is.
AC_CACHE_CHECK([for $ax_display_LUA platform],
[ax_cv_lua_platform],
[ax_cv_lua_platform=[`$LUA -e 'print("unknown")'`]])
AC_SUBST([LUA_PLATFORM], [$ax_cv_lua_platform])
dnl Use the values of $prefix and $exec_prefix for the corresponding
dnl values of LUA_PREFIX and LUA_EXEC_PREFIX. These are made distinct
dnl variables so they can be overridden if need be. However, the general
dnl consensus is that you shouldn't need this ability.
AC_SUBST([LUA_PREFIX], ['${prefix}'])
AC_SUBST([LUA_EXEC_PREFIX], ['${exec_prefix}'])
dnl Lua provides no way to query the script directory, and instead
dnl provides LUA_PATH. However, we should be able to make a safe educated
dnl guess. If the built-in search path contains a directory which is
dnl prefixed by $prefix, then we can store scripts there. The first
dnl matching path will be used.
AC_CACHE_CHECK([for $ax_display_LUA script directory],
[ax_cv_lua_luadir],
[ AS_IF([test "x$prefix" = 'xNONE'],
[ax_lua_prefix=$ac_default_prefix],
[ax_lua_prefix=$prefix])
dnl Initialize to the default path.
ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION"
dnl Try to find a path with the prefix.
_AX_LUA_FND_PRFX_PTH([$LUA], [$ax_lua_prefix], [script])
AS_IF([test "x$ax_lua_prefixed_path" != 'x'],
[ dnl Fix the prefix.
_ax_strip_prefix=`echo "$ax_lua_prefix" | $SED 's|.|.|g'`
ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \
$SED "s|^$_ax_strip_prefix|$LUA_PREFIX|"`
])
])
AC_SUBST([luadir], [$ax_cv_lua_luadir])
AC_SUBST([pkgluadir], [\${luadir}/$PACKAGE])
dnl Lua provides no way to query the module directory, and instead
dnl provides LUA_PATH. However, we should be able to make a safe educated
dnl guess. If the built-in search path contains a directory which is
dnl prefixed by $exec_prefix, then we can store modules there. The first
dnl matching path will be used.
AC_CACHE_CHECK([for $ax_display_LUA module directory],
[ax_cv_lua_luaexecdir],
[ AS_IF([test "x$exec_prefix" = 'xNONE'],
[ax_lua_exec_prefix=$ax_lua_prefix],
[ax_lua_exec_prefix=$exec_prefix])
dnl Initialize to the default path.
ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION"
dnl Try to find a path with the prefix.
_AX_LUA_FND_PRFX_PTH([$LUA],
[$ax_lua_exec_prefix], [module])
AS_IF([test "x$ax_lua_prefixed_path" != 'x'],
[ dnl Fix the prefix.
_ax_strip_prefix=`echo "$ax_lua_exec_prefix" | $SED 's|.|.|g'`
ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \
$SED "s|^$_ax_strip_prefix|$LUA_EXEC_PREFIX|"`
])
])
AC_SUBST([luaexecdir], [$ax_cv_lua_luaexecdir])
AC_SUBST([pkgluaexecdir], [\${luaexecdir}/$PACKAGE])
dnl Run any user specified action.
$3
])
])
dnl AX_WITH_LUA is now the same thing as AX_PROG_LUA.
AC_DEFUN([AX_WITH_LUA],
[
AC_MSG_WARN([[$0 is deprecated, please use AX_PROG_LUA instead]])
AX_PROG_LUA
])
dnl =========================================================================
dnl _AX_LUA_CHK_IS_INTRP(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl =========================================================================
AC_DEFUN([_AX_LUA_CHK_IS_INTRP],
[
dnl A minimal Lua factorial to prove this is an interpreter. This should work
dnl for Lua interpreters version 5.0 and beyond.
_ax_lua_factorial=[`$1 2>/dev/null -e '
-- a simple factorial
function fact (n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
print("fact(5) is " .. fact(5))'`]
AS_IF([test "$_ax_lua_factorial" = 'fact(5) is 120'],
[$2], [$3])
])
dnl =========================================================================
dnl _AX_LUA_CHK_VER(PROG, MINIMUM-VERSION, [TOO-BIG-VERSION],
dnl [ACTION-IF-TRUE], [ACTION-IF-FALSE])
dnl =========================================================================
AC_DEFUN([_AX_LUA_CHK_VER],
[
dnl Check that the Lua version is within the bounds. Only the major and minor
dnl version numbers are considered. This should work for Lua interpreters
dnl version 5.0 and beyond.
_ax_lua_good_version=[`$1 -e '
-- a script to compare versions
function verstr2num(verstr)
local _, _, majorver, minorver = string.find(verstr, "^(%d+)%.(%d+)")
if majorver and minorver then
return tonumber(majorver) * 100 + tonumber(minorver)
end
end
local minver = verstr2num("$2")
local _, _, trimver = string.find(_VERSION, "^Lua (.*)")
local ver = verstr2num(trimver)
local maxver = verstr2num("$3") or 1e9
if minver <= ver and ver < maxver then
print("yes")
else
print("no")
end'`]
AS_IF([test "x$_ax_lua_good_version" = "xyes"],
[$4], [$5])
])
dnl =========================================================================
dnl _AX_LUA_FND_PRFX_PTH(PROG, PREFIX, SCRIPT-OR-MODULE-DIR)
dnl =========================================================================
AC_DEFUN([_AX_LUA_FND_PRFX_PTH],
[
dnl Get the script or module directory by querying the Lua interpreter,
dnl filtering on the given prefix, and selecting the shallowest path. If no
dnl path is found matching the prefix, the result will be an empty string.
dnl The third argument determines the type of search, it can be 'script' or
dnl 'module'. Supplying 'script' will perform the search with package.path
dnl and LUA_PATH, and supplying 'module' will search with package.cpath and
dnl LUA_CPATH. This is done for compatibility with Lua 5.0.
ax_lua_prefixed_path=[`$1 -e '
-- get the path based on search type
local searchtype = "$3"
local paths = ""
if searchtype == "script" then
paths = (package and package.path) or LUA_PATH
elseif searchtype == "module" then
paths = (package and package.cpath) or LUA_CPATH
end
-- search for the prefix
local prefix = "'$2'"
local minpath = ""
local mindepth = 1e9
string.gsub(paths, "(@<:@^;@:>@+)",
function (path)
path = string.gsub(path, "%?.*$", "")
path = string.gsub(path, "/@<:@^/@:>@*$", "")
if string.find(path, prefix) then
local depth = string.len(string.gsub(path, "@<:@^/@:>@", ""))
if depth < mindepth then
minpath = path
mindepth = depth
end
end
end)
print(minpath)'`]
])
dnl =========================================================================
dnl AX_LUA_HEADERS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl =========================================================================
AC_DEFUN([AX_LUA_HEADERS],
[
dnl Check for LUA_VERSION.
AC_MSG_CHECKING([if LUA_VERSION is defined])
AS_IF([test "x$LUA_VERSION" != 'x'],
[AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot check Lua headers without knowing LUA_VERSION])
])
AM_COND_IF([LUAJIT],[
dnl Check for LUAJIT_VERSION.
AC_MSG_CHECKING([if LUAJIT_VERSION is defined])
AS_IF([test "x$LUAJIT_VERSION" != 'x'],
[AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot check Lua jit headers without knowing LUAJIT_VERSION])
])
])
dnl Make LUA_INCLUDE a precious variable.
AC_ARG_VAR([LUA_INCLUDE], [The Lua includes, e.g. -I/usr/include/lua5.1])
dnl Some default directories to search.
AM_COND_IF([LUAJIT],
[_ax_lua_include_list="
/usr/include/luajit-$LUAJIT_VERSION
/usr/include/luajit-$LUAJIT_SHORT_VERSION
/usr/local/include/luajit-$LUAJIT_VERSION
/usr/local/include/luajit-$LUAJIT_SHORT_VERSION"],
[_ax_lua_include_list="
/usr/include/lua$LUA_VERSION
/usr/include/lua-$LUA_VERSION
/usr/include/lua/$LUA_VERSION
/usr/include/lua$LUA_SHORT_VERSION
/usr/local/include/lua$LUA_VERSION
/usr/local/include/lua-$LUA_VERSION
/usr/local/include/lua/$LUA_VERSION
/usr/local/include/lua$LUA_SHORT_VERSION"])
dnl Try to find the headers.
_ax_lua_saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h])
AM_COND_IF([LUAJIT], [AC_CHECK_HEADERS([luajit.h])])
CPPFLAGS=$_ax_lua_saved_cppflags
dnl Try some other directories if LUA_INCLUDE was not set.
AS_IF([test "x$LUA_INCLUDE" = 'x' &&
test "x$ac_cv_header_lua_h" != 'xyes' ||
test "x$with_luajit" != 'xno' &&
test "x$ac_cv_header_luajit_h" != 'xyes'],
[ dnl Try some common include paths.
for _ax_include_path in $_ax_lua_include_list; do
test ! -d "$_ax_include_path" && continue
AC_MSG_CHECKING([for Lua headers in])
AC_MSG_RESULT([$_ax_include_path])
AS_UNSET([ac_cv_header_lua_h])
AS_UNSET([ac_cv_header_lualib_h])
AS_UNSET([ac_cv_header_lauxlib_h])
AS_UNSET([ac_cv_header_luaconf_h])
AS_UNSET([ac_cv_header_luajit_h])
_ax_lua_saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$_ax_include_path"
AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h])
AM_COND_IF([LUAJIT], [AC_CHECK_HEADERS([luajit.h])])
CPPFLAGS=$_ax_lua_saved_cppflags
AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'],
[ LUA_INCLUDE="-I$_ax_include_path"
break
])
done
])
AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'],
[ dnl Make a program to print LUA_VERSION defined in the header.
dnl TODO It would be really nice if we could do this without compiling a
dnl program, then it would work when cross compiling. But I'm not sure how
dnl to do this reliably. For now, assume versions match when cross compiling.
AS_IF([test "x$cross_compiling" != 'xyes'],
[ AC_CACHE_CHECK([for Lua header version],
[ax_cv_lua_header_version],
[ _ax_lua_saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LUA_INCLUDE"
AC_COMPUTE_INT(ax_cv_lua_header_version_major,[LUA_VERSION_NUM/100],[AC_INCLUDES_DEFAULT
#include <lua.h>
],[ax_cv_lua_header_version_major=unknown])
AC_COMPUTE_INT(ax_cv_lua_header_version_minor,[LUA_VERSION_NUM%100],[AC_INCLUDES_DEFAULT
#include <lua.h>
],[ax_cv_lua_header_version_minor=unknown])
AS_IF([test "x$ax_cv_lua_header_version_major" = xunknown || test "x$ax_cv_lua_header_version_minor" = xunknown],[
ax_cv_lua_header_version=unknown
],[
ax_cv_lua_header_version="$ax_cv_lua_header_version_major.$ax_cv_lua_header_version_minor"
])
CPPFLAGS=$_ax_lua_saved_cppflags
])
dnl Compare this to the previously found LUA_VERSION.
AC_MSG_CHECKING([if Lua header version matches $LUA_VERSION])
AS_IF([test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"],
[ AC_MSG_RESULT([yes])
ax_header_version_match='yes'
],
[ AC_MSG_RESULT([no])
ax_header_version_match='no'
])
],
[ AC_MSG_WARN([cross compiling so assuming header version number matches])
ax_header_version_match='yes'
])
])
dnl Was LUA_INCLUDE specified?
AS_IF([test "x$ax_header_version_match" != 'xyes' &&
test "x$LUA_INCLUDE" != 'x'],
[AC_MSG_ERROR([cannot find headers for specified LUA_INCLUDE])])
dnl Test the final result and run user code.
AS_IF([test "x$ax_header_version_match" = 'xyes'], [$1],
[m4_default([$2], [AC_MSG_ERROR([cannot find Lua includes])])])
])
dnl AX_LUA_HEADERS_VERSION no longer exists, use AX_LUA_HEADERS.
AC_DEFUN([AX_LUA_HEADERS_VERSION],
[
AC_MSG_WARN([[$0 is deprecated, please use AX_LUA_HEADERS instead]])
])
dnl =========================================================================
dnl AX_LUA_LIBS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl =========================================================================
AC_DEFUN([AX_LUA_LIBS],
[
dnl TODO Should this macro also check various -L flags?
dnl Check for LUA_VERSION.
AC_MSG_CHECKING([if LUA_VERSION is defined])
AS_IF([test "x$LUA_VERSION" != 'x'],
[AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot check Lua libs without knowing LUA_VERSION])
])
dnl Make LUA_LIB a precious variable.
AC_ARG_VAR([LUA_LIB], [The Lua library, e.g. -llua5.1])
AS_IF([test "x$LUA_LIB" != 'x'],
[ dnl Check that LUA_LIBS works.
_ax_lua_saved_libs=$LIBS
LIBS="$LIBS $LUA_LIB"
AC_SEARCH_LIBS([lua_load], [],
[_ax_found_lua_libs='yes'],
[_ax_found_lua_libs='no'])
LIBS=$_ax_lua_saved_libs
dnl Check the result.
AS_IF([test "x$_ax_found_lua_libs" != 'xyes'],
[AC_MSG_ERROR([cannot find libs for specified LUA_LIB])])
],
[ dnl First search for extra libs.
_ax_lua_extra_libs=''
_ax_lua_saved_libs=$LIBS
LIBS="$LIBS $LUA_LIB"
AC_SEARCH_LIBS([exp], [m])
AC_SEARCH_LIBS([dlopen], [dl])
LIBS=$_ax_lua_saved_libs
AS_IF([test "x$ac_cv_search_exp" != 'xno' &&
test "x$ac_cv_search_exp" != 'xnone required'],
[_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp"])
AS_IF([test "x$ac_cv_search_dlopen" != 'xno' &&
test "x$ac_cv_search_dlopen" != 'xnone required'],
[_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen"])
dnl Try to find the Lua libs.
_ax_lua_saved_libs=$LIBS
LIBS="$LIBS $LUA_LIB"
AM_COND_IF([LUAJIT],
[AC_SEARCH_LIBS([lua_load],
[ luajit$LUA_VERSION \
luajit$LUA_SHORT_VERSION \
luajit-$LUA_VERSION \
luajit-$LUA_SHORT_VERSION \
luajit],
[_ax_found_lua_libs='yes'],
[_ax_found_lua_libs='no'],
[$_ax_lua_extra_libs])],
[AC_SEARCH_LIBS([lua_load],
[ lua$LUA_VERSION \
lua$LUA_SHORT_VERSION \
lua-$LUA_VERSION \
lua-$LUA_SHORT_VERSION \
lua \
],
[_ax_found_lua_libs='yes'],
[_ax_found_lua_libs='no'],
[$_ax_lua_extra_libs])])
LIBS=$_ax_lua_saved_libs
AS_IF([test "x$ac_cv_search_lua_load" != 'xno' &&
test "x$ac_cv_search_lua_load" != 'xnone required'],
[LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs"])
])
dnl Test the result and run user code.
AS_IF([test "x$_ax_found_lua_libs" = 'xyes'], [$1],
[m4_default([$2], [AC_MSG_ERROR([cannot find Lua libs])])])
])
dnl =========================================================================
dnl AX_LUA_READLINE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl =========================================================================
AC_DEFUN([AX_LUA_READLINE],
[
AX_LIB_READLINE
AS_IF([test "x$ac_cv_header_readline_readline_h" != 'x' &&
test "x$ac_cv_header_readline_history_h" != 'x'],
[ LUA_LIBS_CFLAGS="-DLUA_USE_READLINE $LUA_LIBS_CFLAGS"
$1
],
[$2])
])
+522
View File
@@ -0,0 +1,522 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is
# needed for multi-threaded programs (defaults to the value of CC
# respectively CXX otherwise). (This is necessary on e.g. AIX to use the
# special cc_r/CC_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
# CXX="$PTHREAD_CXX"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
# Copyright (c) 2019 Marc Stevens <marc.stevens@cwi.nl>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 31
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
ax_pthread_save_CC="$CC"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
CC="$ax_pthread_save_CC"
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items with a "," contain both
# C compiler flags (before ",") and linker flags (after ","). Other items
# starting with a "-" are C compiler flags, and remaining items are
# library names, except for "none" which indicates that we try without
# any flags at all, and "pthread-config" which is a program returning
# the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# (Note: HP C rejects this with "bad form for `-t' option")
# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing
# pthread_cleanup_push, or rather a function called by this macro,
# so we could check for that, but who knows whether they'll stub
# that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread).
ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags"
;;
esac
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
# Note that for GCC and Clang -pthread generally implies -lpthread,
# except when -nostdlib is passed.
# This is problematic using libtool to build C++ shared libraries with pthread:
# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460
# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333
# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555
# To solve this, first try -pthread together with -lpthread for GCC
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"])
# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first
AS_IF([test "x$ax_pthread_clang" = "xyes"],
[ax_pthread_flags="-pthread,-lpthread -pthread"])
# The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is
# correctly enabled
case $host_os in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
*,*)
PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`
PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`
AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void *some_global = NULL;
static void routine(void *a)
{
/* To avoid any unused-parameter or
unused-but-set-parameter warning. */
some_global = a;
}
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`AS_ECHO(["$ac_link"]) | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
# Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute],
[ax_cv_PTHREAD_JOINABLE_ATTR],
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
[])
done
])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes
])
AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in
solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
;;
esac
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;
return i;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[
AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])
AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])])
],
[
AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])
AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])])
]
)
])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
AC_SUBST([PTHREAD_CXX])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD
+37
View File
@@ -0,0 +1,37 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_REQUIRE_DEFINED(MACRO)
#
# DESCRIPTION
#
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
# been defined and thus are available for use. This avoids random issues
# where a macro isn't expanded. Instead the configure script emits a
# non-fatal:
#
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
#
# It's like AC_REQUIRE except it doesn't expand the required macro.
#
# Here's an example:
#
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
#
# LICENSE
#
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 2
AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
])dnl AX_REQUIRE_DEFINED
+582
View File
@@ -0,0 +1,582 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_with_curses.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_WITH_CURSES
#
# DESCRIPTION
#
# This macro checks whether a SysV or X/Open-compatible Curses library is
# present, along with the associated header file. The NcursesW
# (wide-character) library is searched for first, followed by Ncurses,
# then the system-default plain Curses. The first library found is the
# one returned. Finding libraries will first be attempted by using
# pkg-config, and should the pkg-config files not be available, will
# fallback to combinations of known flags itself.
#
# The following options are understood: --with-ncursesw, --with-ncurses,
# --without-ncursesw, --without-ncurses. The "--with" options force the
# macro to use that particular library, terminating with an error if not
# found. The "--without" options simply skip the check for that library.
# The effect on the search pattern is:
#
# (no options) - NcursesW, Ncurses, Curses
# --with-ncurses --with-ncursesw - NcursesW only [*]
# --without-ncurses --with-ncursesw - NcursesW only [*]
# --with-ncursesw - NcursesW only [*]
# --with-ncurses --without-ncursesw - Ncurses only [*]
# --with-ncurses - NcursesW, Ncurses [**]
# --without-ncurses --without-ncursesw - Curses only
# --without-ncursesw - Ncurses, Curses
# --without-ncurses - NcursesW, Curses
#
# [*] If the library is not found, abort the configure script.
#
# [**] If the second library (Ncurses) is not found, abort configure.
#
# The following preprocessor symbols may be defined by this macro if the
# appropriate conditions are met:
#
# HAVE_CURSES - if any SysV or X/Open Curses library found
# HAVE_CURSES_ENHANCED - if library supports X/Open Enhanced functions
# HAVE_CURSES_COLOR - if library supports color (enhanced functions)
# HAVE_CURSES_OBSOLETE - if library supports certain obsolete features
# HAVE_NCURSESW - if NcursesW (wide char) library is to be used
# HAVE_NCURSES - if the Ncurses library is to be used
#
# HAVE_CURSES_H - if <curses.h> is present and should be used
# HAVE_NCURSESW_H - if <ncursesw.h> should be used
# HAVE_NCURSES_H - if <ncurses.h> should be used
# HAVE_NCURSESW_CURSES_H - if <ncursesw/curses.h> should be used
# HAVE_NCURSES_CURSES_H - if <ncurses/curses.h> should be used
#
# (These preprocessor symbols are discussed later in this document.)
#
# The following output variables are defined by this macro; they are
# precious and may be overridden on the ./configure command line:
#
# CURSES_LIBS - library to add to xxx_LDADD
# CURSES_CFLAGS - include paths to add to xxx_CPPFLAGS
#
# In previous versions of this macro, the flags CURSES_LIB and
# CURSES_CPPFLAGS were defined. These have been renamed, in keeping with
# AX_WITH_CURSES's close bigger brother, PKG_CHECK_MODULES, which should
# eventually supersede the use of AX_WITH_CURSES. Neither the library
# listed in CURSES_LIBS, nor the flags in CURSES_CFLAGS are added to LIBS,
# respectively CPPFLAGS, by default. You need to add both to the
# appropriate xxx_LDADD/xxx_CPPFLAGS line in your Makefile.am. For
# example:
#
# prog_LDADD = @CURSES_LIBS@
# prog_CPPFLAGS = @CURSES_CFLAGS@
#
# If CURSES_LIBS is set on the configure command line (such as by running
# "./configure CURSES_LIBS=-lmycurses"), then the only header searched for
# is <curses.h>. If the user needs to specify an alternative path for a
# library (such as for a non-standard NcurseW), the user should use the
# LDFLAGS variable.
#
# The following shell variables may be defined by this macro:
#
# ax_cv_curses - set to "yes" if any Curses library found
# ax_cv_curses_enhanced - set to "yes" if Enhanced functions present
# ax_cv_curses_color - set to "yes" if color functions present
# ax_cv_curses_obsolete - set to "yes" if obsolete features present
#
# ax_cv_ncursesw - set to "yes" if NcursesW library found
# ax_cv_ncurses - set to "yes" if Ncurses library found
# ax_cv_plaincurses - set to "yes" if plain Curses library found
# ax_cv_curses_which - set to "ncursesw", "ncurses", "plaincurses" or "no"
#
# These variables can be used in your configure.ac to determine the level
# of support you need from the Curses library. For example, if you must
# have either Ncurses or NcursesW, you could include:
#
# AX_WITH_CURSES
# if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
# AC_MSG_ERROR([requires either NcursesW or Ncurses library])
# fi
#
# If any Curses library will do (but one must be present and must support
# color), you could use:
#
# AX_WITH_CURSES
# if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then
# AC_MSG_ERROR([requires an X/Open-compatible Curses library with color])
# fi
#
# Certain preprocessor symbols and shell variables defined by this macro
# can be used to determine various features of the Curses library. In
# particular, HAVE_CURSES and ax_cv_curses are defined if the Curses
# library found conforms to the traditional SysV and/or X/Open Base Curses
# definition. Any working Curses library conforms to this level.
#
# HAVE_CURSES_ENHANCED and ax_cv_curses_enhanced are defined if the
# library supports the X/Open Enhanced Curses definition. In particular,
# the wide-character types attr_t, cchar_t and wint_t, the functions
# wattr_set() and wget_wch() and the macros WA_NORMAL and _XOPEN_CURSES
# are checked. The Ncurses library does NOT conform to this definition,
# although NcursesW does.
#
# HAVE_CURSES_COLOR and ax_cv_curses_color are defined if the library
# supports color functions and macros such as COLOR_PAIR, A_COLOR,
# COLOR_WHITE, COLOR_RED and init_pair(). These are NOT part of the
# X/Open Base Curses definition, but are part of the Enhanced set of
# functions. The Ncurses library DOES support these functions, as does
# NcursesW.
#
# HAVE_CURSES_OBSOLETE and ax_cv_curses_obsolete are defined if the
# library supports certain features present in SysV and BSD Curses but not
# defined in the X/Open definition. In particular, the functions
# getattrs(), getcurx() and getmaxx() are checked.
#
# To use the HAVE_xxx_H preprocessor symbols, insert the following into
# your system.h (or equivalent) header file:
#
# #if defined HAVE_NCURSESW_CURSES_H
# # include <ncursesw/curses.h>
# #elif defined HAVE_NCURSESW_H
# # include <ncursesw.h>
# #elif defined HAVE_NCURSES_CURSES_H
# # include <ncurses/curses.h>
# #elif defined HAVE_NCURSES_H
# # include <ncurses.h>
# #elif defined HAVE_CURSES_H
# # include <curses.h>
# #else
# # error "SysV or X/Open-compatible Curses header file required"
# #endif
#
# For previous users of this macro: you should not need to change anything
# in your configure.ac or Makefile.am, as the previous (serial 10)
# semantics are still valid. However, you should update your system.h (or
# equivalent) header file to the fragment shown above. You are encouraged
# also to make use of the extended functionality provided by this version
# of AX_WITH_CURSES, as well as in the additional macros
# AX_WITH_CURSES_PANEL, AX_WITH_CURSES_MENU and AX_WITH_CURSES_FORM.
#
# LICENSE
#
# Copyright (c) 2009 Mark Pulford <mark@kyne.com.au>
# Copyright (c) 2009 Damian Pietras <daper@daper.net>
# Copyright (c) 2012 Reuben Thomas <rrt@sc3d.org>
# Copyright (c) 2011 John Zaitseff <J.Zaitseff@zap.org.au>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 18
# internal function to factorize common code that is used by both ncurses
# and ncursesw
AC_DEFUN([_FIND_CURSES_FLAGS], [
AC_MSG_CHECKING([for $1 via pkg-config])
AX_REQUIRE_DEFINED([PKG_CHECK_EXISTS])
_PKG_CONFIG([_ax_cv_$1_libs], [libs], [$1])
_PKG_CONFIG([_ax_cv_$1_cppflags], [cflags], [$1])
AS_IF([test "x$pkg_failed" = "xyes" || test "x$pkg_failed" = "xuntried"],[
AC_MSG_RESULT([no])
# No suitable .pc file found, have to find flags via fallback
AC_CACHE_CHECK([for $1 via fallback], [ax_cv_$1], [
AS_ECHO()
pkg_cv__ax_cv_$1_libs="-l$1"
pkg_cv__ax_cv_$1_cppflags="-D_GNU_SOURCE $CURSES_CFLAGS"
LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs"
CPPFLAGS="$ax_saved_CPPFLAGS $pkg_cv__ax_cv_$1_cppflags"
AC_MSG_CHECKING([for initscr() with $pkg_cv__ax_cv_$1_libs])
AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
[
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for nodelay() with $pkg_cv__ax_cv_$1_libs])
AC_LINK_IFELSE([AC_LANG_CALL([], [nodelay])],[
ax_cv_$1=yes
],[
AC_MSG_RESULT([no])
m4_if(
[$1],[ncursesw],[pkg_cv__ax_cv_$1_libs="$pkg_cv__ax_cv_$1_libs -ltinfow"],
[$1],[ncurses],[pkg_cv__ax_cv_$1_libs="$pkg_cv__ax_cv_$1_libs -ltinfo"]
)
LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs"
AC_MSG_CHECKING([for nodelay() with $pkg_cv__ax_cv_$1_libs])
AC_LINK_IFELSE([AC_LANG_CALL([], [nodelay])],[
ax_cv_$1=yes
],[
ax_cv_$1=no
])
])
],[
ax_cv_$1=no
])
])
],[
AC_MSG_RESULT([yes])
# Found .pc file, using its information
LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs"
CPPFLAGS="$ax_saved_CPPFLAGS $pkg_cv__ax_cv_$1_cppflags"
ax_cv_$1=yes
])
])
AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
AC_DEFUN([AX_WITH_CURSES], [
AC_ARG_VAR([CURSES_LIBS], [linker library for Curses, e.g. -lcurses])
AC_ARG_VAR([CURSES_CFLAGS], [preprocessor flags for Curses, e.g. -I/usr/include/ncursesw])
AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses],
[force the use of Ncurses or NcursesW])],
[], [with_ncurses=check])
AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw],
[do not use NcursesW (wide character support)])],
[], [with_ncursesw=check])
ax_saved_LIBS=$LIBS
ax_saved_CPPFLAGS=$CPPFLAGS
AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes],
[ax_with_plaincurses=no], [ax_with_plaincurses=check])
ax_cv_curses_which=no
# Test for NcursesW
AS_IF([test "x$CURSES_LIBS" = x && test "x$with_ncursesw" != xno], [
_FIND_CURSES_FLAGS([ncursesw])
AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [
AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library])
])
AS_IF([test "x$ax_cv_ncursesw" = xyes], [
ax_cv_curses=yes
ax_cv_curses_which=ncursesw
CURSES_LIBS="$pkg_cv__ax_cv_ncursesw_libs"
CURSES_CFLAGS="$pkg_cv__ax_cv_ncursesw_cppflags"
AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present])
AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@define _XOPEN_SOURCE_EXTENDED 1
@%:@include <ncursesw/curses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
attr_t d = WA_NORMAL;
cchar_t e;
wint_t f;
int g = getattrs(stdscr);
int h = getcurx(stdscr) + getmaxx(stdscr);
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
wattr_set(stdscr, d, 0, NULL);
wget_wch(stdscr, &f);
]])],
[ax_cv_header_ncursesw_curses_h=yes],
[ax_cv_header_ncursesw_curses_h=no])
])
AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [
ax_cv_curses_enhanced=yes
ax_cv_curses_color=yes
ax_cv_curses_obsolete=yes
AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if <ncursesw/curses.h> is present])
])
AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@define _XOPEN_SOURCE_EXTENDED 1
@%:@include <ncursesw.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
attr_t d = WA_NORMAL;
cchar_t e;
wint_t f;
int g = getattrs(stdscr);
int h = getcurx(stdscr) + getmaxx(stdscr);
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
wattr_set(stdscr, d, 0, NULL);
wget_wch(stdscr, &f);
]])],
[ax_cv_header_ncursesw_h=yes],
[ax_cv_header_ncursesw_h=no])
])
AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [
ax_cv_curses_enhanced=yes
ax_cv_curses_color=yes
ax_cv_curses_obsolete=yes
AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
AC_DEFINE([HAVE_NCURSESW_H], [1], [Define to 1 if <ncursesw.h> is present])
])
AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@define _XOPEN_SOURCE_EXTENDED 1
@%:@include <ncurses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
attr_t d = WA_NORMAL;
cchar_t e;
wint_t f;
int g = getattrs(stdscr);
int h = getcurx(stdscr) + getmaxx(stdscr);
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
wattr_set(stdscr, d, 0, NULL);
wget_wch(stdscr, &f);
]])],
[ax_cv_header_ncurses_h_with_ncursesw=yes],
[ax_cv_header_ncurses_h_with_ncursesw=no])
])
AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [
ax_cv_curses_enhanced=yes
ax_cv_curses_color=yes
ax_cv_curses_obsolete=yes
AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if <ncurses.h> is present])
])
AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xno && test "x$ax_cv_header_ncursesw_h" = xno && test "x$ax_cv_header_ncurses_h_with_ncursesw" = xno], [
AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h])
])
])
])
unset pkg_cv__ax_cv_ncursesw_libs
unset pkg_cv__ax_cv_ncursesw_cppflags
# Test for Ncurses
AS_IF([test "x$CURSES_LIBS" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [
_FIND_CURSES_FLAGS([ncurses])
AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [
AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library])
])
AS_IF([test "x$ax_cv_ncurses" = xyes], [
ax_cv_curses=yes
ax_cv_curses_which=ncurses
CURSES_LIBS="$pkg_cv__ax_cv_ncurses_libs"
CURSES_CFLAGS="$pkg_cv__ax_cv_ncurses_cppflags"
AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present])
AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@include <ncurses/curses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
int g = getattrs(stdscr);
int h = getcurx(stdscr) + getmaxx(stdscr);
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
]])],
[ax_cv_header_ncurses_curses_h=yes],
[ax_cv_header_ncurses_curses_h=no])
])
AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [
ax_cv_curses_color=yes
ax_cv_curses_obsolete=yes
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if <ncurses/curses.h> is present])
])
AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@include <ncurses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
int g = getattrs(stdscr);
int h = getcurx(stdscr) + getmaxx(stdscr);
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
]])],
[ax_cv_header_ncurses_h=yes],
[ax_cv_header_ncurses_h=no])
])
AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [
ax_cv_curses_color=yes
ax_cv_curses_obsolete=yes
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if <ncurses.h> is present])
])
AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [
AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h])
])
])
])
unset pkg_cv__ax_cv_ncurses_libs
unset pkg_cv__ax_cv_ncurses_cppflags
# Test for plain Curses (or if CURSES_LIBS was set by user)
AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [
AS_IF([test "x$CURSES_LIBS" != x], [
LIBS="$ax_saved_LIBS $CURSES_LIBS"
], [
LIBS="$ax_saved_LIBS -lcurses"
])
AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [
AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
[ax_cv_plaincurses=yes], [ax_cv_plaincurses=no])
])
AS_IF([test "x$ax_cv_plaincurses" = xyes], [
ax_cv_curses=yes
ax_cv_curses_which=plaincurses
AS_IF([test "x$CURSES_LIBS" = x], [
CURSES_LIBS="-lcurses"
])
AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
# Check for base conformance (and header file)
AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@include <curses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
initscr();
]])],
[ax_cv_header_curses_h=yes],
[ax_cv_header_curses_h=no])
])
AS_IF([test "x$ax_cv_header_curses_h" = xyes], [
AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if <curses.h> is present])
# Check for X/Open Enhanced conformance
AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@define _XOPEN_SOURCE_EXTENDED 1
@%:@include <curses.h>
@%:@ifndef _XOPEN_CURSES
@%:@error "this Curses library is not enhanced"
"this Curses library is not enhanced"
@%:@endif
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
attr_t d = WA_NORMAL;
cchar_t e;
wint_t f;
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
wattr_set(stdscr, d, 0, NULL);
wget_wch(stdscr, &f);
]])],
[ax_cv_plaincurses_enhanced=yes],
[ax_cv_plaincurses_enhanced=no])
])
AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [
ax_cv_curses_enhanced=yes
ax_cv_curses_color=yes
AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
])
# Check for color functions
AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@define _XOPEN_SOURCE_EXTENDED 1
@%:@include <curses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
chtype c = COLOR_PAIR(1) & A_COLOR;
initscr();
init_pair(1, COLOR_WHITE, COLOR_RED);
]])],
[ax_cv_plaincurses_color=yes],
[ax_cv_plaincurses_color=no])
])
AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [
ax_cv_curses_color=yes
AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
])
# Check for obsolete functions
AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@include <curses.h>
]], [[
chtype a = A_BOLD;
int b = KEY_LEFT;
int g = getattrs(stdscr);
int h = getcurx(stdscr) + getmaxx(stdscr);
initscr();
]])],
[ax_cv_plaincurses_obsolete=yes],
[ax_cv_plaincurses_obsolete=no])
])
AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [
ax_cv_curses_obsolete=yes
AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
])
])
AS_IF([test "x$ax_cv_header_curses_h" = xno], [
AC_MSG_WARN([could not find a working curses.h])
])
])
])
AS_IF([test "x$ax_cv_curses" != xyes], [ax_cv_curses=no])
AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no])
AS_IF([test "x$ax_cv_curses_color" != xyes], [ax_cv_curses_color=no])
AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no])
LIBS=$ax_saved_LIBS
CPPFLAGS=$ax_saved_CPPFLAGS
unset ax_saved_LIBS
unset ax_saved_CPPFLAGS
])dnl
+350
View File
@@ -0,0 +1,350 @@
AC_DEFUN([TORRENT_CHECK_EPOLL], [
AC_MSG_CHECKING(for epoll support)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/epoll.h>
int main() {
int fd = epoll_create(100);
return 0;
}
])],
[
use_epoll=yes
AC_DEFINE(USE_EPOLL, 1, Use epoll.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_WITHOUT_EPOLL], [
AC_ARG_WITH(epoll,
AS_HELP_STRING([--without-epoll],[do not check for epoll support]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_EPOLL
fi
], [
TORRENT_CHECK_EPOLL
])
])
AC_DEFUN([TORRENT_CHECK_KQUEUE], [
AC_MSG_CHECKING(for kqueue support)
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <sys/time.h> /* Because OpenBSD's sys/event.h fails to compile otherwise. Yeah... */
#include <sys/event.h>
int main() {
int fd = kqueue();
return 0;
}
])],
[
use_kqueue=yes
AC_DEFINE(USE_KQUEUE, 1, Use kqueue.)
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_WITH_KQUEUE], [
AC_ARG_WITH(kqueue,
AS_HELP_STRING([--with-kqueue],[enable kqueue [[default=no]]]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_KQUEUE
fi
])
])
AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [
AC_ARG_WITH(kqueue,
AS_HELP_STRING([--without-kqueue],[do not check for kqueue support]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_KQUEUE
fi
], [
TORRENT_CHECK_KQUEUE
])
])
AC_DEFUN([TORRENT_WITH_ADDRESS_SPACE], [
AC_ARG_WITH(address-space,
AS_HELP_STRING([--with-address-space=MB],[change the default address space size [default=1024mb-or-32768mb]]),
[
if test ! -z $withval -a "$withval" != "yes" -a "$withval" != "no"; then
AC_DEFINE_UNQUOTED(DEFAULT_ADDRESS_SPACE_SIZE, [$withval])
else
AC_MSG_ERROR(--with-address-space requires a parameter.)
fi
],
[
AC_CHECK_SIZEOF(long)
if test $ac_cv_sizeof_long = 8; then
AC_DEFINE(DEFAULT_ADDRESS_SPACE_SIZE, 32768, Default address space size.)
else
AC_DEFINE(DEFAULT_ADDRESS_SPACE_SIZE, 1024, Default address space size.)
fi
])
])
AC_DEFUN([TORRENT_CHECK_ATOMIC], [
AC_MSG_CHECKING([whether 64-bit atomic operations require -latomic])
AC_LANG_PUSH(C++)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cstdint>
#include <atomic>]],
[[std::atomic<uint64_t> x(0);
return x.load();]])],
[
AC_MSG_RESULT([no])
ATOMIC_LIBS=""
],
[
save_LIBS="$LIBS"
LIBS="$LIBS -latomic"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cstdint>
#include <atomic>]],
[[std::atomic<uint64_t> x(0);
return x.load();]])],
[
AC_MSG_RESULT([yes])
ATOMIC_LIBS="-latomic"
],
[
AC_MSG_RESULT([unsupported])
AC_MSG_ERROR([Compiler target lacks proper 64-bit atomic support.])
])
LIBS="$save_LIBS"
])
AC_LANG_POP(C++)
AC_SUBST([ATOMIC_LIBS])
])
AC_DEFUN([TORRENT_WITH_XMLRPC_C], [
AC_MSG_CHECKING(for XMLRPC-C)
AC_ARG_WITH(xmlrpc-c,
AS_HELP_STRING([--with-xmlrpc-c=PATH],[enable XMLRPC-C support]),
[
if test "$withval" = "no"; then
AC_MSG_RESULT(no)
else
if test "$withval" = "yes"; then
xmlrpc_cc_prg="xmlrpc-c-config"
else
xmlrpc_cc_prg="$withval"
fi
if eval $xmlrpc_cc_prg --version 2>/dev/null >/dev/null; then
CXXFLAGS="$CXXFLAGS `$xmlrpc_cc_prg --cflags server-util`"
LIBS="$LIBS `$xmlrpc_cc_prg server-util --libs`"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <xmlrpc-c/server.h>
]], [[ xmlrpc_registry_new(NULL); ]])],[
AC_MSG_RESULT(ok)
],[
AC_MSG_RESULT(failed)
AC_MSG_ERROR(Could not compile XMLRPC-C test.)
])
AC_DEFINE(HAVE_XMLRPC_C, 1, Support for XMLRPC-C.)
else
AC_MSG_RESULT(failed)
AC_MSG_ERROR(Could not compile XMLRPC-C test.)
fi
fi
],[
AC_MSG_RESULT(ignored)
])
])
AC_DEFUN([TORRENT_WITH_TINYXML2], [
AC_MSG_CHECKING(for tinyxml2)
AC_ARG_WITH(xmlrpc-tinyxml2,
AS_HELP_STRING([--with-xmlrpc-tinyxml2],[enable XMLRPC support via tinyxml2]),
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XMLRPC_TINYXML2, 1, Support for XMLRPC via tinyxml2.)
],[
AC_MSG_RESULT(ignored)
])
])
AC_DEFUN([TORRENT_WITH_LUA], [
AC_ARG_WITH(lua,
AS_HELP_STRING([--with-lua],[enable LUA support]),
[
if test "$withval" = "no"; then
AC_MSG_RESULT(no)
else
AX_PROG_LUA
# 1. Override AX_LUA_LIBS default crash behavior
AX_LUA_LIBS([have_lua_libs=yes], [have_lua_libs=no])
# 2. Override AX_LUA_HEADERS default crash behavior
AX_LUA_HEADERS([have_lua_headers=yes], [have_lua_headers=no])
# 3. Only inject if both checks completely pass
if test "x$have_lua_libs" = "xyes" && test "x$have_lua_headers" = "xyes"; then
AC_DEFINE(HAVE_LUA, 1, Use LUA.)
AC_DEFINE(LUA_DATADIR, [PACKAGE_DATADIR "/lua"], [LUA data directory])
LIBS="$LIBS $LUA_LIB"
CXXFLAGS="$CXXFLAGS $LUA_INCLUDE"
else
# Throw fatal error ONLY if user strictly ran --with-lua=yes
if test "$withval" = "yes"; then
AC_MSG_ERROR([Lua support explicitly requested, but compatible Lua 5.3 libs/headers were not found.])
else
AC_MSG_WARN([Lua 5.3 libs or headers missing. Proceeding without Lua support.])
fi
fi
fi
],[
AC_MSG_RESULT(ignored)
])
])
AC_DEFUN([TORRENT_WITH_INOTIFY], [
AC_LANG_PUSH(C++)
AC_CHECK_HEADERS([sys/inotify.h])
AC_MSG_CHECKING([whether sys/inotify.h actually works])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/inotify.h>
int main(int,const char**) { return (-1 == inotify_init()); }])
],[
AC_DEFINE(USE_INOTIFY, 1, [sys/inotify.h exists and works correctly])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(failed)]
)
AC_LANG_POP(C++)
])
AC_DEFUN([TORRENT_CHECK_PTHREAD_SETNAME_NP], [
AC_CHECK_HEADERS(pthread.h)
AC_MSG_CHECKING(for pthread_setname_np type)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <pthread.h>
#include <sys/types.h>
]], [[
pthread_t t;
pthread_setname_np(t, "foo");
]])],[
AC_DEFINE(HAS_PTHREAD_SETNAME_NP_GENERIC, 1, The function to set pthread name has a pthread_t argumet.)
AC_MSG_RESULT(generic)
],[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <pthread.h>
#include <sys/types.h>
]],[[
pthread_t t;
pthread_setname_np("foo");
]])],[
AC_DEFINE(HAS_PTHREAD_SETNAME_NP_DARWIN, 1, The function to set pthread name has no pthread argument.)
AC_MSG_RESULT(darwin)
],[
AC_MSG_RESULT(no)
])
])
])
AC_DEFUN([TORRENT_DISABLE_PTHREAD_SETNAME_NP], [
AC_MSG_CHECKING([for pthread_setname_no])
AC_ARG_ENABLE(pthread-setname-np,
AS_HELP_STRING([--disable-pthread-setname-np],[disable pthread_setname_np]),
[
if test "$enableval" = "no"; then
AC_MSG_RESULT(disabled)
else
AC_MSG_RESULT(checking)
TORRENT_CHECK_PTHREAD_SETNAME_NP
fi
], [
TORRENT_CHECK_PTHREAD_SETNAME_NP
]
)
])
AC_DEFUN([TORRENT_CHECK_POSIX_SPAWN_ADDCLOSEFROM_NP], [
AC_MSG_CHECKING(for posix_spawn_file_actions_addclosefrom_np)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <spawn.h>
]], [[
posix_spawn_file_actions_t actions;
posix_spawn_file_actions_addclosefrom_np(&actions, 3);
]])],[
AC_DEFINE(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP, 1, [Define if posix_spawn_file_actions_addclosefrom_np is available.])
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_WITH_SYSTEMD], [
AC_ARG_WITH(systemd,
AS_HELP_STRING([--with-systemd],[enable systemd socket activation support [[default=no]]]),
[
if test "$withval" = "yes"; then
PKG_CHECK_MODULES([SYSTEMD], [libsystemd],
[
CXXFLAGS="$CXXFLAGS $SYSTEMD_CFLAGS"
LIBS="$LIBS $SYSTEMD_LIBS"
AC_DEFINE(HAVE_SYSTEMD, 1, [Support for systemd socket activation.])
],
[AC_MSG_ERROR([libsystemd not found. Install libsystemd-dev (or the equivalent for your distribution).])])
fi
])
])
AC_DEFUN([TORRENT_WITHOUT_NCURSES], [
AC_ARG_WITH([ncurses],
[AS_HELP_STRING([--without-ncurses], [build without ncurses (daemon-only mode)])],
[with_ncurses=$withval],
[with_ncurses=yes])
if test "x$with_ncurses" = xno; then
AC_DEFINE([HAVE_NO_NCURSES], [1], [Define to 1 if building without ncurses])
CURSES_LIBS=""
CURSES_CFLAGS=""
CURSES_LIB=""
fi
AM_CONDITIONAL([NO_NCURSES], [test "x$with_ncurses" = xno])
])
+282
View File
@@ -0,0 +1,282 @@
AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [
AC_LANG_PUSH(C++)
AC_MSG_CHECKING(signedness of mincore parameter)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
void f() { mincore((char*)0, 0, (unsigned char*)0); }
])],
[
AC_DEFINE(USE_MINCORE, 1, Use mincore)
AC_DEFINE(USE_MINCORE_UNSIGNED, 1, use unsigned char* in mincore)
AC_MSG_RESULT(unsigned)
],
[
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
void f() { mincore((char*)0, 0, (char*)0); }
])],
[
AC_DEFINE(USE_MINCORE, 1, Use mincore)
AC_DEFINE(USE_MINCORE_UNSIGNED, 0, use char* in mincore)
AC_MSG_RESULT(signed)
],
[
AC_MSG_ERROR([failed, do *not* attempt fix this with --disable-mincore unless you are running Win32 or OpenBSD.])
])
])
AC_LANG_POP(C++)
])
AC_DEFUN([TORRENT_MINCORE], [
AC_ARG_ENABLE(mincore,
AS_HELP_STRING([--disable-mincore],
[disable mincore check [[default=enable]]]),
[
if test "$enableval" = "yes"; then
TORRENT_MINCORE_SIGNEDNESS()
else
AC_MSG_CHECKING(for mincore)
AC_MSG_RESULT(disabled)
fi
],[
TORRENT_MINCORE_SIGNEDNESS()
])
])
AC_DEFUN([TORRENT_CHECK_MADVISE], [
AC_MSG_CHECKING(for madvise)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <sys/mman.h>
void f() { static char test@<:@1024@:>@; madvise((void *)test, sizeof(test), MADV_NORMAL); }
])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(USE_MADVISE, 1, Use madvise)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_CHECK_POSIX_FADVISE], [
AC_MSG_CHECKING(for posix_fadvise)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <fcntl.h>
void f() { posix_fadvise(0, 0, 0, POSIX_FADV_RANDOM); }
])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(USE_POSIX_FADVISE, 1, Use posix_fadvise)
], [
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_CHECK_CACHELINE], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_MSG_CHECKING([for target cacheline size])
case "$host_os" in
linux*)
# REGION: Linux Kernel Extraction Loop
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
#include <linux/cache.h>
void* vptr;
void f() {
int res = posix_memalign(&vptr, SMP_CACHE_BYTES, 42);
(void)res;
}
]])],[
# We need an explicit variable fallback condition inside AC_COMPUTE_INT
AC_COMPUTE_INT([torrent_cv_cacheline_size], [SMP_CACHE_BYTES], [#include <linux/cache.h>], [torrent_cv_cacheline_size=0])
if test "$torrent_cv_cacheline_size" -gt 0; then
AC_MSG_RESULT([linux builtin ($torrent_cv_cacheline_size bytes)])
AC_DEFINE_UNQUOTED([LT_SMP_CACHE_BYTES], [$torrent_cv_cacheline_size], [System-defined Linux L1 SMP cacheline size.])
else
# Handle scenarios where macro maps to a complex runtime expression or fails
AC_MSG_RESULT([failed to parse SMP_CACHE_BYTES value])
AC_MSG_FAILURE([Linux kernel headers found, but cacheline constant could not be computed at compile-time.])
fi
],[
# Explicitly validate the CPU type even on Linux if the header check fails
case "$host_cpu" in
x86_64*|amd64*|i386*|i486*|i586*|i686*)
AC_MSG_RESULT([linux fallback x86 64 bytes])
AC_DEFINE([LT_SMP_CACHE_BYTES], 64, [Fallback 64-byte alignment for Linux x86 hardware.])
;;
arm*|aarch64*|powerpc*|ppc*|s390x*)
AC_MSG_RESULT([linux fallback enterprise 128 bytes])
AC_DEFINE([LT_SMP_CACHE_BYTES], 128, [Fallback 128-byte alignment for Linux enterprise hardware.])
;;
riscv32*|riscv64*)
AC_MSG_RESULT([linux fallback RISC-V 64 bytes])
AC_DEFINE([LT_SMP_CACHE_BYTES], 64, [Fallback 64-byte alignment for Linux RISC-V hardware.])
;;
loongarch32*|loongarch64*)
AC_MSG_RESULT([linux fallback LoongArch 64 bytes])
AC_DEFINE([LT_SMP_CACHE_BYTES], 64, [Fallback 64-byte alignment for Linux LoongArch hardware.])
;;
*)
AC_MSG_RESULT([unrecognized CPU arch on Linux header fallback])
AC_MSG_FAILURE([Unrecognized CPU architecture ($host_cpu) on Linux fallback path. Aborting build.])
;;
esac
])
;;
*)
# REGION: Cross-Platform Strict Hardware Mapping (macOS, FreeBSD, OpenBSD, NetBSD)
case "$host_cpu" in
x86_64*|amd64*|i386*|i486*|i586*|i686*)
# Explicit x86 desktop hardware baseline block
AC_MSG_RESULT([$host_os ($host_cpu) standard x86 64 bytes])
AC_DEFINE([LT_SMP_CACHE_BYTES], 64, [Standard 64-byte alignment for stable x86 hardware layout.])
;;
arm*|aarch64*|powerpc*|ppc*|s390x*)
# Explicit modern enterprise and Apple Silicon hardware baseline block
AC_MSG_RESULT([$host_os ($host_cpu) stable enterprise 128 bytes])
AC_DEFINE([LT_SMP_CACHE_BYTES], 128, [Optimized 128-byte alignment for newer high-performance chipsets.])
;;
*)
# STRICT ENFORCEMENT: Fail the build immediately if the CPU isn't explicitly known
AC_MSG_RESULT([unrecognized architecture])
AC_MSG_FAILURE([The target CPU architecture ($host_cpu) is unrecognized. Aborting configuration to prevent fatal runtime false-sharing or memory misalignment errors.])
;;
esac
;;
esac
])
AC_DEFUN([TORRENT_CHECK_CUSTOM_ENDIAN64], [
AC_CHECK_HEADERS([endian.h sys/endian.h libkern/OSByteOrder.h])
AC_C_BIGENDIAN
AH_TEMPLATE([CUSTOM_ENDIAN_HEADER], [The system header to include for endian conversions.])
AH_TEMPLATE([custom_ntohll], [Convert 64-bit integer from network to host byte order.])
AH_TEMPLATE([custom_htonll], [Convert 64-bit integer from host to network byte order.])
dnl 1. Initialize our header variable tracking
endian_header_file='<stdint.h>'
dnl 2. Test if native be64toh works natively via <endian.h> (Standard Linux/glibc)
AC_MSG_CHECKING([for native be64toh via endian.h])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <stdint.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif
int main() { uint64_t x = be64toh(1); return 0; }
])],
[has_native_be64=yes; endian_header_file='<endian.h>'],
[has_native_be64=no]
)
AC_MSG_RESULT([$has_native_be64])
dnl 3. If missing, test if it works via <sys/endian.h> (True BSD systems like FreeBSD)
if test "$has_native_be64" = "no"; then
AC_MSG_CHECKING([for native be64toh via sys/endian.h])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <stdint.h>
#ifdef HAVE_SYS_ENDIAN_H
# include <sys/endian.h>
#endif
int main() { uint64_t x = be64toh(1); return 0; }
])],
[has_native_be64=yes; endian_header_file='<sys/endian.h>'],
[has_native_be64=no]
)
AC_MSG_RESULT([$has_native_be64])
fi
dnl 4. Route definitions cleanly based on actual testing results
if test "$has_native_be64" = "yes"; then
dnl Linux or true BSD environment
AC_DEFINE_UNQUOTED([CUSTOM_ENDIAN_HEADER], [$endian_header_file], [The header containing native endian macros.])
AC_DEFINE([custom_ntohll(x)], [(be64toh(x))], [Use native platform be64toh])
AC_DEFINE([custom_htonll(x)], [(htobe64(x))], [Use native platform htobe64])
else
dnl Fallback block: Check if we are on macOS using Apple's optimized hardware libraries
if test "$ac_cv_header_libkern_OSByteOrder_h" = "yes"; then
AC_DEFINE([CUSTOM_ENDIAN_HEADER], [<libkern/OSByteOrder.h>], [The header containing native endian macros.])
AC_DEFINE([custom_ntohll(x)], [(OSSwapBigToHostInt64(x))], [Map missing be64toh to macOS native swap])
AC_DEFINE([custom_htonll(x)], [(OSSwapHostToBigInt64(x))], [Map missing htobe64 to macOS native swap])
else
dnl Fallback for platforms with no built-in architecture macros (compiler built-ins)
AC_DEFINE([CUSTOM_ENDIAN_HEADER], [<stdint.h>], [The header containing native endian macros.])
if test "$ac_cv_c_bigendian" = "yes"; then
AC_DEFINE([custom_ntohll(x)], [((uint64_t)(x))], [Fallback 64-bit conversion.])
AC_DEFINE([custom_htonll(x)], [((uint64_t)(x))], [Fallback 64-bit conversion.])
else
AC_DEFINE([custom_ntohll(x)], [(__builtin_bswap64((uint64_t)(x)))], [Fallback 64-bit conversion.])
AC_DEFINE([custom_htonll(x)], [(__builtin_bswap64((uint64_t)(x)))], [Fallback 64-bit conversion.])
fi
fi
fi
])
AC_DEFUN([TORRENT_ENABLE_INSTRUMENTATION], [
AC_MSG_CHECKING([if instrumentation should be included])
AC_ARG_ENABLE(instrumentation,
AS_HELP_STRING([--enable-instrumentation],
[enable instrumentation [[default=disabled]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(LT_INSTRUMENTATION, 1, enable instrumentation)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
],[
AC_MSG_RESULT(no)
])
])
AC_DEFUN([TORRENT_ENABLE_CUSTOM_STACK_SIZE], [
AC_ARG_ENABLE([pthread-setstacksize],
[AS_HELP_STRING([--enable-pthread-setstacksize], [explicitly set pthread stack size (auto-enabled for musl)])],
[enable_pthread_setstacksize=$enableval],
[enable_pthread_setstacksize=auto])
AC_CANONICAL_HOST
if test "x$enable_pthread_setstacksize" = "xauto"; then
case "$host" in
*-musl*)
enable_pthread_setstacksize=yes
;;
*)
enable_pthread_setstacksize=no
;;
esac
fi
if test "x$enable_pthread_setstacksize" = "xyes"; then
AC_DEFINE([USE_PTHREAD_SETSTACKSIZE], [1], [Use explicit pthread stack size])
AC_DEFINE([DEFAULT_PTHREAD_STACKSIZE], [(8 * 1024 * 1024)], [Default pthread stack size in bytes])
fi
])
AC_DEFUN([TORRENT_DISABLE_IPV6], [
AC_ARG_ENABLE(ipv6,
AS_HELP_STRING([--enable-ipv6],
[enable ipv6 [[default=no]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(RAK_USE_INET6, 1, enable ipv6 stuff)
fi
])
])
+63
View File
@@ -0,0 +1,63 @@
AC_DEFUN([RAK_CHECK_CFLAGS], [
AC_MSG_CHECKING([for user-defined CFLAGS])
if test "$CFLAGS" = ""; then
unset CFLAGS
AC_MSG_RESULT([undefined])
else
AC_MSG_RESULT([user-defined "$CFLAGS"])
fi
])
AC_DEFUN([RAK_CHECK_CXXFLAGS], [
AC_MSG_CHECKING([for user-defined CXXFLAGS])
if test "$CXXFLAGS" = ""; then
unset CXXFLAGS
AC_MSG_RESULT([undefined])
else
AC_MSG_RESULT([user-defined "$CXXFLAGS"])
fi
])
AC_DEFUN([RAK_ENABLE_DEBUG], [
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],[enable debug information [[default=yes]]]),
[
if test "$enableval" = "yes"; then
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
else
CXXFLAGS="$CXXFLAGS -DNDEBUG"
fi
],[
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
])
])
AC_DEFUN([RAK_ENABLE_WERROR], [
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror],[enable the -Werror and -Wall flags [[default -Wall only]]]),
[
if test "$enableval" = "yes"; then
CXXFLAGS="$CXXFLAGS -Werror -Wall"
fi
],[
CXXFLAGS="$CXXFLAGS -Wall"
])
])
AC_DEFUN([RAK_ENABLE_EXTRA_DEBUG], [
AC_ARG_ENABLE(extra-debug,
AS_HELP_STRING([--enable-extra-debug],[enable extra debugging checks [[default=no]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(USE_EXTRA_DEBUG, 1, Enable extra debugging checks.)
fi
])
])
+38
View File
@@ -0,0 +1,38 @@
AC_DEFUN([TORRENT_CHECK_OPENSSL],
[
PKG_CHECK_MODULES(OPENSSL, libcrypto,
CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS";
LIBS="$LIBS $OPENSSL_LIBS")
AC_DEFINE(USE_OPENSSL, 1, Using OpenSSL.)
AC_DEFINE(USE_OPENSSL_SHA, 1, Using OpenSSL's SHA1 implementation.)
]
)
AC_DEFUN([TORRENT_ARG_OPENSSL],
[
AC_ARG_ENABLE(openssl,
[ --disable-openssl Don't use OpenSSL's SHA1 implementation.],
[
if test "$enableval" = "yes"; then
TORRENT_CHECK_OPENSSL
else
AC_DEFINE(USE_NSS_SHA, 1, Using Mozilla's SHA1 implementation.)
fi
],[
TORRENT_CHECK_OPENSSL
])
]
)
AC_DEFUN([TORRENT_ARG_CYRUS_RC4],
[
AC_ARG_ENABLE(cyrus-rc4,
[ --enable-cyrus-rc4=PFX Use Cyrus RC4 implementation.],
[
CXXFLAGS="$CXXFLAGS -I${enableval}/include";
LIBS="$LIBS -lrc4 -L${enableval}/lib"
AC_DEFINE(USE_CYRUS_RC4, 1, Using Cyrus RC4 implementation.)
])
]
)
+214
View File
@@ -0,0 +1,214 @@
noinst_LIBRARIES = libsub_root.a
bin_PROGRAMS = rtorrent
rtorrent_LDADD = libsub_root.a @PTHREAD_LIBS@
rtorrent_SOURCES = main.cc
libsub_root_a_SOURCES = \
core/dht_manager.cc \
core/dht_manager.h \
core/download.cc \
core/download.h \
core/download_factory.cc \
core/download_factory.h \
core/download_list.cc \
core/download_list.h \
core/http_queue.cc \
core/http_queue.h \
core/manager.cc \
core/manager.h \
core/range_map.h \
core/view.cc \
core/view.h \
core/view_manager.cc \
core/view_manager.h \
\
display/attributes.h \
display/canvas.cc \
display/canvas.h \
display/color_map.h \
display/frame.cc \
display/frame.h \
display/manager.cc \
display/manager.h \
display/utils.cc \
display/utils.h \
display/text_element.h \
display/text_element_list.cc \
display/text_element_list.h \
display/text_element_string.cc \
display/text_element_string.h \
display/text_element_value.cc \
display/text_element_value.h \
display/window.cc \
display/window.h \
display/window_download_chunks_seen.cc \
display/window_download_chunks_seen.h \
display/window_download_list.cc \
display/window_download_list.h \
display/window_download_statusbar.cc \
display/window_download_statusbar.h \
display/window_download_transfer_list.cc \
display/window_download_transfer_list.h \
display/window_file_list.cc \
display/window_file_list.h \
display/window_http_queue.cc \
display/window_http_queue.h \
display/window_input.cc \
display/window_input.h \
display/window_log.cc \
display/window_log.h \
display/window_log_complete.cc \
display/window_log_complete.h \
display/window_peer_list.cc \
display/window_peer_list.h \
display/window_statusbar.cc \
display/window_statusbar.h \
display/window_string_list.cc \
display/window_string_list.h \
display/window_text.cc \
display/window_text.h \
display/window_title.cc \
display/window_title.h \
display/window_tracker_list.cc \
display/window_tracker_list.h \
\
input/bindings.cc \
input/bindings.h \
input/input_event.cc \
input/input_event.h \
input/manager.cc \
input/manager.h \
input/path_input.cc \
input/path_input.h \
input/text_input.cc \
input/text_input.h \
\
rpc/command.h \
rpc/command.cc \
rpc/command_impl.h \
rpc/command_map.cc \
rpc/command_map.h \
rpc/command_scheduler.cc \
rpc/command_scheduler.h \
rpc/command_scheduler_item.cc \
rpc/command_scheduler_item.h \
rpc/exec_file.cc \
rpc/exec_file.h \
rpc/fixed_key.h \
rpc/ip_table_list.h \
rpc/lua.h \
rpc/lua.cc \
rpc/jsonrpc.cc \
rpc/jsonrpc.h \
rpc/rpc_manager.cc \
rpc/rpc_manager.h \
rpc/object_storage.cc \
rpc/object_storage.h \
rpc/parse.cc \
rpc/parse.h \
rpc/parse_commands.cc \
rpc/parse_commands.h \
rpc/parse_options.cc \
rpc/parse_options.h \
rpc/scgi.cc \
rpc/scgi.h \
rpc/scgi_task.cc \
rpc/scgi_task.h \
rpc/xmlrpc.h \
rpc/xmlrpc.cc \
rpc/xmlrpc_c.cc \
rpc/xmlrpc_tinyxml2.cc \
rpc/tinyxml2/tinyxml2.h \
rpc/tinyxml2/tinyxml2.cc \
rpc/nlohmann/json.h \
\
scgi/thread_scgi.cc \
scgi/thread_scgi.h \
\
session/download_storer.cc \
session/download_storer.h \
session/session_manager.cc \
session/session_manager.h \
session/thread_session.cc \
session/thread_session.h \
\
ui/download.cc \
ui/download.h \
ui/download_list.cc \
ui/download_list.h \
ui/element_base.h \
ui/element_base.cc \
ui/element_chunks_seen.cc \
ui/element_chunks_seen.h \
ui/element_download_list.cc \
ui/element_download_list.h \
ui/element_file_list.cc \
ui/element_file_list.h \
ui/element_log_complete.cc \
ui/element_log_complete.h \
ui/element_menu.cc \
ui/element_menu.h \
ui/element_peer_list.cc \
ui/element_peer_list.h \
ui/element_string_list.cc \
ui/element_string_list.h \
ui/element_text.cc \
ui/element_text.h \
ui/element_tracker_list.cc \
ui/element_tracker_list.h \
ui/element_transfer_list.cc \
ui/element_transfer_list.h \
ui/root.cc \
ui/root.h \
\
utils/base64.cc \
utils/base64.h \
utils/directory.cc \
utils/directory.h \
utils/file_status_cache.cc \
utils/file_status_cache.h \
utils/functional.h \
utils/gzip.cc \
utils/gzip.h \
utils/list_focus.h \
utils/lockfile.cc \
utils/lockfile.h \
utils/waitpid_queue.cc \
utils/waitpid_queue.h \
utils/watch_ready_queue.cc \
utils/watch_ready_queue.h \
\
command_download.cc \
command_dynamic.cc \
command_events.cc \
command_file.cc \
command_ip.cc \
command_helpers.cc \
command_helpers.h \
command_groups.cc \
command_local.cc \
command_logging.cc \
command_network.cc \
command_peer.cc \
command_throttle.cc \
command_tracker.cc \
command_scheduler.cc \
command_ui.cc \
control.cc \
control.h \
globals.cc \
globals.h \
option_parser.cc \
option_parser.h \
setup.cc \
setup.h \
signal_handler.cc \
signal_handler.h
if NO_NCURSES
libsub_root_a_SOURCES += display/curses_stub.cc display/curses_stub.h
endif
AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -DPACKAGE_DATADIR=\"$(pkgdatadir)\"
File diff suppressed because it is too large Load Diff
+487
View File
@@ -0,0 +1,487 @@
#include "config.h"
#include <algorithm>
#include <torrent/utils/log.h>
#include <torrent/utils/option_strings.h>
#include "command_helpers.h"
#include "control.h"
#include "globals.h"
#include "rpc/parse.h"
#include "rpc/parse_options.h"
static std::vector<std::pair<const char*, int>> object_storage_flags = {
{"multi", rpc::object_storage::flag_multi_type},
{"simple", rpc::object_storage::flag_function_type},
{"value", rpc::object_storage::flag_value_type},
{"bool", rpc::object_storage::flag_bool_type},
{"string", rpc::object_storage::flag_string_type},
{"list", rpc::object_storage::flag_list_type},
{"static", rpc::object_storage::flag_static},
{"private", rpc::object_storage::flag_private},
{"const", rpc::object_storage::flag_constant},
{"rlookup", rpc::object_storage::flag_rlookup}};
static int
object_storage_parse_flag(const std::string& flag) {
for (auto [n, f] : object_storage_flags)
if (n == flag)
return f;
throw torrent::input_error("unknown flag");
}
std::string
system_method_generate_command(torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last) {
std::string command;
while (first != last) {
if (!command.empty())
command += " ;";
command += (first++)->as_string();
}
return command;
}
void
system_method_generate_command2(torrent::Object* object, torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last) {
if (first == last) {
// TODO: Use empty object.
*object = "";
return;
}
if (first->is_string()) {
std::string command;
while (first != last) {
if (!command.empty())
command += " ;";
command += (first++)->as_string();
}
*object = command;
return;
}
if (first + 1 == last) {
if (!first->is_dict_key())
throw torrent::input_error("New command of wrong type.");
*object = *first;
uint32_t flags = object->flags() & torrent::Object::mask_function;
object->unset_flags(torrent::Object::mask_function);
object->set_flags((flags >> 1) & torrent::Object::mask_function);
} else {
*object = torrent::Object::create_list();
while (first != last) {
if (!first->is_dict_key())
throw torrent::input_error("New command of wrong type.");
object->as_list().push_back(*first++);
uint32_t flags = object->as_list().back().flags() & torrent::Object::mask_function;
object->as_list().back().unset_flags(torrent::Object::mask_function);
object->as_list().back().set_flags((flags >> 1) & torrent::Object::mask_function);
}
}
}
// torrent::Object
// system_method_insert_function(const torrent::Object::list_type& args, int flags) {
// }
// This is only used by tinyxml2, xmlrpc-c intercepts the call internally
torrent::Object
system_listMethods() {
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
result.push_back("system.multicall"); // Handled directly by the XMLRPC code
for (auto itr : rpc::commands) {
result.push_back(itr.first);
}
return resultRaw;
}
torrent::Object
system_method_insert_object(const torrent::Object::list_type& args, int flags) {
if (args.empty())
throw torrent::input_error("Invalid argument count.");
torrent::Object::list_const_iterator itrArgs = args.begin();
const std::string& raw_key = (itrArgs++)->as_string();
if (raw_key.empty() ||
control->object_storage()->find_raw_string(torrent::raw_string::from_string(raw_key)) != control->object_storage()->end() ||
rpc::commands.has(raw_key) || rpc::commands.has(raw_key + ".set"))
throw torrent::input_error("Invalid key.");
torrent::Object value;
switch (flags & rpc::object_storage::mask_type) {
case rpc::object_storage::flag_bool_type:
case rpc::object_storage::flag_value_type:
value = itrArgs != args.end() ? rpc::convert_to_value(*itrArgs) : int64_t();
break;
case rpc::object_storage::flag_string_type:
value = itrArgs != args.end() ? rpc::convert_to_string(*itrArgs) : "";
break;
case rpc::object_storage::flag_function_type:
system_method_generate_command2(&value, itrArgs, args.end());
break;
case rpc::object_storage::flag_list_type:
break;
case rpc::object_storage::flag_multi_type:
break;
default:
throw torrent::input_error("Invalid type.");
}
int cmd_flags = 0;
if (!(flags & rpc::object_storage::flag_static))
cmd_flags |= rpc::CommandMap::flag_modifiable;
if (!(flags & rpc::object_storage::flag_private))
cmd_flags |= rpc::CommandMap::flag_public_rpc;
if ((flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_list_type) {
torrent::Object valueList = torrent::Object::create_list();
torrent::Object::list_type& valueListType = valueList.as_list();
if ((itrArgs)->is_list())
valueListType = (itrArgs)->as_list();
control->object_storage()->insert_str(raw_key, valueList, flags);
} else {
control->object_storage()->insert_str(raw_key, value, flags);
}
if ((flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_function_type ||
(flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_multi_type) {
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call<rpc::target_type>>::type>(
raw_key,
std::bind(&rpc::object_storage::call_function_str, control->object_storage(), raw_key, std::placeholders::_1, std::placeholders::_2),
&rpc::command_base_call<rpc::target_type>,
cmd_flags,
NULL,
NULL);
} else {
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call<rpc::target_type>>::type>(
raw_key,
std::bind(&rpc::object_storage::get_str, control->object_storage(), raw_key),
&rpc::command_base_call<rpc::target_type>,
cmd_flags,
NULL,
NULL);
}
// Not the right argument.
// if (flags & rpc::object_storage::flag_rlookup) {
// rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_string<rpc::target_type> >::type>
// (create_new_key<9>(raw_key, ".rlookup"),
// std::bind(&rpc::object_storage::rlookup_obj_list, control->object_storage(), raw_key),
// &rpc::command_base_call_string<rpc::target_type>,
// cmd_flags, NULL, NULL);
// }
// TODO: Next... Make test class for this.
// // Ehm... no proper handling if these throw.
if (!(flags & rpc::object_storage::flag_constant)) {
switch (flags & rpc::object_storage::mask_type) {
case rpc::object_storage::flag_bool_type:
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_value<rpc::target_type>>::type>(
raw_key + ".set",
std::bind(&rpc::object_storage::set_str_bool, control->object_storage(), raw_key, std::placeholders::_2),
&rpc::command_base_call_value<rpc::target_type>,
cmd_flags,
NULL,
NULL);
break;
case rpc::object_storage::flag_value_type:
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_value<rpc::target_type>>::type>(
raw_key + ".set",
std::bind(&rpc::object_storage::set_str_value, control->object_storage(), raw_key, std::placeholders::_2),
&rpc::command_base_call_value<rpc::target_type>,
cmd_flags,
NULL,
NULL);
break;
case rpc::object_storage::flag_string_type:
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_string<rpc::target_type>>::type>(
raw_key + ".set",
std::bind(&rpc::object_storage::set_str_string, control->object_storage(), raw_key, std::placeholders::_2),
&rpc::command_base_call_string<rpc::target_type>,
cmd_flags,
NULL,
NULL);
break;
case rpc::object_storage::flag_list_type:
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_list<rpc::target_type>>::type>(
raw_key + ".set",
std::bind(&rpc::object_storage::set_str_list, control->object_storage(), raw_key, std::placeholders::_2),
&rpc::command_base_call_list<rpc::target_type>,
cmd_flags,
NULL,
NULL);
break;
case rpc::object_storage::flag_function_type:
case rpc::object_storage::flag_multi_type:
default:
break;
}
}
return torrent::Object();
}
// method.insert <generic> {name, "simple|private|const", ...}
// method.insert <generic> {name, "multi|private|const"}
// method.insert <generic> {name, "value|private|const"}
// method.insert <generic> {name, "value|private|const", value}
// method.insert <generic> {name, "bool|private|const"}
// method.insert <generic> {name, "bool|private|const", bool}
// method.insert <generic> {name, "string|private|const"}
// method.insert <generic> {name, "string|private|const", string}
//
// Add a new user-defined method called 'name' and any number of
// lines.
//
// TODO: Make a static version of this that doesn't need to be called
// as a command, and which takes advantage of static const char
// strings, etc.
torrent::Object
system_method_insert(const torrent::Object::list_type& args) {
if (args.empty() || ++args.begin() == args.end())
throw torrent::input_error("Invalid argument count.");
torrent::Object::list_const_iterator itrArgs = args.begin();
const std::string& raw_key = (itrArgs++)->as_string();
if (raw_key.empty() || rpc::commands.has(raw_key))
throw torrent::input_error("Invalid key.");
int new_flags = rpc::parse_option_flags(itrArgs->as_string(), std::bind(&object_storage_parse_flag, std::placeholders::_1));
torrent::Object::list_type new_args;
new_args.push_back(raw_key);
if ((new_flags & rpc::object_storage::flag_function_type) ||
(new_flags & rpc::object_storage::flag_multi_type)) {
new_args.push_back(system_method_generate_command(++itrArgs, args.end()));
} else if ((new_flags & rpc::object_storage::flag_value_type) ||
(new_flags & rpc::object_storage::flag_bool_type) ||
(new_flags & rpc::object_storage::flag_string_type) ||
(new_flags & rpc::object_storage::flag_list_type)) {
if (++itrArgs != args.end())
new_args.insert(new_args.end(), itrArgs, args.end());
} else {
throw torrent::input_error("No object type specified.");
}
return system_method_insert_object(new_args, new_flags);
}
// method.erase <> {name}
//
// Erase a modifiable method called 'name. Trying to remove methods
// that aren't modifiable, e.g. defined by rtorrent or set to
// read-only by the user, will result in an error.
torrent::Object
system_method_erase(const torrent::Object::string_type& args) {
rpc::CommandMap::iterator itr = rpc::commands.find(args.c_str());
if (itr == rpc::commands.end())
return torrent::Object();
if (!rpc::commands.is_modifiable(itr))
throw torrent::input_error("Command not modifiable.");
rpc::commands.erase(itr);
return torrent::Object();
}
torrent::Object
system_method_redirect(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Invalid argument count.");
std::string new_key = torrent::object_create_string(args.front());
std::string dest_key = torrent::object_create_string(args.back());
rpc::commands.create_redirect(new_key, dest_key, rpc::CommandMap::flag_public_rpc | rpc::CommandMap::flag_modifiable);
return torrent::Object();
}
torrent::Object
system_method_set_function(const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("Invalid argument count.");
rpc::object_storage::iterator itr =
control->object_storage()->find_raw_string(torrent::raw_string::from_string(args.front().as_string()));
if (itr == control->object_storage()->end() || itr->second.flags & rpc::object_storage::flag_constant)
throw torrent::input_error("Command is not modifiable.");
return control->object_storage()->set_str_function(args.front().as_string(),
system_method_generate_command(++args.begin(), args.end()));
}
torrent::Object
system_method_has_key(const torrent::Object::list_type& args) {
if (args.empty() || ++args.begin() == args.end())
throw torrent::input_error("Invalid argument count.");
torrent::Object::list_const_iterator itrArgs = args.begin();
const std::string& key = (itrArgs++)->as_string();
const std::string& cmd_key = (itrArgs++)->as_string();
return control->object_storage()->has_str_multi_key(key, cmd_key);
}
torrent::Object
system_method_set_key(const torrent::Object::list_type& args) {
if (args.empty() || ++args.begin() == args.end())
throw torrent::input_error("Invalid argument count.");
torrent::Object::list_const_iterator itrArgs = args.begin();
const std::string& key = (itrArgs++)->as_string();
const std::string& cmd_key = (itrArgs++)->as_string();
if (itrArgs == args.end()) {
control->object_storage()->erase_str_multi_key(key, cmd_key);
return torrent::Object();
}
if (itrArgs->is_dict_key() || itrArgs->is_list())
control->object_storage()->set_str_multi_key_obj(key.c_str(), cmd_key, *itrArgs);
else
control->object_storage()->set_str_multi_key(key, cmd_key, system_method_generate_command(itrArgs, args.end()));
return torrent::Object();
}
torrent::Object
system_method_list_keys(const torrent::Object::string_type& args) {
torrent::Object rawResult = torrent::Object::create_list();
torrent::Object::list_type& result = rawResult.as_list();
for (const auto& itr : control->object_storage()->get_str(args).as_map())
result.push_back(itr.first);
return rawResult;
}
torrent::Object
cmd_catch(rpc::target_type target, const torrent::Object& args) {
try {
return rpc::call_object(args, target);
} catch (torrent::input_error& e) {
lt_log_print(torrent::LOG_WARN, "Caught exception: '%s'.", e.what());
return torrent::Object();
}
}
#define CMD2_METHOD_INSERT(key, flags) \
CMD2_ANY_LIST(key, std::bind(&system_method_insert_object, std::placeholders::_2, flags));
void
initialize_command_dynamic() {
// clang-format off
#ifdef HAVE_XMLRPC_TINYXML2
CMD2_ANY ("system.listMethods", std::bind(&system_listMethods)); // only used by tinyxml2
#endif
// Keep these for future use when we deprecate more commands.
CMD2_VAR_BOOL ("method.use_deprecated", false);
CMD2_VAR_VALUE ("method.use_intermediate", 3);
CMD2_ANY_LIST ("method.insert", std::bind(&system_method_insert, std::placeholders::_2));
CMD2_ANY_LIST ("method.insert.value", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_value_type));
CMD2_ANY_LIST ("method.insert.bool", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_bool_type));
CMD2_ANY_LIST ("method.insert.string", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_string_type));
CMD2_ANY_LIST ("method.insert.list", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_list_type));
CMD2_METHOD_INSERT("method.insert.simple", rpc::object_storage::flag_function_type);
CMD2_METHOD_INSERT("method.insert.c_simple", rpc::object_storage::flag_constant | rpc::object_storage::flag_function_type);
CMD2_METHOD_INSERT("method.insert.s_c_simple", rpc::object_storage::flag_static |
rpc::object_storage::flag_constant |rpc::object_storage::flag_function_type);
CMD2_ANY_STRING ("method.erase", std::bind(&system_method_erase, std::placeholders::_2));
CMD2_ANY_LIST ("method.redirect", std::bind(&system_method_redirect, std::placeholders::_2));
CMD2_ANY_STRING ("method.get", std::bind(&rpc::object_storage::get_str, control->object_storage(),
std::placeholders::_2));
CMD2_ANY_LIST ("method.set", std::bind(&system_method_set_function, std::placeholders::_2));
CMD2_ANY_STRING ("method.const", std::bind(&rpc::object_storage::has_flag_str, control->object_storage(),
std::placeholders::_2, rpc::object_storage::flag_constant));
CMD2_ANY_STRING_V("method.const.enable", std::bind(&rpc::object_storage::enable_flag_str, control->object_storage(),
std::placeholders::_2, rpc::object_storage::flag_constant));
CMD2_ANY_LIST ("method.has_key", std::bind(&system_method_has_key, std::placeholders::_2));
CMD2_ANY_LIST ("method.set_key", std::bind(&system_method_set_key, std::placeholders::_2));
CMD2_ANY_STRING ("method.list_keys", std::bind(&system_method_list_keys, std::placeholders::_2));
CMD2_ANY_STRING ("method.rlookup", std::bind(&rpc::object_storage::rlookup_obj_list, control->object_storage(), std::placeholders::_2));
CMD2_ANY_STRING_V("method.rlookup.clear", std::bind(&rpc::object_storage::rlookup_clear, control->object_storage(), std::placeholders::_2));
CMD2_ANY ("catch", std::bind(&cmd_catch, std::placeholders::_1, std::placeholders::_2));
CMD2_ANY_STRING ("enum.log_group", [](auto, const auto& str) { return torrent::option_find_string_str(torrent::OPTION_LOG_GROUP, str); });
CMD2_ANY ("strings.choke_heuristics", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_CHOKE_HEURISTICS); });
CMD2_ANY ("strings.choke_heuristics.upload", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_CHOKE_HEURISTICS_UPLOAD); });
CMD2_ANY ("strings.choke_heuristics.download", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_CHOKE_HEURISTICS_DOWNLOAD); });
CMD2_ANY ("strings.connection_type", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_CONNECTION_TYPE); });
CMD2_ANY ("strings.encryption", [](auto, auto) { return torrent::Object::create_list(); });
CMD2_ANY ("strings.encryption.handshake", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_ENCRYPTION_HANDSHAKE); });
CMD2_ANY ("strings.encryption.stream", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_ENCRYPTION_STREAM); });
CMD2_ANY ("strings.ip_filter", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_IP_FILTER); });
CMD2_ANY ("strings.ip_tos", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_IP_TOS); });
CMD2_ANY ("strings.log_group", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_LOG_GROUP); });
CMD2_ANY ("strings.tracker_event", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_TRACKER_EVENT); });
CMD2_ANY ("strings.tracker_mode", [](auto, auto) { return torrent::option_list_strings(torrent::OPTION_TRACKER_MODE); });
// clang-format on
#ifdef HAVE_XMLRPC_TINYXML2
rpc::rpc.mark_safe("system.listMethods");
#endif
rpc::rpc.mark_safe("method.use_deprecated");
rpc::rpc.mark_safe("method.const");
rpc::rpc.mark_safe("method.has_key");
rpc::rpc.mark_safe("method.list_keys");
rpc::rpc.mark_safe("method.get");
rpc::rpc.mark_safe("method.rlookup");
rpc::rpc.mark_safe("catch");
rpc::rpc.mark_safe("enum.log_group");
rpc::rpc.mark_safe("strings.choke_heuristics");
rpc::rpc.mark_safe("strings.choke_heuristics.upload");
rpc::rpc.mark_safe("strings.choke_heuristics.download");
rpc::rpc.mark_safe("strings.connection_type");
rpc::rpc.mark_safe("strings.encryption");
rpc::rpc.mark_safe("strings.ip_filter");
rpc::rpc.mark_safe("strings.ip_tos");
rpc::rpc.mark_safe("strings.log_group");
rpc::rpc.mark_safe("strings.tracker_event");
rpc::rpc.mark_safe("strings.tracker_mode");
}
+380
View File
@@ -0,0 +1,380 @@
#include "config.h"
#include <functional>
#include <cstdio>
#include <string>
#include <vector>
#include <torrent/rate.h>
#include <torrent/hash_string.h>
#include <torrent/utils/log.h>
#include <torrent/utils/directory_events.h>
#include <torrent/utils/file_stat.h>
#include <torrent/utils/string_manip.h>
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
#include "core/download.h"
#include "core/download_list.h"
#include "core/manager.h"
#include "core/view_manager.h"
#include "rpc/command_scheduler.h"
#include "rpc/parse.h"
#include "rpc/parse_commands.h"
#include "utils/watch_ready_queue.h"
torrent::Object
apply_on_ratio(const torrent::Object& rawArgs) {
auto& group_name = rawArgs.as_string();
auto view_itr = control->view_manager()->find(rpc::commands.call("group." + group_name + ".view", rpc::make_target()).as_string());
if (view_itr == control->view_manager()->end())
throw torrent::input_error("Could not find view.");
// first argument: minimum ratio to reach
// second argument: minimum upload amount to reach [optional]
// third argument: maximum ratio to reach [optional]
int64_t min_ratio = rpc::commands.call("group." + group_name + ".ratio.min", rpc::make_target()).as_value();
int64_t max_ratio = rpc::commands.call("group." + group_name + ".ratio.max", rpc::make_target()).as_value();
int64_t min_upload = rpc::commands.call("group." + group_name + ".ratio.upload", rpc::make_target()).as_value();
std::vector<core::Download*> downloads;
for (auto itr = (*view_itr)->begin_visible(), last = (*view_itr)->end_visible(); itr != last; itr++) {
if (!(*itr)->is_seeding() || rpc::call_command_value("d.ignore_commands", rpc::make_target(*itr)) != 0)
continue;
int64_t total_done = (*itr)->download()->bytes_done();
int64_t total_upload = (*itr)->info()->up_rate()->total();
if (!(total_upload >= min_upload && total_upload * 100 >= total_done * min_ratio) &&
!(max_ratio > 0 && total_upload * 100 > total_done * max_ratio))
continue;
downloads.push_back(*itr);
}
auto ratio_command = "group." + group_name + ".ratio.command";
for (const auto& download : downloads)
rpc::commands.call_catch(ratio_command, rpc::make_target(download), torrent::Object(), "Ratio reached, but command failed: ");
return torrent::Object();
}
torrent::Object
apply_start_tied() {
for (const auto& download : *control->core()->download_list()) {
if (rpc::call_command_value("d.state", rpc::make_target(download)) == 1)
continue;
torrent::utils::FileStat fs;
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
if (!tied_to_file.empty() && fs.update(expand_path(tied_to_file)))
rpc::parse_command_single(rpc::make_target(download), "d.try_start=");
}
return torrent::Object();
}
torrent::Object
apply_stop_untied() {
for (const auto& download : *control->core()->download_list()) {
if (rpc::call_command_value("d.state", rpc::make_target(download)) == 0)
continue;
torrent::utils::FileStat fs;
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
if (!tied_to_file.empty() && !fs.update(expand_path(tied_to_file)))
rpc::parse_command_single(rpc::make_target(download), "d.try_stop=");
}
return torrent::Object();
}
torrent::Object
apply_close_untied() {
for (const auto& download : *control->core()->download_list()) {
torrent::utils::FileStat fs;
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
if (rpc::call_command_value("d.ignore_commands", rpc::make_target(download)) == 0 && !tied_to_file.empty() && !fs.update(expand_path(tied_to_file)))
rpc::parse_command_single(rpc::make_target(download), "d.try_close=");
}
return torrent::Object();
}
torrent::Object
apply_remove_untied() {
for (auto itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ) {
torrent::utils::FileStat fs;
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
if (!tied_to_file.empty() && !fs.update(expand_path(tied_to_file))) {
// Need to clear tied_to_file so it doesn't try to delete it.
rpc::call_command("d.tied_to_file.set", std::string(), rpc::make_target(*itr));
itr = control->core()->download_list()->erase(itr);
} else {
++itr;
}
}
return torrent::Object();
}
torrent::Object
apply_schedule(const torrent::Object::list_type& args) {
if (args.size() != 4)
throw torrent::input_error("Wrong number of arguments.");
torrent::Object::list_const_iterator itr = args.begin();
auto& arg1 = (itr++)->as_string();
auto& arg2 = (itr++)->as_string();
auto& arg3 = (itr++)->as_string();
control->command_scheduler()->parse(arg1, arg2, arg3, *itr);
return torrent::Object();
}
torrent::Object
apply_load(const torrent::Object::list_type& args, int flags) {
torrent::Object::list_const_iterator argsItr = args.begin();
if (argsItr == args.end())
throw torrent::input_error("Too few arguments.");
auto& filename = argsItr->as_string();
core::Manager::command_list_type commands;
while (++argsItr != args.end())
commands.push_back(argsItr->as_string());
control->core()->try_create_download_expand(filename, flags, commands);
return torrent::Object();
}
void apply_import(const std::string& path) { if (!rpc::parse_command_file(path)) throw torrent::input_error("Could not open option file: " + path); }
void apply_try_import(const std::string& path) { if (!rpc::parse_command_file(path)) control->core()->push_log_std("Could not read resource file: " + path); }
torrent::Object
apply_close_low_diskspace(int64_t arg, uint32_t skip_priority) {
bool closed = false;
torrent::FileList::cache_list cache;
for (auto download : *control->core()->download_list()) {
if (!download->is_downloading())
continue;
if (download->priority() >= skip_priority)
continue;
if (download->file_list()->free_diskspace(cache) >= (uint64_t)arg)
continue;
control->core()->download_list()->close(download);
download->set_hash_failed(true);
download->set_message(std::string("Low diskspace."));
closed = true;
}
if (closed)
lt_log_print(torrent::LOG_TORRENT_ERROR, "Closed torrents due to low diskspace.");
return torrent::Object();
}
torrent::Object
apply_download_list(const torrent::Object::list_type& args) {
torrent::Object::list_const_iterator argsItr = args.begin();
core::ViewManager* viewManager = control->view_manager();
core::ViewManager::iterator view_itr;
if (argsItr != args.end() && !argsItr->as_string().empty())
view_itr = viewManager->find((argsItr++)->as_string());
else
view_itr = viewManager->find("default");
if (view_itr == viewManager->end())
throw torrent::input_error("Could not find view.");
torrent::Object result = torrent::Object::create_list();
torrent::Object::list_type& resultList = result.as_list();
for (core::View::const_iterator itr = (*view_itr)->begin_visible(), last = (*view_itr)->end_visible(); itr != last; itr++) {
const torrent::HashString* hashString = &(*itr)->info()->hash();
resultList.push_back(torrent::utils::transform_to_hex_str(*hashString));
}
return result;
}
torrent::Object
d_multicall(const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("Too few arguments.");
core::ViewManager* viewManager = control->view_manager();
core::ViewManager::iterator view_itr;
if (!args.front().as_string().empty())
view_itr = viewManager->find(args.front().as_string());
else
view_itr = viewManager->find("default");
if (view_itr == viewManager->end())
throw torrent::input_error("Could not find view.");
// Add some pre-parsing of the commands, so we don't spend time
// parsing and searching command map for every single call.
std::vector<core::Download*> dlist((*view_itr)->begin_visible(), (*view_itr)->end_visible());
torrent::Object resultRaw = torrent::Object::create_list();
torrent::Object::list_type& result = resultRaw.as_list();
for (auto download : dlist) {
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
for (torrent::Object::list_const_iterator cItr = ++args.begin(); cItr != args.end(); cItr++) {
auto& cmd = cItr->as_string();
row.push_back(rpc::parse_command(rpc::make_target(download), cmd.c_str(), cmd.c_str() + cmd.size()).first);
}
}
return resultRaw;
}
torrent::Object
d_multicall_filtered(const torrent::Object::list_type& args) {
if (args.size() < 2)
throw torrent::input_error("d.multicall.filtered requires at least 2 arguments.");
auto arg = args.begin();
// Find the given view
auto* viewManager = control->view_manager();
auto view_itr = viewManager->find(arg->as_string().empty() ? "default" : arg->as_string());
if (view_itr == viewManager->end())
throw torrent::input_error("Could not find view '" + arg->as_string() + "'.");
// Make a filtered copy of the current item list
core::View::base_type dlist;
(*view_itr)->filter_by(*++arg, dlist);
// Generate result by iterating over all items
auto resultRaw = torrent::Object::create_list();
auto& result = resultRaw.as_list();
++arg; // skip to first command
for (const auto& item : dlist) {
// Add empty row to result
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
// Call the provided commands and assemble their results
for (torrent::Object::list_const_iterator command = arg; command != args.end(); command++) {
auto& cmdstr = command->as_string();
row.push_back(rpc::parse_command(rpc::make_target(item), cmdstr.c_str(), cmdstr.c_str() + cmdstr.size()).first);
}
}
return resultRaw;
}
static void
call_watch_command(const std::string& command, const std::string& path) {
rpc::commands.call_catch(command.c_str(), rpc::make_target(), path);
}
torrent::Object
directory_watch(const torrent::Object::list_type& args, int flags) {
if (args.size() != 2)
throw torrent::input_error("Too few arguments.");
auto& path = args.front().as_string();
auto& command = args.back().as_string();
std::string expanded_path = expand_path(path);
if (!control->directory_events()->open())
throw torrent::input_error("Could not open inotify:" + std::string(std::strerror(errno)));
torrent::watch_descriptor::slot_string slot =
flags == torrent::directory_events::flag_on_ready ?
torrent::watch_descriptor::slot_string([command](const auto& arg) { control->watch_ready_queue()->push(command, arg); }) :
torrent::watch_descriptor::slot_string(std::bind(&call_watch_command, command, std::placeholders::_1));
control->directory_events()->notify_on(expanded_path.c_str(), flags, slot);
return torrent::Object();
}
torrent::Object
directory_watch_added(const torrent::Object::list_type& args) {
return directory_watch(args,
torrent::directory_events::flag_on_added |
torrent::directory_events::flag_on_updated);
}
torrent::Object
directory_watch_ready(const torrent::Object::list_type& args) {
return directory_watch(args,
torrent::directory_events::flag_on_ready);
}
void
initialize_command_events() {
CMD2_ANY_STRING ("on_ratio", [](auto, auto& args) { return apply_on_ratio(args); });
CMD2_ANY ("start_tied", [](auto, auto) { return apply_start_tied(); });
CMD2_ANY ("stop_untied", [](auto, auto) { return apply_stop_untied(); });
CMD2_ANY ("close_untied", [](auto, auto) { return apply_close_untied(); });
CMD2_ANY ("remove_untied", [](auto, auto) { return apply_remove_untied(); });
CMD2_ANY_LIST ("schedule", [](auto, auto& args) { return apply_schedule(args); });
CMD2_ANY_STRING_V("schedule.remove", [](auto, auto& str) { return control->command_scheduler()->erase_str(str); });
CMD2_ANY_STRING_V("import", [](auto, auto& str) { return apply_import(str); });
CMD2_ANY_STRING_V("try_import", [](auto, auto& str) { return apply_try_import(str); });
CMD2_ANY_LIST ("load.normal", [](auto, auto& args) { return apply_load(args, core::Manager::create_quiet | core::Manager::create_tied); });
CMD2_ANY_LIST ("load.verbose", [](auto, auto& args) { return apply_load(args, core::Manager::create_tied); });
CMD2_ANY_LIST ("load.start", [](auto, auto& args) { return apply_load(args, core::Manager::create_quiet | core::Manager::create_tied | core::Manager::create_start); });
CMD2_ANY_LIST ("load.start_verbose", [](auto, auto& args) { return apply_load(args, core::Manager::create_tied | core::Manager::create_start); });
CMD2_ANY_LIST ("load.raw", [](auto, auto& args) { return apply_load(args, core::Manager::create_quiet | core::Manager::create_raw_data); });
CMD2_ANY_LIST ("load.raw_verbose", [](auto, auto& args) { return apply_load(args, core::Manager::create_raw_data); });
CMD2_ANY_LIST ("load.raw_start", [](auto, auto& args) { return apply_load(args, core::Manager::create_quiet | core::Manager::create_start | core::Manager::create_raw_data); });
CMD2_ANY_LIST ("load.raw_start_verbose", [](auto, auto& args) { return apply_load(args, core::Manager::create_start | core::Manager::create_raw_data); });
CMD2_ANY_VALUE ("close_low_diskspace", [](auto, auto& arg) { return apply_close_low_diskspace(arg, 99); });
CMD2_ANY_VALUE ("close_low_diskspace.normal", [](auto, auto& arg) { return apply_close_low_diskspace(arg, 3); });
CMD2_ANY_LIST ("download_list", [](auto, auto& args) { return apply_download_list(args); });
// TODO: Deprecate d.multicall2. (6/2026)
CMD2_ANY_LIST ("d.multicall", [](auto, auto& args) { return d_multicall(args); });
CMD2_ANY_LIST ("d.multicall.filtered", [](auto, auto& args) { return d_multicall_filtered(args); });
CMD2_ANY_LIST ("directory.watch.added", [](auto, auto& args) { return directory_watch_added(args); });
CMD2_ANY_LIST ("directory.watch.ready", [](auto, auto& args) { return directory_watch_ready(args); });
rpc::rpc.mark_safe("start_tied");
rpc::rpc.mark_safe("stop_untied");
rpc::rpc.mark_safe("close_untied");
rpc::rpc.mark_safe("remove_untied");
rpc::rpc.mark_safe("close_low_diskspace");
rpc::rpc.mark_safe("close_low_diskspace.normal");
rpc::rpc.mark_safe("download_list");
rpc::rpc.mark_safe("d.multicall");
rpc::rpc.mark_safe("d.multicall.filtered");
}
+161
View File
@@ -0,0 +1,161 @@
#include "config.h"
#include <torrent/data/file.h>
#include <torrent/data/file_list.h>
#include <torrent/data/file_list_iterator.h>
#include "core/manager.h"
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
void
apply_f_set_priority(torrent::File* file, uint32_t value) {
if (value > torrent::PRIORITY_HIGH)
throw torrent::input_error("Invalid value.");
file->set_priority(static_cast<torrent::priority_enum>(value));
}
// TODO: Redundant.
torrent::Object
apply_f_path(torrent::File* file) {
if (file->path()->empty())
return std::string();
torrent::Object result_raw(file->path()->begin()->str());
auto& result = result_raw.as_string();
for (torrent::Path::const_iterator itr = ++file->path()->begin(), last = file->path()->end(); itr != last; itr++)
result += '/' + itr->str();
return result_raw;
}
torrent::Object
apply_f_path_components(torrent::File* file, int output_type) {
auto result_raw = torrent::Object::create_list();
auto& result = result_raw.as_list();
for (const auto& itr : *file->path()) {
switch (output_type) {
case 0: result.push_back(itr.str()); break;
case 1: result.push_back(itr.object_hex()); break;
case 2: result.push_back(itr.object_base64()); break;
case 3: result.push_back(itr.object_base64_as_binary()); break;
case 4: result.push_back(itr.object_as_binary()); break;
case 5: result.push_back(itr.object_utf8_or_base64()); break;
case 6: result.push_back(itr.object_utf8_or_as_binary()); break;
default: throw torrent::input_error("apply_f_path_components(): invalid output type");
};
}
return result_raw;
}
torrent::Object
apply_f_path_depth(torrent::File* file) {
return (int64_t)file->path()->size();
}
torrent::Object
apply_fi_filename_last(torrent::FileListIterator* itr) {
if (itr->file()->path()->empty())
return "EMPTY";
if (itr->depth() >= itr->file()->path()->size())
return "ERROR";
return itr->file()->path()->at(itr->depth()).str();
}
void
initialize_command_file() {
CMD2_FILE("f.is_created", std::bind(&torrent::File::is_created, std::placeholders::_1));
CMD2_FILE("f.is_open", std::bind(&torrent::File::is_open, std::placeholders::_1));
CMD2_FILE("f.is_create_queued", std::bind(&torrent::File::is_create_queued, std::placeholders::_1));
CMD2_FILE("f.is_resize_queued", std::bind(&torrent::File::is_resize_queued, std::placeholders::_1));
CMD2_FILE_VALUE_V("f.set_create_queued", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_create_queued));
CMD2_FILE_VALUE_V("f.set_resize_queued", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_resize_queued));
CMD2_FILE_VALUE_V("f.unset_create_queued", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_create_queued));
CMD2_FILE_VALUE_V("f.unset_resize_queued", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_resize_queued));
CMD2_FILE ("f.prioritize_first", std::bind(&torrent::File::has_flags, std::placeholders::_1, torrent::File::flag_prioritize_first));
CMD2_FILE_V("f.prioritize_first.enable", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_prioritize_first));
CMD2_FILE_V("f.prioritize_first.disable", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_prioritize_first));
CMD2_FILE ("f.prioritize_last", std::bind(&torrent::File::has_flags, std::placeholders::_1, torrent::File::flag_prioritize_last));
CMD2_FILE_V("f.prioritize_last.enable", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_prioritize_last));
CMD2_FILE_V("f.prioritize_last.disable", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_prioritize_last));
CMD2_FILE("f.size_bytes", [](auto* file, auto) { return file->size_bytes(); });
CMD2_FILE("f.size_chunks", [](auto* file, auto) { return file->size_chunks(); });
CMD2_FILE("f.completed_chunks", [](auto* file, auto) { return file->completed_chunks(); });
CMD2_FILE("f.offset", [](auto* file, auto) { return file->offset(); });
CMD2_FILE("f.range_first", [](auto* file, auto) { return file->range_first(); });
CMD2_FILE("f.range_second", [](auto* file, auto) { return file->range_second(); });
CMD2_FILE("f.priority", [](auto* file, auto) { return file->priority(); });
CMD2_FILE_VALUE_V("f.priority.set", [](auto* file, auto v) { apply_f_set_priority(file, v); });
CMD2_FILE("f.path", [](auto* file, auto) { return apply_f_path(file); });
CMD2_FILE("f.path_components", [](auto* file, auto) { return apply_f_path_components(file, 0); });
CMD2_FILE("f.path_components.hex", [](auto* file, auto) { return apply_f_path_components(file, 1); });
CMD2_FILE("f.path_components.base64", [](auto* file, auto) { return apply_f_path_components(file, 2); });
CMD2_FILE("f.path_components.base64_as_binary", [](auto* file, auto) { return apply_f_path_components(file, 3); });
CMD2_FILE("f.path_components.as_binary", [](auto* file, auto) { return apply_f_path_components(file, 4); });
CMD2_FILE("f.path_components.or_base64", [](auto* file, auto) { return apply_f_path_components(file, 5); });
CMD2_FILE("f.path_components.or_as_binary", [](auto* file, auto) { return apply_f_path_components(file, 6); });
CMD2_FILE("f.path_depth", [](auto* file, auto) { return apply_f_path_depth(file); });
CMD2_FILE("f.frozen_path", [](auto* file, auto) { return file->frozen_path().str(); });
CMD2_FILE("f.frozen_path.hex", [](auto* file, auto) { return file->frozen_path().object_hex(); });
CMD2_FILE("f.frozen_path.base64", [](auto* file, auto) { return file->frozen_path().object_base64(); });
CMD2_FILE("f.frozen_path.as_binary", [](auto* file, auto) { return file->frozen_path().object_as_binary(); });
CMD2_FILE("f.frozen_path.or_base64", [](auto* file, auto) { return file->frozen_path().object_utf8_or_base64(); });
CMD2_FILE("f.frozen_path.or_as_binary", [](auto* file, auto) { return file->frozen_path().object_utf8_or_as_binary(); });
CMD2_FILE("f.match_depth_prev", std::bind(&torrent::File::match_depth_prev, std::placeholders::_1));
CMD2_FILE("f.match_depth_next", std::bind(&torrent::File::match_depth_next, std::placeholders::_1));
CMD2_FILE("f.last_touched", std::bind(&torrent::File::last_touched, std::placeholders::_1));
CMD2_FILEITR("fi.filename_last", std::bind(&apply_fi_filename_last, std::placeholders::_1));
CMD2_FILEITR("fi.is_file", std::bind(&torrent::FileListIterator::is_file, std::placeholders::_1));
rpc::rpc.mark_safe("f.path");
rpc::rpc.mark_safe("f.path_components");
rpc::rpc.mark_safe("f.path_depth");
rpc::rpc.mark_safe("f.frozen_path");
rpc::rpc.mark_safe("f.frozen_path.hex");
rpc::rpc.mark_safe("f.frozen_path.base64");
rpc::rpc.mark_safe("f.frozen_path.base64_as_binary");
rpc::rpc.mark_safe("f.frozen_path.as_binary");
rpc::rpc.mark_safe("f.frozen_path.or_base64");
rpc::rpc.mark_safe("f.frozen_path.or_as_binary");
rpc::rpc.mark_safe("f.offset");
rpc::rpc.mark_safe("f.size_bytes");
rpc::rpc.mark_safe("f.size_chunks");
rpc::rpc.mark_safe("f.completed_chunks");
rpc::rpc.mark_safe("f.range_first");
rpc::rpc.mark_safe("f.range_second");
rpc::rpc.mark_safe("f.priority");
rpc::rpc.mark_safe("f.priority.set");
rpc::rpc.mark_safe("f.is_created");
rpc::rpc.mark_safe("f.is_open");
rpc::rpc.mark_safe("f.is_create_queued");
rpc::rpc.mark_safe("f.is_resize_queued");
rpc::rpc.mark_safe("f.prioritize_first");
rpc::rpc.mark_safe("f.prioritize_first.enable");
rpc::rpc.mark_safe("f.prioritize_first.disable");
rpc::rpc.mark_safe("f.prioritize_last");
rpc::rpc.mark_safe("f.prioritize_last.enable");
rpc::rpc.mark_safe("f.prioritize_last.disable");
rpc::rpc.mark_safe("f.last_touched");
rpc::rpc.mark_safe("f.match_depth_prev");
rpc::rpc.mark_safe("f.match_depth_next");
rpc::rpc.mark_safe("fi.filename_last");
rpc::rpc.mark_safe("fi.is_file");
}
+405
View File
@@ -0,0 +1,405 @@
#include "config.h"
#include <torrent/download/resource_manager.h>
#include <torrent/download/choke_group.h>
#include <torrent/download/choke_queue.h>
#include <torrent/utils/log.h>
#include <torrent/utils/option_strings.h>
#include "ui/root.h"
#include "rpc/parse.h"
#include "rpc/parse_commands.h"
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
// For cg_d_group.
#include "core/download.h"
#define LT_LOG_SUBSYSTEM(log_fmt, ...) \
lt_log_print_subsystem(torrent::LOG_TORRENT_INFO, "choke_queue", log_fmt, __VA_ARGS__);
// A hack to allow testing of the new choke_group API without the
// working parts present.
#define USE_CHOKE_GROUP 0
#if USE_CHOKE_GROUP
int64_t
cg_get_index(const torrent::Object& raw_args) {
const torrent::Object& arg = (raw_args.is_list() && !raw_args.as_list().empty()) ? raw_args.as_list().front() : raw_args;
int64_t index = 0;
if (arg.is_string()) {
if (!rpc::parse_whole_value_nothrow(arg.as_string().c_str(), &index))
return torrent::resource_manager()->group_index_of(arg.as_string());
} else {
index = arg.as_value();
}
if (index < 0)
index = (int64_t)torrent::resource_manager()->group_size() + index;
return std::min<uint64_t>(index, torrent::resource_manager()->group_size());
}
torrent::choke_group*
cg_get_group(const torrent::Object& raw_args) {
return torrent::resource_manager()->group_at(cg_get_index(raw_args));
}
int64_t
cg_d_group(core::Download* download) {
return torrent::resource_manager()->entry_at(download->main()).group();
}
const std::string&
cg_d_group_name(core::Download* download) {
return torrent::resource_manager()->group_at(torrent::resource_manager()->entry_at(download->main()).group())->name();
}
void
cg_d_group_set(core::Download* download, const torrent::Object& arg) {
torrent::resource_manager()->set_group(torrent::resource_manager()->find_throw(download->main()), cg_get_index(arg));
}
torrent::Object
apply_cg_list() {
torrent::Object::list_type result;
for (torrent::ResourceManager::group_iterator
itr = torrent::resource_manager()->group_begin(),
last = torrent::resource_manager()->group_end(); itr != last; itr++)
result.push_back((*itr)->name());
return torrent::Object::from_list(result);
}
torrent::Object
apply_cg_insert(const std::string& arg) {
int64_t dummy;
if (rpc::parse_whole_value_nothrow(arg.c_str(), &dummy))
throw torrent::input_error("Cannot use a value string as choke group name.");
torrent::resource_manager()->push_group(arg);
return torrent::Object();
}
torrent::Object
apply_cg_all_update_balance(bool is_up) {
LT_LOG_SUBSYSTEM("apply update balance: resource_manager is_up:%i", (int)is_up);
for (torrent::ResourceManager::group_iterator
itr = torrent::resource_manager()->group_begin(),
last = torrent::resource_manager()->group_end(); itr != last; itr++) {
if (is_up)
itr->up_queue()->balance();
else
itr->down_queue()->balance();
}
return torrent::Object();
}
//
// The hacked version:
//
#else
std::vector<torrent::choke_group*> cg_list_hack;
int64_t
cg_get_index(const torrent::Object& raw_args) {
const torrent::Object& arg = (raw_args.is_list() && !raw_args.as_list().empty()) ? raw_args.as_list().front() : raw_args;
int64_t index = 0;
if (arg.is_string()) {
if (!rpc::parse_whole_value_nothrow(arg.as_string().c_str(), &index)) {
auto itr = std::find_if(cg_list_hack.begin(), cg_list_hack.end(), [&arg](torrent::choke_group* cg) { return arg.as_string() == cg->name(); });
if (itr == cg_list_hack.end())
throw torrent::input_error("Choke group not found.");
return std::distance(cg_list_hack.begin(), itr);
}
} else {
index = arg.as_value();
}
if (index < 0)
index = (int64_t)cg_list_hack.size() + index;
if ((size_t)index >= cg_list_hack.size())
throw torrent::input_error("Choke group not found.");
return index;
}
torrent::choke_group*
cg_get_group(const torrent::Object& raw_args) {
int64_t index = cg_get_index(raw_args);
if ((size_t)index >= cg_list_hack.size())
throw torrent::input_error("Choke group not found.");
return cg_list_hack.at(index);
}
int64_t cg_d_group(core::Download* download) { return download->group(); }
const std::string& cg_d_group_name(core::Download* download) {
return cg_list_hack.at(download->group())->name();
}
void cg_d_group_set(core::Download* download, const torrent::Object& arg) { download->set_group(cg_get_index(arg)); }
torrent::Object
apply_cg_list() {
torrent::Object::list_type result;
for (auto itr : cg_list_hack)
result.push_back(itr->name());
return torrent::Object::from_list(result);
}
int
cg_get_can_unchoke(torrent::choke_queue* cq) {
return cq->max_unchoked_signed() - (int)cq->size_unchoked();
}
torrent::Object
apply_cg_insert(const std::string& arg) {
int64_t dummy;
if (rpc::parse_whole_value_nothrow(arg.c_str(), &dummy))
throw torrent::input_error("Cannot use a value string as choke group name.");
if (arg.empty() || std::any_of(cg_list_hack.begin(), cg_list_hack.end(), [&arg](auto cg) { return arg == cg->name(); }))
throw torrent::input_error("Duplicate name for choke group.");
cg_list_hack.push_back(new torrent::choke_group());
cg_list_hack.back()->set_name(arg);
cg_list_hack.back()->up_queue()->set_heuristics(torrent::HEURISTICS_UPLOAD_LEECH);
cg_list_hack.back()->down_queue()->set_heuristics(torrent::HEURISTICS_DOWNLOAD_LEECH);
return torrent::Object();
}
torrent::Object
apply_cg_index_of(const std::string& arg) {
auto itr = std::find_if(cg_list_hack.begin(), cg_list_hack.end(), [&arg](torrent::choke_group* cg) { return arg == cg->name(); });
if (itr == cg_list_hack.end())
throw torrent::input_error("Choke group not found.");
return std::distance(cg_list_hack.begin(), itr);
}
torrent::Object
apply_cg_all_update_balance(bool is_up) {
LT_LOG_SUBSYSTEM("apply update balance: hack is_up:%i", (int)is_up);
for (auto itr : cg_list_hack) {
if (is_up)
itr->up_queue()->balance();
else
itr->down_queue()->balance();
}
return torrent::Object();
}
//
// End of choke group hack.
//
#endif
torrent::Object
apply_cg_max_set(const torrent::Object::list_type& args, bool is_up) {
if (args.size() != 2)
throw torrent::input_error("Incorrect number of arguments.");
int64_t second_arg = 0;
rpc::parse_whole_value(args.back().as_string().c_str(), &second_arg);
if (is_up)
cg_get_group(args.front())->up_queue()->set_max_unchoked(second_arg);
else
cg_get_group(args.front())->down_queue()->set_max_unchoked(second_arg);
return torrent::Object();
}
torrent::Object
apply_cg_heuristics_set(const torrent::Object::list_type& args, bool is_up) {
if (args.size() != 2)
throw torrent::input_error("Incorrect number of arguments.");
int t = torrent::option_find_string(is_up ? torrent::OPTION_CHOKE_HEURISTICS_UPLOAD : torrent::OPTION_CHOKE_HEURISTICS_DOWNLOAD,
args.back().as_string().c_str());
if (is_up)
cg_get_group(args.front())->up_queue()->set_heuristics((torrent::choke_queue::heuristics_enum)t);
else
cg_get_group(args.front())->down_queue()->set_heuristics((torrent::choke_queue::heuristics_enum)t);
return torrent::Object();
}
torrent::Object
apply_cg_tracker_mode_set(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Incorrect number of arguments.");
int t = torrent::option_find_string(torrent::OPTION_TRACKER_MODE, args.back().as_string().c_str());
cg_get_group(args.front())->set_tracker_mode((torrent::choke_group::tracker_mode_enum)t);
return torrent::Object();
}
#define CG_GROUP_AT() std::bind(&cg_get_group, std::placeholders::_2)
#define CHOKE_GROUP(direction) std::bind(direction, CG_GROUP_AT())
/*
<cg_index> -> '0'..'(choke_group.size)'
-> '-1'..'-(choke_group.size)'
-> '<group_name>'
(choke_group.list) -> List of group names.
(choke_group.size) -> Number of groups.
(choke_group.insert,"group_name")
Adds a new group with default settings, use index '-1' to accessing it
immediately afterwards.
(choke_group.index_of,"group_name") -> <group_index>
Throws if the group name was not found.
(choke_group.general.size,<cg_index>) -> <size>
Number of torrents in this group.
(choke_group.tracker.mode,<cg_index>) -> "tracker_mode"
(choke_group.tracker.mode.set,<cg_index>,"tracker_mode")
Decide on how aggressive a tracker should be, see
'strings.tracker_mode' for list of available options
(choke_group.up.rate,<cg_index>) -> <bytes/second>
(choke_group.down.rate,<cg_index>) -> <bytes/second>
Upload / download rate for the aggregate of all torrents in this
particular group.
(choke_group.up.max,<cg_index>) -> <max_upload_slots>
(choke_group.up.max.unlimited,<cg_index>) -> <max_upload_slots>
(choke_group.up.max.set,<cg_index>, <max_upload_slots>)
(choke_group.down.max,<cg_index>) -> <max_download_slots>
(choke_group.down.max.unlimited,<cg_index>) -> <max_download_slots>
(choke_group.down.max.set,<cg_index>, <max_download_slots)
Number of unchoked upload / download peers regulated on a group basis.
(choke_group.up.total,<cg_index>) -> <number of queued and unchoked interested peers>
(choke_group.up.queued,<cg_index>) -> <number of queued interested peers>
(choke_group.up.unchoked,<cg_index>) -> <number of unchoked uploads>
(choke_group.down.total,<cg_index>) -> <number of queued and unchoked interested peers>
(choke_group.down.queued,<cg_index>) -> <number of queued interested peers>
(choke_group.down.unchoked,<cg_index>) -> <number of unchoked uploads>
(choke_group.up.heuristics,<cg_index>) -> "heuristics"
(choke_group.up.heuristics.set,<cg_index>,"heuristics")
(choke_group.down.heuristics,<cg_index>) -> "heuristics"
(choke_group.down.heuristics.set,<cg_index>,"heuristics")
Heuristics are used for deciding what peers to choke and unchoke, see
'strings.choke_heuristics{,_download,_upload}' for a list of available
options.
(d.group) -> <choke_group_index>
(d.group.name) -> "choke_group_name"
(d.group.set,<cg_index>)
*/
void
initialize_command_groups() {
CMD_ANY ("choke_group.list", std::bind(&apply_cg_list));
CMD_ANY_STRING ("choke_group.insert", std::bind(&apply_cg_insert, std::placeholders::_2));
#if USE_CHOKE_GROUP
CMD_ANY ("choke_group.size", std::bind(&torrent::ResourceManager::group_size, torrent::resource_manager()));
CMD_ANY_STRING ("choke_group.index_of", std::bind(&torrent::ResourceManager::group_index_of, torrent::resource_manager(), std::placeholders::_2));
#else
apply_cg_insert("default");
CMD_ANY ("choke_group.size", std::bind(&std::vector<torrent::choke_group*>::size, cg_list_hack));
CMD_ANY_STRING ("choke_group.index_of", std::bind(&apply_cg_index_of, std::placeholders::_2));
#endif
// Commands specific for a group. Supports as the first argument the
// name, the index or a negative index.
CMD_ANY ("choke_group.general.size", std::bind(&torrent::choke_group::size, CG_GROUP_AT()));
CMD_ANY ("choke_group.tracker.mode", [](auto, auto arg) { return torrent::option_to_str_or_throw(torrent::OPTION_TRACKER_MODE, cg_get_group(arg)->tracker_mode()); });
CMD_ANY_LIST ("choke_group.tracker.mode.set", [](auto, auto arg) { return apply_cg_tracker_mode_set(arg); });
CMD_ANY ("choke_group.all.up.update_balance", std::bind(&apply_cg_all_update_balance, true));
CMD_ANY ("choke_group.all.down.update_balance", std::bind(&apply_cg_all_update_balance, false));
CMD_ANY ("choke_group.up.rate", std::bind(&torrent::choke_group::up_rate, CG_GROUP_AT()));
CMD_ANY ("choke_group.down.rate", std::bind(&torrent::choke_group::down_rate, CG_GROUP_AT()));
CMD_ANY ("choke_group.up.max.unlimited", std::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::up_queue)));
CMD_ANY ("choke_group.up.max", std::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::up_queue)));
CMD_ANY_LIST ("choke_group.up.max.set", std::bind(&apply_cg_max_set, std::placeholders::_2, true));
CMD_ANY ("choke_group.up.total", std::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::up_queue)));
CMD_ANY ("choke_group.up.queued", std::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::up_queue)));
CMD_ANY ("choke_group.up.unchoked", std::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::up_queue)));
CMD_ANY ("choke_group.up.heuristics", [](auto, auto arg) { return torrent::option_to_str_or_throw(torrent::OPTION_CHOKE_HEURISTICS, cg_get_group(arg)->up_queue()->heuristics()); });
CMD_ANY_LIST ("choke_group.up.heuristics.set", [](auto, auto arg) { return apply_cg_heuristics_set(arg, true); });
CMD_ANY ("choke_group.down.max.unlimited", std::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::down_queue)));
CMD_ANY ("choke_group.down.max", std::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::down_queue)));
CMD_ANY_LIST ("choke_group.down.max.set", std::bind(&apply_cg_max_set, std::placeholders::_2, false));
CMD_ANY ("choke_group.down.total", std::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::down_queue)));
CMD_ANY ("choke_group.down.queued", std::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::down_queue)));
CMD_ANY ("choke_group.down.unchoked", std::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::down_queue)));
CMD_ANY ("choke_group.down.heuristics", [](auto, auto arg) { return torrent::option_to_str_or_throw(torrent::OPTION_CHOKE_HEURISTICS, cg_get_group(arg)->down_queue()->heuristics()); });
CMD_ANY_LIST ("choke_group.down.heuristics.set", [](auto, auto arg) { return apply_cg_heuristics_set(arg, false); });
rpc::rpc.mark_safe("choke_group.list");
rpc::rpc.mark_safe("choke_group.size");
rpc::rpc.mark_safe("choke_group.index_of");
rpc::rpc.mark_safe("choke_group.general.size");
rpc::rpc.mark_safe("choke_group.tracker.mode");
rpc::rpc.mark_safe("choke_group.up.rate");
rpc::rpc.mark_safe("choke_group.down.rate");
rpc::rpc.mark_safe("choke_group.up.max");
rpc::rpc.mark_safe("choke_group.up.max.unlimited");
rpc::rpc.mark_safe("choke_group.up.total");
rpc::rpc.mark_safe("choke_group.up.queued");
rpc::rpc.mark_safe("choke_group.up.unchoked");
rpc::rpc.mark_safe("choke_group.up.heuristics");
rpc::rpc.mark_safe("choke_group.down.max");
rpc::rpc.mark_safe("choke_group.down.max.unlimited");
rpc::rpc.mark_safe("choke_group.down.total");
rpc::rpc.mark_safe("choke_group.down.queued");
rpc::rpc.mark_safe("choke_group.down.unchoked");
rpc::rpc.mark_safe("choke_group.down.heuristics");
}
+40
View File
@@ -0,0 +1,40 @@
#include "config.h"
#include <torrent/exceptions.h>
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
void initialize_command_dynamic();
void initialize_command_download();
void initialize_command_events();
void initialize_command_file();
void initialize_command_ip();
void initialize_command_peer();
void initialize_command_local();
void initialize_command_logging();
void initialize_command_network();
void initialize_command_groups();
void initialize_command_throttle();
void initialize_command_tracker();
void initialize_command_scheduler();
void initialize_command_ui();
void
initialize_commands() {
initialize_command_dynamic();
initialize_command_events();
initialize_command_network();
initialize_command_groups();
initialize_command_local();
initialize_command_logging();
initialize_command_ui();
initialize_command_download();
initialize_command_file();
initialize_command_ip();
initialize_command_peer();
initialize_command_throttle();
initialize_command_tracker();
initialize_command_scheduler();
}
+170
View File
@@ -0,0 +1,170 @@
#ifndef RTORRENT_UTILS_COMMAND_HELPERS_H
#define RTORRENT_UTILS_COMMAND_HELPERS_H
#include "rpc/command.h"
#include "rpc/parse_commands.h"
#include "rpc/object_storage.h"
void initialize_commands();
//
// Aliases with CMD_* for the below
//
#define CMD_ANY(key, slot) CMD2_ANY(key, slot)
#define CMD_ANY_P(key, slot) CMD2_ANY_P(key, slot)
#define CMD_REDIRECT(key, slot) CMD2_REDIRECT(key, slot)
#define CMD_REDIRECT_NO_EXPORT(key, slot) CMD2_REDIRECT_NO_EXPORT(key, slot)
#define CMD_ANY_STRING(key, slot) CMD2_ANY_STRING(key, slot)
#define CMD_ANY_STRING_V(key, slot) CMD2_ANY_STRING_V(key, slot)
#define CMD_ANY_LIST(key, slot) CMD2_ANY_LIST(key, slot)
#define CMD_VAR_VALUE(key, value) CMD2_VAR_VALUE(key, value)
#define CMD_VAR_BOOL(key, value) CMD2_VAR_BOOL(key, value)
#define CMD_VAR_STRING(key, value) CMD2_VAR_STRING(key, value)
#define CMD_VAR_C_STRING(key, value) CMD2_VAR_C_STRING(key, value)
#define CMD_VAR_LIST(key) CMD2_VAR_LIST(key)
#define CMD_ANY_V(key, slot) CMD2_ANY_V(key, slot)
#define CMD_ANY_VALUE_V(key, slot) CMD2_ANY_VALUE_V(key, slot)
//
// New std::function based command_base helper functions:
//
#define CMD2_A_FUNCTION(key, function, slot, parm, doc) \
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::function>::type>(key, slot, &rpc::function, \
rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_rpc, NULL, NULL);
#define CMD2_A_FUNCTION_PRIVATE(key, function, slot, parm, doc) \
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::function>::type>(key, slot, &rpc::function, \
rpc::CommandMap::flag_dont_delete, NULL, NULL);
#define CMD2_ANY(key, slot) CMD2_A_FUNCTION(key, command_base_call<rpc::target_type>, slot, "i:", "")
#define CMD2_ANY_P(key, slot) CMD2_A_FUNCTION_PRIVATE(key, command_base_call<rpc::target_type>, slot, "i:", "")
#define CMD2_ANY_VOID(key, slot) CMD2_A_FUNCTION(key, command_base_call<rpc::target_type>, object_convert_void(slot), "i:", "")
#define CMD2_ANY_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<rpc::target_type>, object_convert_void(slot), "i:", "")
#define CMD2_ANY_L(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<rpc::target_type>, slot, "A:", "")
#define CMD2_ANY_VALUE(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<rpc::target_type>, slot, "i:i", "")
#define CMD2_ANY_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<rpc::target_type>, object_convert_void(slot), "i:i", "")
#define CMD2_ANY_VALUE_KB(key, slot) CMD2_A_FUNCTION(key, command_base_call_value_kb<rpc::target_type>, object_convert_void(slot), "i:i", "")
#define CMD2_ANY_STRING(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<rpc::target_type>, slot, "i:s", "")
#define CMD2_ANY_STRING_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<rpc::target_type>, object_convert_void(slot), "i:s", "")
#define CMD2_ANY_LIST(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<rpc::target_type>, slot, "i:", "")
#define CMD2_DL(key, slot) CMD2_A_FUNCTION(key, command_base_call<core::Download*>, slot, "i:", "")
#define CMD2_DL_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<core::Download*>, object_convert_void(slot), "i:", "")
#define CMD2_DL_VALUE(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<core::Download*>, slot, "i:", "")
#define CMD2_DL_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<core::Download*>, object_convert_void(slot), "i:", "")
#define CMD2_DL_STRING(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<core::Download*>, slot, "i:", "")
#define CMD2_DL_STRING_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_string<core::Download*>, object_convert_void(slot), "i:", "")
#define CMD2_DL_LIST(key, slot) CMD2_A_FUNCTION(key, command_base_call_list<core::Download*>, slot, "i:", "")
#define CMD2_DL_VALUE_P(key, slot) CMD2_A_FUNCTION_PRIVATE(key, command_base_call_value<core::Download*>, slot, "i:", "")
#define CMD2_DL_STRING_P(key, slot) CMD2_A_FUNCTION_PRIVATE(key, command_base_call_string<core::Download*>, slot, "i:", "")
#define CMD2_FILE(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::File*>, slot, "i:", "")
#define CMD2_FILE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::File*>, object_convert_void(slot), "i:", "")
#define CMD2_FILE_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<torrent::File*>, object_convert_void(slot), "i:i", "")
#define CMD2_FILEITR(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::FileListIterator*>, slot, "i:", "")
#define CMD2_PEER(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::Peer*>, slot, "i:", "")
#define CMD2_PEER_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::Peer*>, object_convert_void(slot), "i:", "")
#define CMD2_PEER_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<torrent::Peer*>, object_convert_void(slot), "i:i", "")
#define CMD2_TRACKER(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::tracker::Tracker*>, slot, "i:", "")
#define CMD2_TRACKER_V(key, slot) CMD2_A_FUNCTION(key, command_base_call<torrent::tracker::Tracker*>, object_convert_void(slot), "i:", "")
#define CMD2_TRACKER_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_value<torrent::tracker::Tracker*>, object_convert_void(slot), "i:i", "")
#define CMD2_VAR_BOOL(key, value) \
control->object_storage()->insert_c_str(key, int64_t(value), rpc::object_storage::flag_bool_type); \
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
torrent::raw_string::from_c_str(key))); \
CMD2_ANY_VALUE(key ".set", std::bind(&rpc::object_storage::set_bool, control->object_storage(), \
torrent::raw_string::from_c_str(key), std::placeholders::_2));
#define CMD2_VAR_VALUE(key, value) \
control->object_storage()->insert_c_str(key, int64_t(value), rpc::object_storage::flag_value_type); \
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
torrent::raw_string::from_c_str(key))); \
CMD2_ANY_VALUE(key ".set", std::bind(&rpc::object_storage::set_value, control->object_storage(), \
torrent::raw_string::from_c_str(key), std::placeholders::_2));
#define CMD2_VAR_STRING(key, value) \
control->object_storage()->insert_c_str(key, value, rpc::object_storage::flag_string_type); \
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
torrent::raw_string::from_c_str(key))); \
CMD2_ANY_STRING(key ".set", std::bind(&rpc::object_storage::set_string, control->object_storage(), \
torrent::raw_string::from_c_str(key), std::placeholders::_2));
#define CMD2_VAR_C_STRING(key, value) \
control->object_storage()->insert_c_str(key, value, rpc::object_storage::flag_string_type); \
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
torrent::raw_string::from_c_str(key)));
#define CMD2_VAR_LIST(key) \
control->object_storage()->insert_c_str(key, torrent::Object::create_list(), rpc::object_storage::flag_list_type); \
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
torrent::raw_string::from_c_str(key))); \
CMD2_ANY_LIST(key ".set", std::bind(&rpc::object_storage::set_list, control->object_storage(), \
torrent::raw_string::from_c_str(key), std::placeholders::_2)); \
CMD2_ANY_VOID(key ".push_back", std::bind(&rpc::object_storage::list_push_back, control->object_storage(), \
torrent::raw_string::from_c_str(key), std::placeholders::_2));
#define CMD2_FUNC_SINGLE(key, cmds) \
CMD2_ANY(key, std::bind(&rpc::command_function_call_object, torrent::Object(torrent::raw_string::from_c_str(cmds)), \
std::placeholders::_1, std::placeholders::_2));
#define CMD2_REDIRECT(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_rpc | rpc::CommandMap::flag_dont_delete);
#define CMD2_REDIRECT_NO_EXPORT(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_dont_delete);
#define CMD2_REDIRECT_MUTABLE(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_rpc);
#define CMD2_REDIRECT_STR(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_rpc);
#define CMD2_REDIRECT_STR_NO_EXPORT(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, 0);
#define CMD2_REDIRECT_FILE(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_rpc | rpc::CommandMap::flag_file_target | rpc::CommandMap::flag_dont_delete);
#define CMD2_REDIRECT_TRACKER(from_key, to_key) \
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_rpc | rpc::CommandMap::flag_tracker_target | rpc::CommandMap::flag_dont_delete);
//
// Conversion of return types:
//
template <typename Functor, typename Result>
struct object_convert_type;
template <typename Functor>
struct object_convert_type<Functor, void> {
template <typename Signature> struct result {
typedef torrent::Object type;
};
object_convert_type(Functor s) : m_slot(s) {}
torrent::Object operator () () { m_slot(); return torrent::Object(); }
template <typename Arg1>
torrent::Object operator () (Arg1& arg1) { m_slot(arg1); return torrent::Object(); }
template <typename Arg1, typename Arg2>
torrent::Object operator () (const Arg1& arg1) { m_slot(arg1); return torrent::Object(); }
template <typename Arg1, typename Arg2>
torrent::Object operator () (Arg1& arg1, Arg2& arg2) { m_slot(arg1, arg2); return torrent::Object(); }
template <typename Arg1, typename Arg2>
torrent::Object operator () (const Arg1& arg1, const Arg2& arg2) { m_slot(arg1, arg2); return torrent::Object(); }
Functor m_slot;
};
template <typename T>
object_convert_type<T, void>
object_convert_void(T f) { return f; }
#endif
+378
View File
@@ -0,0 +1,378 @@
#include "config.h"
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <torrent/peer/peer_list.h>
#include <torrent/utils/log.h>
#include <torrent/utils/option_strings.h>
#include "globals.h"
#include "command_helpers.h"
bool ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address_end);
torrent::Object
apply_ip_tables_insert_table(const std::string& args) {
if (ip_tables.find(args) != ip_tables.end())
throw torrent::input_error("IP table already exists.");
ip_tables.insert(args);
return torrent::Object();
}
torrent::Object
apply_ip_tables_size_data(const std::string& args) {
rpc::ip_table_list::const_iterator itr = ip_tables.find(args);
if (itr == ip_tables.end())
throw torrent::input_error("IP table does not exist.");
uint32_t size = itr->table.sizeof_data();
return size;
}
torrent::Object
apply_ip_tables_get(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Incorrect number of arguments.");
torrent::Object::list_const_iterator args_itr = args.begin();
const std::string& name = (args_itr++)->as_string();
const std::string& address = (args_itr++)->as_string();
uint32_t address_start;
uint32_t address_end;
rpc::ip_table_list::iterator table_itr = ip_tables.find(name);
if (table_itr == ip_tables.end())
throw torrent::input_error("Could not find ip table.");
if (!ipv4_range_parse(address.c_str(), &address_start, &address_end))
throw torrent::input_error("Invalid address format.");
if(!table_itr->table.defined(address_start, address_end))
throw torrent::input_error("No value defined for specified IP(s).");
return table_itr->table.at(address_start, address_end);
}
torrent::Object
apply_ip_tables_add_address(const torrent::Object::list_type& args) {
if (args.size() != 3)
throw torrent::input_error("Incorrect number of arguments.");
torrent::Object::list_const_iterator args_itr = args.begin();
const std::string& name = (args_itr++)->as_string();
const std::string& address = (args_itr++)->as_string();
const std::string& value_str = (args_itr++)->as_string();
int value;
if (value_str == "block")
value = 1;
else
throw torrent::input_error("Invalid value.");
rpc::ip_table_list::iterator table_itr = ip_tables.find(name);
if (table_itr == ip_tables.end())
throw torrent::input_error("Could not find ip table.");
uint32_t address_start;
uint32_t address_end;
if (ipv4_range_parse(address.c_str(), &address_start, &address_end))
table_itr->table.insert(address_start, address_end, value);
else
throw torrent::input_error("Invalid address format.");
return torrent::Object();
}
//
// IPv4 filter functions:
//
///////////////////////////////////////////////////////////
// IPV4_RANGE_PARSE parses string into an ip range
//
// should be compatible with lines in p2p files
// everything in address before colon is ignored
//
// ip range can be single ip in which case start=end
// ip range can be cidr notation a.b.c.d/e
// ip range can be explicit range like in p2p line a.b.c.d-w.x.y.z
//
// returns false if line does not contain valid ip or ip range
// address_start and address_end will contain start and end ip
//
// addresses parsed are returned in host byte order
// to get network byte order call htonl(address)
///////////////////////////////////////////////////////////
bool
ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address_end) {
// same length as buffer used to do reads so no worries about overflow
char address_copy[4096];
bool valid = false;
char address_start_str[20];
int address_start_index=0;
struct sockaddr_in sa_start;
*address_start=0;
*address_end=0;
// get rid of everything after '#' comments
// copy everything up to '#' to address_copy and work from there
while(address[address_start_index] != '#' && address[address_start_index] != '\r' &&
address[address_start_index] != '\n' && address[address_start_index] != '\0' &&
address_start_index < 4096 ) {
address_copy[address_start_index] = address[address_start_index];
address_start_index++;
}
address_copy[address_start_index] = '\0';
address_start_index=0;
// skip everything up to and including last ':' character and whitespace
const char* addr = strrchr(address_copy, ':');
addr = (addr == NULL) ? address_copy : addr + 1;
while(addr[0] == ' ' || addr[0] == '\t')
addr++;
while(((addr[0] >= '0' && addr[0] <= '9') || addr[0] == '.') && address_start_index < 19) {
address_start_str[address_start_index] = addr[0];
address_start_index++;
addr++;
}
address_start_str[address_start_index] = '\0';
if(strchr(addr, '-') != NULL) {
// explicit range
char address_end_str[20];
int address_end_index=0;
struct sockaddr_in sa_end;
while(addr[0] == '-' || addr[0] == ' ' || addr[0] == '\t')
addr++;
while(((addr[0] >= '0' && addr[0] <= '9') || addr[0] == '.') && address_end_index < 19) {
address_end_str[address_end_index] = addr[0];
address_end_index++;
addr++;
}
address_end_str[address_end_index] = '\0';
if(inet_pton(AF_INET, address_start_str, &(sa_start.sin_addr)) != 0 && inet_pton(AF_INET, address_end_str, &(sa_end.sin_addr)) != 0) {
*address_start = ntohl(sa_start.sin_addr.s_addr);
*address_end = ntohl(sa_end.sin_addr.s_addr);
if(*address_start <= *address_end)
valid=true;
}
} else if(strchr(addr, '/') != NULL) {
// cidr range
char mask_bits_str[20];
int mask_bits_index=0;
uint32_t mask_bits;
while(addr[0] == '/' || addr[0] == ' ' || addr[0] == '\t')
addr++;
while( (addr[0] >= '0' && addr[0] <= '9') && mask_bits_index < 19) {
mask_bits_str[mask_bits_index] = addr[0];
mask_bits_index++;
addr++;
}
mask_bits_str[mask_bits_index] = '\0';
if(inet_pton(AF_INET, address_start_str, &(sa_start.sin_addr)) != 0 && sscanf(mask_bits_str, "%u", &mask_bits) != 0) {
if(mask_bits <=32) {
uint32_t ip=ntohl(sa_start.sin_addr.s_addr);
uint32_t mask=0;
uint32_t end_mask=0;
if (mask_bits == 0) {
mask = 0;
end_mask = ~(uint32_t)0;
} else {
mask = (~mask) << (32-mask_bits);
end_mask = (~end_mask) >> mask_bits;
}
*address_start = ip & mask;
*address_end = (ip & mask) | end_mask;
valid=true;
}
}
} else {
// single ip
if(inet_pton(AF_INET, address_start_str, &(sa_start.sin_addr)) != 0) {
*address_start = ntohl(sa_start.sin_addr.s_addr);
*address_end = *address_start;
valid=true;
}
}
return valid;
}
///////////////////////////////////////////////////////////
// IPV4_FILTER_PARSE
//
// should now be compatible with lines in p2p files
//
// addresses in table MUST be in host byte order
// ntohl is called after parsing ip address(es)
///////////////////////////////////////////////////////////
void
ipv4_filter_parse(const char* address, int value) {
uint32_t address_start;
uint32_t address_end;
if (ipv4_range_parse(address, &address_start, &address_end) ) {
torrent::PeerList::ipv4_filter()->insert(address_start, address_end, value);
char start_str[INET_ADDRSTRLEN];
char end_str[INET_ADDRSTRLEN];
uint32_t net_start = htonl(address_start);
uint32_t net_end = htonl(address_end);
inet_ntop(AF_INET, &net_start, start_str, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &net_end, end_str, INET_ADDRSTRLEN);
lt_log_print(torrent::LOG_CONNECTION_FILTER, "Adding ip filter for %s-%s.", start_str, end_str);
}
}
torrent::Object
apply_ipv4_filter_size_data() {
return torrent::PeerList::ipv4_filter()->sizeof_data();
}
torrent::Object
apply_ipv4_filter_get(const std::string& args) {
uint32_t address_start;
uint32_t address_end;
if (!ipv4_range_parse(args.c_str(), &address_start, &address_end))
throw torrent::input_error("Invalid address format.");
if(!torrent::PeerList::ipv4_filter()->defined(address_start, address_end))
throw torrent::input_error("No value defined for specified IP(s).");
return torrent::PeerList::ipv4_filter()->at(address_start, address_end);
}
torrent::Object
apply_ipv4_filter_add_address(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Incorrect number of arguments.");
ipv4_filter_parse(args.front().as_string().c_str(),
torrent::option_find_string(torrent::OPTION_IP_FILTER, args.back().as_string().c_str()));
return torrent::Object();
}
torrent::Object
apply_ipv4_filter_load(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Incorrect number of arguments.");
std::string filename = args.front().as_string();
std::string value_name = args.back().as_string();
int value = torrent::option_find_string(torrent::OPTION_IP_FILTER, value_name.c_str());
std::fstream file(expand_path(filename).c_str(), std::ios::in);
if (!file.is_open())
throw torrent::input_error("Could not open ip filter file: " + filename);
unsigned int lineNumber = 0;
char buffer[4096];
try {
while (file.good() && !file.getline(buffer, 4096).fail()) {
if (file.gcount() == 0)
throw torrent::internal_error("parse_command_file(...) file.gcount() == 0.");
lineNumber++;
if (buffer[0] == '\0' || buffer[0] == '#')
continue;
ipv4_filter_parse(buffer, value);
}
} catch (torrent::input_error& e) {
snprintf(buffer, 2048, "Error in ip filter file: %s:%u: %s", filename.c_str(), lineNumber, e.what());
throw torrent::input_error(buffer);
}
lt_log_print(torrent::LOG_CONNECTION_FILTER, "loaded %u %s address blocks (%u kb in-memory) from '%s'",
lineNumber,
value_name.c_str(),
torrent::PeerList::ipv4_filter()->sizeof_data() / 1024,
filename.c_str());
return torrent::Object();
}
torrent::Object
apply_ipv4_filter_dump() {
torrent::Object raw_result = torrent::Object::create_list();
torrent::Object::list_type& result = raw_result.as_list();
torrent::ipv4_table::range_map_type range_map = torrent::PeerList::ipv4_filter()->range_map;
torrent::ipv4_table::range_map_type::iterator iter = range_map.begin();
while(iter != range_map.end()) {
char buffer[64];
uint32_t address_start = iter->first;
uint32_t address_end = (iter->second).first;
int value = (iter->second).second;
char start_str[INET_ADDRSTRLEN];
char end_str[INET_ADDRSTRLEN];
uint32_t net_start = htonl(address_start);
uint32_t net_end = htonl(address_end);
inet_ntop(AF_INET, &net_start, start_str, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &net_end, end_str, INET_ADDRSTRLEN);
snprintf(buffer, 64, "%s-%s %s", start_str, end_str, torrent::option_to_c_str_or_throw(torrent::OPTION_IP_FILTER, value));
result.push_back((std::string)buffer);
iter++;
}
return raw_result;
}
void
initialize_command_ip() {
CMD2_ANY_STRING ("ip_tables.insert_table", std::bind(&apply_ip_tables_insert_table, std::placeholders::_2));
CMD2_ANY_STRING ("ip_tables.size_data", std::bind(&apply_ip_tables_size_data, std::placeholders::_2));
CMD2_ANY_LIST ("ip_tables.get", std::bind(&apply_ip_tables_get, std::placeholders::_2));
CMD2_ANY_LIST ("ip_tables.add_address", std::bind(&apply_ip_tables_add_address, std::placeholders::_2));
CMD2_ANY ("ipv4_filter.size_data", std::bind(&apply_ipv4_filter_size_data));
CMD2_ANY_STRING ("ipv4_filter.get", std::bind(&apply_ipv4_filter_get, std::placeholders::_2));
CMD2_ANY_LIST ("ipv4_filter.add_address", std::bind(&apply_ipv4_filter_add_address, std::placeholders::_2));
CMD2_ANY_LIST ("ipv4_filter.load", std::bind(&apply_ipv4_filter_load, std::placeholders::_2));
CMD2_ANY_LIST ("ipv4_filter.dump", std::bind(&apply_ipv4_filter_dump));
}
+386
View File
@@ -0,0 +1,386 @@
#include "config.h"
#include <cerrno>
#include <fcntl.h>
#include <functional>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <torrent/torrent.h>
#include <torrent/data/file_manager.h>
#include <torrent/data/chunk_utils.h>
#include <torrent/runtime/runtime.h>
#include <torrent/runtime/memory_manager.h>
#include <torrent/runtime/socket_manager.h>
#include <torrent/utils/chrono.h>
#include <torrent/utils/option_strings.h>
#include "core/download.h"
#include "core/download_list.h"
#include "core/manager.h"
#include "rpc/parse_commands.h"
#include "rpc/scgi.h"
#include "session/session_manager.h"
#include "utils/file_status_cache.h"
#include "globals.h"
#include "rpc/lua.h"
#include "control.h"
#include "command_helpers.h"
typedef torrent::ChunkManager CM_t;
typedef torrent::FileManager FM_t;
torrent::Object
apply_pieces_stats_total_size() {
uint64_t size = 0;
for (const auto& d : *control->core()->download_list())
if (d->is_active())
size += d->file_list()->size_bytes();
return size;
}
torrent::Object
system_env(const torrent::Object::string_type& arg) {
if (arg.empty())
throw torrent::input_error("system.env: Missing variable name.");
char* val = getenv(arg.c_str());
return std::string(val ? val : "");
}
torrent::Object
system_hostname() {
char buffer[1024];
if (gethostname(buffer, 1023) == -1)
throw torrent::input_error("Unable to read hostname.");
// if (shorten)
// *std::find(buffer, buffer + 1023, '.') = '\0';
return std::string(buffer);
}
torrent::Object
system_get_cwd() {
char* buffer = getcwd(NULL, 0);
if (buffer == NULL)
throw torrent::input_error("Unable to read cwd.");
torrent::Object result = torrent::Object(std::string(buffer));
free(buffer);
return result;
}
torrent::Object
system_set_cwd(const torrent::Object::string_type& rawArgs) {
if (::chdir(rawArgs.c_str()) != 0)
throw torrent::input_error("Could not change current working directory.");
return torrent::Object();
}
inline torrent::Object::list_const_iterator
post_increment(torrent::Object::list_const_iterator& itr, const torrent::Object::list_const_iterator& last) {
if (itr == last)
throw torrent::input_error("Invalid number of arguments.");
return itr++;
}
inline const std::string&
check_name(const std::string& str) {
auto itr = std::find_if(str.begin(), str.end(), [](char c) {
return !std::isalnum(c, std::locale::classic()) && c != '_';
});
if (itr != str.end())
throw torrent::input_error("Invalid characters found in name.");
return str;
}
torrent::Object
group_insert(const torrent::Object::list_type& args) {
torrent::Object::list_const_iterator itr = args.begin();
torrent::Object::list_const_iterator last = args.end();
const std::string& name = check_name(post_increment(itr, last)->as_string());
const std::string& view = check_name(post_increment(itr, last)->as_string());
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.enable", "simple",
"schedule=group." + name + ".ratio,5,60,on_ratio=" + name));
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.disable", "simple",
"schedule.remove=group." + name + ".ratio"));
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple",
"d.try_close= ;d.ignore_commands.set=1"));
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".view", "string", view));
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.min", "value", (int64_t)200));
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.max", "value", (int64_t)300));
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.upload", "value", (int64_t)20 << 20));
rpc::rpc.mark_safe("group." + name + ".view");
rpc::rpc.mark_safe("group." + name + ".view.set");
rpc::rpc.mark_safe("group." + name + ".ratio.min");
rpc::rpc.mark_safe("group." + name + ".ratio.min.set");
rpc::rpc.mark_safe("group." + name + ".ratio.max");
rpc::rpc.mark_safe("group." + name + ".ratio.max.set");
rpc::rpc.mark_safe("group." + name + ".ratio.upload");
rpc::rpc.mark_safe("group." + name + ".ratio.upload.set");
return name;
}
static const int file_print_use_space = 0x1;
static const int file_print_delim_space = 0x2;
void
file_print_list(torrent::Object::list_const_iterator first, torrent::Object::list_const_iterator last, FILE* output, int flags) {
while (first != last) {
switch (first->type()) {
case torrent::Object::TYPE_STRING:
fprintf(output, (const char*)" %s" + !(flags & file_print_use_space), first->as_string().c_str());
break;
case torrent::Object::TYPE_VALUE:
fprintf(output, (const char*)" %" PRIi64 + !(flags & file_print_use_space), first->as_value());
break;
case torrent::Object::TYPE_LIST:
file_print_list(first->as_list().begin(), first->as_list().end(), output, 0);
break;
case torrent::Object::TYPE_NONE:
break;
default:
throw torrent::input_error("Invalid type.");
}
flags |= (flags & file_print_delim_space) >> 1;
first++;
}
}
torrent::Object
cmd_file_append(const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("Invalid number of arguments.");
FILE* output = fopen(args.front().as_string().c_str(), "a");
if (output == nullptr)
throw torrent::input_error("Could not append to file '" + args.front().as_string() + "': " + std::strerror(errno));
try {
file_print_list(++args.begin(), args.end(), output, file_print_delim_space);
fprintf(output, "\n");
} catch (...) {
fclose(output);
throw;
}
fclose(output);
return torrent::Object();
}
void
initialize_command_local() {
core::DownloadList* dList = control->core()->download_list();
torrent::FileManager* fileManager = torrent::file_manager();
CMD_ANY ("system.hostname", std::bind(&system_hostname));
CMD_ANY ("system.pid", std::bind(&getpid));
CMD_VAR_C_STRING("system.api_version", (int64_t)API_VERSION);
CMD_VAR_C_STRING("system.client_version", PACKAGE_VERSION);
CMD_VAR_C_STRING("system.library_version", torrent::runtime::version());
CMD_VAR_VALUE ("system.file.allocate", 0);
CMD_VAR_VALUE ("system.file.max_size", (int64_t)512 << 30);
CMD_VAR_VALUE ("system.file.split_size", -1);
CMD_VAR_STRING ("system.file.split_suffix", ".part");
CMD_ANY ("system.file_status_cache.size", std::bind(&utils::FileStatusCache::size,
(utils::FileStatusCache::base_type*)control->core()->file_status_cache()));
CMD_ANY_V ("system.file_status_cache.prune", std::bind(&utils::FileStatusCache::prune, control->core()->file_status_cache()));
CMD_VAR_BOOL ("file.prioritize_toc", 0);
CMD_VAR_LIST ("file.prioritize_toc.first");
CMD_VAR_LIST ("file.prioritize_toc.last");
CMD_ANY ("system.files.advise_random", std::bind(&FM_t::advise_random, fileManager));
CMD_ANY_VALUE_V ("system.files.advise_random.set", std::bind(&FM_t::set_advise_random, fileManager, std::placeholders::_2));
CMD_ANY ("system.files.advise_random.hashing", std::bind(&FM_t::advise_random_hashing, fileManager));
CMD_ANY_VALUE_V ("system.files.advise_random.hashing.set", std::bind(&FM_t::set_advise_random_hashing, fileManager, std::placeholders::_2));
CMD_ANY ("system.files.session.fdatasync", [](auto, auto) { return session_thread::manager()->use_fsyncdisk(); });
CMD_ANY_VALUE_V ("system.files.session.fdatasync.set", [](auto, auto& value) { return session_thread::manager()->set_use_fsyncdisk(value); });
CMD_ANY ("system.files.opened_counter", std::bind(&FM_t::files_opened_counter, fileManager));
CMD_ANY ("system.files.closed_counter", std::bind(&FM_t::files_closed_counter, fileManager));
CMD_ANY ("system.files.failed_counter", std::bind(&FM_t::files_failed_counter, fileManager));
CMD_ANY_STRING ("system.env", [](auto, auto& str) { return system_env(str); });
CMD_ANY ("system.time", [](auto, auto) { return torrent::this_thread::cached_seconds().count(); });
CMD_ANY ("system.time_seconds", [](auto, auto) { return torrent::utils::cast_seconds(torrent::utils::time_since_epoch()).count(); });
CMD_ANY ("system.time_usec", [](auto, auto) { return torrent::utils::time_since_epoch().count(); });
CMD_ANY_VALUE_V ("system.umask.set", [](auto, auto& value) { return ::umask(value); });
CMD_VAR_BOOL ("system.daemon", false);
CMD_ANY_V ("system.shutdown.normal", [](auto, auto) { control->receive_normal_shutdown(); });
CMD_ANY_V ("system.shutdown.quick", [](auto, auto) { control->receive_quick_shutdown(); });
CMD_REDIRECT_NO_EXPORT("system.shutdown", "system.shutdown.normal");
CMD_ANY ("system.cwd", [](auto, auto) { return system_get_cwd(); });
CMD_ANY_STRING ("system.cwd.set", [](auto, auto& str) { return system_set_cwd(str); });
CMD_ANY ("system.sockets.size", [](auto, auto) { return torrent::runtime::socket_manager()->size(); });
CMD_ANY ("system.sockets.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->max_size(); });
CMD_ANY_VALUE_V ("system.sockets.max_size.set", [](auto, auto& value) { return torrent::runtime::socket_manager()->set_max_size_and_adjust(value); });
CMD_ANY_V ("system.sockets.adjust_alloc", [](auto, auto) { torrent::runtime::socket_manager()->adjust_allocation(); });
CMD_ANY ("system.sockets.reserved_alloc", [](auto, auto) { return torrent::runtime::socket_manager()->reserved_allocation(); });
CMD_ANY ("system.sockets.available_alloc", [](auto, auto) { return torrent::runtime::socket_manager()->available_allocation(); });
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
auto category = static_cast<torrent::runtime::socket_manager_category_t>(i);
auto category_name = "system.sockets." + torrent::option_to_str_or_throw(torrent::OPTION_SOCKET_CATEGORY, i);
CMD_ANY (category_name + ".size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(category); });
CMD_ANY (category_name + ".max_size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(category); });
if (i == 0) {
CMD_ANY (category_name + ".min_alloc", [](auto, auto) { return torrent::runtime::socket_manager()->generic_min_allocation(); });
continue;
}
CMD_ANY (category_name + ".min_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_min_allocation(category); });
CMD_ANY (category_name + ".max_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_allocation(category); });
CMD_ANY_VALUE_V(category_name + ".min_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_min_allocation(category, value); });
CMD_ANY_VALUE_V(category_name + ".max_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_max_allocation(category, value); });
}
CMD_ANY ("pieces.sync.always_safe", [](auto, auto) { return torrent::runtime::memory_manager()->safe_sync(); });
CMD_ANY_VALUE_V ("pieces.sync.always_safe.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_safe_sync(value); });
CMD_ANY ("pieces.sync.safe_free_diskspace", [](auto, auto) { return torrent::runtime::memory_manager()->sync_safe_free_diskspace(); });
CMD_ANY ("pieces.sync.timeout", [](auto, auto) { return torrent::runtime::memory_manager()->timeout_sync().count(); });
CMD_ANY_VALUE_V ("pieces.sync.timeout.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_timeout_sync(value); });
// CMD_ANY ("pieces.sync.timeout_safe", [](auto, auto) { return torrent::runtime::memory_manager()->timeout_safe_sync(); });
// CMD_ANY_VALUE_V ("pieces.sync.timeout_safe.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_timeout_safe_sync(value); });
CMD_ANY ("pieces.sync.timeout_safe", [](auto, auto) { return 0; });
CMD_ANY_VALUE_V ("pieces.sync.timeout_safe.set", [](auto, auto) { });
CMD_ANY ("pieces.sync.queue_size", [](auto, auto) { return torrent::runtime::memory_manager()->sync_queue_block_count(); });
CMD_ANY ("pieces.preload.type", [](auto, auto) { return torrent::runtime::memory_manager()->preload_type(); });
CMD_ANY_VALUE_V ("pieces.preload.type.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_preload_type(value); });
CMD_ANY ("pieces.preload.min_size", [](auto, auto) { return torrent::runtime::memory_manager()->preload_min_size(); });
CMD_ANY_VALUE_V ("pieces.preload.min_size.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_preload_min_size(value); });
CMD_ANY ("pieces.preload.min_rate", [](auto, auto) { return torrent::runtime::memory_manager()->preload_required_rate(); });
CMD_ANY_VALUE_V ("pieces.preload.min_rate.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_preload_required_rate(value); });
CMD_ANY ("pieces.stats_preloaded", [](auto, auto) { return torrent::runtime::memory_manager()->stats_preloaded(); });
CMD_ANY ("pieces.stats_not_preloaded", [](auto, auto) { return torrent::runtime::memory_manager()->stats_not_preloaded(); });
CMD_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size));
CMD_ANY ("pieces.memory.current", [](auto, auto) { return torrent::runtime::memory_manager()->memory_usage(); });
CMD_ANY ("pieces.memory.sync_queue", [](auto, auto) { return torrent::runtime::memory_manager()->sync_queue_memory_usage(); });
CMD_ANY ("pieces.memory.block_count", [](auto, auto) { return torrent::runtime::memory_manager()->memory_block_count(); });
CMD_ANY ("pieces.memory.max", [](auto, auto) { return torrent::runtime::memory_manager()->max_memory_usage(); });
CMD_ANY_VALUE_V ("pieces.memory.max.set", [](auto, auto& value) { return torrent::runtime::memory_manager()->set_max_memory_usage(value); });
CMD_ANY ("pieces.hash.queue_size", std::bind(&torrent::main_thread::hash_queue_size));
CMD_VAR_BOOL ("pieces.hash.on_completion", true);
CMD_VAR_STRING ("directory.default", "./");
CMD_VAR_STRING ("session.name", "");
CMD_ANY ("session.path", [](auto, auto) { return session_thread::manager()->path(); });
CMD_ANY_STRING_V("session.path.set", [](auto, auto& str) { return session_thread::manager()->set_path(str); });
CMD_ANY ("session.use_lock", [](auto, auto) { return session_thread::manager()->use_lock(); });
CMD_ANY_VALUE_V ("session.use_lock.set", [](auto, auto& value) { return session_thread::manager()->set_use_lock(value); });
CMD_VAR_BOOL ("session.on_completion", true);
CMD_ANY_V ("session.save", [dList](auto, auto) { return dList->session_save(); });
CMD_ANY ("magnet.path", [](auto, auto) { return control->core()->magnet_path(); });
CMD_ANY_STRING_V("magnet.path.set", [](auto, auto& str) { return control->core()->set_magnet_path(str); });
#ifdef HAVE_LUA
rpc::LuaEngine* lua_engine = control->lua_engine();
CMD_ANY ("lua.execute", std::bind(&rpc::execute_lua, lua_engine, std::placeholders::_1, std::placeholders::_2, 0));
CMD_ANY ("lua.execute.str", std::bind(&rpc::execute_lua, lua_engine, std::placeholders::_1, std::placeholders::_2, rpc::LuaEngine::flag_string));
#endif
#define CMD_EXECUTE(key, flags) \
CMD_ANY(key, std::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::placeholders::_2, flags));
CMD_EXECUTE ("execute", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw);
CMD_EXECUTE ("execute.throw", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw);
CMD_EXECUTE ("execute.throw.bg", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw | rpc::ExecFile::flag_background);
CMD_EXECUTE ("execute.nothrow", rpc::ExecFile::flag_expand_tilde);
CMD_EXECUTE ("execute.nothrow.bg", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_background);
CMD_EXECUTE ("execute.raw", rpc::ExecFile::flag_throw);
CMD_EXECUTE ("execute.raw.bg", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_background);
CMD_EXECUTE ("execute.raw_nothrow", 0);
CMD_EXECUTE ("execute.raw_nothrow.bg", rpc::ExecFile::flag_background);
CMD_EXECUTE ("execute.capture", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
CMD_EXECUTE ("execute.capture_nothrow", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
// TODO: Convert to new command types:
*rpc::command_base::argument(0) = "placeholder.0";
*rpc::command_base::argument(1) = "placeholder.1";
*rpc::command_base::argument(2) = "placeholder.2";
*rpc::command_base::argument(3) = "placeholder.3";
CMD_ANY_P("argument.0", std::bind(&rpc::command_base::argument_ref, 0));
CMD_ANY_P("argument.1", std::bind(&rpc::command_base::argument_ref, 1));
CMD_ANY_P("argument.2", std::bind(&rpc::command_base::argument_ref, 2));
CMD_ANY_P("argument.3", std::bind(&rpc::command_base::argument_ref, 3));
CMD_ANY_LIST ("group.insert", std::bind(&group_insert, std::placeholders::_2));
rpc::rpc.mark_safe("system.api_version");
rpc::rpc.mark_safe("system.client_version");
rpc::rpc.mark_safe("system.library_version");
rpc::rpc.mark_safe("system.file.max_size");
rpc::rpc.mark_safe("system.file.split_size");
rpc::rpc.mark_safe("system.file.split_suffix");
rpc::rpc.mark_safe("system.sockets.size");
rpc::rpc.mark_safe("system.sockets.max_size");
rpc::rpc.mark_safe("system.sockets.reserved_alloc");
rpc::rpc.mark_safe("system.sockets.available_alloc");
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
auto category_name = "system.sockets." + torrent::option_to_str_or_throw(torrent::OPTION_SOCKET_CATEGORY, i);
rpc::rpc.mark_safe(category_name + ".size");
rpc::rpc.mark_safe(category_name + ".max_size");
if (i == 0) {
rpc::rpc.mark_safe(category_name + ".min_alloc");
continue;
}
rpc::rpc.mark_safe(category_name + ".min_alloc");
rpc::rpc.mark_safe(category_name + ".max_alloc");
}
rpc::rpc.mark_safe("directory.default");
rpc::rpc.mark_safe("session.path");
rpc::rpc.mark_safe("session.use_lock");
rpc::rpc.mark_safe("session.on_completion");
rpc::rpc.mark_safe("pieces.sync.always_safe");
rpc::rpc.mark_safe("pieces.sync.timeout");
rpc::rpc.mark_safe("pieces.sync.timeout_safe");
rpc::rpc.mark_safe("pieces.preload.type");
rpc::rpc.mark_safe("pieces.preload.min_size");
rpc::rpc.mark_safe("pieces.preload.min_rate");
rpc::rpc.mark_safe("pieces.memory.max");
rpc::rpc.mark_safe("pieces.hash.on_completion");
}
+150
View File
@@ -0,0 +1,150 @@
#include "config.h"
#include <fcntl.h>
#include <iterator>
#include <stdio.h>
#include <unistd.h>
#include <torrent/data/chunk_utils.h>
#include <torrent/object.h>
#include <torrent/utils/log.h>
#include <torrent/utils/option_strings.h>
#include "control.h"
#include "command_helpers.h"
#include "globals.h"
#include "setup.h"
#include "core/download.h"
#include "core/download_list.h"
#include "core/manager.h"
#include "rpc/parse.h"
#include "rpc/parse_commands.h"
torrent::Object
apply_log_open(int output_flags, const torrent::Object::list_type& raw_args) {
std::vector<std::string> args;
for (const auto& arg : raw_args)
args.push_back(arg.as_string());
apply_log_open_str(output_flags, args);
return torrent::Object();
}
torrent::Object
apply_log_add_output(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Invalid number of arguments.");
log_add_group_output_str(args.front().as_string(), args.back().as_string());
return torrent::Object();
}
torrent::Object
apply_log_print(const torrent::Object::list_type& args) {
if (args.size() < 2)
throw torrent::input_error("Invalid number of arguments.");
torrent::Object::value_type group;
if (args.front().is_value())
group = args.front().as_value();
else if (args.front().is_string())
group = torrent::option_find_string_str(torrent::OPTION_LOG_GROUP, args.front().as_string());
else
throw torrent::input_error("Invalid log group.");
if (group < 0 || group >= torrent::LOG_GROUP_MAX_SIZE)
throw torrent::input_error("Invalid log group.");
std::string message;
for (auto itr = std::next(args.begin()); itr != args.end(); ++itr)
rpc::print_object_std(&message, &*itr, 0);
torrent::log_groups[group].internal_print(message);
return torrent::Object();
}
// TODO: Deprecated.
torrent::Object
apply_log(const torrent::Object::string_type& arg, int logType) {
if (rpc::execFile.log_fd() != -1) {
switch (logType) {
case 0: ::close(rpc::execFile.log_fd()); rpc::execFile.set_log_fd(-1); break;
case 1:
// if (control->scgi()) {
// ::close(control->scgi()->log_fd());
// control->scgi()->set_log_fd(-1);
// }
break;
default: break;
}
}
if (!arg.empty()) {
int logFd = open(expand_path(arg).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
if (logFd < 0)
throw torrent::input_error("Could not open execute log file.");
switch (logType) {
case 0: rpc::execFile.set_log_fd(logFd); break;
// case 1: if (control->scgi()) control->scgi()->set_log_fd(logFd); break;
default: break;
}
control->core()->push_log("Opened log file.");
} else {
control->core()->push_log("Closed log file.");
}
return torrent::Object();
}
torrent::Object
log_vmmap_dump(const std::string& str) {
std::vector<torrent::vm_mapping> all_mappings;
for (const auto& d : *control->core()->download_list()) {
std::vector<torrent::vm_mapping> tmp_mappings = torrent::chunk_list_mapping(d->download());
all_mappings.insert(all_mappings.end(), tmp_mappings.begin(), tmp_mappings.end());
}
FILE* log_file = fopen(str.c_str(), "w");
if (log_file == NULL)
throw torrent::input_error("Could not open log file: " + str);
for (auto& all_mapping : all_mappings) {
fprintf(log_file, "%8p-%8p [%5llxk]\n", all_mapping.ptr, (char*)all_mapping.ptr + all_mapping.length, (long long unsigned int)(all_mapping.length / 1024));
}
fclose(log_file);
return torrent::Object();
}
void
initialize_command_logging() {
CMD2_ANY_LIST ("log.open_file", std::bind(&apply_log_open, 0, std::placeholders::_2));
CMD2_ANY_LIST ("log.open_file.flush", std::bind(&apply_log_open, log_flag_flush, std::placeholders::_2));
CMD2_ANY_LIST ("log.open_gz_file", std::bind(&apply_log_open, log_flag_use_gz, std::placeholders::_2));
CMD2_ANY_LIST ("log.open_file_pid", std::bind(&apply_log_open, log_flag_append_pid, std::placeholders::_2));
CMD2_ANY_LIST ("log.open_gz_file_pid", std::bind(&apply_log_open, log_flag_append_pid | log_flag_use_gz, std::placeholders::_2));
CMD2_ANY_LIST ("log.append_file", std::bind(&apply_log_open, log_flag_append_file, std::placeholders::_2));
CMD2_ANY_LIST ("log.append_file.flush", std::bind(&apply_log_open, log_flag_append_file | log_flag_flush, std::placeholders::_2));
CMD2_ANY_LIST ("log.append_gz_file", std::bind(&apply_log_open, log_flag_append_file, std::placeholders::_2));
CMD2_ANY_STRING_V("log.close", std::bind(&torrent::log_close_output_str, std::placeholders::_2));
CMD2_ANY_LIST ("log.add_output", std::bind(&apply_log_add_output, std::placeholders::_2));
CMD2_ANY_LIST ("log.print", std::bind(&apply_log_print, std::placeholders::_2));
CMD2_ANY_STRING ("log.execute", std::bind(&apply_log, std::placeholders::_2, 0));
CMD2_ANY_STRING ("log.vmmap.dump", std::bind(&log_vmmap_dump, std::placeholders::_2));
CMD2_ANY_STRING_V("log.rpc", [](const auto&, const auto& str) { scgi_thread::set_rpc_log(str); });
CMD2_REDIRECT ("log.xmlrpc", "log.rpc"); // For backwards compatibility
}
+453
View File
@@ -0,0 +1,453 @@
#include "config.h"
#include <functional>
#include <cstdio>
#include <unistd.h>
#include <torrent/torrent.h>
#include <torrent/rate.h>
#include <torrent/data/file_manager.h>
#include <torrent/download/resource_manager.h>
#include <torrent/net/http_stack.h>
#include <torrent/net/socket_address.h>
#include <torrent/runtime/client_config.h>
#include <torrent/runtime/network_config.h>
#include <torrent/runtime/network_manager.h>
#include <torrent/runtime/proxy_manager.h>
#include <torrent/runtime/runtime.h>
#include <torrent/runtime/socket_manager.h>
#include <torrent/tracker/tracker.h>
#include <torrent/utils/log.h>
#include <torrent/utils/option_strings.h>
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
#include "core/download.h"
#include "core/manager.h"
#include "rpc/scgi.h"
#include "ui/root.h"
#include "rpc/parse.h"
#include "rpc/parse_commands.h"
#ifdef HAVE_SYSTEMD
#include <sys/socket.h>
#include <systemd/sd-daemon.h>
#endif
torrent::Object
listen_port_range() {
auto port_range = torrent::runtime::client_config()->listen_port_range();
return std::to_string(port_range.first) + "-" + std::to_string(port_range.second);
}
void
set_listen_port_range(const std::string& arg) {
unsigned int port_first{}, port_last{};
if (std::sscanf(arg.c_str(), "%i-%i", &port_first, &port_last) != 2)
throw torrent::input_error("Invalid port_range argument.");
if (port_first >= (1 << 16) || port_last >= (1 << 16))
throw torrent::input_error("Port range out-of-bounds.");
torrent::runtime::client_config()->set_listen_port_range(port_first, port_last);
}
torrent::Object
get_encryption() {
auto encryption_modes = torrent::runtime::network_config()->encryption_modes();
return torrent::option_to_str_or_throw(torrent::OPTION_ENCRYPTION_HANDSHAKE, encryption_modes.first) + "," +
torrent::option_to_str_or_throw(torrent::OPTION_ENCRYPTION_STREAM, encryption_modes.second);
}
torrent::Object
get_handshake_encryption() {
auto encryption_modes = torrent::runtime::network_config()->encryption_modes();
return torrent::option_to_str_or_throw(torrent::OPTION_ENCRYPTION_MODE, encryption_modes.first);
}
torrent::Object
get_stream_encryption() {
auto encryption_modes = torrent::runtime::network_config()->encryption_modes();
return torrent::option_to_str_or_throw(torrent::OPTION_ENCRYPTION_MODE, encryption_modes.second);
}
torrent::Object
apply_obsolete_encryption(const torrent::Object::list_type& args) {
torrent::encryption_mode handshake_mode{torrent::ENCRYPTION_MODE_ALLOW};
torrent::encryption_mode stream_mode{torrent::ENCRYPTION_MODE_ALLOW};
for (auto& itr : args) {
auto arg = itr.as_string();
if (arg == "none") {
handshake_mode = torrent::ENCRYPTION_MODE_DENY;
stream_mode = torrent::ENCRYPTION_MODE_DENY;
break;
} else if (arg == "allow_incoming") {
} else if (arg == "try_outgoing") {
} else if (arg == "require") {
handshake_mode = torrent::ENCRYPTION_MODE_REQUIRE;
} else if (arg == "require_RC4" || arg == "require_rc4") {
handshake_mode = torrent::ENCRYPTION_MODE_REQUIRE;
stream_mode = torrent::ENCRYPTION_MODE_REQUIRE;
break;
} else if (arg == "enable_retry") {
} else if (arg == "prefer_plaintext") {
} else {
throw torrent::input_error("Invalid encryption option: '" + arg + "'");
}
}
lt_log_print(torrent::LOG_WARN, "Obsolete encryption options used, use 'handshake_{deny,allow,prefer,require}, stream_{deny,allow,prefer,require}' instead.");
torrent::runtime::network_config()->set_encryption_modes(handshake_mode, stream_mode);
return {};
}
torrent::Object
apply_encryption(const torrent::Object::list_type& args) {
if (args.empty())
throw torrent::input_error("No encryption options specified.");
torrent::encryption_mode encryption_mode, handshake_mode, stream_mode;
if (args.size() == 1) {
try {
encryption_mode = static_cast<torrent::encryption_mode>(torrent::option_find_string_str(torrent::OPTION_ENCRYPTION_MODE, args.front().as_string()));
} catch (torrent::input_error& e) {
return apply_obsolete_encryption(args);
}
torrent::runtime::network_config()->set_encryption_modes(encryption_mode, encryption_mode);
return {};
}
if (args.size() != 2)
return apply_obsolete_encryption(args);
try {
handshake_mode = static_cast<torrent::encryption_mode>(torrent::option_find_string_str(torrent::OPTION_ENCRYPTION_HANDSHAKE, args.front().as_string()));
stream_mode = static_cast<torrent::encryption_mode>(torrent::option_find_string_str(torrent::OPTION_ENCRYPTION_STREAM, args.back().as_string()));
} catch (torrent::input_error& e) {
return apply_obsolete_encryption(args);
}
torrent::runtime::network_config()->set_encryption_modes(handshake_mode, stream_mode);
return {};
}
torrent::Object
apply_tos(const torrent::Object::string_type& arg) {
rpc::command_base::value_type value;
if (!rpc::parse_whole_value_nothrow(arg.c_str(), &value, 16, 1))
value = torrent::option_find_string(torrent::OPTION_IP_TOS, arg.c_str());
torrent::runtime::network_config()->set_priority(value);
return torrent::Object();
}
void
initialize_rpc_handlers() {
rpc::rpc.initialize_handlers();
unsigned int count = 0;
for (const auto& [name, cmd] : rpc::commands) {
if (!(cmd.m_flags & rpc::CommandMap::flag_public_rpc))
continue;
rpc::rpc.insert_command(name.c_str(), cmd.m_parm, cmd.m_doc);
++count;
}
lt_log_print(torrent::LOG_RPC_EVENTS, "RPC manager initialized with %u functions.", count);
}
torrent::Object
apply_scgi(const std::string& arg, int type) {
if (scgi_thread::scgi() != nullptr)
throw torrent::input_error("SCGI already enabled.");
initialize_rpc_handlers();
torrent::sa_unique_ptr sa;
auto scgi = std::make_unique<rpc::SCgi>();
try {
int port{};
char dummy{};
char address[1024];
std::string path;
switch (type) {
case 1:
if (std::sscanf(arg.c_str(), ":%i%c", &port, &dummy) == 1) {
sa = torrent::sa_make_inet();
lt_log_print(torrent::LOG_RPC_EVENTS, "SCGI socket is open to any address and is a security risk");
} else if (std::sscanf(arg.c_str(), "%1023[^:]:%i%c", address, &port, &dummy) == 2 ||
std::sscanf(arg.c_str(), "[%64[^]]]:%i%c", address, &port, &dummy) == 2) { // [xx::xx]:port format
try {
sa = torrent::sa_copy(torrent::sa_lookup_address(address, AF_UNSPEC).get());
} catch (torrent::input_error& e) {
throw torrent::input_error("Could not bind address: " + std::string(e.what()));
}
lt_log_print(torrent::LOG_RPC_EVENTS, "SCGI socket is bound to an address and might be a security risk");
} else {
throw torrent::input_error("Could not parse address.");
}
if (port <= 0 || port >= (1 << 16))
throw torrent::input_error("Invalid port number.");
torrent::sap_set_port(sa, port);
scgi->open_port(sa.get(), torrent::sap_length(sa), rpc::call_command_value("network.scgi.dont_route"));
break;
case 2:
default:
path = expand_path(arg);
unlink(path.c_str());
scgi->open_named(path);
break;
}
} catch (torrent::local_error& e) {
throw torrent::input_error(e.what());
}
scgi_thread::set_scgi(scgi.release());
return torrent::Object();
}
torrent::Object
apply_scgi_systemd() {
#ifdef HAVE_SYSTEMD
if (scgi_thread::scgi() != nullptr)
throw torrent::input_error("SCGI already enabled.");
int n = sd_listen_fds(0);
if (n < 1)
throw torrent::input_error("No systemd socket(s) provided (sd_listen_fds returned " +
std::to_string(n) + ").");
// Iterate over all provided fds. Use the first listening stream socket;
// close the rest. The systemd docs say unused fds should be closed.
int selected_fd = -1;
for (int i = 0; i < n; i++) {
int fd = SD_LISTEN_FDS_START + i;
if (selected_fd != -1) {
::close(fd);
continue;
}
auto err = sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1);
if (err < 0) {
// Safe to ignore errors here - we just skip it and move on.
::close(fd);
continue;
}
if (err == 0) {
// Not the socket we're looking for.
::close(fd);
continue;
}
selected_fd = fd;
}
if (selected_fd == -1)
throw torrent::input_error("No listening stream socket found among systemd-provided fds.");
initialize_rpc_handlers();
rpc::SCgi* scgi = new rpc::SCgi;
scgi->open_fd(selected_fd);
scgi_thread::set_scgi(scgi);
return torrent::Object();
#else
throw torrent::input_error("Systemd SCGI endpoint is not supported.");
#endif
}
torrent::Object
apply_xmlrpc_dialect(const std::string& arg) {
int value;
if (arg == "i8")
value = rpc::XmlRpc::dialect_i8;
else if (arg == "apache")
value = rpc::XmlRpc::dialect_apache;
else if (arg == "generic")
value = rpc::XmlRpc::dialect_generic;
else
value = -1;
rpc::rpc.set_dialect(value);
return torrent::Object();
}
void
initialize_command_network() {
auto file_manager = torrent::file_manager();
auto http_stack = torrent::net_thread::http_stack();
auto nw_config = torrent::runtime::network_config();
CMD_ANY ("network.listen.port", [](auto, auto) { return torrent::runtime::network_manager()->listen_port(); });
CMD_ANY_VALUE_V ("network.listen.port.set", [](auto, auto& value) { return torrent::runtime::network_manager()->set_listen_port(value); });
CMD_ANY ("network.listen.port.random", [](auto, auto) { return torrent::runtime::client_config()->listen_port_random(); });
CMD_ANY_VALUE_V ("network.listen.port.random.set", [](auto, auto& value) { return torrent::runtime::client_config()->set_listen_port_random(value); });
CMD_ANY ("network.listen.port.range", [](auto, auto) { return listen_port_range(); });
CMD_ANY_STRING_V("network.listen.port.range.set", [](auto, auto& value) { return set_listen_port_range(value); });
CMD_ANY ("network.listen.backlog", [](auto, auto) { return torrent::runtime::network_config()->listen_backlog(); });
CMD_ANY_VALUE_V ("network.listen.backlog.set", [](auto, auto& value) { return torrent::runtime::network_config()->set_listen_backlog(value); });
CMD_ANY ("protocol.pex", [](auto, auto) { return torrent::runtime::client_config()->is_pex_enabled(); });
CMD_ANY_VALUE_V ("protocol.pex.set", [](auto, auto& value) { return torrent::runtime::client_config()->set_pex_enabled(value); });
CMD_ANY_LIST ("protocol.encryption", [](auto, auto) { return get_encryption(); });
CMD_ANY_LIST ("protocol.encryption.set", [](auto, auto& args) { return apply_encryption(args); });
CMD_ANY_LIST ("protocol.encryption.handshake", [](auto, auto) { return get_handshake_encryption(); });
CMD_ANY_LIST ("protocol.encryption.stream", [](auto, auto) { return get_stream_encryption(); });
CMD_VAR_STRING ("protocol.connection.leech", "leech");
CMD_VAR_STRING ("protocol.connection.seed", "seed");
CMD_VAR_STRING ("protocol.choke_heuristics.up.leech", "upload_leech");
CMD_VAR_STRING ("protocol.choke_heuristics.up.seed", "upload_leech");
CMD_VAR_STRING ("protocol.choke_heuristics.down.leech", "download_leech");
CMD_VAR_STRING ("protocol.choke_heuristics.down.seed", "download_leech");
CMD_ANY ("network.http.cacert", [http_stack](auto, auto) { return http_stack->http_cacert(); });
CMD_ANY_STRING_V("network.http.cacert.set", [http_stack](auto, auto& str) { return http_stack->set_http_cacert(str); });
CMD_ANY ("network.http.capath", [http_stack](auto, auto) { return http_stack->http_capath(); });
CMD_ANY_STRING_V("network.http.capath.set", [http_stack](auto, auto& str) { return http_stack->set_http_capath(str); });
CMD_ANY ("network.http.dns_cache_timeout", [http_stack](auto, auto) { return http_stack->dns_timeout(); });
CMD_ANY_VALUE_V ("network.http.dns_cache_timeout.set", [http_stack](auto, auto& value) { return http_stack->set_dns_timeout(value); });
CMD_ANY ("network.http.current_open", [http_stack](auto, auto) { return http_stack->size(); });
CMD_ANY ("network.http.max_cache_connections", [http_stack](auto, auto) { return http_stack->max_cache_connections(); });
CMD_ANY_VALUE_V ("network.http.max_cache_connections.set", [http_stack](auto, auto& value) { return http_stack->set_max_cache_connections(value); });
CMD_ANY ("network.http.max_host_connections", [http_stack](auto, auto) { return http_stack->max_host_connections(); });
CMD_ANY_VALUE_V ("network.http.max_host_connections.set", [http_stack](auto, auto& value) { return http_stack->set_max_host_connections(value); });
CMD_ANY ("network.http.max_total_connections", [http_stack](auto, auto) { return http_stack->max_total_connections(); });
CMD_ANY ("network.http.ssl_verify_host", [http_stack](auto, auto) { return http_stack->ssl_verify_host(); });
CMD_ANY_VALUE_V ("network.http.ssl_verify_host.set", [http_stack](auto, auto& value) { return http_stack->set_ssl_verify_host(value); });
CMD_ANY ("network.http.ssl_verify_peer", [http_stack](auto, auto) { return http_stack->ssl_verify_peer(); });
CMD_ANY_VALUE_V ("network.http.ssl_verify_peer.set", [http_stack](auto, auto& value) { return http_stack->set_ssl_verify_peer(value); });
CMD_ANY ("network.send_buffer.size", [nw_config](auto, auto) { return nw_config->send_buffer_size(); });
CMD_ANY_VALUE_V ("network.send_buffer.size.set", [nw_config](auto, auto& value) { return nw_config->set_send_buffer_size(value); });
CMD_ANY ("network.receive_buffer.size", [nw_config](auto, auto) { return nw_config->receive_buffer_size(); });
CMD_ANY_VALUE_V ("network.receive_buffer.size.set", [nw_config](auto, auto& value) { return nw_config->set_receive_buffer_size(value); });
CMD_ANY_STRING ("network.tos.set", [](auto, auto& str) { return apply_tos(str); });
CMD_ANY ("network.bind_address", [nw_config](auto, auto) { return nw_config->bind_address_best_match_str(); });
CMD_ANY_STRING_V("network.bind_address.set", [nw_config](auto, auto& str) { return nw_config->set_bind_address_str(str); });
CMD_ANY ("network.bind_address.ipv4", [nw_config](auto, auto) { return nw_config->bind_inet_address_str(); });
CMD_ANY_STRING_V("network.bind_address.ipv4.set", [nw_config](auto, auto& str) { return nw_config->set_bind_inet_address_str(str); });
CMD_ANY ("network.bind_address.ipv6", [nw_config](auto, auto) { return nw_config->bind_inet6_address_str(); });
CMD_ANY_STRING_V("network.bind_address.ipv6.set", [nw_config](auto, auto& str) { return nw_config->set_bind_inet6_address_str(str); });
CMD_ANY ("network.local_address", [nw_config](auto, auto) { return nw_config->local_address_best_match_str(); });
CMD_ANY_STRING_V("network.local_address.set", [nw_config](auto, auto& str) { return nw_config->set_local_address_str(str); });
CMD_ANY ("network.local_address.ipv4", [nw_config](auto, auto) { return nw_config->local_inet_address_str(); });
CMD_ANY_STRING_V("network.local_address.ipv4.set", [nw_config](auto, auto& str) { return nw_config->set_local_inet_address_str(str); });
CMD_ANY ("network.local_address.ipv6", [nw_config](auto, auto) { return nw_config->local_inet6_address_str(); });
CMD_ANY_STRING_V("network.local_address.ipv6.set", [nw_config](auto, auto& str) { return nw_config->set_local_inet6_address_str(str); });
CMD_ANY ("network.proxy.global", [](auto, auto) { return torrent::runtime::proxy_manager()->proxy_url(); });
CMD_ANY_STRING_V("network.proxy.global.set", [](auto, auto& str) { return torrent::runtime::proxy_manager()->set_proxy_url(str); });
CMD_ANY ("network.proxy.http", [](auto, auto) { return torrent::runtime::proxy_manager()->http_proxy_url(); });
CMD_ANY_STRING_V("network.proxy.http.set", [](auto, auto& str) { return torrent::runtime::proxy_manager()->set_http_proxy_url(str); });
CMD_ANY ("network.open_files", [file_manager](auto, auto) { return file_manager->open_files(); });
CMD_ANY ("network.max_open_files", [file_manager](auto, auto) { return file_manager->max_open_files(); });
CMD_ANY ("network.total_handshakes", [](auto, auto) { return torrent::runtime::total_handshakes(); });
CMD_ANY_STRING ("network.scgi.open_port", [](auto, auto& arg) { return apply_scgi(arg, 1); });
CMD_ANY_STRING ("network.scgi.open_local", [](auto, auto& arg) { return apply_scgi(arg, 2); });
CMD_VAR_BOOL ("network.scgi.dont_route", false);
CMD_ANY ("network.scgi.open_systemd", [](auto, auto) { return apply_scgi_systemd(); });
CMD_ANY ("network.scgi.use_gzip", [](auto, auto) { return rpc::rpc.scgi_allow_compression(); });
CMD_ANY_VALUE_V ("network.scgi.use_gzip.set", [](auto, auto& arg) { return rpc::rpc.set_scgi_allow_compression(arg); });
CMD_ANY ("network.scgi.gzip.min_size", [](auto, auto) { return rpc::rpc.scgi_min_compress_size(); });
CMD_ANY_VALUE_V ("network.scgi.gzip.min_size.set", [](auto, auto& arg) { return rpc::rpc.set_scgi_min_compress_size(arg); });
CMD_ANY_STRING ("network.xmlrpc.dialect.set", [](auto, auto& arg) { return apply_xmlrpc_dialect(arg); })
CMD_ANY ("network.xmlrpc.size_limit", [](auto, auto) { return rpc::rpc.size_limit(); });
CMD_ANY_VALUE_V ("network.xmlrpc.size_limit.set", [](auto, auto& arg) { return rpc::rpc.set_size_limit(arg); });
CMD_ANY ("network.rpc.use_xmlrpc", [](auto, auto) { return rpc::rpc.use_xmlrpc(); });
CMD_ANY_VALUE_V ("network.rpc.use_xmlrpc.set", [](auto, auto& arg) { return rpc::rpc.set_use_xmlrpc(arg); });
CMD_ANY ("network.rpc.use_jsonrpc", [](auto, auto) { return rpc::rpc.use_jsonrpc(); });
CMD_ANY_VALUE_V ("network.rpc.use_jsonrpc.set", [](auto, auto& arg) { return rpc::rpc.set_use_jsonrpc(arg); });
CMD_ANY ("network.block.ipv4", [nw_config](auto, auto) { return nw_config->is_block_ipv4(); });
CMD_ANY_VALUE_V ("network.block.ipv4.set", [nw_config](auto, auto& value) { return nw_config->set_block_ipv4(value); });
CMD_ANY ("network.block.ipv6", [nw_config](auto, auto) { return nw_config->is_block_ipv6(); });
CMD_ANY_VALUE_V ("network.block.ipv6.set", [nw_config](auto, auto& value) { return nw_config->set_block_ipv6(value); });
CMD_ANY ("network.block.ipv4in6", [nw_config](auto, auto) { return nw_config->is_block_ipv4in6(); });
CMD_ANY_VALUE_V ("network.block.ipv4in6.set", [nw_config](auto, auto& value) { return nw_config->set_block_ipv4in6(value); });
CMD_ANY ("network.block.outgoing", [nw_config](auto, auto) { return nw_config->is_block_outgoing(); });
CMD_ANY_VALUE_V ("network.block.outgoing.set", [nw_config](auto, auto& value) { return nw_config->set_block_outgoing(value); });
CMD_ANY ("network.prefer.ipv6", [nw_config](auto, auto) { return nw_config->is_prefer_ipv6(); });
CMD_ANY_VALUE_V ("network.prefer.ipv6.set", [nw_config](auto, auto& value) { return nw_config->set_prefer_ipv6(value); });
rpc::rpc.mark_safe("network.port_open");
rpc::rpc.mark_safe("network.port_random");
rpc::rpc.mark_safe("network.port_range");
rpc::rpc.mark_safe("network.listen.port");
rpc::rpc.mark_safe("network.listen.backlog");
rpc::rpc.mark_safe("network.http.current_open");
rpc::rpc.mark_safe("network.http.max_cache_connections");
rpc::rpc.mark_safe("network.http.max_host_connections");
rpc::rpc.mark_safe("network.http.max_total_connections");
rpc::rpc.mark_safe("network.total_handshakes");
rpc::rpc.mark_safe("network.open_files");
rpc::rpc.mark_safe("network.max_open_files");
rpc::rpc.mark_safe("network.send_buffer.size");
rpc::rpc.mark_safe("network.receive_buffer.size");
rpc::rpc.mark_safe("network.bind_address");
rpc::rpc.mark_safe("network.local_address");
rpc::rpc.mark_safe("network.xmlrpc.size_limit");
rpc::rpc.mark_safe("network.open_sockets");
rpc::rpc.mark_safe("network.http.cacert");
rpc::rpc.mark_safe("network.http.capath");
rpc::rpc.mark_safe("network.proxy.global");
rpc::rpc.mark_safe("network.proxy.http");
rpc::rpc.mark_safe("network.scgi.dont_route");
rpc::rpc.mark_safe("protocol.pex");
rpc::rpc.mark_safe("network.rpc.use_xmlrpc");
rpc::rpc.mark_safe("network.rpc.use_jsonrpc");
}
+109
View File
@@ -0,0 +1,109 @@
#include "config.h"
#include <torrent/bitfield.h>
#include <torrent/rate.h>
#include <torrent/net/socket_address.h>
#include <torrent/peer/connection_list.h>
#include <torrent/peer/peer.h>
#include <torrent/peer/peer_info.h>
#include <torrent/utils/string_manip.h>
#include "globals.h"
#include "command_helpers.h"
#include "control.h"
#include "core/manager.h"
#include "display/utils.h"
torrent::Object
retrieve_p_address(torrent::Peer* peer) {
auto sa = peer->peer_info()->socket_address();
auto addr_str = torrent::sa_addr_str(sa);
if (sa->sa_family == AF_INET6)
return "[" + addr_str + "]";
return addr_str;
}
torrent::Object
retrieve_p_client_version(torrent::Peer* peer) {
char buf[128];
display::print_client_version(buf, buf + 128, peer->peer_info()->client_info());
return std::string(buf);
}
torrent::Object
retrieve_p_options_str(torrent::Peer* peer) {
return torrent::utils::transform_to_hex_str(peer->peer_info()->options(), peer->peer_info()->options() + 8);
}
torrent::Object
retrieve_p_completed_percent(torrent::Peer* peer) {
if (peer->bitfield()->size_bits() == 0)
return int64_t(0);
return (100 * peer->bitfield()->size_set()) / peer->bitfield()->size_bits();
}
void
initialize_command_peer() {
CMD2_PEER("p.id", [](auto* peer, auto) { return torrent::utils::transform_to_hex_str(peer->id()); });
CMD2_PEER("p.id_html", [](auto* peer, auto) { return torrent::utils::copy_escape_html_str(peer->id()); });
CMD2_PEER("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("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("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("p.address", std::bind(&retrieve_p_address, std::placeholders::_1));
CMD2_PEER("p.port", [](auto* peer, auto) { return torrent::sa_port(peer->peer_info()->socket_address()); });
CMD2_PEER("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 ("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_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));
rpc::rpc.mark_safe("p.address");
rpc::rpc.mark_safe("p.port");
rpc::rpc.mark_safe("p.client_version");
rpc::rpc.mark_safe("p.options_str");
rpc::rpc.mark_safe("p.id");
rpc::rpc.mark_safe("p.id_html");
rpc::rpc.mark_safe("p.up_rate");
rpc::rpc.mark_safe("p.up_total");
rpc::rpc.mark_safe("p.down_rate");
rpc::rpc.mark_safe("p.down_total");
rpc::rpc.mark_safe("p.peer_rate");
rpc::rpc.mark_safe("p.peer_total");
rpc::rpc.mark_safe("p.is_encrypted");
rpc::rpc.mark_safe("p.is_incoming");
rpc::rpc.mark_safe("p.is_obfuscated");
rpc::rpc.mark_safe("p.is_snubbed");
rpc::rpc.mark_safe("p.is_unwanted");
rpc::rpc.mark_safe("p.is_preferred");
rpc::rpc.mark_safe("p.snubbed");
rpc::rpc.mark_safe("p.snubbed.set");
rpc::rpc.mark_safe("p.banned");
rpc::rpc.mark_safe("p.banned.set");
rpc::rpc.mark_safe("p.completed_percent");
rpc::rpc.mark_safe("p.disconnect");
rpc::rpc.mark_safe("p.disconnect_delayed");
}
+83
View File
@@ -0,0 +1,83 @@
#include "config.h"
#include <sys/types.h>
#include "core/manager.h"
#include "core/download.h"
#include "core/download_list.h"
#include "core/view.h"
#include "core/view_manager.h"
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
torrent::Object
cmd_scheduler_simple_added(core::Download* download) {
unsigned int numActive = (*control->view_manager()->find("active"))->size_visible();
int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
if (numActive < (uint64_t)maxActive)
control->core()->download_list()->resume(download);
return torrent::Object();
}
torrent::Object
cmd_scheduler_simple_removed(core::Download* download) {
control->core()->download_list()->pause(download);
core::View* viewActive = *control->view_manager()->find("active");
int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
if ((int64_t)viewActive->size_visible() >= maxActive)
return torrent::Object();
// The 'started' view contains all the views we may choose amongst.
core::View* viewStarted = *control->view_manager()->find("started");
for (core::View::iterator itr = viewStarted->begin_visible(), last = viewStarted->end_visible(); itr != last; itr++) {
if ((*itr)->is_active())
continue;
control->core()->download_list()->resume(*itr);
}
return torrent::Object();
}
torrent::Object
cmd_scheduler_simple_update([[maybe_unused]] core::Download* download) {
core::View* viewActive = *control->view_manager()->find("active");
core::View* viewStarted = *control->view_manager()->find("started");
unsigned int numActive = viewActive->size_visible();
uint64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value();
if (viewActive->size_visible() < maxActive) {
for (core::View::iterator itr = viewStarted->begin_visible(), last = viewStarted->end_visible(); itr != last; itr++) {
if ((*itr)->is_active())
continue;
control->core()->download_list()->resume(*itr);
if (++numActive >= maxActive)
break;
}
} else {
while (viewActive->size_visible() > maxActive)
control->core()->download_list()->pause(*viewActive->begin_visible());
}
return torrent::Object();
}
void
initialize_command_scheduler() {
CMD2_VAR_VALUE("scheduler.max_active", int64_t(-1));
CMD2_DL("scheduler.simple.added", std::bind(&cmd_scheduler_simple_added, std::placeholders::_1));
CMD2_DL("scheduler.simple.removed", std::bind(&cmd_scheduler_simple_removed, std::placeholders::_1));
CMD2_DL("scheduler.simple.update", std::bind(&cmd_scheduler_simple_update, std::placeholders::_1));
}
+250
View File
@@ -0,0 +1,250 @@
#include "config.h"
#include <cstdio>
#include <torrent/throttle.h>
#include <torrent/rate.h>
#include <torrent/download/resource_manager.h>
#include <torrent/net/socket_address.h>
#include "core/manager.h"
#include "ui/root.h"
#include "rpc/parse.h"
#include "rpc/parse_commands.h"
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
std::pair<uint32_t, uint32_t>
parse_address_range(const torrent::Object::list_type& args, torrent::Object::list_type::const_iterator itr) {
unsigned int prefixWidth, ret;
char dummy;
char host[1024];
torrent::sa_unique_ptr sa;
ret = std::sscanf(itr->as_string().c_str(), "%1023[^/]/%d%c", host, &prefixWidth, &dummy);
if (ret < 1)
throw torrent::input_error("Invalid address/prefix.");
try {
sa = torrent::sa_copy(torrent::sa_lookup_address(host, AF_INET).get());
} catch (torrent::input_error& e) {
throw torrent::input_error("Could not resolve host: " + std::string(e.what()));
}
uint32_t begin, end;
auto sa_addr = htonl(reinterpret_cast<sockaddr_in*>(sa.get())->sin_addr.s_addr);
begin = end = sa_addr;
if (ret == 2) {
if (++itr != args.end())
throw torrent::input_error("Cannot specify both network and range end.");
uint32_t netmask = std::numeric_limits<uint32_t>::max() << (32 - prefixWidth);
if (prefixWidth >= 32 || sa_addr & ~netmask)
throw torrent::input_error("Invalid address/prefix.");
end = sa_addr | ~netmask;
} else if (++itr != args.end()) {
try {
sa = torrent::sa_copy(torrent::sa_lookup_address(itr->as_string(), AF_INET).get());
} catch (torrent::input_error& e) {
throw torrent::input_error("Could not resolve host: " + std::string(e.what()));
}
sa_addr = htonl(reinterpret_cast<sockaddr_in*>(sa.get())->sin_addr.s_addr);
end = sa_addr;
}
// convert to [begin, end) making sure the end doesn't overflow
// (this precludes 255.255.255.255 from ever matching, but that's not a real IP anyway)
return std::make_pair((uint32_t)begin, (uint32_t)std::max(end, end + 1));
}
torrent::Object
apply_throttle(const torrent::Object::list_type& args, bool up) {
auto arg_itr = args.begin();
if (arg_itr == args.end())
throw torrent::input_error("Missing throttle name.");
const std::string& name = arg_itr->as_string();
if (name.empty() || name == "NULL")
throw torrent::input_error("Invalid throttle name '" + name + "'.");
if (++arg_itr == args.end() || arg_itr->as_string().empty())
throw torrent::input_error("Missing throttle rate for '" + name + "'.");
int64_t rate;
rpc::parse_whole_value_nothrow(arg_itr->as_string().c_str(), &rate);
if (rate < 0)
throw torrent::input_error("Throttle rate must be non-negative.");
auto itr = control->core()->throttles().find(name);
if (itr == control->core()->throttles().end())
itr = control->core()->throttles().insert(std::make_pair(name, core::ThrottlePair(nullptr, nullptr))).first;
auto*& throttle = up ? itr->second.first : itr->second.second;
if (rate != 0 && throttle == nullptr)
throttle = (up ? torrent::up_throttle_global() : torrent::down_throttle_global())->create_slave();
if (throttle != nullptr)
throttle->set_max_rate(rate * 1024);
return torrent::Object();
}
static const int throttle_info_up = (1 << 0);
static const int throttle_info_down = (1 << 1);
static const int throttle_info_max = (1 << 2);
static const int throttle_info_rate = (1 << 3);
torrent::Object
retrieve_throttle_info(const torrent::Object::string_type& name, int flags) {
auto itr = control->core()->throttles().find(name);
auto throttles = (itr == control->core()->throttles().end()) ? core::ThrottlePair(nullptr, nullptr) : itr->second;
auto* throttle = flags & throttle_info_down ? throttles.second : throttles.first;
auto* global = flags & throttle_info_down ? torrent::down_throttle_global() : torrent::up_throttle_global();
if (throttle == NULL && name.empty())
throttle = global;
if (throttle == NULL)
return flags & throttle_info_rate ? (int64_t)0 : (int64_t)-1;
else if (!throttle->is_throttled() || !global->is_throttled())
return (int64_t)0;
else if (flags & throttle_info_rate)
return (int64_t)throttle->rate()->rate();
else
return (int64_t)throttle->max_rate();
}
torrent::Object
throttle_update(const char* variable, int64_t value) {
rpc::commands.call_command(variable, value);
control->ui()->adjust_up_throttle(0);
control->ui()->adjust_down_throttle(0);
return torrent::Object();
}
void
initialize_command_throttle() {
CMD2_ANY ("throttle.unchoked_uploads", std::bind(&torrent::ResourceManager::currently_upload_unchoked, torrent::resource_manager()));
CMD2_ANY ("throttle.max_unchoked_uploads", std::bind(&torrent::ResourceManager::max_upload_unchoked, torrent::resource_manager()));
CMD2_ANY ("throttle.unchoked_downloads", std::bind(&torrent::ResourceManager::currently_download_unchoked, torrent::resource_manager()));
CMD2_ANY ("throttle.max_unchoked_downloads", std::bind(&torrent::ResourceManager::max_download_unchoked, torrent::resource_manager()));
CMD2_VAR_VALUE ("throttle.min_peers.normal", 100);
CMD2_VAR_VALUE ("throttle.max_peers.normal", 200);
CMD2_VAR_VALUE ("throttle.min_peers.seed", -1);
CMD2_VAR_VALUE ("throttle.max_peers.seed", -1);
CMD2_VAR_VALUE ("throttle.min_uploads", 0);
CMD2_VAR_VALUE ("throttle.max_uploads", 50);
CMD2_VAR_VALUE ("throttle.min_downloads", 0);
CMD2_VAR_VALUE ("throttle.max_downloads", 50);
CMD2_VAR_VALUE ("throttle.max_uploads.div._val", 1);
CMD2_VAR_VALUE ("throttle.max_uploads.global._val", 0);
CMD2_VAR_VALUE ("throttle.max_downloads.div._val", 1);
CMD2_VAR_VALUE ("throttle.max_downloads.global._val", 0);
CMD2_REDIRECT ("throttle.max_uploads.div", "throttle.max_uploads.div._val");
CMD2_REDIRECT ("throttle.max_uploads.global", "throttle.max_uploads.global._val");
CMD2_REDIRECT ("throttle.max_downloads.div", "throttle.max_downloads.div._val");
CMD2_REDIRECT ("throttle.max_downloads.global", "throttle.max_downloads.global._val");
CMD2_ANY_VALUE ("throttle.max_uploads.div.set", std::bind(&throttle_update, "throttle.max_uploads.div._val.set", std::placeholders::_2));
CMD2_ANY_VALUE ("throttle.max_uploads.global.set", std::bind(&throttle_update, "throttle.max_uploads.global._val.set", std::placeholders::_2));
CMD2_ANY_VALUE ("throttle.max_downloads.div.set", std::bind(&throttle_update, "throttle.max_downloads.div._val.set", std::placeholders::_2));
CMD2_ANY_VALUE ("throttle.max_downloads.global.set", std::bind(&throttle_update, "throttle.max_downloads.global._val.set", std::placeholders::_2));
// TODO: Move the logic into some libtorrent function.
CMD2_ANY ("throttle.global_up.rate", std::bind(&torrent::Rate::rate, torrent::up_rate()));
CMD2_ANY ("throttle.global_up.total", std::bind(&torrent::Rate::total, torrent::up_rate()));
CMD2_ANY ("throttle.global_up.max_rate", std::bind(&torrent::Throttle::max_rate, torrent::up_throttle_global()));
CMD2_ANY_VALUE_V ("throttle.global_up.max_rate.set", std::bind(&ui::Root::set_up_throttle_i64, control->ui(), std::placeholders::_2));
CMD2_ANY_VALUE_KB("throttle.global_up.max_rate.set_kb", std::bind(&ui::Root::set_up_throttle_i64, control->ui(), std::placeholders::_2));
CMD2_ANY ("throttle.global_down.rate", std::bind(&torrent::Rate::rate, torrent::down_rate()));
CMD2_ANY ("throttle.global_down.total", std::bind(&torrent::Rate::total, torrent::down_rate()));
CMD2_ANY ("throttle.global_down.max_rate", std::bind(&torrent::Throttle::max_rate, torrent::down_throttle_global()));
CMD2_ANY_VALUE_V ("throttle.global_down.max_rate.set", std::bind(&ui::Root::set_down_throttle_i64, control->ui(), std::placeholders::_2));
CMD2_ANY_VALUE_KB("throttle.global_down.max_rate.set_kb", std::bind(&ui::Root::set_down_throttle_i64, control->ui(), std::placeholders::_2));
// Temporary names, need to change this to accept real rates rather
// than kB.
CMD2_ANY_LIST ("throttle.up", std::bind(&apply_throttle, std::placeholders::_2, true));
CMD2_ANY_LIST ("throttle.down", std::bind(&apply_throttle, std::placeholders::_2, false));
CMD2_ANY_STRING ("throttle.up.max", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_up | throttle_info_max));
CMD2_ANY_STRING ("throttle.up.rate", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_up | throttle_info_rate));
CMD2_ANY_STRING ("throttle.down.max", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_down | throttle_info_max));
CMD2_ANY_STRING ("throttle.down.rate", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_down | throttle_info_rate));
rpc::rpc.mark_safe("throttle.unchoked_uploads");
rpc::rpc.mark_safe("throttle.max_unchoked_uploads");
rpc::rpc.mark_safe("throttle.unchoked_downloads");
rpc::rpc.mark_safe("throttle.max_unchoked_downloads");
rpc::rpc.mark_safe("throttle.min_peers.normal");
rpc::rpc.mark_safe("throttle.min_peers.normal.set");
rpc::rpc.mark_safe("throttle.max_peers.normal");
rpc::rpc.mark_safe("throttle.max_peers.normal.set");
rpc::rpc.mark_safe("throttle.min_peers.seed");
rpc::rpc.mark_safe("throttle.min_peers.seed.set");
rpc::rpc.mark_safe("throttle.max_peers.seed");
rpc::rpc.mark_safe("throttle.max_peers.seed.set");
rpc::rpc.mark_safe("throttle.min_uploads");
rpc::rpc.mark_safe("throttle.min_uploads.set");
rpc::rpc.mark_safe("throttle.max_uploads");
rpc::rpc.mark_safe("throttle.max_uploads.set");
rpc::rpc.mark_safe("throttle.min_downloads");
rpc::rpc.mark_safe("throttle.min_downloads.set");
rpc::rpc.mark_safe("throttle.max_downloads");
rpc::rpc.mark_safe("throttle.max_downloads.set");
rpc::rpc.mark_safe("throttle.max_uploads.div");
rpc::rpc.mark_safe("throttle.max_uploads.div.set");
rpc::rpc.mark_safe("throttle.max_uploads.div._val");
rpc::rpc.mark_safe("throttle.max_uploads.div._val.set");
rpc::rpc.mark_safe("throttle.max_uploads.global");
rpc::rpc.mark_safe("throttle.max_uploads.global.set");
rpc::rpc.mark_safe("throttle.max_uploads.global._val");
rpc::rpc.mark_safe("throttle.max_uploads.global._val.set");
rpc::rpc.mark_safe("throttle.max_downloads.div");
rpc::rpc.mark_safe("throttle.max_downloads.div.set");
rpc::rpc.mark_safe("throttle.max_downloads.div._val");
rpc::rpc.mark_safe("throttle.max_downloads.div._val.set");
rpc::rpc.mark_safe("throttle.max_downloads.global");
rpc::rpc.mark_safe("throttle.max_downloads.global.set");
rpc::rpc.mark_safe("throttle.max_downloads.global._val");
rpc::rpc.mark_safe("throttle.max_downloads.global._val.set");
rpc::rpc.mark_safe("throttle.global_up.rate");
rpc::rpc.mark_safe("throttle.global_up.total");
rpc::rpc.mark_safe("throttle.global_up.max_rate");
rpc::rpc.mark_safe("throttle.global_up.max_rate.set");
rpc::rpc.mark_safe("throttle.global_up.max_rate.set_kb");
rpc::rpc.mark_safe("throttle.global_down.rate");
rpc::rpc.mark_safe("throttle.global_down.total");
rpc::rpc.mark_safe("throttle.global_down.max_rate");
rpc::rpc.mark_safe("throttle.global_down.max_rate.set");
rpc::rpc.mark_safe("throttle.global_down.max_rate.set_kb");
rpc::rpc.mark_safe("throttle.up.max");
rpc::rpc.mark_safe("throttle.up.rate");
rpc::rpc.mark_safe("throttle.down.max");
rpc::rpc.mark_safe("throttle.down.rate");
}
+180
View File
@@ -0,0 +1,180 @@
#include "config.h"
#include <cassert>
#include <cstdio>
#include <netdb.h>
#include <torrent/net/resolver.h>
#include <torrent/runtime/network_config.h>
#include <torrent/runtime/network_manager.h>
#include <torrent/system/callbacks.h>
#include <torrent/tracker/dht_controller.h>
#include <torrent/tracker/tracker.h>
#include <torrent/utils/log.h>
#include "core/download.h"
#include "core/manager.h"
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
#include "core/dht_manager.h"
void
tracker_set_enabled(torrent::tracker::Tracker* tracker, bool state) {
if (state)
tracker->enable();
else
tracker->disable();
}
torrent::Object
apply_dht_add_node(const std::string& arg) {
int port;
char dummy;
char host[1024];
int ret = std::sscanf(arg.c_str(), "%1023[^:]:%i%c", host, &port, &dummy);
if (ret == 1)
port = 6881;
else if (ret != 2)
throw torrent::input_error("Could not parse host.");
if (port < 1 || port > 65535)
throw torrent::input_error("Invalid port number.");
assert(std::this_thread::get_id() == torrent::main_thread::thread_id());
auto host_str = std::string(host);
// TODO: Move this lookup to DhtController.
auto callback_id = torrent::system::make_callback_id();
// Currently discarding SOCK_STREAM.
torrent::this_thread::resolver()->resolve_specific(callback_id, host_str, PF_INET, [host_str, port](torrent::c_sa_shared_ptr sa, int err) {
if (sa == nullptr) {
lt_log_print(torrent::LOG_DHT_ERROR, "dht.add_node : could not resolve host : %s (%s)", gai_strerror(err), host_str.c_str());
return;
}
lt_log_print(torrent::LOG_DHT_CONTROLLER, "dht.add_node : %s", host_str.c_str());
torrent::runtime::network_manager()->dht_add_bootstrap_node(host_str.c_str(), port);
});
return torrent::Object();
}
torrent::Object
apply_enable_trackers(int64_t arg) {
if (arg == 0) {
for (auto download : *control->core()->download_list())
download->tracker_controller().for_each([](auto& tracker) { tracker.disable(); });
} else {
for (auto download : *control->core()->download_list())
download->tracker_controller().for_each([](auto& tracker) { tracker.enable(); });
}
return torrent::Object();
}
void
initialize_command_tracker() {
CMD2_TRACKER ("t.is_busy", [](auto* tracker, auto) { return tracker->is_requesting(); });
CMD2_TRACKER ("t.is_enabled", [](auto* tracker, auto) { return tracker->is_enabled(); });
CMD2_TRACKER ("t.is_extra_tracker", [](auto* tracker, auto) { return tracker->is_extra_tracker(); });
CMD2_TRACKER ("t.is_open", [](auto* tracker, auto) { return tracker->is_requesting(); });
CMD2_TRACKER ("t.is_scrapable", [](auto* tracker, auto) { return tracker->is_scrapable(); });
CMD2_TRACKER ("t.is_usable", [](auto* tracker, auto) { return tracker->is_usable(); });
// TODO: Deprecate.
CMD2_TRACKER ("t.can_scrape", [](auto* tracker, auto) { return tracker->is_scrapable(); });
CMD2_TRACKER_V ("t.enable", [](auto* tracker, auto) { tracker->enable(); });
CMD2_TRACKER_V ("t.disable", [](auto* tracker, auto) { tracker->disable(); });
CMD2_TRACKER_VALUE_V("t.is_enabled.set", [](auto* tracker, auto& value) { return tracker_set_enabled(tracker, value); });
CMD2_TRACKER ("t.url", [](auto* tracker, auto) { return tracker->url(); });
CMD2_TRACKER ("t.group", [](auto* tracker, auto) { return tracker->group(); });
CMD2_TRACKER ("t.type", [](auto* tracker, auto) { return tracker->type(); });
CMD2_TRACKER ("t.id", [](auto* tracker, auto) { return tracker->tracker_id(); });
CMD2_TRACKER ("t.latest_event", [](auto* tracker, auto) { return tracker->state().latest_event(); });
CMD2_TRACKER ("t.latest_new_peers", [](auto* tracker, auto) { return tracker->state().latest_new_peers(); });
CMD2_TRACKER ("t.latest_sum_peers", [](auto* tracker, auto) { return tracker->state().latest_sum_peers(); });
CMD2_TRACKER ("t.normal_interval", [](auto* tracker, auto) { return tracker->state().normal_interval().count(); });
CMD2_TRACKER ("t.min_interval", [](auto* tracker, auto) { return tracker->state().min_interval().count(); });
CMD2_TRACKER ("t.activity_time_next", [](auto* tracker, auto) { return tracker->state().activity_time_next().count(); });
CMD2_TRACKER ("t.activity_time_last", [](auto* tracker, auto) { return tracker->state().activity_time_last().count(); });
CMD2_TRACKER ("t.success_time_next", [](auto* tracker, auto) { return tracker->state().success_time_next().count(); });
CMD2_TRACKER ("t.success_time_last", [](auto* tracker, auto) { return tracker->state().success_time_last().count(); });
CMD2_TRACKER ("t.success_counter", [](auto* tracker, auto) { return tracker->state().success_counter(); });
CMD2_TRACKER ("t.failed_time_next", [](auto* tracker, auto) { return tracker->state().failed_time_next().count(); });
CMD2_TRACKER ("t.failed_time_last", [](auto* tracker, auto) { return tracker->state().failed_time_last().count(); });
CMD2_TRACKER ("t.failed_counter", [](auto* tracker, auto) { return tracker->state().failed_counter(); });
CMD2_TRACKER ("t.scrape_time_last", [](auto* tracker, auto) { return tracker->state().scrape_time_last().count(); });
CMD2_TRACKER ("t.scrape_counter", [](auto* tracker, auto) { return tracker->state().scrape_counter(); });
CMD2_TRACKER ("t.scrape_complete", [](auto* tracker, auto) { return tracker->state().scrape_complete(); });
CMD2_TRACKER ("t.scrape_incomplete", [](auto* tracker, auto) { return tracker->state().scrape_incomplete(); });
CMD2_TRACKER ("t.scrape_downloaded", [](auto* tracker, auto) { return tracker->state().scrape_downloaded(); });
CMD2_ANY_VALUE ("trackers.enable", [](auto, auto) { return apply_enable_trackers(1); });
CMD2_ANY_VALUE ("trackers.disable", [](auto, auto) { return apply_enable_trackers(0); });
CMD2_VAR_BOOL ("trackers.delay_scrape", false);
CMD2_VAR_VALUE ("trackers.numwant", -1);
CMD2_ANY ("trackers.use_udp", [](auto, auto) { return true; });
CMD2_ANY_VALUE_V ("trackers.use_udp.set", [](auto, auto) {
lt_log_print(torrent::LOG_ERROR, "trackers.use_udp.set is no longer supported", 0);
})
CMD2_ANY_STRING_V ("dht.mode.set", [](auto, auto& str) { return control->dht_manager()->set_mode_by_user(str); });
CMD2_ANY ("dht.port", [](auto, auto) { return torrent::runtime::network_manager()->dht_controller()->port(); });
CMD2_ANY_VALUE_V ("dht.port.set", [](auto, auto) {
lt_log_print(torrent::LOG_DHT_ERROR, "dht.port.set is no longer supported, use dht.override_port.set", 0);
});
CMD2_ANY ("dht.override_port", [](auto, auto) { return torrent::runtime::network_config()->override_dht_port(); });
CMD2_ANY_VALUE_V ("dht.override_port.set", [](auto, auto& value) { return torrent::runtime::network_manager()->set_dht_port(value); });
CMD2_ANY_STRING ("dht.add_node", [](auto, auto& str) { return apply_dht_add_node(str); });
CMD2_ANY ("dht.statistics", [](auto, auto) { return control->dht_manager()->dht_statistics(); });
rpc::rpc.mark_safe("t.url");
rpc::rpc.mark_safe("t.group");
rpc::rpc.mark_safe("t.id");
rpc::rpc.mark_safe("t.type");
rpc::rpc.mark_safe("t.is_usable");
rpc::rpc.mark_safe("t.is_busy");
rpc::rpc.mark_safe("t.is_enabled");
rpc::rpc.mark_safe("t.is_enabled.set");
rpc::rpc.mark_safe("t.is_extra_tracker");
rpc::rpc.mark_safe("t.is_open");
rpc::rpc.mark_safe("t.normal_interval");
rpc::rpc.mark_safe("t.scrape_time_last");
rpc::rpc.mark_safe("t.scrape_counter");
rpc::rpc.mark_safe("t.success_time_last");
rpc::rpc.mark_safe("t.success_counter");
rpc::rpc.mark_safe("t.failed_time_last");
rpc::rpc.mark_safe("t.failed_counter");
rpc::rpc.mark_safe("t.activity_time_last");
rpc::rpc.mark_safe("t.activity_time_next");
rpc::rpc.mark_safe("t.scrape_complete");
rpc::rpc.mark_safe("t.scrape_incomplete");
rpc::rpc.mark_safe("t.scrape_downloaded");
rpc::rpc.mark_safe("dht.mode.set");
rpc::rpc.mark_safe("dht.port");
rpc::rpc.mark_safe("dht.override_port");
rpc::rpc.mark_safe("dht.add_node");
rpc::rpc.mark_safe("dht.statistics");
rpc::rpc.mark_safe("trackers.numwant");
rpc::rpc.mark_safe("trackers.use_udp");
}
+940
View File
@@ -0,0 +1,940 @@
#include "config.h"
#include <sys/types.h>
#include <ctime>
#include <regex>
#include <torrent/utils/log.h>
#include "core/manager.h"
#include "core/view_manager.h"
#include "display/canvas.h"
#include "ui/root.h"
#include "ui/download_list.h"
#include "display/color_map.h"
#include "rpc/parse.h"
#include "globals.h"
#include "control.h"
#include "command_helpers.h"
typedef void (core::ViewManager::*view_event_slot)(const std::string&, const torrent::Object&);
torrent::Object
apply_view_filter_on(const torrent::Object::list_type& args) {
if (args.size() < 1)
throw torrent::input_error("Too few arguments.");
const std::string& name = args.front().as_string();
if (name.empty())
throw torrent::input_error("First argument must be a string.");
core::ViewManager::filter_args filterArgs;
for (torrent::Object::list_const_iterator itr = ++args.begin(), last = args.end(); itr != last; itr++)
filterArgs.push_back(itr->as_string());
control->view_manager()->set_filter_on(name, filterArgs);
return torrent::Object();
}
torrent::Object
apply_view_event(view_event_slot viewFilterSlot, const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Wrong argument count.");
(control->view_manager()->*viewFilterSlot)(args.front().as_string(), args.back());
return torrent::Object();
}
torrent::Object
apply_view_sort(const torrent::Object::list_type& args) {
if (args.size() <= 0 || args.size() > 2)
throw torrent::input_error("Wrong argument count.");
const std::string& name = args.front().as_string();
if (name.empty())
throw torrent::input_error("First argument must be a string.");
int32_t value = 0;
if (args.size() == 2)
value = rpc::convert_to_value(args.back());
control->view_manager()->sort(name, value);
return torrent::Object();
}
torrent::Object
apply_view_list() {
torrent::Object rawResult = torrent::Object::create_list();
torrent::Object::list_type& result = rawResult.as_list();
for (auto itr : *control->view_manager())
result.push_back(itr->name());
return rawResult;
}
torrent::Object
apply_view_set(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Wrong argument count.");
core::ViewManager::iterator itr = control->view_manager()->find(args.back().as_string());
if (itr == control->view_manager()->end())
throw torrent::input_error("Could not find view \"" + args.back().as_string() + "\".");
// if (args.front().as_string() == "main")
// control->ui()->download_list()->set_view(*itr);
// else
throw torrent::input_error("No such target.");
}
torrent::Object
apply_print([[maybe_unused]] rpc::target_type target, const torrent::Object& rawArgs) {
char buffer[1024];
rpc::print_object(buffer, buffer + 1024, &rawArgs, 0);
control->core()->push_log(buffer);
return torrent::Object();
}
torrent::Object
apply_cat([[maybe_unused]] rpc::target_type target, const torrent::Object& rawArgs) {
std::string result;
rpc::print_object_std(&result, &rawArgs, 0);
return result;
}
torrent::Object
apply_value([[maybe_unused]] rpc::target_type target, const torrent::Object::list_type& args) {
if (args.size() < 1)
throw torrent::input_error("'value' takes at least a number argument!");
if (args.size() > 2)
throw torrent::input_error("'value' takes at most two arguments!");
torrent::Object::value_type val = 0;
if (args.front().is_value()) {
val = args.front().as_value();
} else {
int base = args.size() > 1 ? args.back().is_value() ?
args.back().as_value() : strtol(args.back().as_string().c_str(), NULL, 10) : 10;
char* endptr = 0;
val = strtoll(args.front().as_string().c_str(), &endptr, base);
while (*endptr == ' ' || *endptr == '\n') ++endptr;
if (*endptr)
throw torrent::input_error("Junk at end of number: " + args.front().as_string());
}
return val;
}
torrent::Object
apply_try(rpc::target_type target, const torrent::Object& args) {
try {
return rpc::call_object(args, target);
} catch (torrent::input_error& e) {
lt_log_print(torrent::LOG_RPC_EVENTS, "try command caught input_error: %s", e.what());
}
return torrent::Object();
}
// Move these boolean operators to a new file.
inline bool
as_boolean(const torrent::Object& rawArgs) {
switch (rawArgs.type()) {
case torrent::Object::TYPE_VALUE: return rawArgs.as_value();
case torrent::Object::TYPE_STRING: return !rawArgs.as_string().empty();
// We need to properly handle argument lists that are single-object
// at a higher level.
case torrent::Object::TYPE_LIST: return !rawArgs.as_list().empty() && as_boolean(rawArgs.as_list().front());
// case torrent::Object::TYPE_MAP: return !rawArgs.as_map().empty();
default: return false;
}
}
torrent::Object
apply_not(rpc::target_type target, const torrent::Object& rawArgs) {
bool result;
if (rawArgs.is_dict_key())
result = as_boolean(rpc::commands.call_command(rawArgs.as_dict_key().c_str(), rawArgs.as_dict_obj(),
target));
// TODO: Thus we should clean this up...
else if (rawArgs.is_list() && !rawArgs.as_list().empty())
return apply_not(target, rawArgs.as_list().front());
else
result = as_boolean(rawArgs);
return (int64_t)!result;
}
torrent::Object
apply_false([[maybe_unused]] rpc::target_type target, [[maybe_unused]] const torrent::Object& rawArgs) {
return (int64_t)0;
}
torrent::Object
apply_and(rpc::target_type target, const torrent::Object& rawArgs) {
if (rawArgs.type() != torrent::Object::TYPE_LIST)
return as_boolean(rawArgs);
for (const auto& itr : rawArgs.as_list())
if (itr.is_dict_key()) {
if (!as_boolean(rpc::commands.call_command(itr.as_dict_key().c_str(), itr.as_dict_obj(), target)))
return (int64_t)false;
} else if (itr.is_value()) {
if (!itr.as_value())
return (int64_t)false;
} else {
// TODO: Switch to new versions that only accept the new command syntax.
if (!as_boolean(rpc::parse_command_single(target, itr.as_string())))
return (int64_t)false;
}
return (int64_t)true;
}
torrent::Object
apply_or(rpc::target_type target, const torrent::Object& rawArgs) {
if (rawArgs.type() != torrent::Object::TYPE_LIST)
return as_boolean(rawArgs);
for (const auto& itr : rawArgs.as_list())
if (itr.is_dict_key()) {
if (as_boolean(rpc::commands.call_command(itr.as_dict_key().c_str(), itr.as_dict_obj(), target)))
return (int64_t)true;
} else if (itr.is_value()) {
if (itr.as_value())
return (int64_t)true;
} else {
if (as_boolean(rpc::parse_command_single(target, itr.as_string())))
return (int64_t)true;
}
return (int64_t)false;
}
torrent::Object
apply_cmp(rpc::target_type target, const torrent::Object::list_type& args) {
// We only need to check if empty() since if size() == 1 it calls
// the same command for both, or if size() == 2 then each side of
// the comparison has different commands.
if (args.empty())
throw torrent::input_error("Wrong argument count.");
// This really should be converted to using args flagged as
// commands, so that we can compare commands and statics values.
torrent::Object result1;
torrent::Object result2;
rpc::target_type target1 = rpc::is_target_pair(target) ? rpc::get_target_left(target) : target;
rpc::target_type target2 = rpc::is_target_pair(target) ? rpc::get_target_right(target) : target;
if (args.front().is_dict_key())
result1 = rpc::commands.call_command(args.front().as_dict_key().c_str(), args.front().as_dict_obj(), target1);
else
result1 = rpc::parse_command_single(target1, args.front().as_string());
if (args.back().is_dict_key())
result2 = rpc::commands.call_command(args.back().as_dict_key().c_str(), args.back().as_dict_obj(), target2);
else
result2 = rpc::parse_command_single(target2, args.back().as_string());
if (result1.type() != result2.type())
throw torrent::input_error("Type mismatch.");
switch (result1.type()) {
case torrent::Object::TYPE_VALUE: return result1.as_value() - result2.as_value();
case torrent::Object::TYPE_STRING: return result1.as_string().compare(result2.as_string());
default: return torrent::Object();
}
}
torrent::Object apply_less(rpc::target_type target, const torrent::Object::list_type& args) {
torrent::Object result = apply_cmp(target, args);
return result.is_value() ? result.as_value() < 0 : (int64_t)false;
}
torrent::Object apply_greater(rpc::target_type target, const torrent::Object::list_type& args) {
torrent::Object result = apply_cmp(target, args);
return result.is_value() ? result.as_value() > 0 : (int64_t)false;
}
torrent::Object apply_equal(rpc::target_type target, const torrent::Object::list_type& args) {
torrent::Object result = apply_cmp(target, args);
return result.is_value() ? result.as_value() == 0 : (int64_t)false;
}
torrent::Object
apply_compare(rpc::target_type target, const torrent::Object::list_type& args) {
if (!rpc::is_target_pair(target))
throw torrent::input_error("Can only compare a target pair.");
if (args.size() < 2)
throw torrent::input_error("Need at least order and one field.");
torrent::Object::list_const_iterator itr = args.begin();
std::string order = (itr++)->as_string();
const char* current = order.c_str();
torrent::Object result1;
torrent::Object result2;
for (torrent::Object::list_const_iterator last = args.end(); itr != last; itr++) {
std::string field = itr->as_string();
result1 = rpc::parse_command_single(rpc::get_target_left(target), field);
result2 = rpc::parse_command_single(rpc::get_target_right(target), field);
if (result1.type() != result2.type())
throw torrent::input_error(std::string("Type mismatch in compare of ") + field);
bool descending = *current == 'd' || *current == 'D' || *current == '-';
if (*current) {
if (!descending && !(*current == 'a' || *current == 'A' || *current == '+'))
throw torrent::input_error(std::string("Bad order '") + *current + "' in " + order);
++current;
}
switch (result1.type()) {
case torrent::Object::TYPE_VALUE:
if (result1.as_value() != result2.as_value())
return (int64_t) (descending ^ (result1.as_value() < result2.as_value()));
break;
case torrent::Object::TYPE_STRING:
if (result1.as_string() != result2.as_string())
return (int64_t) (descending ^ (result1.as_string() < result2.as_string()));
break;
default:
break; // treat unknown types as equal
}
}
// if all else is equal, ensure stable sort order based on memory location
return (int64_t) (target.second < target.third);
}
// Regexp based 'match' function.
// arg1: the text to match.
// arg2: the regexp pattern.
// eg: match{d.name=,.*linux.*iso}
torrent::Object apply_match(rpc::target_type target, const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Wrong argument count for 'match': 2 arguments needed.");
// This really should be converted to using args flagged as
// commands, so that we can compare commands and statics values.
torrent::Object result1;
torrent::Object result2;
rpc::target_type target1 = rpc::is_target_pair(target) ? rpc::get_target_left(target) : target;
rpc::target_type target2 = rpc::is_target_pair(target) ? rpc::get_target_right(target) : target;
if (args.front().is_dict_key())
result1 = rpc::commands.call_command(args.front().as_dict_key().c_str(), args.front().as_dict_obj(), target1);
else
result1 = rpc::parse_command_single(target1, args.front().as_string());
if (args.back().is_dict_key())
result2 = rpc::commands.call_command(args.back().as_dict_key().c_str(), args.back().as_dict_obj(), target2);
else
result2 = args.back().as_string();
if (result1.type() != result2.type())
throw torrent::input_error("Type mismatch for 'match' arguments.");
std::string text = result1.as_string();
std::string pattern = result2.as_string();
std::transform(text.begin(), text.end(), text.begin(), ::tolower);
std::transform(pattern.begin(), pattern.end(), pattern.begin(), ::tolower);
bool isAMatch = false;
try {
std::regex re(pattern);
isAMatch = std::regex_match(text, re);
} catch (const std::regex_error& exc) {
control->core()->push_log_std("regex_error: " + std::string(exc.what()));
}
return isAMatch ? (int64_t)true : (int64_t)false;
}
torrent::Object
apply_to_time(const torrent::Object& rawArgs, int flags) {
std::tm *u;
time_t t = (uint64_t)rawArgs.as_value();
if (flags & 0x1)
u = std::localtime(&t);
else
u = std::gmtime(&t);
if (u == NULL)
return torrent::Object();
char buffer[11];
if (flags & 0x2)
snprintf(buffer, 11, "%02u/%02u/%04u", u->tm_mday, (u->tm_mon + 1), (1900 + u->tm_year));
else
snprintf(buffer, 9, "%2d:%02d:%02d", u->tm_hour, u->tm_min, u->tm_sec);
return std::string(buffer);
}
torrent::Object
apply_to_elapsed_time(const torrent::Object& rawArgs) {
auto cached_seconds = torrent::this_thread::cached_seconds().count();
uint64_t arg = cached_seconds - rawArgs.as_value();
char buffer[48];
snprintf(buffer, 48, "%2d:%02d:%02d", (int)(arg / 3600), (int)((arg / 60) % 60), (int)(arg % 60));
return std::string(buffer);
}
torrent::Object
apply_to_kb(const torrent::Object& rawArgs) {
char buffer[32];
snprintf(buffer, 32, "%5.1f", (double)rawArgs.as_value() / (1 << 10));
return std::string(buffer);
}
torrent::Object
apply_to_mb(const torrent::Object& rawArgs) {
char buffer[32];
snprintf(buffer, 32, "%8.1f", (double)rawArgs.as_value() / (1 << 20));
return std::string(buffer);
}
torrent::Object
apply_to_xb(const torrent::Object& rawArgs) {
char buffer[48];
int64_t arg = rawArgs.as_value();
if (arg < (int64_t(1000) << 10))
snprintf(buffer, 48, "%5.1f KB", (double)arg / (int64_t(1) << 10));
else if (arg < (int64_t(1000) << 20))
snprintf(buffer, 48, "%5.1f MB", (double)arg / (int64_t(1) << 20));
else if (arg < (int64_t(1000) << 30))
snprintf(buffer, 48, "%5.1f GB", (double)arg / (int64_t(1) << 30));
else
snprintf(buffer, 48, "%5.1f TB", (double)arg / (int64_t(1) << 40));
return std::string(buffer);
}
torrent::Object
apply_to_throttle(const torrent::Object& rawArgs) {
int64_t arg = rawArgs.as_value();
if (arg < 0)
return "---";
else if (arg == 0)
return "off";
char buffer[32];
snprintf(buffer, 32, "%3d", (int)(arg / (1 << 10)));
return std::string(buffer);
}
// A series of if/else statements. Every even arguments are
// conditionals and odd arguments are branches to be executed, except
// the last one which is always a branch.
//
// if (cond1) { branch1 }
// <cond1>,<branch1>
//
// if (cond1) { branch1 } else if (cond2) { branch2 } else { branch3 }
// <cond1>,<branch1>,<cond2>,<branch2>,<branch3>
torrent::Object
apply_if(rpc::target_type target, const torrent::Object& raw_args, int flags) {
auto& args = raw_args.as_list();
auto itr = args.begin();
if (args.empty())
throw torrent::input_error("Empty argument list to " + std::string((flags & 0x1) ? "branch" : "if") + ".");
{
torrent::Object tmp;
const torrent::Object* conditional;
if (flags & 0x1 && itr->is_string())
conditional = &(tmp = rpc::parse_command(target, itr->as_string().c_str(), itr->as_string().c_str() + itr->as_string().size()).first);
else if (flags & 0x1 && itr->is_dict_key())
conditional = &(tmp = rpc::commands.call_command(itr->as_dict_key().c_str(), itr->as_dict_obj(), target));
else
conditional = &*itr;
bool result;
switch (conditional->type()) {
case torrent::Object::TYPE_STRING:
result = !conditional->as_string().empty();
break;
case torrent::Object::TYPE_VALUE:
result = conditional->as_value();
break;
case torrent::Object::TYPE_NONE:
result = false;
break;
default:
throw torrent::input_error("Type not supported by " + std::string((flags & 0x1) ? "branch" : "if") + ".");
};
itr++;
if (!result && itr != args.end())
itr++;
}
if (itr == args.end())
return torrent::Object();
if (flags & 0x1) {
if (itr->is_string())
return rpc::parse_command(target, itr->as_string().c_str(), itr->as_string().c_str() + itr->as_string().size()).first;
if (itr->is_dict_key())
return rpc::commands.call_command(itr->as_dict_key().c_str(), itr->as_dict_obj(), target);
if (itr->is_list()) {
for (const auto& cmd_itr : itr->as_list()) {
if (cmd_itr.is_string())
rpc::parse_command(target, cmd_itr.as_string().c_str(), cmd_itr.as_string().c_str() + cmd_itr.as_string().size());
else if (cmd_itr.is_dict_key())
rpc::commands.call_command(cmd_itr.as_dict_key().c_str(), cmd_itr.as_dict_obj(), target);
else
throw torrent::input_error("Invalid command type in branch list.");
}
return torrent::Object();
}
throw torrent::input_error("Invalid command type in branch.");
}
return *itr;
}
torrent::Object
cmd_view_size(const torrent::Object::string_type& args) {
return (*control->view_manager()->find_throw(args))->size_visible();
}
torrent::Object
cmd_view_size_not_visible(const torrent::Object::string_type& args) {
return (*control->view_manager()->find_throw(args))->size_not_visible();
}
torrent::Object
cmd_view_persistent(const torrent::Object::string_type& args) {
core::View* view = *control->view_manager()->find_throw(args);
if (!view->get_filter().is_empty() || !view->event_added().is_empty() || !view->event_removed().is_empty())
throw torrent::input_error("Cannot set modified views as persitent.");
view->set_filter("d.views.has=" + args);
view->set_event_added("d.views.push_back_unique=" + args);
view->set_event_removed("d.views.remove=" + args);
return torrent::Object();
}
// TODO: These don't need wrapper functions anymore...
torrent::Object
cmd_ui_set_view(const torrent::Object::string_type& args) {
control->ui()->download_list()->set_current_view(args);
return torrent::Object();
}
torrent::Object
cmd_ui_current_view() {
return control->ui()->download_list()->current_view()->name();
}
torrent::Object
cmd_ui_unfocus_download(core::Download* download) {
control->ui()->download_list()->unfocus_download(download);
return torrent::Object();
}
torrent::Object
cmd_view_filter_download(core::Download* download, const torrent::Object::string_type& args) {
(*control->view_manager()->find_throw(args))->filter_download(download);
return torrent::Object();
}
torrent::Object
cmd_view_set_visible(core::Download* download, const torrent::Object::string_type& args) {
(*control->view_manager()->find_throw(args))->set_visible(download);
return torrent::Object();
}
torrent::Object
cmd_view_set_not_visible(core::Download* download, const torrent::Object::string_type& args) {
(*control->view_manager()->find_throw(args))->set_not_visible(download);
return torrent::Object();
}
torrent::Object
apply_elapsed_less(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Wrong argument count.");
int64_t start_time = rpc::convert_to_value(args.front());
auto cached_seconds = torrent::this_thread::cached_seconds().count();
return (int64_t)(start_time != 0 && cached_seconds - start_time < rpc::convert_to_value(args.back()));
}
torrent::Object
apply_elapsed_greater(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Wrong argument count.");
int64_t start_time = rpc::convert_to_value(args.front());
auto cached_seconds = torrent::this_thread::cached_seconds().count();
return (int64_t)(start_time != 0 && cached_seconds - start_time > rpc::convert_to_value(args.back()));
}
inline std::vector<int64_t>
as_vector(const torrent::Object::list_type& args) {
if (args.size() == 0)
throw torrent::input_error("Wrong argument count in as_vector.");
std::vector<int64_t> result;
for (const auto& arg : args) {
if (arg.is_value()) {
result.push_back(arg.as_value());
} else if (arg.is_string()) {
result.push_back(rpc::convert_to_value(arg.as_string()));
} else if (arg.is_list()) {
std::vector<int64_t> subResult = as_vector(arg.as_list());
result.insert(result.end(), subResult.begin(), subResult.end());
} else {
throw torrent::input_error("Wrong type supplied to as_vector.");
}
}
return result;
}
template <typename Comp>
int64_t
apply_math_basic(const char* name, Comp op, const torrent::Object::list_type& args) {
int64_t val = 0, rhs = 0;
bool divides = !strcmp(name, "math.div") || !strcmp(name, "math.mod");
if (args.size() == 0)
throw torrent::input_error(std::string(name) + ": No arguments provided!");
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
if (itr->is_value()) {
rhs = itr->as_value();
} else if (itr->is_string()) {
rhs = rpc::convert_to_value(itr->as_string());
} else if (itr->is_list()) {
rhs = apply_math_basic(name, op, itr->as_list());
} else {
throw torrent::input_error(std::string(name) + ": Wrong argument type");
}
if (divides && !rhs && itr != args.begin())
throw torrent::input_error(std::string(name) + ": Division by zero!");
val = itr == args.begin() ? rhs : op(val, rhs);
}
return val;
}
template <typename Comp>
int64_t
apply_arith_basic(Comp op, const torrent::Object::list_type& args) {
if (args.size() == 0)
throw torrent::input_error("Wrong argument count in apply_arith_basic.");
int64_t val = 0;
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
if (itr->is_value()) {
val = itr == args.begin() ? itr->as_value() : (op(val, itr->as_value()) ? val : itr->as_value());
} else if (itr->is_string()) {
int64_t cval = rpc::convert_to_value(itr->as_string());
val = itr == args.begin() ? cval : (op(val, cval) ? val : cval);
} else if (itr->is_list()) {
int64_t fval = apply_arith_basic(op, itr->as_list());
val = itr == args.begin() ? fval : (op(val, fval) ? val : fval);
} else {
throw torrent::input_error("Wrong type supplied to apply_arith_basic.");
}
}
return val;
}
int64_t
apply_arith_count(const torrent::Object::list_type& args) {
if (args.size() == 0)
throw torrent::input_error("Wrong argument count in apply_arith_count.");
int64_t val = 0;
for (const auto& arg : args) {
switch (arg.type()) {
case torrent::Object::TYPE_VALUE:
case torrent::Object::TYPE_STRING:
val++;
break;
case torrent::Object::TYPE_LIST:
val += apply_arith_count(arg.as_list());
break;
default:
throw torrent::input_error("Wrong type supplied to apply_arith_count.");
}
}
return val;
}
// Get the median of an unordered set of numbers of arbitrary
// type by modifing the underlying dataset
template <typename T = double, typename _InputIter>
T median(_InputIter __first, _InputIter __last) {
T __med;
unsigned int __size = __last - __first;
unsigned int __middle = __size / 2;
_InputIter __target1 = __first + __middle;
std::nth_element(__first, __target1, __last);
__med = *__target1;
if (__size % 2 == 0) {
_InputIter __target2 = std::max_element(__first, __target1);
__med = (__med + *__target2) / 2.0;
}
return __med;
}
int64_t
apply_arith_other(const char* op, const torrent::Object::list_type& args) {
if (args.size() == 0)
throw torrent::input_error("Wrong argument count in apply_arith_other.");
if (strcmp(op, "average") == 0) {
return (int64_t)(apply_math_basic(op, std::plus<int64_t>(), args) / apply_arith_count(args));
} else if (strcmp(op, "median") == 0) {
std::vector<int64_t> result = as_vector(args);
return (int64_t)median(result.begin(), result.end());
} else {
throw torrent::input_error("Wrong operation supplied to apply_arith_other.");
}
}
torrent::Object
cmd_status_throttle_names(bool up, const torrent::Object::list_type& args) {
if (args.size() == 0)
return torrent::Object();
std::vector<std::string> throttle_name_list;
for (const auto& arg : args) {
if (arg.is_string())
throttle_name_list.push_back(arg.as_string());
}
if (up)
control->ui()->set_status_throttle_up_names(throttle_name_list);
else
control->ui()->set_status_throttle_down_names(throttle_name_list);
return torrent::Object();
}
torrent::Object
apply_set_color(int color_id, const torrent::Object::string_type& color_str) {
control->object_storage()->set_str_string(display::color_vars[color_id], color_str);
display::Canvas::build_colors();
return torrent::Object();
}
void
initialize_command_ui() {
CMD2_VAR_STRING ("keys.layout", "qwerty");
CMD2_ANY_STRING ("view.add", object_convert_void(std::bind(&core::ViewManager::insert_throw, control->view_manager(), std::placeholders::_2)));
CMD2_ANY_L ("view.list", std::bind(&apply_view_list));
CMD2_ANY_LIST ("view.set", std::bind(&apply_view_set, std::placeholders::_2));
CMD2_ANY_LIST ("view.filter", std::bind(&apply_view_event, &core::ViewManager::set_filter, std::placeholders::_2));
CMD2_ANY_LIST ("view.filter_on", std::bind(&apply_view_filter_on, std::placeholders::_2));
CMD2_ANY_LIST ("view.filter.temp", std::bind(&apply_view_event, &core::ViewManager::set_filter_temp, std::placeholders::_2));
CMD2_VAR_STRING ("view.filter.temp.excluded", "default,started,stopped");
CMD2_VAR_BOOL ("view.filter.temp.log", 0);
CMD2_ANY_LIST ("view.sort", std::bind(&apply_view_sort, std::placeholders::_2));
CMD2_ANY_LIST ("view.sort_new", std::bind(&apply_view_event, &core::ViewManager::set_sort_new, std::placeholders::_2));
CMD2_ANY_LIST ("view.sort_current", std::bind(&apply_view_event, &core::ViewManager::set_sort_current, std::placeholders::_2));
CMD2_ANY_LIST ("view.event_added", std::bind(&apply_view_event, &core::ViewManager::set_event_added, std::placeholders::_2));
CMD2_ANY_LIST ("view.event_removed", std::bind(&apply_view_event, &core::ViewManager::set_event_removed, std::placeholders::_2));
CMD2_ANY_STRING ("view.size", std::bind(&cmd_view_size, std::placeholders::_2));
CMD2_ANY_STRING ("view.size_not_visible", std::bind(&cmd_view_size_not_visible, std::placeholders::_2));
CMD2_ANY_STRING ("view.persistent", std::bind(&cmd_view_persistent, std::placeholders::_2));
CMD2_ANY_STRING_V("view.filter_all", std::bind(&core::View::filter, std::bind(&core::ViewManager::find_ptr_throw, control->view_manager(), std::placeholders::_2)));
CMD2_DL_STRING ("view.filter_download", std::bind(&cmd_view_filter_download, std::placeholders::_1, std::placeholders::_2));
CMD2_DL_STRING ("view.set_visible", std::bind(&cmd_view_set_visible, std::placeholders::_1, std::placeholders::_2));
CMD2_DL_STRING ("view.set_not_visible", std::bind(&cmd_view_set_not_visible, std::placeholders::_1, std::placeholders::_2));
// Commands that affect the default rtorrent UI.
CMD2_DL ("ui.unfocus_download", std::bind(&cmd_ui_unfocus_download, std::placeholders::_1));
CMD2_ANY ("ui.current_view", std::bind(&cmd_ui_current_view));
CMD2_ANY_STRING ("ui.current_view.set", std::bind(&cmd_ui_set_view, std::placeholders::_2));
CMD2_ANY ("ui.input.history.size", std::bind(&ui::Root::get_input_history_size, control->ui()));
CMD2_ANY_VALUE_V ("ui.input.history.size.set", std::bind(&ui::Root::set_input_history_size, control->ui(), std::placeholders::_2));
CMD2_ANY_V ("ui.input.history.clear", std::bind(&ui::Root::clear_input_history, control->ui()));
CMD2_VAR_VALUE ("ui.throttle.global.step.small", 5);
CMD2_VAR_VALUE ("ui.throttle.global.step.medium", 50);
CMD2_VAR_VALUE ("ui.throttle.global.step.large", 500);
CMD2_VAR_VALUE ("ui.focus.page_size", 0);
CMD2_ANY_LIST ("ui.status.throttle.up.set", std::bind(&cmd_status_throttle_names, true, std::placeholders::_2));
CMD2_ANY_LIST ("ui.status.throttle.down.set", std::bind(&cmd_status_throttle_names, false, std::placeholders::_2));
CMD2_ANY ("ui.keymap.style", std::bind(&ui::Root::keymap_style, control->ui()));
CMD2_ANY_STRING_V("ui.keymap.style.set", std::bind(&ui::Root::set_keymap_style, control->ui(), std::placeholders::_2));
// TODO: Add 'option_string' for rtorrent-specific options.
CMD2_VAR_STRING ("ui.torrent_list.layout", "full");
// Move.
CMD2_ANY("print", &apply_print);
CMD2_ANY("cat", &apply_cat);
CMD2_ANY_LIST("value", &apply_value);
CMD2_ANY("try", &apply_try);
CMD2_ANY("if", std::bind(&apply_if, std::placeholders::_1, std::placeholders::_2, 0));
CMD2_ANY("not", &apply_not);
CMD2_ANY("false", &apply_false);
CMD2_ANY("and", &apply_and);
CMD2_ANY("or", &apply_or);
// A temporary command for handling stuff until we get proper
// support for seperation of commands and literals.
CMD2_ANY("branch", std::bind(&apply_if, std::placeholders::_1, std::placeholders::_2, 1));
CMD2_ANY_LIST("less", &apply_less);
CMD2_ANY_LIST("greater", &apply_greater);
CMD2_ANY_LIST("equal", &apply_equal);
CMD2_ANY_LIST("compare", &apply_compare);
CMD2_ANY_LIST("match", &apply_match);
CMD2_ANY_VALUE("convert.gm_time", std::bind(&apply_to_time, std::placeholders::_2, 0));
CMD2_ANY_VALUE("convert.gm_date", std::bind(&apply_to_time, std::placeholders::_2, 0x2));
CMD2_ANY_VALUE("convert.time", std::bind(&apply_to_time, std::placeholders::_2, 0x1));
CMD2_ANY_VALUE("convert.date", std::bind(&apply_to_time, std::placeholders::_2, 0x1 | 0x2));
CMD2_ANY_VALUE("convert.elapsed_time", std::bind(&apply_to_elapsed_time, std::placeholders::_2));
CMD2_ANY_VALUE("convert.kb", std::bind(&apply_to_kb, std::placeholders::_2));
CMD2_ANY_VALUE("convert.mb", std::bind(&apply_to_mb, std::placeholders::_2));
CMD2_ANY_VALUE("convert.xb", std::bind(&apply_to_xb, std::placeholders::_2));
CMD2_ANY_VALUE("convert.throttle", std::bind(&apply_to_throttle, std::placeholders::_2));
CMD2_ANY_LIST("math.add", [](auto, const auto& args) { return apply_math_basic("math.add", std::plus(), args); });
CMD2_ANY_LIST("math.sub", [](auto, const auto& args) { return apply_math_basic("math.sub", std::minus(), args); });
CMD2_ANY_LIST("math.mul", [](auto, const auto& args) { return apply_math_basic("math.mul", std::multiplies(), args); });
CMD2_ANY_LIST("math.div", [](auto, const auto& args) { return apply_math_basic("math.div", std::divides(), args); });
CMD2_ANY_LIST("math.mod", [](auto, const auto& args) { return apply_math_basic("math.mod", std::modulus(), args); });
CMD2_ANY_LIST("math.min", [](auto, const auto& args) { return apply_arith_basic(std::less(), args); });
CMD2_ANY_LIST("math.max", [](auto, const auto& args) { return apply_arith_basic(std::greater(), args); });
CMD2_ANY_LIST("math.cnt", std::bind(&apply_arith_count, std::placeholders::_2));
CMD2_ANY_LIST("math.avg", std::bind(&apply_arith_other, "average", std::placeholders::_2));
CMD2_ANY_LIST("math.med", std::bind(&apply_arith_other, "median", std::placeholders::_2));
CMD2_ANY_LIST ("elapsed.less", std::bind(&apply_elapsed_less, std::placeholders::_2));
CMD2_ANY_LIST ("elapsed.greater", std::bind(&apply_elapsed_greater, std::placeholders::_2));
// Build set/get methods for all color definitions
for (int color_id = 1; color_id < display::RCOLOR_MAX; color_id++) {
control->object_storage()->insert_str(display::color_vars[color_id], "", rpc::object_storage::flag_string_type);
CMD2_ANY_STRING(std::string(display::color_vars[color_id]) + ".set", [color_id](const auto&, const auto& arg) {
return apply_set_color(color_id, arg);
});
CMD2_ANY(display::color_vars[color_id], [color_id](const auto&, const auto&) {
return control->object_storage()->get_str(display::color_vars[color_id]);
});
}
rpc::rpc.mark_safe("view.set_visible");
rpc::rpc.mark_safe("view.set_not_visible");
rpc::rpc.mark_safe("cat");
rpc::rpc.mark_safe("if");
rpc::rpc.mark_safe("branch");
rpc::rpc.mark_safe("and");
rpc::rpc.mark_safe("or");
rpc::rpc.mark_safe("not");
rpc::rpc.mark_safe("value");
rpc::rpc.mark_safe("compare");
rpc::rpc.mark_safe("elapsed.less");
rpc::rpc.mark_safe("elapsed.greater");
rpc::rpc.mark_safe("convert.gm_time");
rpc::rpc.mark_safe("convert.gm_date");
rpc::rpc.mark_safe("convert.time");
rpc::rpc.mark_safe("convert.date");
rpc::rpc.mark_safe("convert.elapsed_time");
rpc::rpc.mark_safe("convert.kb");
rpc::rpc.mark_safe("convert.mb");
rpc::rpc.mark_safe("convert.xb");
rpc::rpc.mark_safe("convert.throttle");
}
+171
View File
@@ -0,0 +1,171 @@
#include "config.h"
#include "control.h"
#include <unistd.h>
#include <sys/stat.h>
#include <torrent/net/http_stack.h>
#include <torrent/runtime/network_manager.h>
#include <torrent/runtime/runtime.h>
#include <torrent/utils/directory_events.h>
#include "core/dht_manager.h"
#include "core/http_queue.h"
#include "core/manager.h"
#include "core/view_manager.h"
#include "display/canvas.h"
#include "display/window.h"
#include "display/window_http_queue.h"
#include "display/window_input.h"
#include "display/window_statusbar.h"
#include "display/window_title.h"
#include "display/manager.h"
#include "input/manager.h"
#include "input/input_event.h"
#include "rpc/command_scheduler.h"
#include "rpc/lua.h"
#include "rpc/parse_commands.h"
#include "rpc/object_storage.h"
#include "session/session_manager.h"
#include "ui/root.h"
#include "utils/watch_ready_queue.h"
Control::Control()
: m_ui(new ui::Root()),
m_display(new display::Manager()),
m_input(new input::Manager()),
m_inputStdin(new input::InputEvent(STDIN_FILENO)),
m_commandScheduler(new rpc::CommandScheduler()),
m_objectStorage(new rpc::object_storage()),
m_lua_engine(new rpc::LuaEngine()),
m_directory_events(new torrent::directory_events()),
m_watch_ready_queue(new utils::WatchReadyQueue()) {
m_core = std::make_unique<core::Manager>();
m_view_manager = std::make_unique<core::ViewManager>();
m_dht_manager = std::make_unique<core::DhtManager>();
m_inputStdin->slot_pressed(std::bind(&input::Manager::pressed, m_input.get(), std::placeholders::_1));
m_task_shutdown.slot() = [this] { handle_shutdown(); };
m_task_shutdown_clear_requests.slot() = [this] { handle_shutdown_clear_requests(); };
m_commandScheduler->set_slot_error_message([this](const std::string& msg) { m_core->push_log_std(msg); });
}
Control::~Control() {
m_view_manager.reset();
m_ui.reset();
m_display.reset();
}
void
Control::initialize() {
session_thread::thread()->start_thread();
scgi_thread::thread()->start_thread();
display::Canvas::initialize();
display::Window::slot_schedule([this](display::Window* w, std::chrono::microseconds t) { m_display->schedule(w, t); });
display::Window::slot_unschedule([this](display::Window* w) { m_display->unschedule(w); });
display::Window::slot_adjust([this]() { m_display->adjust_layout(); });
m_core->set_hashing_view(*m_view_manager->find_throw("hashing"));
m_ui->init(this);
if(!display::Canvas::daemon())
m_inputStdin->insert();
}
void
Control::cleanup() {
rpc::rpc.cleanup();
torrent::this_thread::scheduler()->erase(&m_task_shutdown);
torrent::this_thread::scheduler()->erase(&m_task_shutdown_clear_requests);
if(!display::Canvas::daemon())
m_inputStdin->remove();
m_directory_events->close();
if (scgi_thread::thread()->is_active())
scgi_thread::thread()->stop_thread_wait();
// Wait for all session files to be written.
session_thread::manager()->flush_all_pending_builds();
session_thread::thread()->stop_thread_wait();
m_ui->cleanup();
m_core->cleanup();
display::Canvas::erase_std();
display::Canvas::refresh_std();
display::Canvas::do_update();
display::Canvas::cleanup();
}
void
Control::cleanup_exception() {
display::Canvas::cleanup();
}
bool
Control::is_shutdown_completed() {
if (!m_shutdown_quick)
return false;
// Tracker requests can be disowned, so wait for these to
// finish. The edge case of torrent http downloads may delay
// shutdown.
// TODO: We keep http requests in the queue for a while after, so improve this check to ignore
// those.
if (torrent::net_thread::http_stack()->size() != 0 || !core()->http_queue()->empty())
return false;
return core()->is_download_shutdown_completed();
}
void
Control::handle_shutdown() {
m_watch_ready_queue->shutdown();
rpc::commands.call_catch("event.system.shutdown", rpc::make_target(), "shutdown", "System shutdown event action failed: ");
if (scgi_thread::thread()->is_active())
scgi_thread::thread()->stop_thread_wait();
if (!m_shutdown_quick) {
torrent::runtime::network_manager()->listen_close();
torrent::runtime::shutdown();
m_directory_events->close();
m_core->shutdown(false);
if (!m_task_shutdown.is_scheduled())
torrent::this_thread::scheduler()->wait_for_ceil_seconds(&m_task_shutdown, 5s);
} else {
torrent::runtime::quick_shutdown();
m_core->shutdown(true);
}
if (!m_task_shutdown_clear_requests.is_scheduled())
torrent::this_thread::scheduler()->wait_for_ceil_seconds(&m_task_shutdown_clear_requests, 10s);
m_shutdown_quick = true;
m_shutdown_received = false;
}
void
Control::handle_shutdown_clear_requests() {
torrent::net_thread::http_stack()->clear_requests();
// Use 5s for the initial wait to ensure trackers get a chance to finish both IPv4 and IPv6 requests.
if (m_clear_requests_count++ == 0)
torrent::this_thread::scheduler()->wait_for(&m_task_shutdown_clear_requests, 5s);
else
torrent::this_thread::scheduler()->wait_for(&m_task_shutdown_clear_requests, 1s);
}
+121
View File
@@ -0,0 +1,121 @@
#ifndef RTORRENT_CONTROL_H
#define RTORRENT_CONTROL_H
#include <atomic>
#include <cinttypes>
#include <memory>
#include <sys/types.h>
#include <torrent/torrent.h>
#include <torrent/system/scheduler.h>
namespace ui {
class Root;
}
namespace core {
class Manager;
class ViewManager;
class DhtManager;
}
namespace display {
class Manager;
}
namespace input {
class InputEvent;
class Manager;
}
namespace rpc {
class CommandScheduler;
class XmlRpc;
class object_storage;
class LuaEngine;
}
namespace torrent {
class directory_events;
}
namespace utils {
class WatchReadyQueue;
}
class Control {
public:
Control();
~Control();
bool is_shutdown_completed();
bool is_shutdown_received() { return m_shutdown_received; }
bool is_shutdown_started() { return m_shutdown_quick; }
void initialize();
void cleanup();
void cleanup_exception();
void handle_shutdown();
void handle_shutdown_clear_requests();
void receive_normal_shutdown() { m_shutdown_received = true; }
void receive_quick_shutdown() { m_shutdown_received = true; m_shutdown_quick = true; }
core::Manager* core() { return m_core.get(); }
core::ViewManager* view_manager() { return m_view_manager.get(); }
core::DhtManager* dht_manager() { return m_dht_manager.get(); }
ui::Root* ui() { return m_ui.get(); }
display::Manager* display() { return m_display.get(); }
input::Manager* input() { return m_input.get(); }
input::InputEvent* input_stdin() { return m_inputStdin.get(); }
rpc::CommandScheduler* command_scheduler() { return m_commandScheduler.get(); }
rpc::object_storage* object_storage() { return m_objectStorage.get(); }
rpc::LuaEngine* lua_engine() { return m_lua_engine.get(); }
torrent::directory_events* directory_events() { return m_directory_events.get(); }
utils::WatchReadyQueue* watch_ready_queue() { return m_watch_ready_queue.get(); }
uint64_t tick() const { return m_tick; }
void inc_tick() { m_tick++; }
const std::string& working_directory() const { return m_workingDirectory; }
void set_working_directory(const std::string& dir);
private:
Control(const Control&);
void operator = (const Control&);
std::unique_ptr<core::Manager> m_core;
std::unique_ptr<core::ViewManager> m_view_manager;
std::unique_ptr<core::DhtManager> m_dht_manager;
std::unique_ptr<ui::Root> m_ui;
std::unique_ptr<display::Manager> m_display;
std::unique_ptr<input::Manager> m_input;
std::unique_ptr<input::InputEvent> m_inputStdin;
std::unique_ptr<rpc::CommandScheduler> m_commandScheduler;
std::unique_ptr<rpc::object_storage> m_objectStorage;
std::unique_ptr<rpc::LuaEngine> m_lua_engine;
std::unique_ptr<torrent::directory_events> m_directory_events;
std::unique_ptr<utils::WatchReadyQueue> m_watch_ready_queue;
uint64_t m_tick{};
mode_t m_umask;
std::string m_workingDirectory;
torrent::system::SchedulerEntry m_task_shutdown;
torrent::system::SchedulerEntry m_task_shutdown_clear_requests;
int m_clear_requests_count{};
align_cacheline
std::atomic<bool> m_shutdown_received{};
std::atomic<bool> m_shutdown_quick{};
};
#endif
+319
View File
@@ -0,0 +1,319 @@
#include "config.h"
#include "dht_manager.h"
#include <fstream>
#include <sstream>
#include <torrent/object.h>
#include <torrent/object_stream.h>
#include <torrent/rate.h>
#include <torrent/runtime/network_manager.h>
#include <torrent/runtime/runtime.h>
#include <torrent/tracker/dht_controller.h>
#include <torrent/utils/log.h>
#include "control.h"
#include "download.h"
#include "globals.h"
#include "manager.h"
#include "rpc/parse_commands.h"
#include "session/session_manager.h"
#define LT_LOG(log_fmt, ...) \
lt_log_print_subsystem(torrent::LOG_DHT_CONTROLLER, "dht_manager", log_fmt, __VA_ARGS__);
#define LT_LOG_ERROR(log_fmt, ...) \
lt_log_print_subsystem(torrent::LOG_DHT_ERROR, "dht_manager", log_fmt, __VA_ARGS__);
namespace core {
const char* DhtManager::dht_settings[dht_settings_num] = { "disable", "off", "auto", "on" };
DhtManager::~DhtManager() {
torrent::this_thread::scheduler()->erase(&m_update_timeout);
torrent::this_thread::scheduler()->erase(&m_stop_timeout);
}
void
DhtManager::load_dht_cache() {
if (m_start == dht_disable || !session_thread::manager()->is_used()) {
LT_LOG("ignoring cache file", 0);
return;
}
auto cache_filename = session_thread::manager()->path() + "rtorrent.dht_cache";
auto cache_stream = std::fstream(cache_filename.c_str(), std::ios::in | std::ios::binary);
torrent::Object cache = torrent::Object::create_map();
if (cache_stream.is_open()) {
cache_stream >> cache;
// If the cache file is corrupted we will just discard it with an
// error message.
if (cache_stream.fail()) {
LT_LOG_ERROR("cache file corrupted, discarding (path:%s)", cache_filename.c_str());
cache = torrent::Object::create_map();
} else {
LT_LOG("cache file read (path:%s)", cache_filename.c_str());
}
} else {
LT_LOG("could not open cache file (path:%s)", cache_filename.c_str());
}
torrent::runtime::network_manager()->dht_controller()->initialize(cache);
if (m_start == dht_on)
start_dht();
}
void
DhtManager::start_dht() {
torrent::this_thread::scheduler()->erase(&m_stop_timeout);
if (!torrent::runtime::network_manager()->is_dht_valid()) {
LT_LOG("server start skipped, manager is uninitialized", 0);
return;
}
if (torrent::runtime::network_manager()->is_dht_active()) {
LT_LOG("server start skipped, already active", 0);
return;
}
if (!torrent::runtime::network_manager()->dht_controller()->start()) {
m_start = dht_off;
return;
}
torrent::runtime::network_manager()->dht_controller()->reset_statistics();
m_update_timeout.slot() = std::bind(&DhtManager::update, this);
torrent::this_thread::scheduler()->wait_for_ceil_seconds(&m_update_timeout, 60s);
m_dhtPrevCycle = 0;
m_dhtPrevQueriesSent = 0;
m_dhtPrevRepliesReceived = 0;
m_dhtPrevQueriesReceived = 0;
m_dhtPrevBytesUp = 0;
m_dhtPrevBytesDown = 0;
}
void
DhtManager::stop_dht() {
torrent::this_thread::scheduler()->erase(&m_update_timeout);
torrent::this_thread::scheduler()->erase(&m_stop_timeout);
if (torrent::runtime::network_manager()->is_dht_active()) {
LT_LOG("stopping server", 0);
log_statistics(true);
torrent::runtime::network_manager()->dht_controller()->stop();
}
}
void
DhtManager::save_dht_cache() {
if (!session_thread::manager()->is_used())
return;
if (!torrent::runtime::network_manager()->is_dht_valid())
return;
auto filename = session_thread::manager()->path() + "rtorrent.dht_cache";
auto filename_tmp = filename + ".new";
auto cache_file = std::fstream(filename_tmp.c_str(), std::ios::out | std::ios::trunc);
if (!cache_file.is_open())
return;
torrent::Object cache = torrent::Object::create_map();
cache_file << *torrent::runtime::network_manager()->dht_controller()->store_cache(&cache);
if (!cache_file.good())
return;
cache_file.close();
::rename(filename_tmp.c_str(), filename.c_str());
}
void
DhtManager::set_mode_by_user(const std::string& arg) {
unsigned int mode = [arg]() {
for (int i = 0; i < dht_settings_num; i++) {
if (arg == dht_settings[i])
return i;
}
throw torrent::input_error("Invalid dht mode: " + arg);
}();
m_set_by_user = true;
if (!torrent::runtime::is_network_initialized()) {
m_start = mode;
return;
}
set_mode_directly(mode);
}
void
DhtManager::set_mode_directly(unsigned int mode) {
if (mode >= dht_settings_num)
throw torrent::input_error("Invalid dht mode.");
m_start = mode;
if (m_start == dht_off)
stop_dht();
else if (m_start == dht_on)
start_dht();
}
void
DhtManager::set_auto_if_untouched_and_has_session() {
if (m_set_by_user) {
set_mode_directly(m_start);
return;
}
if (rpc::call_command_string("session.path").empty()) {
LT_LOG("DHT auto-start disabled, session path not set.", 0);
return;
}
set_mode_directly(dht_auto);
LT_LOG("DHT auto-start enabled.", 0);
}
void
DhtManager::update() {
if (!torrent::runtime::network_manager()->is_dht_active())
throw torrent::internal_error("DhtManager::update called with DHT inactive.");
if (m_start == dht_auto && !m_stop_timeout.is_scheduled()) {
DownloadList::const_iterator itr, end;
for (itr = control->core()->download_list()->begin(), end = control->core()->download_list()->end(); itr != end; ++itr)
if ((*itr)->download()->info()->is_active() && !(*itr)->download()->info()->is_private())
break;
if (itr == end) {
m_stop_timeout.slot() = std::bind(&DhtManager::stop_dht, this);
torrent::this_thread::scheduler()->wait_for_ceil_seconds(&m_stop_timeout, 15min);
}
}
// While bootstrapping (log_statistics returns true), check every minute if it completed, otherwise update every 15 minutes.
if (log_statistics(false))
torrent::this_thread::scheduler()->wait_for_ceil_seconds(&m_update_timeout, 1min);
else
torrent::this_thread::scheduler()->wait_for_ceil_seconds(&m_update_timeout, 15min);
}
bool
DhtManager::log_statistics(bool force) {
auto stats = torrent::runtime::network_manager()->dht_controller()->get_statistics();
// Check for firewall problems.
if (stats.cycle > 2 && stats.queries_sent - m_dhtPrevQueriesSent > 100 && stats.queries_received == m_dhtPrevQueriesReceived) {
// We should have had clients ping us at least but have received
// nothing, that means the UDP port is probably unreachable.
if (torrent::runtime::network_manager()->is_dht_active_and_receiving_requests())
LT_LOG("listening port appears to be unreachable, no queries received", 0);
torrent::runtime::network_manager()->dht_controller()->set_receive_requests(false);
}
if (stats.queries_sent - m_dhtPrevQueriesSent > stats.num_nodes * 2 + 20 && stats.replies_received == m_dhtPrevRepliesReceived) {
// No replies to over 20 queries plus two per node we have. Probably firewalled.
if (!m_warned)
LT_LOG("listening port appears to be firewalled, no replies received", 0);
m_warned = true;
return false;
}
m_warned = false;
if (stats.queries_received > m_dhtPrevQueriesReceived)
torrent::runtime::network_manager()->dht_controller()->set_receive_requests(true);
// Nothing to log while bootstrapping, but check again every minute.
if (stats.cycle <= 1) {
m_dhtPrevCycle = stats.cycle;
return true;
}
// If bootstrap completed between now and the previous check, notify user.
if (m_dhtPrevCycle == 1) {
char buffer[128];
snprintf(buffer, sizeof(buffer), "DHT bootstrap complete, have %d nodes in %d buckets.", stats.num_nodes, stats.num_buckets);
control->core()->push_log_complete(buffer);
m_dhtPrevCycle = stats.cycle;
return false;
};
// Standard DHT statistics on first real cycle, and every 8th cycle
// afterwards (i.e. every 2 hours), or when forced.
if ((force && stats.cycle != m_dhtPrevCycle) || stats.cycle == 3 || stats.cycle > m_dhtPrevCycle + 7) {
char buffer[256];
snprintf(buffer, sizeof(buffer),
"DHT statistics: %d queries in, %d queries out, %d replies received, "
"%d known nodes in %d buckets, %d peers (highest: %d) tracked in %d torrents.",
stats.queries_received - m_dhtPrevQueriesReceived,
stats.queries_sent - m_dhtPrevQueriesSent,
stats.replies_received - m_dhtPrevRepliesReceived,
stats.num_nodes,
stats.num_buckets,
stats.num_peers,
stats.max_peers,
stats.num_trackers);
control->core()->push_log_complete(buffer);
m_dhtPrevCycle = stats.cycle;
m_dhtPrevQueriesSent = stats.queries_sent;
m_dhtPrevRepliesReceived = stats.replies_received;
m_dhtPrevQueriesReceived = stats.queries_received;
}
return false;
}
torrent::Object
DhtManager::dht_statistics() {
torrent::Object dhtStats = torrent::Object::create_map();
dhtStats.insert_key("dht", dht_settings[m_start]);
dhtStats.insert_key("active", torrent::runtime::network_manager()->is_dht_active());
dhtStats.insert_key("throttle", "");
if (torrent::runtime::network_manager()->is_dht_active()) {
auto stats = torrent::runtime::network_manager()->dht_controller()->get_statistics();
dhtStats.insert_key("cycle", stats.cycle);
dhtStats.insert_key("queries_received", stats.queries_received);
dhtStats.insert_key("queries_sent", stats.queries_sent);
dhtStats.insert_key("replies_received", stats.replies_received);
dhtStats.insert_key("errors_received", stats.errors_received);
dhtStats.insert_key("errors_caught", stats.errors_caught);
dhtStats.insert_key("bytes_read", int64_t());
dhtStats.insert_key("bytes_written", int64_t());
dhtStats.insert_key("nodes", stats.num_nodes);
dhtStats.insert_key("buckets", stats.num_buckets);
dhtStats.insert_key("peers", stats.num_peers);
dhtStats.insert_key("peers_max", stats.max_peers);
dhtStats.insert_key("torrents", stats.num_trackers);
}
return dhtStats;
}
}
+55
View File
@@ -0,0 +1,55 @@
#ifndef RTORRENT_CORE_DHT_MANAGER_H
#define RTORRENT_CORE_DHT_MANAGER_H
#include <torrent/object.h>
#include <torrent/system/scheduler.h>
namespace core {
class DhtManager {
public:
static constexpr int dht_disable = 0;
static constexpr int dht_off = 1;
static constexpr int dht_auto = 2;
static constexpr int dht_on = 3;
~DhtManager();
void load_dht_cache();
void save_dht_cache();
torrent::Object dht_statistics();
void start_dht();
void stop_dht();
void auto_start() { if (m_start == dht_auto) start_dht(); }
void set_mode_by_user(const std::string& arg);
void set_mode_directly(unsigned int mode);
void set_auto_if_untouched_and_has_session();
private:
static constexpr int dht_settings_num = 4;
static const char* dht_settings[dht_settings_num];
void update();
bool log_statistics(bool force);
unsigned int m_dhtPrevCycle;
unsigned int m_dhtPrevQueriesSent;
unsigned int m_dhtPrevRepliesReceived;
unsigned int m_dhtPrevQueriesReceived;
uint64_t m_dhtPrevBytesUp;
uint64_t m_dhtPrevBytesDown;
torrent::system::SchedulerEntry m_update_timeout;
torrent::system::SchedulerEntry m_stop_timeout;
bool m_warned{};
bool m_set_by_user{};
int m_start{dht_off};
};
}
#endif
+135
View File
@@ -0,0 +1,135 @@
#include "config.h"
#include "core/download.h"
#include <list>
#include <torrent/exceptions.h>
#include <torrent/rate.h>
#include <torrent/torrent.h>
#include <torrent/tracker/tracker.h>
#include <torrent/data/file.h>
#include <torrent/data/file_list.h>
#include <torrent/utils/file_stat.h>
#include "rpc/parse_commands.h"
#include "control.h"
#include "core/manager.h"
namespace core {
Download::Download(download_type d)
: m_download(d) {
m_download.info()->signal_tracker_success().push_back(std::bind(&Download::receive_tracker_msg, this, ""));
m_download.info()->signal_tracker_failed().push_back(std::bind(&Download::receive_tracker_msg, this, std::placeholders::_1));
}
Download::~Download() {
if (!m_download.is_valid())
return;
m_download = download_type();
}
uint32_t
Download::priority() {
return bencode()->get_key("rtorrent").get_key_value("priority");
}
void
Download::set_priority(uint32_t p) {
p %= 4;
// Seeding torrents get half the priority of unfinished torrents.
if (!is_done())
torrent::download_set_priority(m_download, p * p * 2);
else
torrent::download_set_priority(m_download, p * p);
bencode()->get_key("rtorrent").insert_key("priority", (int64_t)p);
}
uint32_t
Download::connection_list_size() const {
return m_download.connection_list()->size();
}
void
Download::receive_tracker_msg(std::string msg) {
if (msg.empty())
m_message = "";
else
m_message = "Tracker: [" + msg + "]";
}
float
Download::distributed_copies() const {
const uint8_t* avail = m_download.chunks_seen();
const torrent::Bitfield* bitfield = m_download.file_list()->bitfield();
if (avail == NULL)
return 0;
int minAvail = std::numeric_limits<uint8_t>::max();
int num = 0;
for (uint32_t i = m_download.file_list()->size_chunks(); i-- > 0; ) {
int totAvail = (int)avail[i] + bitfield->get(i);
if (totAvail == minAvail) {
num++;
} else if (totAvail < minAvail) {
minAvail = totAvail;
num = 1;
}
}
return minAvail + 1 - bitfield->is_all_set() - (float)num / m_download.file_list()->size_chunks();
}
void
Download::set_throttle_name(const std::string& name) {
if (m_download.info()->is_active())
throw torrent::input_error("Cannot set throttle on active download.");
auto throttles = control->core()->get_throttle(name);
m_download.set_upload_throttle(throttles.first);
m_download.set_download_throttle(throttles.second);
m_download.bencode()->get_key("rtorrent").insert_key("throttle_name", name);
}
void
Download::set_root_directory(const std::string& path) {
// If the download is open, hashed and has completed chunks make
// sure to verify that the download files are still present.
//
// This should ensure that no one tries to set the destination
// directory 'after' moving files. In cases where the user wants to
// override this behavior the download must first be closed or
// 'd.directory_base.set' may be used.
torrent::utils::FileStat file_stat;
torrent::FileList* file_list = m_download.file_list();
if (is_hash_checked() && file_list->completed_chunks() != 0 &&
(file_list->is_multi_file() ?
!file_list->is_root_dir_created() :
!file_stat.update(file_list->front()->frozen_path().str()))) {
set_message("Cannot change the directory of an open download after the files have been moved.");
rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(this));
control->core()->download_list()->close_directly(this);
throw torrent::input_error("Cannot change the directory of an open download after the files have been moved.");
}
control->core()->download_list()->close_directly(this);
file_list->set_root_dir(expand_path(path));
bencode()->get_key("rtorrent").insert_key("directory", path);
}
}
+116
View File
@@ -0,0 +1,116 @@
#ifndef RTORRENT_CORE_DOWNLOAD_H
#define RTORRENT_CORE_DOWNLOAD_H
#include <torrent/common.h>
#include <torrent/download.h>
#include <torrent/download_info.h>
#include <torrent/hash_string.h>
#include <torrent/data/file_list.h>
#include <torrent/peer/connection_list.h>
#include <torrent/tracker/wrappers.h>
#include "globals.h"
namespace core {
class Download {
public:
typedef torrent::Download download_type;
typedef torrent::FileList file_list_type;
typedef torrent::PeerList peer_list_type;
typedef torrent::TrackerList tracker_list_type;
typedef torrent::ConnectionList connection_list_type;
typedef download_type::ConnectionType connection_type;
static constexpr uint32_t default_resume_flags = ~uint32_t{} & ~torrent::Download::open_enable_fallocate;
static const int variable_hashing_stopped = 0;
static const int variable_hashing_initial = 1;
static const int variable_hashing_last = 2;
static const int variable_hashing_rehash = 3;
Download(download_type d);
~Download();
auto info() const { return m_download.info(); }
auto data() const { return m_download.data(); }
auto main() { return m_download.main(); }
bool is_open() const { return m_download.info()->is_open(); }
bool is_active() const { return m_download.info()->is_active(); }
bool is_done() const { return m_download.file_list()->is_done(); }
bool is_downloading() const { return is_active() && !is_done(); }
bool is_seeding() const { return is_active() && is_done(); }
// FIXME: Fixed a bug in libtorrent that caused is_hash_checked to
// return true when the torrent is closed. Remove this redundant
// test in the next milestone.
bool is_hash_checked() const { return is_open() && m_download.is_hash_checked(); }
bool is_hash_checking() const { return m_download.is_hash_checking(); }
bool is_hash_failed() const { return m_hashFailed; }
void set_hash_failed(bool v) { m_hashFailed = v; }
download_type* download() { return &m_download; }
const download_type* c_download() const { return &m_download; }
file_list_type* file_list() { return m_download.file_list(); }
const file_list_type* c_file_list() const { return m_download.file_list(); }
peer_list_type* peer_list() { return m_download.peer_list(); }
const peer_list_type* c_peer_list() const { return m_download.peer_list(); }
torrent::Object* bencode() { return m_download.bencode(); }
auto tracker_controller() { return m_download.tracker_controller(); }
uint32_t tracker_list_size() const { return m_download.c_tracker_controller().size(); }
auto connection_list() { return m_download.connection_list(); }
uint32_t connection_list_size() const;
const std::string& message() const { return m_message; }
void set_message(const std::string& msg) { m_message = msg; }
uint32_t priority();
void set_priority(uint32_t p);
uint32_t resume_flags() { return m_resumeFlags; }
void set_resume_flags(uint32_t flags) { m_resumeFlags = flags; }
void set_root_directory(const std::string& path);
void set_throttle_name(const std::string& name);
bool operator == (const std::string& str) const;
float distributed_copies() const;
// HACK: Choke group setting.
unsigned int group() const { return m_group; }
void set_group(unsigned int g) { m_group = g; }
private:
Download(const Download&);
void operator () (const Download&);
void receive_tracker_msg(std::string msg);
void receive_chunk_failed(uint32_t idx);
// Store the FileList instance so we can use slots etc on it.
download_type m_download;
bool m_hashFailed{};
std::string m_message;
uint32_t m_resumeFlags{default_resume_flags};
unsigned int m_group{};
};
inline bool
Download::operator == (const std::string& str) const {
return str.size() == torrent::HashString::size_data && *torrent::HashString::cast_from(str) == m_download.info()->hash();
}
}
#endif
+417
View File
@@ -0,0 +1,417 @@
#include "config.h"
#include "download_factory.h"
#include <cstdlib>
#include <fstream>
#include <functional>
#include <sstream>
#include <stdexcept>
#include <torrent/utils/log.h>
#include <torrent/utils/resume.h>
#include <torrent/object.h>
#include <torrent/object_stream.h>
#include <torrent/exceptions.h>
#include <torrent/rate.h>
#include <torrent/data/file_utils.h>
#include <torrent/net/http_stack.h>
#include <torrent/runtime/client_config.h>
#include <torrent/utils/string_manip.h>
#include "control.h"
#include "globals.h"
#include "core/download.h"
#include "core/http_queue.h"
#include "core/manager.h"
#include "rpc/parse_commands.h"
namespace core {
bool
is_network_uri(const std::string& uri) {
return
std::strncmp(uri.c_str(), "http://", 7) == 0 ||
std::strncmp(uri.c_str(), "https://", 8) == 0 ||
std::strncmp(uri.c_str(), "ftp://", 6) == 0;
}
static std::unique_ptr<torrent::Object>
download_factory_load_stream(const char* filename) {
std::fstream stream(filename, std::ios::in | std::ios::binary);
if (!stream.is_open())
return std::unique_ptr<torrent::Object>();
auto obj = std::make_unique<torrent::Object>();
stream >> *obj;
if (!stream.good())
return std::unique_ptr<torrent::Object>();
return obj;
}
bool
is_magnet_uri(const std::string& uri) {
return
std::strncmp(uri.c_str(), "magnet:?", 8) == 0;
}
DownloadFactory::DownloadFactory(Manager* m) :
m_manager(m) {
m_task_load.slot() = std::bind(&DownloadFactory::receive_load, this);
m_task_commit.slot() = std::bind(&DownloadFactory::receive_commit, this);
// m_variables["connection_leech"] = rpc::call_command("protocol.connection.leech");
// m_variables["connection_seed"] = rpc::call_command("protocol.connection.seed");
m_variables["connection_leech"] = std::string();
m_variables["connection_seed"] = std::string();
m_variables["directory"] = rpc::call_command("directory.default");
m_variables["tied_to_file"] = torrent::Object((int64_t)false);
}
DownloadFactory::~DownloadFactory() {
torrent::this_thread::scheduler()->erase(&m_task_load);
torrent::this_thread::scheduler()->erase(&m_task_commit);
delete m_object;
}
void
DownloadFactory::load(const std::string& uri) {
m_uri = uri;
torrent::this_thread::scheduler()->wait_for(&m_task_load, 0ms);
}
// This function must be called before DownloadFactory::commit().
void
DownloadFactory::load_raw_data(const std::string& input) {
if (m_stream)
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
m_stream.reset(new std::stringstream(input));
m_loaded = true;
}
void
DownloadFactory::commit() {
torrent::this_thread::scheduler()->wait_for(&m_task_commit, 0ms);
}
void
DownloadFactory::receive_load() {
if (m_stream)
throw torrent::internal_error("DownloadFactory::load*() called on an object with m_stream != NULL");
if (is_network_uri(m_uri)) {
m_stream.reset(new std::stringstream);
auto done_fn = [this]() { receive_loaded(); };
auto failed_fn = [this](const std::string& error) { receive_failed(error); };
m_manager->http_queue()->insert(m_uri, m_stream, done_fn, failed_fn);
m_variables["tied_to_file"] = (int64_t)false;
return;
}
if (is_magnet_uri(m_uri)) {
// DEBUG: Use m_object.
m_stream.reset(new std::stringstream());
*m_stream << "d10:magnet-uri" << m_uri.length() << ":" << m_uri << "e";
m_variables["tied_to_file"] = (int64_t)false;
receive_loaded();
return;
}
std::fstream stream(expand_path(m_uri).c_str(), std::ios::in | std::ios::binary);
if (!stream.is_open())
return receive_failed("Could not open file");
m_object = new torrent::Object;
stream >> *m_object;
if (!stream.good())
return receive_failed("Reading torrent file failed");
m_isFile = true;
receive_loaded();
}
void
DownloadFactory::receive_loaded() {
m_loaded = true;
if (m_commited)
receive_success();
}
void
DownloadFactory::receive_commit() {
m_commited = true;
if (m_loaded)
receive_success();
}
void
DownloadFactory::receive_success() {
auto rtorrent_object = download_factory_load_stream((expand_path(m_uri) + ".rtorrent").c_str());
auto libtorrent_resume_object = download_factory_load_stream((expand_path(m_uri) + ".libtorrent_resume").c_str());
uint32_t tracker_key;
if (rtorrent_object && rtorrent_object->has_key_value("key"))
tracker_key = rtorrent_object->get_key_value("key");
else
tracker_key = random() % (std::numeric_limits<uint32_t>::max() - 1) + 1;
Download* download = m_stream != nullptr ?
m_manager->download_list()->create(m_stream.get(), tracker_key, m_printLog) :
m_manager->download_list()->create(m_object, tracker_key, m_printLog);
m_object = NULL;
if (download == NULL) {
// core::Manager should already have added the error message to
// the log.
m_slot_finished();
return;
}
torrent::Object* root = download->bencode();
if (download->download()->info()->is_meta_download()) {
torrent::Object& meta = root->insert_key("rtorrent_meta_download", torrent::Object::create_map());
meta.insert_key("start", m_start);
meta.insert_key("print_log", m_printLog);
torrent::Object::list_type& commands = meta.insert_key("commands", torrent::Object::create_list()).as_list();
for (auto& m_command : m_commands)
commands.push_back(m_command);
}
if (m_session) {
if (rtorrent_object)
root->insert_key_move("rtorrent", *rtorrent_object);
if (libtorrent_resume_object)
root->insert_key_move("libtorrent_resume", *libtorrent_resume_object);
} else {
// We only allow session torrents to keep their
// 'rtorrent/libtorrent' sections. The "fast_resume" section
// should be safe to keep.
root->erase_key("rtorrent");
}
torrent::Object* rtorrent = &root->insert_preserve_copy("rtorrent", torrent::Object::create_map()).first->second;
torrent::Object& resumeObject = root->insert_preserve_copy("libtorrent_resume", torrent::Object::create_map()).first->second;
rtorrent->insert_key("key", download->tracker_controller().key());
initialize_rtorrent(download, rtorrent);
if (!rtorrent->has_key_string("custom1")) rtorrent->insert_key("custom1", std::string());
if (!rtorrent->has_key_string("custom2")) rtorrent->insert_key("custom2", std::string());
if (!rtorrent->has_key_string("custom3")) rtorrent->insert_key("custom3", std::string());
if (!rtorrent->has_key_string("custom4")) rtorrent->insert_key("custom4", std::string());
if (!rtorrent->has_key_string("custom5")) rtorrent->insert_key("custom5", std::string());
rpc::call_command("d.uploads_min.set", rpc::call_command("throttle.min_uploads"), rpc::make_target(download));
rpc::call_command("d.uploads_max.set", rpc::call_command("throttle.max_uploads"), rpc::make_target(download));
rpc::call_command("d.downloads_min.set", rpc::call_command("throttle.min_downloads"), rpc::make_target(download));
rpc::call_command("d.downloads_max.set", rpc::call_command("throttle.max_downloads"), rpc::make_target(download));
rpc::call_command("d.peers_min.set", rpc::call_command("throttle.min_peers.normal"), rpc::make_target(download));
rpc::call_command("d.peers_max.set", rpc::call_command("throttle.max_peers.normal"), rpc::make_target(download));
rpc::call_command("d.tracker_numwant.set", rpc::call_command("trackers.numwant"), rpc::make_target(download));
rpc::call_command("d.max_file_size.set", rpc::call_command("system.file.max_size"), rpc::make_target(download));
if (rpc::call_command_value("d.complete", rpc::make_target(download)) != 0) {
if (rpc::call_command_value("throttle.min_peers.seed") >= 0)
rpc::call_command("d.peers_min.set", rpc::call_command("throttle.min_peers.seed"), rpc::make_target(download));
if (rpc::call_command_value("throttle.max_peers.seed") >= 0)
rpc::call_command("d.peers_max.set", rpc::call_command("throttle.max_peers.seed"), rpc::make_target(download));
}
// Skip forcing trackers to scrape when rtorrent starts
if (m_initLoad && rpc::call_command_value("trackers.delay_scrape"))
download->set_resume_flags(torrent::Download::start_skip_tracker);
// Check first if we already have these values set in the session
// torrent, so that it is safe to change the values.
//
// Need to also catch the exceptions.
if (rpc::call_command_value("system.file.split_size") >= 0)
torrent::file_split_all(download->download()->file_list(),
rpc::call_command_value("system.file.split_size"),
rpc::call_command_string("system.file.split_suffix"));
if (rtorrent->has_key_string("directory")) {
rpc::call_command("d.directory_base.set", rtorrent->get_key("directory"), rpc::make_target(download));
} else if (download->download()->info()->is_meta_download()) {
auto& metadata_path = control->core()->magnet_path();
if (!metadata_path.empty())
rpc::call_command("d.directory.set", metadata_path, rpc::make_target(download));
else
rpc::call_command("d.directory.set", session_thread::session_path(), rpc::make_target(download));
} else {
rpc::call_command("d.directory.set", m_variables["directory"], rpc::make_target(download));
}
if (!m_session && m_variables["tied_to_file"].as_value())
rpc::call_command("d.tied_to_file.set", m_uri.empty() ? m_variables["tied_file"] : m_uri, rpc::make_target(download));
rpc::call_command("d.peer_exchange.set", torrent::runtime::client_config()->is_pex_enabled(), rpc::make_target(download));
torrent::resume_load_addresses(*download->download(), resumeObject);
torrent::resume_load_file_priorities(*download->download(), resumeObject);
torrent::resume_load_tracker_settings(*download->download(), resumeObject);
// The action of inserting might cause the torrent to be
// opened/started or such. Figure out a nicer way of handling this.
if (m_manager->download_list()->insert(download) == m_manager->download_list()->end()) {
// ATM doesn't really ever get here.
delete download;
m_slot_finished();
return;
}
// Save the info-hash just in case the commands decide to delete it.
torrent::HashString infohash = download->info()->hash();
try {
if (torrent::log_groups[torrent::LOG_TORRENT_DEBUG].valid())
log_created(download, rtorrent);
for (const auto& command : m_commands)
rpc::parse_command_multiple_std(command, rpc::make_target(download));
if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end())
throw torrent::input_error("The newly created download was removed.");
if (!m_session)
rpc::call_command("d.state.set", (int64_t)m_start, rpc::make_target(download));
rpc::commands.call_catch(m_session ? "event.download.inserted_session" : "event.download.inserted_new",
rpc::make_target(download), torrent::Object(), "Download event action failed: ");
} catch (torrent::input_error& e) {
std::string msg = "Command on torrent creation failed: " + std::string(e.what());
if (m_printLog)
m_manager->push_log_std(msg);
if (m_manager->download_list()->find(infohash) != m_manager->download_list()->end()) {
// Should stop it, mark it bad. Perhaps even delete it?
download->set_hash_failed(true);
download->set_message(msg);
// m_manager->download_list()->erase(m_manager->download_list()->find(infohash.data()));
}
}
m_slot_finished();
}
void
DownloadFactory::log_created(Download* download, torrent::Object* rtorrent) {
std::stringstream dump;
dump << "info_hash = " << torrent::utils::transform_to_hex_str(download->info()->hash()) << std::endl;
dump << "session = " << (m_session ? "true" : "false") << std::endl;
if (download->download()->info()->is_meta_download())
dump << "magnet = true" << std::endl;
if (!rtorrent->has_key_string("directory"))
dump << "directory = \"" << (m_variables["directory"].is_string() ? m_variables["directory"].as_string() : std::string()) << '"' << std::endl;
else
dump << "directory_base = \"" << (rtorrent->get_key("directory").is_string() ? rtorrent->get_key("directory").as_string() : std::string()) << '"' << std::endl;
dump << "---COMMANDS---" << std::endl;
for (const auto& m_command : m_commands) {
dump << m_command << std::endl;
}
std::string dump_str = dump.str();
lt_log_print_dump(torrent::LOG_TORRENT_DEBUG, dump_str.c_str(), dump_str.size(), "Creating new download:");
}
void
DownloadFactory::receive_failed(const std::string& msg) {
// Add message to log.
if (m_printLog)
m_manager->push_log_std(msg + ": \"" + m_uri + "\"");
m_slot_finished();
}
void
DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorrent) {
auto cached_seconds = torrent::this_thread::cached_seconds().count();
if (!rtorrent->has_key_value("state") || rtorrent->get_key_value("state") > 1) {
rtorrent->insert_key("state", (int64_t)m_start);
rtorrent->insert_key("state_changed", cached_seconds);
rtorrent->insert_key("state_counter", int64_t());
} else if (!rtorrent->has_key_value("state_changed") ||
rtorrent->get_key_value("state_changed") > cached_seconds || rtorrent->get_key_value("state_changed") == 0 ||
!rtorrent->has_key_value("state_counter") || (uint64_t)rtorrent->get_key_value("state_counter") > (1 << 20)) {
rtorrent->insert_key("state_changed", cached_seconds);
rtorrent->insert_key("state_counter", int64_t());
}
rtorrent->insert_preserve_copy("complete", (int64_t)0);
rtorrent->insert_preserve_copy("hashing", (int64_t)Download::variable_hashing_stopped);
rtorrent->insert_preserve_copy("timestamp.started", (int64_t)0);
rtorrent->insert_preserve_copy("timestamp.finished", (int64_t)0);
rtorrent->insert_preserve_copy("tied_to_file", "");
rtorrent->insert_key("loaded_file", m_isFile ? m_uri : std::string());
if (rtorrent->has_key_value("priority"))
rpc::call_command("d.priority.set", rtorrent->get_key_value("priority") % 4, rpc::make_target(download));
else
rpc::call_command("d.priority.set", (int64_t)2, rpc::make_target(download));
if (rtorrent->has_key_value("total_uploaded"))
download->info()->mutable_up_rate()->set_total(rtorrent->get_key_value("total_uploaded"));
if (rtorrent->has_key_value("total_downloaded"))
download->info()->mutable_down_rate()->set_total(rtorrent->get_key_value("total_downloaded"));
if (rtorrent->has_key_value("chunks_done") && rtorrent->has_key_value("chunks_wanted"))
download->download()->set_chunks_done(rtorrent->get_key_value("chunks_done"), rtorrent->get_key_value("chunks_wanted"));
download->set_throttle_name(rtorrent->has_key_string("throttle_name")
? rtorrent->get_key_string("throttle_name")
: std::string());
rtorrent->insert_preserve_copy("ignore_commands", (int64_t)0);
rtorrent->insert_preserve_copy("views", torrent::Object::create_list());
rtorrent->insert_preserve_type("connection_leech", m_variables["connection_leech"]);
rtorrent->insert_preserve_type("connection_seed", m_variables["connection_seed"]);
rtorrent->insert_preserve_copy("choke_heuristics.up.leech", std::string());
rtorrent->insert_preserve_copy("choke_heuristics.up.seed", std::string());
rtorrent->insert_preserve_copy("choke_heuristics.down.leech", std::string());
rtorrent->insert_preserve_copy("choke_heuristics.down.seed", std::string());
}
}
+92
View File
@@ -0,0 +1,92 @@
// The DownloadFactory class assures that loading torrents can be done
// anywhere in the code by queueing the task. The user may change
// settings while, or even after, the torrent is loading.
#ifndef RTORRENT_CORE_DOWNLOAD_FACTORY_H
#define RTORRENT_CORE_DOWNLOAD_FACTORY_H
#include <functional>
#include <iosfwd>
#include <torrent/object.h>
#include <torrent/system/scheduler.h>
#include "http_queue.h"
namespace core {
class Download;
class Manager;
class DownloadFactory {
public:
typedef std::function<void ()> slot_void;
typedef std::vector<std::string> command_list_type;
// Do not destroy this object while it is in a HttpQueue.
DownloadFactory(Manager* m);
~DownloadFactory();
// Calling of receive_load() is delayed so you can change whatever
// you want without fear of the slots being triggered as you call
// load() or commit().
void load(const std::string& uri);
void load_raw_data(const std::string& input);
void commit();
command_list_type& commands() { return m_commands; }
torrent::Object::map_type& variables() { return m_variables; }
bool get_session() const { return m_session; }
void set_session(bool v) { m_session = v; }
bool get_start() const { return m_start; }
void set_start(bool v) { m_start = v; }
bool get_init_load() const { return m_initLoad; }
void set_init_load(bool v) { m_initLoad = v; }
bool print_log() const { return m_printLog; }
void set_print_log(bool v) { m_printLog = v; }
void slot_finished(slot_void s) { m_slot_finished = s; }
private:
void receive_load();
void receive_loaded();
void receive_commit();
void receive_success();
void receive_failed(const std::string& msg);
void log_created(Download* download, torrent::Object* rtorrent);
void initialize_rtorrent(Download* download, torrent::Object* rtorrent);
Manager* m_manager;
std::shared_ptr<std::iostream> m_stream;
torrent::Object* m_object{};
bool m_commited{};
bool m_loaded{};
std::string m_uri;
bool m_session{};
bool m_start{};
bool m_printLog{true};
bool m_isFile{};
bool m_initLoad{};
command_list_type m_commands;
torrent::Object::map_type m_variables;
slot_void m_slot_finished;
torrent::system::SchedulerEntry m_task_load;
torrent::system::SchedulerEntry m_task_commit;
};
bool is_network_uri(const std::string& uri);
bool is_magnet_uri(const std::string& uri);
}
#endif
+722
View File
@@ -0,0 +1,722 @@
#include "config.h"
#include <algorithm>
#include <cstring>
#include <fstream>
#include <iostream>
#include <torrent/data/file.h>
#include <torrent/utils/resume.h>
#include <torrent/exceptions.h>
#include <torrent/download.h>
#include <torrent/hash_string.h>
#include <torrent/object.h>
#include <torrent/object_stream.h>
#include <torrent/torrent.h>
#include <torrent/utils/log.h>
#include <torrent/utils/string_manip.h>
#include "rpc/parse_commands.h"
#include "control.h"
#include "globals.h"
#include "manager.h"
#include "view.h"
#include "view_manager.h"
#include "core/dht_manager.h"
#include "core/download.h"
#include "core/download_list.h"
#include "session/session_manager.h"
#include "ui/root.h"
#define DL_TRIGGER_EVENT(download, event_name) \
rpc::commands.call_catch(event_name, rpc::make_target(download), torrent::Object(), "Event '" event_name "' failed: ");
namespace core {
inline void
DownloadList::check_contains([[maybe_unused]] Download* d) {
#ifdef USE_EXTRA_DEBUG
if (std::find(begin(), end(), d) == end())
throw torrent::internal_error("DownloadList::check_contains(...) failed.");
#endif
}
void
DownloadList::clear() {
int error_count = 0;
while (!empty()) {
auto download = back();
try {
close(download);
base_type::pop_back();
torrent::download_remove(*download->download());
delete download;
} catch (torrent::internal_error& e) {
lt_log_print(torrent::LOG_ERROR, "DownloadList::clear() failed to close or remove download: %s", e.what());
error_count++;
continue;
}
}
if (error_count > 0)
throw torrent::internal_error("DownloadList::clear() failed to close or remove " + std::to_string(error_count) + " downloads.");
}
void
DownloadList::session_save() {
for (auto& download : *this)
session_thread::manager()->save_resume_download(download);
control->dht_manager()->save_dht_cache();
control->ui()->save_input_history();
}
DownloadList::iterator
DownloadList::find(const torrent::HashString& hash) {
return std::find_if(begin(), end(), [hash](Download* d) { return hash == d->info()->hash(); });
}
DownloadList::iterator
DownloadList::find_hex(const char* hash) {
if (strlen(hash) < 40)
return end();
torrent::HashString key;
if (torrent::utils::transform_from_hex(hash, hash + 40, key) != key.end())
return end();
return std::find_if(begin(), end(), [key](Download* d) { return key == d->info()->hash(); });
}
Download*
DownloadList::find_hex_ptr(const char* hash) {
iterator itr = find_hex(hash);
return itr != end() ? *itr : NULL;
}
Download*
DownloadList::create(torrent::Object* obj, uint32_t tracker_key, bool printLog) {
torrent::Download download;
try {
download = torrent::download_add(obj, tracker_key);
} catch (torrent::local_error& e) {
if (printLog)
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download: %s", e.what());
delete obj;
return NULL;
}
// There's no non-critical exceptions that should be throwable by
// the ctor, so don't catch.
return new Download(download);
}
Download*
DownloadList::create(std::istream* str, uint32_t tracker_key, bool printLog) {
torrent::Object* object = new torrent::Object;
torrent::Download download;
try {
*str >> *object;
// Don't throw input_error from here as gcc-3.3.5 produces bad
// code.
if (str->fail()) {
delete object;
if (printLog)
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download, the input is not a valid torrent.");
return NULL;
}
download = torrent::download_add(object, tracker_key);
} catch (torrent::local_error& e) {
delete object;
if (printLog)
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download: %s", e.what());
return NULL;
}
// There's no non-critical exceptions that should be throwable by
// the ctor, so don't catch.
return new Download(download);
}
DownloadList::iterator
DownloadList::insert(Download* download) {
iterator itr = base_type::insert(end(), download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Inserting download.");
try {
(*itr)->data()->slot_initial_hash() = std::bind(&DownloadList::hash_done, this, download);
(*itr)->data()->slot_download_done() = std::bind(&DownloadList::received_finished, this, download);
// This needs to be separated into two different calls to ensure
// the download remains in the view.
for (auto v : *control->view_manager())
v->insert(download);
for (auto v : *control->view_manager())
v->filter_download(download);
DL_TRIGGER_EVENT(*itr, "event.download.inserted");
} catch (torrent::local_error& e) {
// Should perhaps relax this, just print an error and remove the
// downloads?
throw torrent::internal_error("Caught during DownloadList::insert(...): " + std::string(e.what()));
}
return itr;
}
void
DownloadList::erase_ptr(Download* download) {
erase(std::find(begin(), end(), download));
}
DownloadList::iterator
DownloadList::erase(iterator itr) {
if (itr == end())
throw torrent::internal_error("DownloadList::erase(...) could not find download.");
lt_log_print_info(torrent::LOG_TORRENT_INFO, (*itr)->info(), "download_list", "Erasing download.");
// Makes sure close doesn't restart hashing of this download.
(*itr)->set_hash_failed(true);
close(*itr);
session_thread::manager()->remove_download(*itr);
DL_TRIGGER_EVENT(*itr, "event.download.erased");
for (auto v : *control->view_manager())
v->erase(*itr);
torrent::download_remove(*(*itr)->download());
delete *itr;
return base_type::erase(itr);
}
bool
DownloadList::open(Download* download) {
try {
open_throw(download);
return true;
} catch (torrent::local_error& e) {
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not open download: %s", e.what());
return false;
}
}
void
DownloadList::open_throw(Download* download) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Opening download.");
if (download->download()->info()->is_open())
return;
int openFlags = download->resume_flags();
if (rpc::call_command_value("system.file.allocate"))
openFlags |= torrent::Download::open_enable_fallocate;
download->download()->open(openFlags);
DL_TRIGGER_EVENT(download, "event.download.opened");
}
void
DownloadList::close(Download* download) {
try {
close_throw(download);
} catch (torrent::local_error& e) {
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not close download: %s", e.what());
}
}
void
DownloadList::close_directly(Download* download) {
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download directly.");
if (download->download()->info()->is_active()) {
download->download()->stop(torrent::Download::stop_skip_tracker);
if (torrent::resume_check_target_files(*download->download(), download->download()->bencode()->get_key("libtorrent_resume")))
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
}
if (download->download()->info()->is_open())
download->download()->close();
}
void
DownloadList::close_quick(Download* download) {
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download quickly.");
close(download);
// Make sure we cancel any tracker requests. This should rather be
// handled by some parameter to the close function, or some other
// way of giving the client more control of when STOPPED requests
// are sent.
download->download()->manual_cancel();
}
void
DownloadList::close_throw(Download* download) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Closing download with throw.");
// When pause gets called it will clear the initial hash check state
// and set hash failed. This should ensure hashing doesn't restart
// until resume gets called.
pause(download);
// Check for is_open after pause due to hashing.
if (!download->is_open())
return;
// Save the torrent on close, this covers shutdown and if a torrent
// is manually closed which would clear the progress data. For
// better crash protection, save regulary in addition to this.
//
// Used to be in pause, but this was wrong for rehashing etc.
//
// Reconsider this save. Should be done explicitly when shutting down.
//control->core()->download_store()->save(download);
download->download()->close();
if (!download->is_hash_failed() && rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
throw torrent::internal_error("DownloadList::close_throw(...) called but we're going into a hashing loop.");
DL_TRIGGER_EVENT(download, "event.download.hash_removed");
DL_TRIGGER_EVENT(download, "event.download.closed");
}
void
DownloadList::resume(Download* download, int flags) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Resuming download: flags:%0x.", flags);
try {
if (download->download()->info()->is_active())
return;
rpc::parse_command_single(rpc::make_target(download), "view.set_visible=active");
// We need to make sure the flags aren't reset if someone decideds
// to call resume() while it is hashing, etc.
if (download->resume_flags() == Download::default_resume_flags)
download->set_resume_flags(flags);
// Manual or end-of-download rehashing clears the resume data so
// we can just start the hashing again without clearing it again.
//
// It is also assumed the is_hash_checked flag gets cleared when
// 'hashing' was set.
if (!download->is_hash_checked()) {
// If the hash failed flag wasn't cleared then hashing won't be
// initiated.
if (download->is_hash_failed())
return;
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) == Download::variable_hashing_stopped)
rpc::call_command("d.hashing.set", Download::variable_hashing_initial, rpc::make_target(download));
DL_TRIGGER_EVENT(download, "event.download.hash_queued");
return;
}
// This will never actually do anything due to the above hash check.
// open_throw(download);
auto cached_seconds = torrent::this_thread::cached_seconds().count();
rpc::call_command("d.state_changed.set", cached_seconds, rpc::make_target(download));
rpc::call_command("d.state_counter.set", rpc::call_command_value("d.state_counter", rpc::make_target(download)) + 1, rpc::make_target(download));
if (download->is_done()) {
torrent::Object conn_current = rpc::call_command("d.connection_seed", torrent::Object(), rpc::make_target(download));
torrent::Object choke_up = rpc::call_command("d.up.choke_heuristics.seed", torrent::Object(), rpc::make_target(download));
torrent::Object choke_down = rpc::call_command("d.down.choke_heuristics.seed", torrent::Object(), rpc::make_target(download));
if (conn_current.is_string_empty()) conn_current = rpc::call_command("protocol.connection.seed", torrent::Object(), rpc::make_target(download));
if (choke_up.is_string_empty()) choke_up = rpc::call_command("protocol.choke_heuristics.up.seed", torrent::Object(), rpc::make_target(download));
if (choke_down.is_string_empty()) choke_down = rpc::call_command("protocol.choke_heuristics.down.seed", torrent::Object(), rpc::make_target(download));
rpc::call_command("d.connection_current.set", conn_current, rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", choke_up, rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", choke_down, rpc::make_target(download));
} else {
torrent::Object conn_current = rpc::call_command("d.connection_leech", torrent::Object(), rpc::make_target(download));
torrent::Object choke_up = rpc::call_command("d.up.choke_heuristics.leech", torrent::Object(), rpc::make_target(download));
torrent::Object choke_down = rpc::call_command("d.down.choke_heuristics.leech", torrent::Object(), rpc::make_target(download));
if (conn_current.is_string_empty()) conn_current = rpc::call_command("protocol.connection.leech", torrent::Object(), rpc::make_target(download));
if (choke_up.is_string_empty()) choke_up = rpc::call_command("protocol.choke_heuristics.up.leech", torrent::Object(), rpc::make_target(download));
if (choke_down.is_string_empty()) choke_down = rpc::call_command("protocol.choke_heuristics.down.leech", torrent::Object(), rpc::make_target(download));
rpc::call_command("d.connection_current.set", conn_current, rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", choke_up, rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", choke_down, rpc::make_target(download));
// For the moment, clear the resume data so we force hash-check
// on non-complete downloads after a crash. This shouldn't be
// needed, but for some reason linux 2.6 is very lazy about
// updating mtime.
//
// Disabling this due to the new resume code.
// torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"), true);
}
// If the DHT server is set to auto, start it now.
if (!download->download()->info()->is_private())
control->dht_manager()->auto_start();
// Update the priority to ensure it has the correct
// seeding/unfinished modifiers.
download->set_priority(download->priority());
download->download()->start(download->resume_flags());
download->set_resume_flags(Download::default_resume_flags);
DL_TRIGGER_EVENT(download, "event.download.resumed");
} catch (torrent::local_error& e) {
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not resume download: %s", e.what());
}
}
void
DownloadList::pause(Download* download, int flags) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Pausing download: flags:%0x.", flags);
try {
download->set_resume_flags(Download::default_resume_flags);
rpc::parse_command_single(rpc::make_target(download), "view.set_not_visible=active");
// Always clear hashing on pause. When a hashing request is added,
// it should have cleared the hash resume data.
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped) {
download->download()->hash_stop();
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_stopped, rpc::make_target(download));
DL_TRIGGER_EVENT(download, "event.download.hash_removed");
}
if (!download->download()->info()->is_active())
return;
download->download()->stop(flags);
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
// TODO: This is actually for pause, not stop... And doesn't get
// called when the download isn't active, but was in the 'started'
// view.
DL_TRIGGER_EVENT(download, "event.download.paused");
auto cached_seconds = torrent::this_thread::cached_seconds().count();
rpc::call_command("d.state_changed.set", cached_seconds, rpc::make_target(download));
rpc::call_command("d.state_counter.set", rpc::call_command_value("d.state_counter", rpc::make_target(download)), rpc::make_target(download));
// If initial seeding is complete, don't try it again when restarting.
if (download->is_done() &&
rpc::call_command("d.connection_current", torrent::Object(), rpc::make_target(download)).as_string() == "initial_seed")
rpc::call_command("d.connection_seed.set", rpc::call_command("d.connection_current", torrent::Object(), rpc::make_target(download)), rpc::make_target(download));
// Save the state after all the slots, etc have been called so we
// include the modifications they may make.
//control->core()->download_store()->save(download);
} catch (torrent::local_error& e) {
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not pause download: %s", e.what());
}
}
void
DownloadList::check_hash(Download* download) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Checking hash.");
try {
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
return;
hash_queue(download, Download::variable_hashing_rehash);
} catch (torrent::local_error& e) {
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not check hash: %s", e.what());
}
}
void
DownloadList::hash_done(Download* download) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Hash done.");
if (download->is_hash_checking() || download->is_active())
throw torrent::internal_error("DownloadList::hash_done(...) download in invalid state.");
if (!download->is_hash_checked()) {
download->set_hash_failed(true);
auto& msg = download->download()->hash_error_message();
if (!msg.empty())
download->set_message(msg);
DL_TRIGGER_EVENT(download, "event.download.hash_failed");
return;
}
// Need to find some sane conditional here. Can we check the total
// downloaded to ensure something was transferred, thus we didn't
// just hash an already completed torrent with lacking session data?
//
// Perhaps we should use a seperate variable or state, and check
// that. Thus we can bork the download if the hash check doesn't
// confirm all the data, avoiding large BW usage on f.ex. the
// ReiserFS bug with >4GB files.
int64_t hashing = rpc::call_command_value("d.hashing", rpc::make_target(download));
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_stopped, rpc::make_target(download));
if (download->is_done() && download->download()->info()->is_meta_download())
return process_meta_download(download);
switch (hashing) {
case Download::variable_hashing_initial:
case Download::variable_hashing_rehash:
// Normal re/hashing.
// If the download was previously completed but the files were
// f.ex deleted, then we clear the state and complete.
if (rpc::call_command_value("d.complete", rpc::make_target(download)) && !download->is_done()) {
rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(download));
download->set_message("Download registered as completed, but hash check returned unfinished chunks.");
}
// Save resume data so we update time-stamps and priorities if
// they were invalid/changed while loading/hashing.
rpc::call_command("d.complete.set", (int64_t)download->is_done(), rpc::make_target(download));
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
if (rpc::call_command_value("d.state", rpc::make_target(download)) == 1)
resume(download, download->resume_flags());
break;
case Download::variable_hashing_last:
if (download->is_done()) {
confirm_finished(download);
} else {
download->set_message("Hash check on download completion found bad chunks.");
lt_log_print(torrent::LOG_TORRENT_ERROR, "Hash check on download completion found bad chunks.");
DL_TRIGGER_EVENT(download, "event.download.hash_final_failed");
}
// TODO: Should we skip the 'hash_done' event here?
return;
case Download::variable_hashing_stopped:
default:
// Either an error or someone wrote to the hashing variable...
download->set_message("Hash check completed but the \"hashing\" variable is in an invalid state.");
return;
}
DL_TRIGGER_EVENT(download, "event.download.hash_done");
}
void
DownloadList::hash_queue(Download* download, int type) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Hash queue.");
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
// HACK
if (download->is_open()) {
pause(download, torrent::Download::stop_skip_tracker);
download->download()->close();
DL_TRIGGER_EVENT(download, "event.download.hash_removed");
DL_TRIGGER_EVENT(download, "event.download.closed");
}
torrent::resume_clear_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
download->set_hash_failed(false);
rpc::call_command_set_value("d.hashing.set", type, rpc::make_target(download));
if (download->is_open())
throw torrent::internal_error("DownloadList::hash_clear(...) download still open.");
// If any more stuff is added here, make sure resume etc are still
// correct.
DL_TRIGGER_EVENT(download, "event.download.hash_queued");
}
void
DownloadList::received_finished(Download* download) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Received finished.");
if (rpc::call_command_value("pieces.hash.on_completion"))
// Set some 'checking_finished_thingie' variable to make hash_done
// trigger correctly, also so it can bork on missing data.
hash_queue(download, Download::variable_hashing_last);
else
confirm_finished(download);
}
// The download must be open when we call this function.
void
DownloadList::confirm_finished(Download* download) {
check_contains(download);
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Confirming finished.");
if (download->download()->info()->is_meta_download())
return process_meta_download(download);
rpc::call_command("d.complete.set", (int64_t)1, rpc::make_target(download));
// Clean up these settings:
torrent::Object conn_current = rpc::call_command("d.connection_seed", torrent::Object(), rpc::make_target(download));
torrent::Object choke_up = rpc::call_command("d.up.choke_heuristics.seed", torrent::Object(), rpc::make_target(download));
torrent::Object choke_down = rpc::call_command("d.down.choke_heuristics.seed", torrent::Object(), rpc::make_target(download));
if (conn_current.is_string_empty()) conn_current = rpc::call_command("protocol.connection.seed", torrent::Object(), rpc::make_target(download));
if (choke_up.is_string_empty()) choke_up = rpc::call_command("protocol.choke_heuristics.up.seed", torrent::Object(), rpc::make_target(download));
if (choke_down.is_string_empty()) choke_down = rpc::call_command("protocol.choke_heuristics.down.seed", torrent::Object(), rpc::make_target(download));
rpc::call_command("d.connection_current.set", conn_current, rpc::make_target(download));
rpc::call_command("d.up.choke_heuristics.set", choke_up, rpc::make_target(download));
rpc::call_command("d.down.choke_heuristics.set", choke_down, rpc::make_target(download));
download->set_priority(download->priority());
if (rpc::call_command_value("d.peers_min", rpc::make_target(download)) == rpc::call_command_value("throttle.min_peers.normal") &&
rpc::call_command_value("throttle.min_peers.seed") >= 0)
rpc::call_command("d.peers_min.set", rpc::call_command("throttle.min_peers.seed"), rpc::make_target(download));
if (rpc::call_command_value("d.peers_max", rpc::make_target(download)) == rpc::call_command_value("throttle.max_peers.normal") &&
rpc::call_command_value("throttle.max_peers.seed") >= 0)
rpc::call_command("d.peers_max.set", rpc::call_command("throttle.max_peers.seed"), rpc::make_target(download));
// Do this before the slots are called in case one of them closes
// the download.
//
// Obsolete.
if (!download->is_active() && rpc::call_command_value("session.on_completion") != 0)
session_thread::manager()->save_resume_download(download);
// Send the completed request before resuming so we don't reset the
// up/downloaded baseline.
download->download()->send_completed();
// Save the hash in case the finished event erases it.
torrent::HashString infohash = download->info()->hash();
DL_TRIGGER_EVENT(download, "event.download.finished");
if (find(infohash) == end())
return;
// if (download->resume_flags() != Download::default_resume_flags)
// throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != Download::default_resume_flags.");
// See #1292.
//
// Just reset the value for the moment. If a torrent finishes while
// others are hashing, or some other situtation that causes resume
// flag to change could cause the state to be invalid.
//
// TODO: Add a check when setting the flags to see if the torrent is
// being hashed.
download->set_resume_flags(Download::default_resume_flags);
if (!download->is_active() && rpc::call_command_value("d.state", rpc::make_target(download)) == 1)
resume(download,
torrent::Download::start_no_create |
torrent::Download::start_skip_tracker |
torrent::Download::start_keep_baseline);
}
void
DownloadList::process_meta_download(Download* download) {
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Processing meta download.");
rpc::call_command("d.stop", torrent::Object(), rpc::make_target(download));
rpc::call_command("d.close", torrent::Object(), rpc::make_target(download));
std::string metafile = (*download->file_list()->begin())->frozen_path().str();
std::fstream file(metafile.c_str(), std::ios::in | std::ios::binary);
if (!file.is_open()) {
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not read download metadata.");
return;
}
torrent::Object* bencode = new torrent::Object(torrent::Object::create_map());
file >> bencode->insert_key("info", torrent::Object());
if (file.fail()) {
delete bencode;
lt_log_print(torrent::LOG_TORRENT_ERROR, "Could not create download, the input is not a valid torrent.");
return;
}
file.close();
// Steal the keys we still need. The old download has no use for them.
bencode->insert_key("rtorrent_meta_download", torrent::Object()).swap(download->bencode()->get_key("rtorrent_meta_download"));
if (download->bencode()->has_key("announce"))
bencode->insert_key("announce", torrent::Object()).swap(download->bencode()->get_key("announce"));
if (download->bencode()->has_key("announce-list"))
bencode->insert_key("announce-list", torrent::Object()).swap(download->bencode()->get_key("announce-list"));
erase_ptr(download);
control->core()->try_create_download_from_meta_download(bencode, metafile);
}
}
+136
View File
@@ -0,0 +1,136 @@
#ifndef RTORRENT_CORE_DOWNLOAD_LIST_H
#define RTORRENT_CORE_DOWNLOAD_LIST_H
#include <iosfwd>
#include <list>
#include <string>
namespace torrent {
class HashString;
class Object;
}
namespace core {
class Download;
// Container for all downloads. Add slots to the slot maps to cause
// some action to be taken when the torrent changes states. Don't
// change the states from outside of core.
//
// Fix apply_on_ratio if the base_type is changed.
class DownloadList : private std::list<Download*> {
public:
typedef std::list<Download*> base_type;
using base_type::iterator;
using base_type::const_iterator;
using base_type::reverse_iterator;
using base_type::const_reverse_iterator;
using base_type::value_type;
using base_type::pointer;
using base_type::begin;
using base_type::end;
using base_type::rbegin;
using base_type::rend;
using base_type::empty;
using base_type::size;
DownloadList() = default;
void clear();
void session_save();
iterator find(const torrent::HashString& hash);
iterator find_hex(const char* hash);
Download* find_hex_ptr(const char* hash);
// Might move this to DownloadFactory.
Download* create(std::istream* str, uint32_t tracker_key, bool printLog);
Download* create(torrent::Object* obj, uint32_t tracker_key, bool printLog);
iterator insert(Download* d);
void erase_ptr(Download* d);
iterator erase(iterator itr);
//void save(Download* d);
bool open(Download* d);
void open_throw(Download* d);
void close(Download* d);
void close_directly(Download* d);
void close_quick(Download* d);
void close_throw(Download* d);
void resume(Download* d, int flags = 0);
void pause(Download* d, int flags = 0);
void resume_default(Download* d) { resume(d); }
void pause_default(Download* d) { pause(d); }
void check_hash(Download* d);
enum {
D_SLOTS_INSERT,
D_SLOTS_ERASE,
D_SLOTS_OPEN,
D_SLOTS_CLOSE,
D_SLOTS_START,
D_SLOTS_STOP,
D_SLOTS_HASH_QUEUED,
D_SLOTS_HASH_REMOVED,
D_SLOTS_HASH_DONE,
D_SLOTS_FINISHED,
SLOTS_MAX_SIZE
};
static const char* slot_name(int m) {
switch(m) {
case D_SLOTS_INSERT: return "event.download.inserted";
case D_SLOTS_ERASE: return "event.download.erased";
case D_SLOTS_OPEN: return "event.download.opened";
case D_SLOTS_CLOSE: return "event.download.closed";
case D_SLOTS_START: return "event.download.resumed";
case D_SLOTS_STOP: return "event.download.paused";
case D_SLOTS_HASH_QUEUED: return "event.download.hash_queued";
case D_SLOTS_HASH_REMOVED: return "event.download.hash_removed";
case D_SLOTS_HASH_DONE: return "event.download.hash_done";
case D_SLOTS_FINISHED: return "event.download.finished";
default: return "BORK";
}
}
// The finished slots will be called when an active download with
// "finished" == 0 performs a hash check which returns a done
// torrent.
//
// But how to avoid sending 'completed' messages to the tracker?
// Also we need to handle cases when a hashing torrent starts up
// after a shutdown.
private:
DownloadList(const DownloadList&);
void operator = (const DownloadList&);
void hash_done(Download* d);
void hash_queue(Download* d, int type);
inline void check_contains(Download* d);
void received_finished(Download* d);
void confirm_finished(Download* d);
void process_meta_download(Download* d);
};
}
#endif
+48
View File
@@ -0,0 +1,48 @@
#include "config.h"
#include "http_queue.h"
#include <torrent/common.h>
#include <torrent/net/http_get.h>
#include <torrent/net/http_stack.h>
namespace core {
HttpQueue::iterator
HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream,
std::function<void()> done_fn, std::function<void(const std::string&)> failed_fn) {
auto itr = base_type::insert(end(), torrent::net::HttpGet(url, stream));
itr->set_max_file_size(15 << 20);
itr->set_redirect_only_http_https();
for (auto& slot : m_signal_insert)
slot(*itr);
itr->add_done_slot(torrent::this_thread::thread(), std::move(done_fn));
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
itr->add_failed_slot(torrent::this_thread::thread(), std::move(failed_fn));
itr->add_failed_slot(torrent::this_thread::thread(), [this, itr](auto) { erase(itr); });
torrent::net_thread::http_stack()->start_get(*itr);
return itr;
}
void
HttpQueue::erase(iterator signal_itr) {
for (const auto& slot : m_signal_erase)
slot(*signal_itr);
signal_itr->close_and_keep_callbacks();
base_type::erase(signal_itr);
}
void
HttpQueue::clear() {
while (!empty())
erase(begin());
}
}
+58
View File
@@ -0,0 +1,58 @@
#ifndef RTORRENT_CORE_HTTP_QUEUE_H
#define RTORRENT_CORE_HTTP_QUEUE_H
#include <functional>
#include <iosfwd>
#include <memory>
#include <list>
#include <string>
#include <torrent/net/http_get.h>
namespace core {
// TODO: Remove this.
class HttpQueue : private std::list<torrent::net::HttpGet> {
public:
using base_type = std::list<torrent::net::HttpGet>;
using slot_curl_get = std::function<void (torrent::net::HttpGet)>;
using signal_curl_get = std::list<slot_curl_get>;
using base_type::iterator;
using base_type::const_iterator;
using base_type::reverse_iterator;
using base_type::const_reverse_iterator;
using base_type::begin;
using base_type::end;
using base_type::rbegin;
using base_type::rend;
using base_type::empty;
using base_type::size;
HttpQueue() = default;
~HttpQueue() { clear(); }
// Note that any slots connected to the CurlGet signals must be
// pushed in front of the erase slot added by HttpQueue::insert.
//
// Consider adding a flag to indicate whetever HttpQueue should
// delete the stream.
iterator insert(const std::string& url, std::shared_ptr<std::ostream> stream,
std::function<void()> done_fn, std::function<void(const std::string&)> failed_fn);
void erase(iterator itr);
void clear();
signal_curl_get& signal_insert() { return m_signal_insert; }
signal_curl_get& signal_erase() { return m_signal_erase; }
private:
signal_curl_get m_signal_insert;
signal_curl_get m_signal_erase;
};
}
#endif
+446
View File
@@ -0,0 +1,446 @@
#include "config.h"
#include "core/manager.h"
#include <cstdio>
#include <cstring>
#include <fstream>
#include <sstream>
#include <unistd.h>
#include <sys/select.h>
#include <fnmatch.h>
#include <torrent/utils/resume.h>
#include <torrent/object.h>
#include <torrent/exceptions.h>
#include <torrent/object_stream.h>
#include <torrent/throttle.h>
#include <torrent/net/http_stack.h>
#include <torrent/net/socket_address.h>
#include <torrent/runtime/network_config.h>
#include <torrent/runtime/network_manager.h>
#include <torrent/utils/log.h>
#include <torrent/utils/string_manip.h>
#include "rpc/parse_commands.h"
#include "utils/directory.h"
#include "utils/base64.h"
#include "utils/file_status_cache.h"
#include "globals.h"
#include "control.h"
#include "core/download.h"
#include "core/download_factory.h"
#include "core/http_queue.h"
#include "core/view.h"
#include <torrent/runtime/client_config.h>
namespace core {
const int Manager::create_start;
const int Manager::create_tied;
const int Manager::create_quiet;
const int Manager::create_raw_data;
void
Manager::push_log(const char* msg) {
m_log_important->lock_and_push_log(msg, strlen(msg), 0);
m_log_complete->lock_and_push_log(msg, strlen(msg), 0);
}
Manager::Manager()
: m_log_important(torrent::log_open_log_buffer("important")),
m_log_complete(torrent::log_open_log_buffer("complete")) {
m_download_list = std::make_unique<DownloadList>();
m_file_status_cache = std::make_unique<FileStatusCache>();
m_http_queue = std::make_unique<HttpQueue>();
torrent::Throttle* unthrottled = torrent::Throttle::create_throttle();
unthrottled->set_max_rate(0);
m_throttles["NULL"] = std::make_pair(unthrottled, unthrottled);
}
Manager::~Manager() {
torrent::Throttle::destroy_throttle(m_throttles["NULL"].first);
}
bool
Manager::is_download_shutdown_completed() {
for (const auto& download : *download_list()) {
// TODO: Why is this being checked?
// if (download->tracker_controller().is_active())
// return false;
if (download->tracker_controller().has_active_trackers_not_dht_scrape_disownable())
return false;
}
return true;
}
void
Manager::set_hashing_view(View* v) {
if (v == nullptr || m_hashingView != nullptr)
throw torrent::internal_error("Manager::set_hashing_view(...) received nullptr or is already set.");
m_hashingView = v;
m_hashingView->signal_changed().push_back(std::bind(&Manager::receive_hashing_changed, this));
}
ThrottlePair
Manager::get_throttle(const std::string& name) {
auto itr = m_throttles.find(name);
auto throttles = (itr == m_throttles.end() ? ThrottlePair(nullptr, nullptr) : itr->second);
if (throttles.first == nullptr)
throttles.first = torrent::up_throttle_global();
if (throttles.second == nullptr)
throttles.second = torrent::down_throttle_global();
return throttles;
}
int64_t
Manager::retrieve_throttle_value(const torrent::Object::string_type& name, bool rate, bool up) {
ThrottleMap::iterator itr = throttles().find(name);
if (itr == throttles().end()) {
return (int64_t)-1;
} else {
torrent::Throttle* throttle = up ? itr->second.first : itr->second.second;
// check whether the actual up/down throttle exist (one of the pair can be missing)
if (throttle == nullptr)
return (int64_t)-1;
int64_t throttle_max = (int64_t)throttle->max_rate();
if (rate) {
if (throttle_max > 0)
return (int64_t)throttle->rate()->rate();
else
return (int64_t)-1;
} else {
return throttle_max;
}
}
}
void
Manager::set_magnet_path(const std::string& path) {
if (path.empty())
m_magnet_path.clear();
else if (path.back() == '/')
m_magnet_path = path;
else
m_magnet_path = path + '/';
}
void
Manager::cleanup() {
// Need to disconnect log signals? Not really since we won't receive
// any more.
m_download_list->clear();
torrent::cleanup();
}
void
Manager::shutdown(bool force) {
if (!force) {
for (auto d : *m_download_list)
m_download_list->pause_default(d);
} else {
for (auto d : *m_download_list)
m_download_list->close_quick(d);
}
}
void
Manager::receive_http_failed(std::string msg) {
push_log_std("Http download error: \"" + msg + "\"");
}
bool
is_data_uri(const std::string& uri) {
return std::strncmp(uri.c_str(), "data:", 5) == 0;
}
std::string
decode_data_uri(const std::string& uri) {
const auto pos = uri.find("base64,", 5);
if (pos == std::string::npos)
throw torrent::input_error("Invalid data uri: not base64 encoded.");
const auto start = pos + 7;
if (start >= uri.size())
throw torrent::input_error("Empty base64.");
return utils::decode_base64(uri.substr(start));
}
void
Manager::try_create_download(const std::string& uri, int flags, const command_list_type& commands) {
// If the path was attempted loaded before, skip it.
if ((flags & create_tied) &&
!(flags & create_raw_data) &&
!is_network_uri(uri) &&
!is_magnet_uri(uri) &&
!is_data_uri(uri) &&
!file_status_cache()->insert(uri))
return;
// Adding download.
DownloadFactory* f = new DownloadFactory(this);
f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied);
f->commands().insert(f->commands().end(), commands.begin(), commands.end());
f->set_start(flags & create_start);
f->set_print_log(!(flags & create_quiet));
f->slot_finished([f]() { delete f; });
if (is_data_uri(uri)) {
// Allow the use of data URIs, primarily for JSON-RPC which
// doesn't have a defined mechanism for binary data
f->load_raw_data(decode_data_uri(uri));
f->variables()["tied_to_file"] = (int64_t)false;
} else if (flags & create_raw_data) {
f->load_raw_data(uri);
} else {
f->load(uri);
}
f->commit();
}
void
Manager::try_create_download_from_meta_download(torrent::Object* bencode, const std::string& metafile) {
DownloadFactory* f = new DownloadFactory(this);
f->variables()["tied_to_file"] = (int64_t)true;
f->variables()["tied_file"] = metafile;
torrent::Object& meta = bencode->get_key("rtorrent_meta_download");
torrent::Object::list_type& commands = meta.get_key_list("commands");
for (const auto& command : commands)
f->commands().insert(f->commands().end(), command.as_string());
f->set_start(meta.get_key_value("start"));
f->set_print_log(meta.get_key_value("print_log"));
f->slot_finished([f]() { delete f; });
// Bit of a waste to create the bencode repesentation here
// only to have the DownloadFactory decode it.
std::stringstream s;
s.imbue(std::locale::classic());
s << *bencode;
f->load_raw_data(s.str());
f->commit();
}
utils::Directory
path_expand_transform(std::string path, const utils::directory_entry& entry) {
return path + entry.s_name;
}
namespace {
// Consider rewritting such that m_seq is replaced by first/last.
template <typename Sequence>
class split_iterator_t {
public:
typedef typename Sequence::const_iterator const_iterator;
typedef typename Sequence::value_type value_type;
split_iterator_t() {}
split_iterator_t(const Sequence& seq, value_type delim) :
m_seq(&seq),
m_delim(delim),
m_pos(seq.begin()),
m_next(std::find(seq.begin(), seq.end(), delim)) {
}
Sequence operator * () { return Sequence(m_pos, m_next); }
split_iterator_t& operator ++ () {
m_pos = m_next;
if (m_pos == m_seq->end())
return *this;
m_pos++;
m_next = std::find(m_pos, m_seq->end(), m_delim);
return *this;
}
bool operator == (const split_iterator_t&) const { return m_pos == m_seq->end(); }
bool operator != (const split_iterator_t&) const { return m_pos != m_seq->end(); }
private:
const Sequence* m_seq;
value_type m_delim;
const_iterator m_pos;
const_iterator m_next;
};
template <typename Sequence>
inline split_iterator_t<Sequence>
split_iterator(const Sequence& seq, typename Sequence::value_type delim) {
return split_iterator_t<Sequence>(seq, delim);
}
template <typename Sequence>
inline split_iterator_t<Sequence>
split_iterator(const Sequence&) {
return split_iterator_t<Sequence>();
}
}
// Move this somewhere better.
void
path_expand(std::vector<std::string>* paths, const std::string& pattern) {
std::vector<utils::Directory> currentCache;
std::vector<utils::Directory> nextCache;
auto first = split_iterator(pattern, '/');
auto last = split_iterator(pattern);
if (first == last)
return;
// Check for initial '/' that indicates the root.
if ((*first).empty()) {
currentCache.push_back(utils::Directory("/"));
++first;
} else if (torrent::utils::trim_spaces_str(*first) == "~") {
currentCache.push_back(utils::Directory("~"));
++first;
} else {
currentCache.push_back(utils::Directory("."));
}
// Might be an idea to use depth-first search instead.
for (; first != last; ++first) {
const std::string& pattern = *first;
if (pattern.empty())
continue;
// Special case for ".."?
for (auto& itr : currentCache) {
// Only include filenames starting with '.' if the pattern
// starts with the same.
itr.update((pattern[0] != '.') ? utils::Directory::update_hide_dot : 0);
itr.erase(std::remove_if(itr.begin(), itr.end(), [&pattern](const utils::directory_entry& entry) { return fnmatch(pattern.c_str(), entry.s_name.c_str(), 0) != 0; }), itr.end());
for (const auto& cache : itr)
nextCache.push_back(path_expand_transform(itr.path() + (itr.path() == "/" ? "" : "/"), cache));
}
currentCache.clear();
currentCache.swap(nextCache);
}
for (const auto& cache : currentCache)
paths->push_back(cache.path());
}
bool
manager_equal_tied(const std::string& path, Download* download) {
return path == rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
}
void
Manager::try_create_download_expand(const std::string& uri, int flags, command_list_type commands) {
if (flags & create_raw_data) {
try_create_download(uri, flags, commands);
return;
}
std::vector<std::string> paths;
paths.reserve(256);
path_expand(&paths, uri);
if (!paths.empty())
for (auto& path : paths)
try_create_download(path, flags, commands);
else
try_create_download(uri, flags, commands);
}
// DownloadList's hashing related functions don't actually start the
// hashing, it only reacts to events. This functions checks the
// hashing view and starts hashing if nessesary.
void
Manager::receive_hashing_changed() {
bool foundHashing = std::any_of(m_hashingView->begin_visible(), m_hashingView->end_visible(),
std::mem_fn(&Download::is_hash_checking));
// Try quick hashing all those with hashing == initial, set them to
// something else when failed.
for (View::iterator itr = m_hashingView->begin_visible(), last = m_hashingView->end_visible(); itr != last; ++itr) {
if ((*itr)->is_hash_checked())
throw torrent::internal_error("core::Manager::receive_hashing_changed() (*itr)->is_hash_checked().");
if ((*itr)->is_hash_checking() || (*itr)->is_hash_failed())
continue;
bool tryQuick =
rpc::call_command_value("d.hashing", rpc::make_target(*itr)) == Download::variable_hashing_initial &&
(*itr)->download()->file_list()->bitfield()->empty();
if (!tryQuick && foundHashing)
continue;
try {
m_download_list->open_throw(*itr);
// Since the bitfield is allocated on loading of resume load or
// hash start, and unallocated on close, we know that if it it
// not empty then we have already loaded any existing resume
// data.
if ((*itr)->download()->file_list()->bitfield()->empty())
torrent::resume_load_progress(*(*itr)->download(), (*itr)->download()->bencode()->get_key("libtorrent_resume"));
if (tryQuick) {
if ((*itr)->download()->hash_check(true))
continue;
(*itr)->download()->hash_stop();
if (foundHashing) {
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_rehash, rpc::make_target(*itr));
continue;
}
}
(*itr)->download()->hash_check(false);
foundHashing = true;
} catch (torrent::local_error& e) {
if (tryQuick) {
// Make sure we don't repeat the quick hashing.
rpc::call_command_set_value("d.hashing.set", Download::variable_hashing_rehash, rpc::make_target(*itr));
} else {
(*itr)->set_hash_failed(true);
(*itr)->set_message("Hashing failed: " + std::string(e.what()));
lt_log_print(torrent::LOG_TORRENT_ERROR, "Hashing failed: %s", e.what());
}
}
}
}
}
+111
View File
@@ -0,0 +1,111 @@
#ifndef RTORRENT_CORE_MANAGER_H
#define RTORRENT_CORE_MANAGER_H
#include <iosfwd>
#include <memory>
#include <vector>
#include <torrent/utils/log_buffer.h>
#include <torrent/object.h>
#include "download_list.h"
#include "range_map.h"
namespace torrent {
class Bencode;
}
namespace utils {
class FileStatusCache;
}
namespace core {
class HttpQueue;
using ThrottlePair = std::pair<torrent::Throttle*, torrent::Throttle*>;
using ThrottleMap = std::map<std::string, ThrottlePair>;
class View;
class Manager {
public:
typedef DownloadList::iterator DListItr;
typedef utils::FileStatusCache FileStatusCache;
Manager();
~Manager();
bool is_download_shutdown_completed();
DownloadList* download_list() { return m_download_list.get(); }
FileStatusCache* file_status_cache() { return m_file_status_cache.get(); }
HttpQueue* http_queue() { return m_http_queue.get(); }
View* hashing_view() { return m_hashingView; }
void set_hashing_view(View* v);
auto* log_important() { return m_log_important.get(); }
auto* log_complete() { return m_log_complete.get(); }
ThrottleMap& throttles() { return m_throttles; }
ThrottlePair get_throttle(const std::string& name);
int64_t retrieve_throttle_value(const torrent::Object::string_type& name, bool rate, bool up);
void cleanup();
const std::string& magnet_path();
void set_magnet_path(const std::string& path);
void shutdown(bool force);
void push_log(const char* msg);
void push_log_std(const std::string& msg) { m_log_important->lock_and_push_log(msg.c_str(), msg.size(), 0); m_log_complete->lock_and_push_log(msg.c_str(), msg.size(), 0); }
void push_log_complete(const std::string& msg) { m_log_complete->lock_and_push_log(msg.c_str(), msg.size(), 0); }
void handshake_log(const sockaddr* sa, int msg, int err, const torrent::HashString* hash);
static const int create_start = 0x1;
static const int create_tied = 0x2;
static const int create_quiet = 0x4;
static const int create_raw_data = 0x8;
typedef std::vector<std::string> command_list_type;
// Temporary, find a better place for this.
void try_create_download(const std::string& uri, int flags, const command_list_type& commands);
void try_create_download_expand(const std::string& uri, int flags, command_list_type commands = command_list_type());
void try_create_download_from_meta_download(torrent::Object* bencode, const std::string& metafile);
private:
void create_http(const std::string& uri);
void create_final(std::istream* s);
void initialize_bencode(Download* d);
void receive_http_failed(std::string msg);
void receive_hashing_changed();
std::unique_ptr<DownloadList> m_download_list;
std::unique_ptr<FileStatusCache> m_file_status_cache;
std::unique_ptr<HttpQueue> m_http_queue;
View* m_hashingView{};
ThrottleMap m_throttles;
torrent::log_buffer_ptr m_log_important;
torrent::log_buffer_ptr m_log_complete;
std::string m_magnet_path;
};
// Meh, cleanup.
extern void receive_tracker_dump(const std::string& url, const char* data, size_t size);
inline const std::string& Manager::magnet_path() { return m_magnet_path; }
}
#endif
+199
View File
@@ -0,0 +1,199 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2008, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <sundell.software@gmail.com>
#ifndef RTORRENT_CORE_RANGE_MAP_H
#define RTORRENT_CORE_RANGE_MAP_H
#include <map>
#include <stdexcept>
namespace core {
// Associate values with a range of keys, and retrieve for any key in the range.
// The template arguments have the same semantics as std::map.
// Exception: if set_merge is used, the value type must have a defined operator ==.
template<typename Key, typename T, typename Compare = std::less<Key>,
typename Alloc = std::allocator<std::pair<const Key, T> > >
class RangeMap : private std::map<Key, std::pair<Key, T>, Compare,
typename std::allocator_traits<Alloc>::template rebind_alloc<std::pair<const Key, std::pair<Key, T>>>> {
typedef std::map<Key, std::pair<Key, T>, Compare,
typename std::allocator_traits<Alloc>::template rebind_alloc<std::pair<const Key, std::pair<Key, T>>>> base_type;
//std::allocator_traits<Alloc>::template rebind_alloc<std::pair<const Key, std::pair<Key, T>>>
public:
RangeMap() = default;
RangeMap(const Compare& c) : base_type(c) {}
typedef typename base_type::iterator iterator;
typedef typename base_type::reverse_iterator reverse_iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
// using typename base_type::const_iterator;
// using typename base_type::const_reverse_iterator;
using base_type::clear;
using base_type::swap;
using base_type::size;
using base_type::empty;
using base_type::begin;
using base_type::end;
using base_type::rbegin;
using base_type::rend;
using base_type::key_comp;
using base_type::value_comp;
// Store a value for the range [begin, end). Returns iterator for the range.
const_iterator set_range(const Key& begin, const Key& end, const T& value);
// Same, but merge adjacent ranges having the same value. Returns iterator for the merged range.
const_iterator set_merge(Key begin, const Key& end, const T& value);
// Find range containing the given key, or end().
const_iterator find(const Key& key) const;
// Retrieve value for key in a range, throw std::out_of_range if range does not exist.
const T& get(const Key& key) const;
// Retrieve value for key in a range, return def if range does not exist.
T get(const Key& key, T def) const;
private:
iterator crop_overlap(const Key& begin, const Key& end);
};
// Semantics of an entry:
// .first End of range (exclusive), map key.
// .second.first Beginning of range.
// .second.second Value.
template<typename Key, typename T, typename C, typename A>
inline typename RangeMap<Key,T,C,A>::iterator
RangeMap<Key,T,C,A>::crop_overlap(const Key& _begin, const Key& _end) {
typename RangeMap::iterator itr = base_type::upper_bound(_begin);
while (itr != end() && key_comp()(itr->second.first, _end)) {
// There's a subrange before the new begin: need new entry (new range end means new key).
if (key_comp()(itr->second.first, _begin))
base_type::insert(itr, typename RangeMap::value_type(_begin, itr->second));
// Old end is within our range: erase entry.
if (!key_comp()(_end, itr->first)) {
base_type::erase(itr++);
// Otherwise simply set the new begin of the old range.
} else {
itr->second.first = _end;
++itr;
}
}
return itr;
}
template<typename Key, typename T, typename C, typename A>
inline typename RangeMap<Key,T,C,A>::const_iterator
RangeMap<Key,T,C,A>::set_merge(Key _begin, const Key& _end, const T& value) {
if (!key_comp()(_begin, _end))
return end();
// Crop overlapping ranges and return iterator to first range after the one we're inserting.
typename RangeMap::iterator itr = crop_overlap(_begin, _end);
// Check if range before new one is adjacent and has same value: if so erase it and use its beginning.
if (itr != begin()) {
typename RangeMap::iterator prev = itr;
if (!key_comp()((--prev)->first, _begin) && prev->second.second == value) {
_begin = prev->second.first;
base_type::erase(prev);
}
}
// Range after new one is adjacent and has same value: set new beginning.
if (itr != end() && !key_comp()(_end, itr->second.first) && itr->second.second == value) {
itr->second.first = _begin;
return itr;
}
// Otherwise, this range isn't mergeable, make new entry.
return base_type::insert(itr, typename RangeMap::value_type(_end, typename RangeMap::mapped_type(_begin, value)));
}
template<typename Key, typename T, typename C, typename A>
inline typename RangeMap<Key,T,C,A>::const_iterator
RangeMap<Key,T,C,A>::set_range(const Key& _begin, const Key& _end, const T& value) {
if (!key_comp()(_begin, _end))
return end();
return base_type::insert(crop_overlap(_begin, _end), typename RangeMap::value_type(_end, typename RangeMap::mapped_type(_begin, value)));
}
template<typename Key, typename T, typename C, typename A>
inline typename RangeMap<Key,T,C,A>::const_iterator
RangeMap<Key,T,C,A>::find(const Key& key) const {
typename RangeMap::const_iterator itr = base_type::upper_bound(key);
if (itr != end() && key_comp()(key, itr->second.first))
itr = end();
return itr;
}
template<typename Key, typename T, typename C, typename A>
inline const T&
RangeMap<Key,T,C,A>::get(const Key& key) const {
typename RangeMap::const_iterator itr = find(key);
if (itr == end())
throw std::out_of_range("RangeMap::get");
return itr->second.second;
}
template<typename Key, typename T, typename C, typename A>
inline T
RangeMap<Key,T,C,A>::get(const Key& key, T def) const {
typename RangeMap::const_iterator itr = find(key);
return (itr == end() ? def : itr->second.second);
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More