This script is designed to interact with the Cloudflare API to retrieve the status of available tunnels. It fetches and displays details about each tunnel such as its name, ID, and status. The script fetches credential information from environment variables and utilizes the requests library to interact with the API.
Ensure that Python 3.12 is installed on your system. You can download it from the official Python website.
All dependencies required for the script to run are included in the requirements.txt
file. You can install them using pip with the following command:
pip install -r requirements.txt
In the case the requirements.txt
file is not provided, you must install the necessary packages manually. For the given script, you'll need:
python-dotenv
: to handle the loading of environment variables from a .env
file.
requests
: to make HTTP requests.
You can install these packages by running:
pip install python-dotenv requests
The script uses environment variables to safely store and use sensitive data, like the Cloudflare API key and email. Ensure to set up your environment variables in a .env
file in the same directory as your script with the following format:
CLOUDFLARE_EMAIL=your_cloudflare_email
CLOUDFLARE_GLOBAL_API_KEY=your_cloudflare_global_api_key
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id
Replace the placeholder values with your actual Cloudflare credentials.
After fulfilling the prerequisites and setting up the environment variables, you can run the script using Python:
python cloudflare_tunnel.py
Upon successful execution, the script will fetch and display the status of available tunnels from Cloudflare in the following format:
Tunnels:
[Tunnel Name] | ID: [Tunnel ID] | Status: [Tunnel Status]
If it encounters an issue, it will display an error message indicating the HTTP status code and response text.
Feel free to fork the repository and submit pull requests for any improvements, bug fixes, or additional functionality. Always ensure to follow best practices for coding and adhere to the current structure of the script.
This integration is released under the MIT License.
This project is not affiliated with or endorsed by Cloudflare.