79 Commits

Author SHA1 Message Date
110c895094 Merge pull request 'Update dependency python-dotenv to v1.1.0' (#40) from renovate/python-dotenv-1.x into main
All checks were successful
Build Docker Image / build (push) Successful in 2m9s
Reviewed-on: #40
2025-03-25 06:12:58 -06:00
15fca90273 Update dependency python-dotenv to v1.1.0
All checks were successful
Build Docker Image / build (push) Successful in 5m0s
2025-03-25 11:00:34 +00:00
b6d64bd6ae Housekeeping fix to pass the token in through click, instead of assuming its going to get picked correctly.
All checks were successful
Build Docker Image / build (push) Successful in 1m23s
2025-03-17 08:15:11 -06:00
daed7b92b4 Merge pull request 'Update dependency certifi to v2025' (#39) from renovate/certifi-2025.x into main
All checks were successful
Build Docker Image / build (push) Successful in 2m2s
Reviewed-on: #39
2025-01-31 19:31:34 -07:00
58b169f6e0 Update dependency certifi to v2025
All checks were successful
Build Docker Image / build (push) Successful in 2m30s
2025-01-31 03:01:38 +00:00
bc3a76319b Merge pull request 'Update dependency charset-normalizer to v3.4.1' (#38) from renovate/charset-normalizer-3.x into main
All checks were successful
Build Docker Image / build (push) Successful in 53s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/38
2024-12-24 15:56:05 -07:00
06894c215c Update dependency charset-normalizer to v3.4.1
All checks were successful
Build Docker Image / build (push) Successful in 1m4s
2024-12-24 19:00:31 +00:00
deee8da21f Merge pull request 'Update dependency urllib3 to v2.3.0' (#37) from renovate/urllib3-2.x into main
All checks were successful
Build Docker Image / build (push) Successful in 1m5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/37
2024-12-22 10:43:48 -07:00
1800c200f2 Merge pull request 'Update dependency click to v8.1.8' (#36) from renovate/click-8.x into main
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/36
2024-12-22 10:43:42 -07:00
fcc03ee33a Update dependency urllib3 to v2.3.0
All checks were successful
Build Docker Image / build (push) Successful in 1m14s
2024-12-22 08:00:36 +00:00
850333b7c0 Update dependency click to v8.1.8
All checks were successful
Build Docker Image / build (push) Successful in 1m26s
2024-12-21 19:00:29 +00:00
a9d2dbab3e Merge pull request 'Update dependency certifi to v2024.12.14' (#35) from renovate/certifi-2024.x into main
All checks were successful
Build Docker Image / build (push) Successful in 1m7s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/35
2024-12-14 09:00:44 -07:00
889fdba885 Update dependency certifi to v2024.12.14
All checks were successful
Build Docker Image / build (push) Successful in 1m18s
2024-12-14 14:00:45 +00:00
17b3ebe923 Merge pull request 'Update dependency flake8-bugbear to ~=24.12.12' (#34) from renovate/flake8-bugbear-24.x into main
All checks were successful
Build Docker Image / build (push) Successful in 51s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/34
2024-12-12 20:23:21 -07:00
2a5406e0e4 Update dependency flake8-bugbear to ~=24.12.12
All checks were successful
Build Docker Image / build (push) Successful in 1m24s
2024-12-12 17:00:33 +00:00
bb22e6e779 Merge pull request 'Update dependency flake8-bugbear to ~=24.10.31' (#33) from renovate/flake8-bugbear-24.x into main
All checks were successful
Build Docker Image / build (push) Successful in 1m8s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/33
2024-11-01 08:11:37 -06:00
d4e0141c8f Update dependency flake8-bugbear to ~=24.10.31
All checks were successful
Build Docker Image / build (push) Successful in 1m15s
2024-10-31 21:00:43 +00:00
f3f48f1575 Merge pull request 'Update dependency flake8-tidy-imports to ~=4.11.0' (#32) from renovate/flake8-tidy-imports-4.x into main
All checks were successful
Build Docker Image / build (push) Successful in 57s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/32
2024-10-27 18:09:43 -06:00
d71fe03e42 Update dependency flake8-tidy-imports to ~=4.11.0
All checks were successful
Build Docker Image / build (push) Successful in 1m17s
2024-10-27 23:00:29 +00:00
8afe81c5d3 Merge pull request 'Update dependency charset-normalizer to v3.4.0' (#31) from renovate/charset-normalizer-3.x into main
All checks were successful
Build Docker Image / build (push) Successful in 59s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/31
2024-10-09 05:16:34 -06:00
661ed95304 Update dependency charset-normalizer to v3.4.0
All checks were successful
Build Docker Image / build (push) Successful in 2m42s
2024-10-09 08:00:41 +00:00
8d0c44e574 Merge pull request 'Update python Docker tag to v3.13' (#30) from renovate/python-3.x into main
All checks were successful
Build Docker Image / build (push) Successful in 4m10s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/30
2024-10-08 18:41:26 -06:00
20403b84fd Update python Docker tag to v3.13
All checks were successful
Build Docker Image / build (push) Successful in 5m2s
2024-10-08 01:00:36 +00:00
30fa0165b8 Merge pull request 'Update docker/build-push-action action to v6' (#29) from renovate/docker-build-push-action-6.x into main
All checks were successful
Build Docker Image / build (push) Successful in 1m18s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/29
2024-09-17 13:27:46 -06:00
4390d59232 Update docker/build-push-action action to v6
All checks were successful
Build Docker Image / build (push) Successful in 1m24s
2024-09-15 22:00:36 +00:00
8b886326a7 Fix in build. Remove demo yaml.
All checks were successful
Build Docker Image / build (push) Successful in 58s
2024-09-15 15:31:51 -06:00
7ecc1eb55c Test build workflow
Some checks failed
Build Docker Image / build (push) Failing after 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
2024-09-15 15:25:33 -06:00
237812f6bc Updated requirements.
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-09-15 15:20:00 -06:00
88fa40ab55 Merge pull request 'Update dependency urllib3 to v2.2.3' (#27) from renovate/urllib3-2.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/27
2024-09-15 14:33:03 -06:00
84141df93f Merge pull request 'Update dependency idna to v3.10' (#28) from renovate/idna-3.x into main
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/28
2024-09-15 14:32:55 -06:00
a250debcda Update dependency idna to v3.10
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 18s
2024-09-15 19:00:37 +00:00
82d3e040a8 Update dependency urllib3 to v2.2.3
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 10s
2024-09-12 11:00:45 +00:00
fb1b934863 Merge pull request 'Update dependency certifi to v2024.8.30' (#26) from renovate/certifi-2024.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 9s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/26
2024-09-05 08:11:53 -06:00
7f08f77706 Update dependency certifi to v2024.8.30
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
2024-08-30 02:00:36 +00:00
80a68d0d3a Merge pull request 'Update dependency idna to v3.8' (#25) from renovate/idna-3.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 44s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/25
2024-08-26 07:06:09 -06:00
54347827bb Update dependency idna to v3.8
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 13s
2024-08-23 17:00:30 +00:00
f6ee2d82e2 Merge pull request 'Update dependency flake8-bugbear to ~=24.8.19' (#24) from renovate/flake8-bugbear-24.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 26s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/24
2024-08-21 14:52:31 -06:00
a6712d3372 Update dependency flake8-bugbear to ~=24.8.19
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s
2024-08-20 03:00:30 +00:00
33e87640f6 Merge pull request 'Update dependency certifi to v2024.7.4 [SECURITY]' (#23) from renovate/pypi-certifi-vulnerability into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 10s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/23
2024-07-09 20:26:39 -06:00
7b457440fc Update dependency certifi to v2024.7.4 [SECURITY]
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 13s
2024-07-06 06:00:16 +00:00
03e5d3d02f Merge pull request 'Update dependency urllib3 to v2.2.2' (#21) from renovate/urllib3-2.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/21
2024-06-17 08:40:55 -06:00
2de766cf38 Update dependency urllib3 to v2.2.2
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
2024-06-17 14:00:22 +00:00
0fdd3e7ed9 Merge pull request 'Update dependency flake8 to ~=7.1.0' (#20) from renovate/flake8-7.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/20
2024-06-15 16:01:09 -06:00
efaaf7a648 Update dependency flake8 to ~=7.1.0
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 10s
2024-06-15 22:00:16 +00:00
f411810e96 Merge pull request 'Update dependency flake8 to v7' (#13) from renovate/flake8-7.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/13
2024-06-11 19:00:46 -06:00
90dc4efa73 Update dependency flake8 to v7
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-06-12 01:00:16 +00:00
e6e0f7b92b Merge pull request 'Update dependency flake8-tidy-imports to ~=4.10.0' (#7) from renovate/flake8-tidy-imports-4.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/7
2024-06-11 18:43:26 -06:00
26b7736fb1 Merge pull request 'Update dependency flake8-docstrings to ~=1.7.0' (#6) from renovate/flake8-docstrings-1.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/6
2024-06-11 18:43:15 -06:00
e8d9c43b33 Merge pull request 'Update dependency flake8-annotations to v3' (#14) from renovate/flake8-annotations-3.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/14
2024-06-11 18:43:00 -06:00
ffc7708cd3 Update dependency flake8-annotations to v3
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-06-12 00:42:07 +00:00
86fe033d7d Update dependency flake8-docstrings to ~=1.7.0
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-06-12 00:42:00 +00:00
85dd9332c0 Merge pull request 'Update dependency pep8-naming to ~=0.14.1' (#8) from renovate/pep8-naming-0.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/8
2024-06-11 18:41:13 -06:00
b09b8837c9 Merge pull request 'Update dependency flake8 to ~=3.9.2' (#3) from renovate/flake8-3.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/3
2024-06-11 18:40:59 -06:00
d7a1736ddf Merge pull request 'Update dependency click to v8.1.7' (#2) from renovate/click-8.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/2
2024-06-11 18:40:43 -06:00
a781f2cd80 Merge pull request 'Update dependency idna to v3 [SECURITY]' (#1) from renovate/pypi-idna-vulnerability into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/1
2024-06-11 18:39:48 -06:00
3e4d6156c7 Merge branch 'main' of git.home.timatlee.com:timatlee/cloudflare-ddns-docker-updated
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
2024-06-11 18:39:20 -06:00
ef4b86c132 Merge remote-tracking branch 'origin/renovate/chardet-5.x' 2024-06-11 18:39:14 -06:00
ce76fa87ed Merge pull request 'Update dependency flake8-bugbear to v24' (#15) from renovate/flake8-bugbear-24.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/15
2024-06-11 18:37:21 -06:00
55d0ec44c0 Merge pull request 'Update dependency urllib3 to v2' (#16) from renovate/urllib3-2.x into main
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
Reviewed-on: https://git.home.timatlee.com/timatlee/cloudflare-ddns-docker-updated/pulls/16
2024-06-11 18:31:40 -06:00
f154083f07 Add dotenv support
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-06-11 18:26:12 -06:00
199763f50e Test action!
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 49s
2024-06-11 11:04:30 -06:00
6905b2adab Update renovate.json 2024-06-11 08:54:42 -06:00
304ba2a48a Update renovate.json
Ignore .github directory, since we're not using it ..  and this is a fork from a mirror.
2024-06-11 08:43:46 -06:00
5201dfa2d4 Update dependency urllib3 to v2 2024-06-11 14:41:25 +00:00
ae038ca034 Update dependency flake8-bugbear to v24 2024-06-11 14:41:24 +00:00
4f7f3f243c Update dependency chardet to v5 2024-06-11 14:41:20 +00:00
4b169c2051 Update dependency pep8-naming to ~=0.14.1 2024-06-11 14:41:13 +00:00
9b24129760 Update dependency flake8-tidy-imports to ~=4.10.0 2024-06-11 14:41:10 +00:00
bb916ed3c1 Update dependency flake8 to ~=3.9.2 2024-06-11 14:41:00 +00:00
35da9d30b2 Update dependency click to v8.1.7 2024-06-11 14:40:59 +00:00
753b3523c6 Update dependency idna to v3 [SECURITY] 2024-06-11 14:40:57 +00:00
0743d7fa6d Update renovate.json 2024-06-11 08:40:20 -06:00
6ac289ccf1 Update requirements.txt 2024-06-11 08:32:16 -06:00
fa8d5c1c61 Add renovate.json 2024-06-10 20:05:20 -06:00
bbc042a642 Updated to current python ver. Learning how to make a container. 2024-06-04 12:12:17 -06:00
b353c04338 Gracefully exit the application 2021-01-30 18:28:01 +01:00
dc284f7a70 Use a requests session instead of normal requests 2021-01-30 18:18:40 +01:00
d344306a82 Write a proper README 2021-01-22 15:37:38 +01:00
a7d809bb7d Add the main application code. 2021-01-22 14:35:49 +01:00
12 changed files with 201 additions and 21 deletions

View File

@ -0,0 +1,30 @@
name: Build Docker Image
on: [push]
jobs:
build:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: git.home.timatlee.com
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: git.home.timatlee.com/timatlee/cloudflare-ddns:latest

View File

@ -0,0 +1,19 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

1
.sops.yaml Normal file
View File

@ -0,0 +1 @@
[]

View File

@ -1,4 +1,4 @@
FROM python:3.9-slim
FROM python:3.13-slim
WORKDIR /app

105
README.md
View File

@ -1,2 +1,103 @@
# cloudflare-ddns-docker
A Docker service updating your CloudFlare DNS records periodically.
# Cloudflare DDNS
![Linting](https://github.com/Akarys42/cloudflare-ddns-docker/workflows/Linting/badge.svg)
![Push Container](https://github.com/Akarys42/cloudflare-ddns-docker/workflows/Push%20Container/badge.svg)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
Cloudflare DDNS is a configurable Docker service updating your CloudFlare DNS records periodically
to match your local IP address.
# Table of Content
- [Cloudflare DDNS](#cloudflare-ddns)
- [Table of Content](#table-of-content)
- [Installation](#installation)
- [Using a Pre-built Container](#using-a-pre-built-container)
- [Building the Container Yourself](#building-the-container-yourself)
- [Hosting](#hosting)
- [Running on the Host](#running-on-the-host)
- [Configuration](#configuration)
- [Getting a Cloudflare Token](#getting-a-cloudflare-token)
- [Supported Options](#supported-options)
- [Contributing](#contributing)
## Installation
While this project is intended to be ran as a Docker container, it can also be ran on the host directly.
This container runs until terminated. It is not a cron job.
### Using a Pre-built Container
This project is available on the GitHub Container Registry.
```shell
docker pull git.home.timatlee.com/timatlee/cloudflare-ddns:latest
```
### Building the Container Yourself
There are no special requirements when building this container. Simply build with:
```shell
docker build -t git.home.timatlee.com/timatlee/cloudflare-ddns:latest .
docker push git.home.timatlee.com/timatlee/cloudflare-ddns:latest
```
#### Hosting
I am hosting this in my own Gitea repository. We can push this with:
```shell
docker login git.home.timatlee.com
username: timatlee
password: // Gitea PAT token
```
### Running on the Host
Python > 3.12 is required. This likely requires a virtualenv.
```shell
python -m venv .env
.env\scripts\activate.ps1
pip install -r requirements.txt
python -m cloudflare_ddns --token ... -d .. domain.example.com
```
In order to run this project on the host, you'll need Python > 3.8, and an environment containing
the dependencies listed in [`requirements.txt`](requirements.txt).
The project can then by launched by running the `cloudflare_ddns` module, usually using `python -m cloudflare_ddns`.
## Configuration
This project will accept parameters through environment variables or command line argument.
Feel free to select the method fitting your setup the best!
### Getting a Cloudflare Token
The first step will be to create an API token with the following scopes:
- `Zone:Read`
- `DNS:Edit`
### Supported Options
We currently support following settings:
| Parameter Name | Short Command Line Option | Long Command Line Option | Environment Variable | Description |
|----------------------------|---------------------------|--------------------------|----------------------|---------------------------------------------------------------------------------------------|
| Token [mandatory] | `-k` | `--token` | `CF_DDNS_TOKEN` | Your Cloudflare token created in the previous step. |
| Delay [default: 5 minutes] | `-d` | `--delay` | `CF_DDNS_DELAY` | The time to wait between each update. It is parsed per [`strftime`](https://strftime.org/). |
The domains to update will have to either be passed as command line arguments after the options
or with a space separated `CF_DDNS_DOMAINS` environment variable.
Each domain can be preceded by the record type, either A or AAAA, followed by a colon.
Otherwise any found A or AAAA record pointing to this domain found will be used.
## Contributing
Any help would be greatly appreciated!
Feel free to check our [open issues](https://github.com/Akarys42/cloudflare-ddns-docker/issues) and send us a Pull Request!

View File

@ -1,13 +1,14 @@
import logging
from os import environ
from typing import Tuple
from dotenv import load_dotenv
import click
from cloudflare_ddns.app import ApplicationJob
from cloudflare_ddns.constants import BASE_ENV_VAR, DEFAULT_DELAY, DOMAINS_ENV_VAR
log = logging.getLogger("ddns")
load_dotenv()
@click.command()
@click.option(
@ -22,6 +23,7 @@ log = logging.getLogger("ddns")
prompt="Enter your Cloudflare Token",
hide_input=True,
show_envvar=True,
envvar='CF_DDNS_TOKEN',
help="Your Cloudflare Bearer token."
)
@click.option('-v', '--verbose', is_flag=True, default=False, help="Show debug logging.")

View File

@ -1,6 +1,7 @@
import logging
import threading
from dataclasses import dataclass
from signal import SIGINT, SIGTERM, signal
from typing import List
import requests
@ -46,9 +47,14 @@ class ApplicationJob(threading.Thread):
self.raw_domains = raw_domains
self.raw_delay = raw_delay
self.session = requests.session()
def launch(self) -> None:
"""Launch the application by validating arguments and starting the thread."""
self.validate_arguments()
log.debug("Registering exit hooks.")
signal(SIGINT, self.exit)
signal(SIGTERM, self.exit)
log.debug("Starting job.")
self.start()
@ -87,9 +93,9 @@ class ApplicationJob(threading.Thread):
for record in self.domains:
log.debug(f"Updating record for {record.domain}.")
check_status(requests.patch(
check_status(self.session.patch(
PATCH_DNS.format(zone_identifier=record.zone, identifier=record.id),
json={"content": get_ip(record.record_type == 'AAAA')},
json={"content": get_ip(record.record_type == 'AAAA', self.session)},
auth=self.auth
))
@ -99,8 +105,8 @@ class ApplicationJob(threading.Thread):
"""Parse the domain in `raw_domains` and populate the `domains` array with `Domain` objects."""
found_domains = {}
for zone_json in check_status(requests.get(LIST_ZONES, auth=self.auth)).json()["result"]:
for record_json in check_status(requests.get(
for zone_json in check_status(self.session.get(LIST_ZONES, auth=self.auth)).json()["result"]:
for record_json in check_status(self.session.get(
LIST_DNS.format(zone_identifier=zone_json["id"]),
auth=self.auth
)).json()["result"]:
@ -108,7 +114,7 @@ class ApplicationJob(threading.Thread):
domain = Domain(
record_json["name"],
record_json["type"],
record_json["zone_id"],
zone_json["id"],
record_json["id"]
)
found_domains[f'{record_json["name"]}-{record_json["type"]}'] = domain
@ -186,8 +192,14 @@ class ApplicationJob(threading.Thread):
def validate_bearer(self) -> None:
"""Utility method to validate a CF bearer token."""
r = requests.get(VERIFY_TOKEN, auth=self.auth)
r = self.session.get(VERIFY_TOKEN, auth=self.auth)
if not r.json()["success"]:
error_message = ' / '.join(error["message"] for error in r.json()["errors"])
raise ValueError(error_message)
def exit(self, *_) -> None:
"""Gracefully exit the application."""
log.info("Exiting application.")
self.stop_signal.set()
self.join()

View File

@ -54,9 +54,9 @@ class BearerAuth(AuthBase):
return r
def get_ip(ipv6: bool) -> str:
def get_ip(ipv6: bool, session: requests.Session) -> str:
"""Return the host public IP as detected by ipify.org."""
r = check_status(requests.get(IP_API_URL_IPV4 if not ipv6 else IP_API_URL_IPV6))
r = check_status(session.get(IP_API_URL_IPV4 if not ipv6 else IP_API_URL_IPV6))
return r.text

View File

@ -1,5 +1,4 @@
## Development docker-compose
version: "3.7"
services:
cloudflare-ddns:
build:

9
renovate.json Normal file
View File

@ -0,0 +1,9 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"forkProcessing": "enabled",
"ignorePaths": [
".github"
]
}

View File

@ -1,9 +1,9 @@
flake8~=3.8.4
flake8-annotations~=2.4.1
flake8-bugbear~=20.1.4
flake8-docstrings~=1.5.0
flake8~=7.1.0
flake8-annotations~=3.1.1
flake8-bugbear~=24.12.12
flake8-docstrings~=1.7.0
flake8-import-order~=0.18.1
flake8-string-format~=0.3.0
flake8-tidy-imports~=4.1.0
flake8-tidy-imports~=4.11.0
flake8-todo~=0.7
pep8-naming~=0.11.1
pep8-naming~=0.14.1

View File

@ -1,2 +1,9 @@
requests~=2.25.1
click8~=8.0.1
certifi==2025.1.31
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
idna==3.10
python-dotenv==1.1.0
requests==2.32.3
urllib3==2.3.0