Skip to content

feat(cloudflare_worker): relay listed APIs through one Cloudflare Worker, replacing telegram_relay - #116

Merged
hackallcode merged 4 commits into
masterfrom
feat/cloudflare-worker
Nov 21, 2026
Merged

hackallcode merged 4 commits into
masterfrom
feat/cloudflare-worker

Conversation

@hackallcode

@hackallcode hackallcode commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

The Telegram relay is one case of a wider need: a host that reaches Cloudflare but not some API can call it through a
Worker that knows what it may reach. A vendor cloud API throttled on the host's network is the next one, and a role
per API, each with its own Worker, hostname and copy of the upload tasks, would drift and put every relayed API in
public DNS and certificate logs.

cloudflare_worker replaces telegram_relay with one Worker for any number of upstreams. The first path segment
names the upstream host: /<host>/<path> goes to https://<host>/<path>, with method, headers, query and body, when
the host is a key of cloudflare_worker_upstreams and the path starts with one of its prefixes. A client takes
https://<hostname>/<host> as the upstream's base URL. The Telegram Bot API needs no mode of its own: it is the
upstream api.telegram.org with /bot<id>: and /file/bot<id>: of the allowed bots as prefixes, and its clients
(Alertmanager's api_url, python-telegram-bot's base_url) accept a base URL with a path.

Every other call gets 404, so the Worker is no open proxy. The check runs on the normalised URL path and on the exact
host key, so .. segments, user@host, a port or an unlisted host do not slip through. The upload, the
deploy-<hash> tag, the hostname handling, uninstall and --check behave as in telegram_relay; the tag now hashes
the upstreams. Detaching a hostname answers 204, which telegram_relay took for a refusal, so a renamed hostname or an
uninstall failed after the detach went through.

telegram_relay was never released, so it goes without a deprecation step. A deployed one keeps running until its
clients move to the new base URL and uninstall deletes it by name. The Worker tests move to
make test/cloudflare-worker, and the CI step follows.

…er, Telegram as one of its modes

A host that reaches Cloudflare but not an API needs the same Worker the
Telegram relay was: a fixed upstream and a list of paths it may reach, so
the Worker is no open proxy. The role keeps one module for both: `relay`
mode takes the upstream and path prefixes as they are, `telegram` mode
builds them from the bot ids. telegram_relay goes, as it was never released.
@hackallcode hackallcode changed the title feat(cloudflare_worker): relay any upstream through a Cloudflare Worker, Telegram as one of its modes feat(cloudflare_worker): relay listed APIs through one Cloudflare Worker, Telegram as one of its modes Nov 21, 2026
@hackallcode hackallcode changed the title feat(cloudflare_worker): relay listed APIs through one Cloudflare Worker, Telegram as one of its modes feat(cloudflare_worker): relay listed APIs through one Cloudflare Worker, replacing telegram_relay Nov 21, 2026
@hackallcode
hackallcode merged commit 0a42ed8 into master Nov 21, 2026
27 checks passed
@hackallcode
hackallcode deleted the feat/cloudflare-worker branch November 21, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant