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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyflared-0.0.1b6.tar.gz
  • Upload date:
  • Size: 28.8 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.1b6.tar.gz
Algorithm Hash digest
SHA256 2d1c734cd0e010d6c73667815263dacec7148bc7bf8fb009d979f284570995c9
MD5 b3afc881f2e2ff27838526600e6580c0
BLAKE2b-256 85ef1aedc5a3bd3ec9adcae9b9f4a8df2290f9568315a87a5ba97cea799c02aa

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyflared-0.0.1b6-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.1b6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c5fd15c9fc40020a87f0a1dbc347fc2374f668942fb00238f604f8d697a1cbe9
MD5 e386fe1e3d340902f1d70f4e8e02f5f5
BLAKE2b-256 2c6b160acb89c01dbc16390a7a8310a52ca95f9dc1f458d6472b2813be8c44a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b6-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ebc9256c8d7ba16343b714ba75bb6d1e4a542d657e522d6bdeee893dac0e8e5e
MD5 aa13141d0c74393fd25ee2a763275834
BLAKE2b-256 6f005086e83872d95be04a2ce76b98cd8a5f632826843ddec5bec3896c10d31b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b6-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f920291979ae5db7c42772a7d5e9fe9f48c1cec8dc8c2495e17f1ab581d147c7
MD5 d149078ebe607a1bc8bc09c384fecce7
BLAKE2b-256 22fe64f53782f914a292b15c6af55757ac76a0cf3cff92483f539d1d7289be11

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28b48513d56bf999fc1519c2d4bdd6695624f6bbd09e9a180b241aa03ab02469
MD5 df37d5fa1526a25762d15b09c2f290dc
BLAKE2b-256 ea85ee2652e14fb4dbd65e7fb8706b7ee80047206e1f873b9909a0a344ca2d18

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyflared-0.0.1b6-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 56a31b1d4997f4025f0509b7e9a7eb828ac7786ccce935e83a5dba170407d2bf
MD5 34b449634c3311cf2a8cb3dbfa547271
BLAKE2b-256 aaca2c46f49e7c90b8dfdce2776fd3476307bedf8626c00efda06a85b4f129ae

See more details on using hashes here.

Provenance

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