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

Uploaded Python 3Windows x86-64

pyflared-0.0.1b7-py3-none-musllinux_1_1_x86_64.whl (20.2 MB view details)

Uploaded Python 3musllinux: musl 1.1+ x86-64

pyflared-0.0.1b7-py3-none-musllinux_1_1_aarch64.whl (18.9 MB view details)

Uploaded Python 3musllinux: musl 1.1+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyflared-0.0.1b7.tar.gz
  • Upload date:
  • Size: 30.5 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.1b7.tar.gz
Algorithm Hash digest
SHA256 d5c1440e09a30d9395e0d9972e1d9b61f770d9f0ae0335b17b10c289aea0aed8
MD5 a95ffec3a359e5ce1674771ea5437994
BLAKE2b-256 f2f24fe3bd5cffb978ece18a47719508ccdc86c58858144a9d476c3715a497e0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyflared-0.0.1b7-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.1b7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 15ec00bfb338faecfbe4eda19e52949081a8a109d74002dbad3f6378ba6409ac
MD5 87b730be9b17f9fee642ac77b451fd89
BLAKE2b-256 88f7fd09b552c6347ff9f9a7e84743414b414f5e7a42ec2a0d581236e50392e1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b7-py3-none-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 146cb0614567e7095753e8e05646f8422e767f895a465cf7070cd2e08b455ad4
MD5 8bcd8bd17ed154b7dc71ec98484c14be
BLAKE2b-256 0bd4b6fe11b0b8df9f3ed7effedb791e37322e13c04f25c5be72c7cad0e96189

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b7-py3-none-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 c73286d120a6fd6ba29742401f7567230fd2b51dde11a8f450707f07bcf304e5
MD5 4e5bf135ed2aecb27127e2122def13d8
BLAKE2b-256 1dc43584b116feab6f6a88316d7111c7d882e0f08dd925d2a95c931f5eca969a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b7-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9115b0ce38af4bf8903c9215fc754e901f5ea5011efd3563f9e8bcdbc0a98dc3
MD5 cd6f10012001f3b63f7c6809170ae840
BLAKE2b-256 1c83199dc4b2dfde71460f66945f2cc6cc6b5a6d196980862580cbe65213ea65

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b7-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 2d43b3ada3abd46b3e8ec0d8ee2a4e9bf1e889bc20c64aaaa839af8903391d74
MD5 6defa0badbd93a8096cfb97588cc943a
BLAKE2b-256 f018cc55c282e4107ceb15e3a0bc77995f38d748178920de99145bffc0c1c137

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34a2a4552e83c59c01bc7ded9be9a85c1aad8d5599a55c31150ffb7a29919884
MD5 15cb82d5a098c77b82787f53050b9ded
BLAKE2b-256 27923d1d876b5655dee4a4936ed0017fe30d72c0739dbba61333a847dbd36050

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b7-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a2eaebd6b06ed6a2e54a08f2b1c4757f85a380e21b83eca07012d6839a0e6c16
MD5 343572c69e2f2cf646328439c11b8ea4
BLAKE2b-256 deea8f993f067ce96cf269461d77fdb346cb3cf5fb8a4713d9e484ad9246602f

See more details on using hashes here.

Provenance

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