Commit graph

10 commits

Author SHA1 Message Date
ookami125
7bbc1ee22c nautd: block adding a torrent that would overlap existing data
spawn_torrent parses each torrent's file list (at add and restore) and
refuses an add whose files would write where a registered torrent's data
lives (NAUT_ERR_EXIST). Magnets are checked once metadata is known is
out of scope; restore skips the check. webui surfaces it as HTTP 409.
Mark #10 done.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 01:01:50 -04:00
ookami125
36c8acc83a webui: add tags when adding a torrent
api_add forwards tags to the daemon, assigns them to the new torrent,
and registers any new tag names in the persisted taxonomy. Mark #7 done.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 00:02:11 -04:00
ookami125
8295b8522c webui: apply category on add + allow no category
api_add now forwards the chosen category to the daemon (and fixes a
use-after-free reading it from the freed request). Mark issues #3, #8, #9
done in ISSUES.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 23:34:50 -04:00
ookami125
b633b7d216 nautd/webui: scripting, labels, settings, set-location, pause fix
Session checkpoint on webui-plugin:
- engine dump (nautctl dump) + engine endgame integration
- per-file move locations persistence; torrent-level "Set location"
  with reset/keep-relative/leave-separate handling + residual prune
- Lua: naut.get_labels, define_settings/get_setting (script_host struct)
- daemon-owned labels (category+tags) + taxonomy persistence; webui write-through
- fix: pausing a completed/seeding torrent now sticks (stop wins over result)
- automation tab responsive layout; anime_sort label gating + settings

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 23:19:41 -04:00
ookami125
6dc711cf57 Limit active pieces and expose file list 2026-06-17 02:23:15 -04:00
ookami125
6ec5b19a73 Expose real tracker state to web UI 2026-06-17 02:14:10 -04:00
ookami125
6ae72907b0 Expose peer and piece state to web UI 2026-06-17 01:29:44 -04:00
ookami125
f4f4e86be4 webui: fix add-torrent crash, add categories/tags, real names
The daemon segfaulted the moment any torrent existed: map_torrent built
its JSON with one 30-key json_pack whose format string had drifted out of
sync with the argument list, so json_pack misread an int as a char* and
crashed in the next snapshot build (an empty fleet hid it). Rebuild the
object field-by-field with json_object_set_new so it can't drift again.

Add a web-layer category/tag store (in memory, like qBittorrent's own Web
API) so the UI can actually create categories and tags and assign them:
- /api/categories[/delete] and /api/tags[/delete] persist and return them
- /api/meta returns the stored categories/tags
- /api/action handles setCategory/addTags/removeTags (still 501 for
  engine-level verbs the daemon can't do)
- map_torrent fills each torrent's category/tags from the store

Uploaded torrents kept their temp upload path as the display name; keep
the name the UI sends at add time and prefer it in the grid.

Fix a use-after-free in api_action that read the action string after
freeing the request, which corrupted the error body into a 500.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 00:43:26 -04:00
ookami125
41ed172272 webui: real speeds, honest actions, and hardening
Address the review of the webui plugin:

- Live download rates. A background sampler polls the daemon once per
  second, derives per-torrent dlspeed from successive byte counts (EWMA
  smoothed), and computes a real ETA. dl_info_speed now aggregates the
  fleet instead of reporting a hardcoded 0.

- Single shared snapshot. The sampler publishes one cached snapshot that
  /api/snapshot, /api/torrents and every SSE stream serve, so N browser
  tabs no longer each poll the engine and race the speed table. SSE
  waiters block on a condition and wake promptly on shutdown.

- Honest /api/action. The engine has no pause/resume/recheck/queue verbs,
  so the endpoint returns 501 with an explanatory message instead of
  claiming success.

- Reject oversized uploads with 413 instead of silently truncating a
  torrent into garbage.

- Auth hardening: constant-time credential comparison, CSPRNG-only token
  generation via getrandom (fail closed, no weak fallback), oldest-session
  eviction instead of clobbering slot 0, and a warning when bound to a
  non-loopback address.

- Cap concurrent connections (503 beyond the limit) so a client can't
  spawn unbounded threads.

- nautd: tear down plugins (joining the webui's threads) before freeing
  torrent tasks, closing a shutdown-time use-after-free window where an
  in-flight request could touch freed state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 00:29:52 -04:00
ookami125
8dde48c05a webui: replace nautctl web server with a loadable plugin
Drop the web UI that was compiled into nautctl and serve the
torrent-ui front end (../torrent-ui/public) from a native plugin
(plugins/webui) loaded via `nautd --plugin`. The plugin talks to the
engine only through the host call_rpc ABI and adapts the daemon's RPC
surface to the qBittorrent-style contract the UI expects (snapshot/SSE,
torrent detail tabs, add/delete, cookie auth).

Also folds in the daemon refactor that owns per-torrent worker threads
and the swarm engine (naut_swarm) used by the plugin's data source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 00:21:48 -04:00