feat(users/Profpatsch/whatcd-resolver): serve torrent files

We want to be able to play the files directly from the web
browser (jukebox).

Luckily, transmission does not seem to change the filenames from the
ones given by the torrent file, so we can literally parse the torrent
file and construct a path to the media file, extraordinary.

Adjusts the caddy reverse proxy to serve the given transmission
directory (using my weird sshfs forwarding scheme in the shell.nix
preset lol), then redirect from a handler that maps from
torrentId/fileId to the actual file.

Change-Id: Iab5faf7cc06066f3253031af31e137c0e28f54e3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13270
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2025-03-15 20:02:36 +01:00
parent 10c8f3386b
commit 498c8e05f8
7 changed files with 164 additions and 18 deletions

View file

@ -0,0 +1,17 @@
{
# Global options block
auto_https off
}
:9092 {
# Serve files from the directory specified by WHATCD_RESOLVER_TRANSMISSION_DOWNLOAD_DIRECTORY
handle_path /files/* {
root * {env.WHATCD_RESOLVER_TRANSMISSION_DOWNLOAD_DIRECTORY}
file_server {
browse off
}
}
# Reverse proxy from localhost:9092 to localhost:9093
reverse_proxy * localhost:9093
}

View file

@ -1,2 +1,2 @@
#!/usr/bin/env execlineb
caddy reverse-proxy --from :9092 --to :9093
caddy run --config ./caddyfile