The original goal was to create a simple Nodejs client that updates a Cloudflare DNS entry to the client's public IP, much like DDNS. The new goal is to create a Python equivalent offering a server mode mimicking the same response as Cloudflare's trace service.
Node client to updates DNS entry in Cloudflare
git clone https://github.com/jhfoo/cloudflare-ddns.git
npm start <host.domain.name> <cloudflare api token>
Create a token with the following permission:
- Zone -> DNS -> Edit
- Check if zone is managed by the token.
- Get IP as reported by Cloudflare trace tool.
- Create/ update host.domain.name with IP.
git clone https://github.com/jhfoo/cloudflare-ddns.git
cd cloudflare-ddns/python
./bin/setup
cd cloudflare-ddns/python
./bin/cloudflare-ddns -h
cd cloudflare-ddns/python
./bin/cloudflare-ddns client <hostname> <api token>
Alternatively the API token can be read from the environment variable CLOUDFLARE_TOKEN. If token is passed in the CLI it supercedes the environment variable.
cd cloudflare-ddns/python
./bin/cloudflare-ddns server [<port>] [--dev|-d]
--dev runs server in development mode which means the server does not exit upon shutdown.
The following paths are valid:
/shutdown # stops the service
/cdn-cgi/trace # mimicks the same path as Cloudflare
/ # same as above: for lazy people