Skip to main content

A Python CLI tool for effortless Cloudflare Tunnel management

Project description

Pyflared

A Python CLI tool for effortless Cloudflare Tunnel management

PyPI - Version PyPI - Python Version Cloudflared Version License


Pyflared wraps the official cloudflared binary and the Cloudflare API to provide a seamless CLI experience for creating and managing Cloudflare Tunnels. No more manual token juggling or complex configurations—just simple commands to expose your local services to the internet.

✨ Features

  • 🚀 Quick Tunnels — Spin up instant, temporary public URLs for local services with a single command
  • 🔗 DNS-Mapped Tunnels — Create persistent tunnels with automatic DNS record management
  • 🧹 Automatic Cleanup — Orphan tunnel and stale DNS record detection & removal
  • 📦 Batteries Included — Bundles the cloudflared binary, no separate installation required
  • 🐳 Docker Ready — Run as a container with minimal setup
  • 🔐 Secure by Design — API tokens are never logged or exposed; uses Pydantic's SecretStr

📦 Installation

Using uv (Recommended)

uv tool install pyflared

Using pip

pip install pyflared

Using Docker

docker pull ghcr.io/azmainmahatab/pyflared:latest
docker run --rm ghcr.io/azmainmahatab/pyflared --help

🚀 Quick Start

Create a Quick Tunnel

Expose a local service instantly with a temporary trycloudflare.com URL:

pyflared tunnel quick 8000

This creates a public URL (e.g., https://random-name.trycloudflare.com) pointing to localhost:8000.

Create a DNS-Mapped Tunnel

Create a persistent tunnel with your own domain:

pyflared tunnel mapped api.example.com=localhost:8000 web.example.com=localhost:3000

This will:

  1. Create a new Cloudflare Tunnel
  2. Configure DNS records for your domains
  3. Route traffic to your local services

Note: Requires a Cloudflare API token with tunnel and DNS permissions. Set via CLOUDFLARE_API_TOKEN environment variable or enter when prompted.

Cleanup Orphan Tunnels

Remove stale tunnels and DNS records created by pyflared:

pyflared tunnel cleanup

📖 Usage

pyflared --help

Commands

Command Description
pyflared version Show the bundled cloudflared version
pyflared tunnel quick <service> Create a quick tunnel to a local service
pyflared tunnel mapped <pairs...> Create DNS-mapped tunnel(s)
pyflared tunnel cleanup Remove orphan tunnels and DNS records

Options for tunnel mapped

Option Description
--keep-orphans, -k Preserve orphan tunnels (prevents default removal)
--tunnel-name, -n Specify a custom tunnel name (default: hostname_YYYY-MM-DD_...)
--verbose, -v Show detailed cloudflared logs

🔧 Configuration

Environment Variables

Variable Description
CLOUDFLARE_API_TOKEN Your Cloudflare API token for tunnel management

API Token Permissions

For DNS-mapped tunnels, your API token needs the following permissions:

  • Account > Cloudflare Tunnel > Edit
  • Zone > DNS > Edit
  • Zone > Zone > Read

🛠️ Development

Prerequisites

Setup

git clone https://github.com/AzmainMahatab/pyflared.git
cd pyflared
hatch env create

Running Tests

hatch test

Type Checking

hatch run types:check

Building

hatch build

📄 License

Pyflared is distributed under the terms of the MIT license.

🙏 Acknowledgments


Made with ❤️ by Azmain Mahatab

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyflared-0.0.1b5.tar.gz (28.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyflared-0.0.1b5-py3-none-win_amd64.whl (18.8 MB view details)

Uploaded Python 3Windows x86-64

pyflared-0.0.1b5-py3-none-manylinux_2_17_x86_64.whl (20.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

pyflared-0.0.1b5-py3-none-manylinux_2_17_aarch64.whl (18.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

pyflared-0.0.1b5-py3-none-macosx_11_0_arm64.whl (19.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

pyflared-0.0.1b5-py3-none-macosx_10_9_x86_64.whl (21.1 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file pyflared-0.0.1b5.tar.gz.

File metadata

  • Download URL: pyflared-0.0.1b5.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyflared-0.0.1b5.tar.gz
Algorithm Hash digest
SHA256 872263c6e853c130422c84b89d28176f7a694a49df06a9cd5dde5ae1b00e3e21
MD5 eec167ce047eaa1d0a43b918a091bc8e
BLAKE2b-256 89562abc1b275ae453461df766d5ff2b20e05eca411d5bc268a13b8f76462c5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b5.tar.gz:

Publisher: cd.yml on AzmainMahatab/pyflared

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyflared-0.0.1b5-py3-none-win_amd64.whl.

File metadata

  • Download URL: pyflared-0.0.1b5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 18.8 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyflared-0.0.1b5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2deb18d76eafd8b18ba616fe3c3843ca59fac4e90d191d254c11d548280c949e
MD5 4e929ab2fad16ad6ac77fe33aea25211
BLAKE2b-256 5be7cc8315f1ce50649cd5f31d7428deb5986bc2b53e19b7d66d952cc50f9355

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b5-py3-none-win_amd64.whl:

Publisher: cd.yml on AzmainMahatab/pyflared

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyflared-0.0.1b5-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b5-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ae1986e6f96b1b91d5cc27011172d58d300b197a7419bba761263628b3dfb2f1
MD5 77f6bf8fa007a24e83f194eed627e453
BLAKE2b-256 2840094a51eb6b67a7b4b95abde4e54f84ab8f6e42e61575ea220f40797d1d0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b5-py3-none-manylinux_2_17_x86_64.whl:

Publisher: cd.yml on AzmainMahatab/pyflared

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyflared-0.0.1b5-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b5-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 73090b4d4a11a6cf12581486e9eb3f8aae8e58410e9c93ca48b10788c02ed1e3
MD5 2df1a713adf7b448e3e175c372811b9d
BLAKE2b-256 ad4de0ac27593c09d4f2d8f3588e73fd577d1a8d43f9acc61e42129f85340ac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b5-py3-none-manylinux_2_17_aarch64.whl:

Publisher: cd.yml on AzmainMahatab/pyflared

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyflared-0.0.1b5-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3bce447f1e8c4ba5c95226e0343c11e9ceb5d3338db97e571150738cfec8084
MD5 dcab39ab37297becd7d0ae655eee2540
BLAKE2b-256 c9edb284f8b686d7c785c306e515fc4a04e82d0534f7a6b210bb452424cab533

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b5-py3-none-macosx_11_0_arm64.whl:

Publisher: cd.yml on AzmainMahatab/pyflared

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyflared-0.0.1b5-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b5-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cb9943f5d116c326f9969b7344b835a6c283384e986df8ef73dc3a9a5a10949c
MD5 5c52cc99f11f482eb4d04b57b3db928e
BLAKE2b-256 9325243916efd57c7fa72df0f70608a7cda63e778648db66ff714af440fe031c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b5-py3-none-macosx_10_9_x86_64.whl:

Publisher: cd.yml on AzmainMahatab/pyflared

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page