|
||
---|---|---|
.vscode | ||
src | ||
submodules | ||
.gitignore | ||
.gitmodules | ||
build.rs | ||
Cargo.lock | ||
Cargo.toml | ||
deny.toml | ||
LICENSE | ||
local.toml | ||
README.md | ||
rust-toolchain | ||
wrangler.toml |
Yumechi-no-kuni-proxy-worker
This is a misskey proxy worker for ゆめちのくに (Yumechi-no-kuni) instance. Runs natively on both local and Cloudflare Workers environments!
Work in progress! Currently to do:
- Content-Type sniffing
- SVG rendering
- Font rendering (likely will not run on Cloudflare Workers Free plan)
- Preset image resizing
- Opportunistic Redirection on large video files
- RFC9110 compliant proxy loop detection with defensive programming against known vulnerable proxies
- HTTPs only mode and X-Forwarded-Proto reflection
- Cache-Control header
- Rate-limiting on local deployment (untested)
- Read config from Cloudflare
- Timing and Rate-limiting headers (some not available on Cloudflare Workers)
- Handle all possible panics reported by Clippy
- Sandboxing the image rendering
Demo
Avatar resizing
Preview at:
Image:
SVG rendering
(font rendering disabled due to size restrictions)
Setup and Deployment
-
Clone this repository. Load the submodules with
git submodule update --init
. -
Install Rust and Cargo, using rustup is recommended. If you do not plan on deploying to Cloudflare Workers, you can remove the
rust-toolchain
file intended to get around cloudflare/worker-rs#668. Otherwise you may need to install that specific version of Rust byrustup install install $(cat rust-toolchain)
. -
IF deploying locally:
-
Edit
local.toml
to your liking. The documentations can be opened withcargo doc --open
. -
Test run with
cargo run --features env-local -- -c local.toml
. -
Build with
cargo build --features env-local --profile release-local
. The built binary will be intarget/release-local/yumechi-no-kuni-proxy-worker
. -
The only flag understood is
-c
for the configuration file. The configuration file is in TOML format. However, theRUST_LOG
environment variable will change the log level. The log level isinfo
by default if the environment variable is not set.
IF deploying to Cloudflare Workers:
-
Add the wasm target with
rustup +$(cat rust-toolchain) target add wasm32-unknown-unknown
. -
Have a working JS environment.
-
Install
wrangler
with you JS package manager of choice. See https://developers.cloudflare.com/workers/wrangler/install-and-update/.npx
also works. -
Edit
wrangler.toml
to your liking. Everything in the[vars]
section maps directly into theconfig
section of the TOML configuration file. -
Test locally with
wrangler dev
. -
Deploy with
wrangler deploy --outdir bundled/
.
-