Giter Site home page Giter Site logo

favonia / cloudflare-ddns Goto Github PK

View Code? Open in Web Editor NEW
651.0 651.0 24.0 1.35 MB

๐ŸŒŸ A small, feature-rich, and robust Cloudflare DDNS updater

License: Apache License 2.0

Go 99.79% Dockerfile 0.21%
cloudflare ddns ddns-client ddns-updater dns dns-over-https docker docker-compose docker-image dynamic-dns go golang healthchecks ipv6 selfhosted

cloudflare-ddns's People

Contributors

dependabot[bot] avatar favonia avatar step-security-bot avatar symgryph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cloudflare-ddns's Issues

direct Mac binary?

any way to get it to build on osx?

kernel.org/pub/linux/libs/security/libcap/cap
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/syscalls.go:16:10: undefined: psx.Syscall3
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/syscalls.go:17:10: undefined: psx.Syscall6
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:229:29: undefined: syscall.SYS_PRCTL
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:241:29: undefined: syscall.SYS_PRCTL
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:253:29: undefined: syscall.SYS_PRCTL
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:266:29: undefined: syscall.SYS_PRCTL
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:279:22: undefined: syscall.SYS_CAPGET
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:346:37: undefined: syscall.SYS_CAPGET
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/cap.go:366:29: undefined: syscall.SYS_CAPSET
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/convenience.go:277:25: undefined: sysSetGroupsVariant
../../go/pkg/mod/kernel.org/pub/linux/libs/security/libcap/[email protected]/convenience.go:277:25: too many errors
bash-5.1$

Rewrite/simplify the template system

Problem

The current template system is working but does not seem to be well-engineered.

  1. Currently, the template engine increases the size of the (compressed) image by ~1MB.
  2. TTL currently supports templates (for fun), but that is probably overkill.
  3. For PROXIED, only Boolean expressions are needed. No need to support variables, template inclusion, looping, etc.

Proposal

  1. TTL should not support templates.
  2. PROXIED should support only very restricted templates as a Boolean expression consisting of
    a. Constants supported by strconv.ParseBool
    b. &&, ||, !
    b. is(a, b, c)
    c. sub(a, b, c): subdomains of a.b.c (not including a.b.c itself)

Benefits

  1. Extremely fast
  2. Extremely small (again)
  3. No ugly string quotations for domains!

Examples

  • is(a.org) || is(b.org)
  • sub(org) && !sub(favonia.org)

Failed to detect the IPv6 address: Failed to send HTTP(S) request to "https://[2606:4700:4700::1111]/cdn-cgi/trace"

Heya!

I was using your container to update my ipv4 and 6 for my own domain from my pi using this template:
https://github.com/novaspirit/pi-hosted/blob/d3d7e5de51d3296568c29a0f10ee334a040df943/template/portainer-v2-arm64.json#L616

But i saw in my logs that it is having some troubles with detecting my ipv6 adres:

๐ŸŒ Detected the IPv4 address: my.correct.public.ip
๐Ÿคท The A records of "mydomain.ext" are already up to date
๐Ÿ˜ž Failed to send HTTP(S) request to "https://[2606:4700:4700::1111]/cdn-cgi/trace": Get "https://[2606:4700:4700::1111]/cdn-cgi/trace": dial tcp [2606:4700:4700::1111]:443: connect: cannot assign requested address
๐Ÿ˜ž Failed to detect the IPv6 address
โฐ Checking the IP addresses in about 5m0s . . .

Outside the container doing a curl to that adres works, also on my own machine.
But i can't go into the container to test and see what the error exactly is.

Do you have any suggestions what i might have wrong? I didn't touched the TZ variable but have set it to my local timezone to see if that might change something. But sadly this also didn't fix the error i'm having.

Getting Error in logs, but update working fine, any reason behind this?

I am getting following error while it is trying to update the IP address, but in CF, ip getting updated successfully.

๐ŸŒ Detected the IPv4 address: X.X.X.X
๐Ÿ˜ž Failed to update a stale A record of "home.domain.fqdn" (ID: 294fcde3fbf00433d8c36b6cf47125d9): operation aborted during backoff: context deadline exceeded
๐Ÿ˜ž Failed to delete a stale A record of "home.domain.fqdn" (ID: 294fcde3fbf00433d8c36b6cf47125d9): operation aborted during backoff: context deadline exceeded
๐Ÿ˜ž Failed to add a new A record of "home.domain.fqdn": operation aborted during backoff: context deadline exceeded
๐Ÿ˜ž Failed to (fully) update A records of "home.domain.fqdn"
๐Ÿ˜ž Failed to retrieve records of "domain.fqdn": operation aborted during backoff: context deadline exceeded
๐Ÿ˜ž Failed to (fully) update A records of "domain.fqdn"
๐Ÿ˜ž Failed to send HTTP(S) request to "https://[2606:4700:4700::1111]/cdn-cgi/trace": Get "https://[2606:4700:4700::1111]/cdn-cgi/trace": dial tcp [2606:4700:4700::1111]:443: connect: cannot assign requested address
๐Ÿ˜ž Failed to detect the IPv6 address

Possible changes to logging

  1. Group similar outputs together when parsing environment variables.
  2. Remove the zone-finding messages.
  3. Don't show the same IP addresses; refactor the checking logic out of the updater.
  4. Confirm that there are no records.

Support webhooks

Possible settings

WEBHOOK_ENDPOINT=
WEBHOOK_HEADERS=
WEBHOOK_BODY=
WEBHOOK_BODY_FILE=

All parameters support template, with getenv functions getting the string from environment variables.

Test internal/droproot

The major difficulty is that testing the Linux capabilities seems complicated. We can test the mocking itself, but that might not be super useful.

Ability to update "pending" DNS zones

Hi, thanks for your work.

I have a domain in another registrar and the NS's pointing to Cloudflare. I'd set these up as websites rather than as a managed domain.

I'm expecting that that's the reason why I get the following messages.

Failed to find the zone of "domain.com"
Failed to (fully) update A records of "domain.com"

Is there a method to work with Cloudflare Websites instead of Domains ?

Thanks!

Fix the testing on GitHub

It seems something about the timezone has been changed. The code still works, but perhaps the TZ environment variable and/or timezone data in the Ubuntu images used by GitHub Actions have been modified, causing the mismatch between the expected output and the real one. More investigations are needed.

Bug: can't work with Docker secrets

Hi, what an awesome service you have created!

I've a minor thing as I can't seem to figure out how to fully disable ipv6 using docker-compose. Hence my logs are full of

๐Ÿ˜ž Failed to send HTTP(S) request to "https://[REMOVED]/cdn-cgi/trace": Get "https://[REMOVED]/cdn-cgi/trace": dial tcp [REMOVED]:443: connect: cannot assign requested address
๐Ÿ˜ž Failed to detect the IPv6 address
๐Ÿ”ง If you are using Docker, Kubernetes, or other frameworks, IPv6 networks often require additional setups.
๐Ÿ”ง Read more about IPv6 networks in the README at https://github.com/favonia/cloudflare-ddns

Under highlights it says "Ability to enable or disable IPv4 and IPv6 individually." I've tried to disable ipv6 by adding the following to the env in docker-compose: - IP6_PROVIDER=none

If I set IP4_POLICY=none which is listed as a valid value in the readme I get:

   ๐Ÿ”ธ Use default IP4_POLICY=cloudflare.trace
   ๐Ÿ˜ก Failed to parse "none": not a valid policy

A separate goroutine to watch for signals?

Currently, signals are checked between each round of updates. We could use asynchronous goroutines to enable cancellation while waiting for responses from Cloudflare.

Way to differentiate proxied and non proxied domains with docker compose

I can't seem to find this information in the readme page.
What's the right way to tell the script to proxy the domain foo.bar and not proxy the subdomain test.foo.bar with docker compose?
And while i'm at it. What about the TTL?
Also, if i write *.foo.bar , will the script update every single subdomain?
Thanks in advance.

Use DNS-over-HTTPS instead of cdn-cgi/trace to obtain public IP addresses

Approaches in comparison

  • Current approach: find ip= in the output of https://1.1.1.1/cdn-cgi/trace
  • Proposed approach: query whoami.cloudflare with class ch and type txt via https://1.1.1.1/dns-query (DoH)

Pros

  1. Potentially more stable
    The DoH protocol is more documented.
  2. Cleaner
    The tracing interface contains useless information, while the DNS response only has the IP address. No additional parsing is needed after the DNS parsing. The current parser based on regular expressions is terrible.
  3. Other DNS methods
    This could facilitate the transition to other DNS-based mechanisms, such as DNSSEC and DNS-over-TLS.
  4. Built-in parsers probably available
    https://pkg.go.dev/golang.org/x/net/dns/dnsmessage should be sufficient to handle DNS responses.
  5. Privacy
    It has the same privacy guarantee as the current approach, much more than DNSSEC.

Cons

  1. I could not find official information about the DNS query whoami.cloudflare.
  2. The footprint would likely be larger than DNSSEC.

Noncommittal

  1. DoH could have a slightly smaller footprint (6328 bytes v.s. 6391 bytes in one experiment using curl without much optimization), but the differences seem neglegible.
  2. The comparison with DNS-over-TLS was not done, though it is likely that TLS would still induce significant overhead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.