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.1b4.tar.gz (28.6 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.1b4-py3-none-win_amd64.whl (18.8 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

pyflared-0.0.1b4-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.1b4.tar.gz.

File metadata

  • Download URL: pyflared-0.0.1b4.tar.gz
  • Upload date:
  • Size: 28.6 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.1b4.tar.gz
Algorithm Hash digest
SHA256 08ba5d73ca69505be77faae35f00cc2536f5ad44c042ad2e66132e1e5a5e3eb6
MD5 e554fefc437863ae42cc8ef55de2adee
BLAKE2b-256 6680665f68dfb9b8de4cae27adc912e7ac814cd9fbf5eceb00be0ac257c0fa16

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b4.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.1b4-py3-none-win_amd64.whl.

File metadata

  • Download URL: pyflared-0.0.1b4-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.1b4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 91ce3b63a3023d8de819d9619bd51fd7a00ca73d97f29123111de1c1c352c9b5
MD5 25f27dcc4e71e42e67aa662dee6fe8e1
BLAKE2b-256 1af848e8fd17bf4ce4d7e714d521a24e443c179924470a1e816ce37496a87344

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b4-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.1b4-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b4-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 39257a159fc2aa3dc908b4f9649b815d018eb56777d2d2e15ec42686266e4998
MD5 c4760b4cbd501936bdbef6d02ace7097
BLAKE2b-256 ea635b9ad0b6922916ab95ae46142eeeecbafdfd50aaa9e7aad6109b24d01b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b4-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.1b4-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b4-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 d5e9e268cfadac4cededa30795c6bbc2ef13901b71be0fa15c131cb54cbb5653
MD5 9a5819b13d0b8072a5010e6690a768f7
BLAKE2b-256 70a8696309629e977e9570f0e05363d5d767a8297b81ce6ad8283ee3262cf9d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b4-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.1b4-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8b8221bd60700b4921c76fd8e00dc0fdf2e2a62e1d2e5bb4c529840cbee615e
MD5 efc8fa70d68ab3e7cf9ddc8c19f4820e
BLAKE2b-256 52511445263e3734bd618889a72156178ba75ea26e02543710937838480c06ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b4-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.1b4-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyflared-0.0.1b4-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2326bc543f6cb1a0e2f80bec4c0f499bd5dade8493eb6e20fbf3639814487557
MD5 a7dde59a2793fc180313382982d4d988
BLAKE2b-256 dbed39974d9c089ae7deab8ff04b0a0f0388efea1b49e7893fe7a6eb2aca1c1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyflared-0.0.1b4-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