Giter Club home page Giter Club logo

cfdyndns's Introduction

cfdyndns

CloudFlare Dynamic DNS Client

Reimplementation of cloudflare-dyndns in Rust.

building

cargo build

usage

Usage: cfdyndns [OPTIONS] --records <RECORDS>

Options:
  -r, --records <RECORDS>  Comma separated DNS records to update with the host's public IP [env: CLOUDFLARE_RECORDS=]
  -t, --token <TOKEN>      recommended: The CloudFlare API token to authenticate with [env: CLOUDFLARE_APITOKEN]
  -k, --key <KEY>          deprecated: The CloudFlare API key to authenticate with, also requires email [env: CLOUDFLARE_APIKEY]
  -e, --email <EMAIL>      deprecated: The CloudFlare email to authenticate with, also requires API key [env: CLOUDFLARE_EMAIL=]
  -v, --verbose...         More output per occurrence
  -q, --quiet...           Less output per occurrence
  -6                       set an AAAA record to the host's ipv6 address
  -4                       set an A record to the host's ipv4 address
  -h, --help               Print help
  -V, --version            Print version

installing as systemd service

  1. edit systemd/cloudflare-dyndns.service to point to your cloudflare-dyndns binary.

  2. copy systemd/cloudflare-dyndns.config.example to systemd/cloudflare-dyndns.config and update as appropriate

  3. make install-systemd

uninstalling systemd service

  1. make uninstall-systemd

acknowledgement

Special thanks to colemickens for bootstrapping and transferring ownership of this project.

cfdyndns's People

Contributors

colemickens avatar dependabot[bot] avatar diogotcorreia avatar maljub01 avatar nrdxp avatar wyn-price avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

cfdyndns's Issues

Wrong Cargo.lock in v0.0.2

Hi,

Thanks for releasing new version tag to help me with NixOS/nixpkgs#75865. But in v0.0.2, the version in Cargo.toml is updated but not in Cargo.lock, could you bump the version again.

Thank you very much

stuck forever

version 0.2.0 via nix

 /nix/store/h9xdjz757ih538p536xfsnk0jb69c9sm-cfdyndns-0.2.0/bin/cfdyndns \
--records "subdomain.domain.com" \
--email "xxxxxxxxxxx" \
--key "yyyyyyyyyyy"

stuck forever, no logs even with --verbose

NixOS failed to parse header value

Hi, it seems like something is broken... I'm using NIXOS 23.05 with 23.11 channel

warning: the following units failed: cfdyndns.service

× cfdyndns.service - CloudFlare Dynamic DNS Client
Loaded: loaded (/etc/systemd/system/cfdyndns.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Tue 2024-01-16 17:01:39 CET; 1s ago
Duration: 452ms
TriggeredBy: ● cfdyndns.timer
Process: 13145 ExecStart=/nix/store/7pdq2618p2fh703z3wz8ib30mbl2kiyq-unit-script-cfdyndns-start/bin/cfdyndns-start (code=exited, status=1/FAILURE)
Main PID: 13145 (code=exited, status=1/FAILURE)
IP: 562B in, 452B out
CPU: 118ms

janv. 16 17:01:38 jerserv systemd[1]: Started CloudFlare Dynamic DNS Client.
janv. 16 17:01:38 jerserv cfdyndns-start[13163]: INFO cfdyndns::ip > 82.66.158.3
janv. 16 17:01:38 jerserv cfdyndns-start[13163]: INFO cfdyndns::ip > 2a01:e0a:1b2:cd70:f3de:71ed:f9eb:6403
janv. 16 17:01:39 jerserv cfdyndns-start[13163]: Error: builder error: failed to parse header value

transfer ownership to nrdxp

Hi, @nrdxp,

GitHub is being picky.

nrdxp already has a repository in the colemickens/cfdyndns network

Want to delete your fork and I'll do the transfer again?

Nixos, SOPS, and apitokenfile = Invalid format for Authorization header

my systemctl status:

× cfdyndns.service - CloudFlare Dynamic DNS Client
     Loaded: loaded (/etc/systemd/system/cfdyndns.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-11-11 08:35:01 UTC; 1min 34s ago
   Duration: 1.137s
TriggeredBy: ● cfdyndns.timer
    Process: 2985448 ExecStart=/nix/store/fgqyp2skdzka08p1d9n8cj5hkqhlg7ag-unit-script-cfdyndns-start/bin/cfdyndns-start (code=exited, status=1/FAILURE)
   Main PID: 2985448 (code=exited, status=1/FAILURE)
         IP: 5.1K in, 1.8K out
        CPU: 139ms

Nov 11 08:35:01 immortal cfdyndns-start[2985451]:  INFO  cfdyndns::ip > 123.123.123.123
Nov 11 08:35:01 immortal cfdyndns-start[2985451]:  INFO  cfdyndns::ip > 1234:ab12:1234:ab12:1234:ab12:1234:ab12
Nov 11 08:35:01 immortal cfdyndns-start[2985451]: Error: HTTP 400 Bad Request
Nov 11 08:35:01 immortal cfdyndns-start[2985451]: 6003: Invalid request headers ({"error_chain": Array [Object {"code": Number(6111), "message": String("Invalid format for Authorization header")}]})
Nov 11 08:35:01 immortal cfdyndns-start[2985451]: success: false
Nov 11 08:35:01 immortal cfdyndns-start[2985451]: result: null
Nov 11 08:35:01 immortal cfdyndns-start[2985451]: messages: []
Nov 11 08:35:01 immortal systemd[1]: cfdyndns.service: Main process exited, code=exited, status=1/FAILURE
Nov 11 08:35:01 immortal systemd[1]: cfdyndns.service: Failed with result 'exit-code'.
Nov 11 08:35:01 immortal systemd[1]: cfdyndns.service: Consumed 139ms CPU time, received 5.0K IP traffic, sent 1.7K IP traffic.

my config:

{ pkgs
, config
, ...
}: {
  sops.secrets."cloudflare/cfdyndns" = { };
  services.cfdyndns = {
    enable = true;
    records = [ "domain.one" "domain.two" ];
    apiTokenFile = config.sops.secrets."cloudflare/cfdyndns".path;
  };
}

SSL error

I am trying to run this service on NixOS but I am facing the following error with both the lastest tagged and master commit.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Request, url: "https://api.cloudflare.com/client/v4/zones", source: hyper::Error(Connect, Ssl(Error { code: ErrorCode(5), cause: Some(Io(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" })) }, X509VerifyResult { code: 0, error: "ok" })) }', src/main.rs:59:10
stack backtrace:
   0:     0x560ea9ef40fc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf2ea00d5f3b53d9f
   1:     0x560ea9f230ae - core::fmt::write::ha076a7e65c6b1874
   2:     0x560ea9f034a1 - std::io::Write::write_fmt::h9630bb3b0fe886f5
   3:     0x560ea9f0b575 - std::panicking::default_hook::{{closure}}::h64163197f96398c1
   4:     0x560ea9f0b1d2 - std::panicking::default_hook::h92625161492e6b48
   5:     0x560ea9f0ba91 - std::panicking::rust_panic_with_hook::hfdd7d6bb6788c6c2
   6:     0x560ea9ef4437 - std::panicking::begin_panic_handler::{{closure}}::he81a60a7ef84ad4a
   7:     0x560ea9ef4214 - std::sys_common::backtrace::__rust_end_short_backtrace::h62801bf9780239e6
   8:     0x560ea9f0b742 - rust_begin_unwind
   9:     0x560ea9cd3733 - core::panicking::panic_fmt::hfd221b9f37504b4a
  10:     0x560ea9cd3873 - core::result::unwrap_failed::h7a3045feac200afb
  11:     0x560ea9cf052b - cfdyndns::cloudflare_api::h2c8c2ef748c7b9e7
  12:     0x560ea9cf0cfb - cfdyndns::main::h890b4ef85ecd2099
  13:     0x560ea9cdbfe3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h7b2f491300ee378a
  14:     0x560ea9ceb8a9 - std::rt::lang_start::{{closure}}::hec8c72fe99e36f09
  15:     0x560ea9efc345 - std::rt::lang_start_internal::h09bcc9fffd987f14
  16:     0x560ea9cf2112 - main
  17:     0x7fa9f902924e - __libc_start_call_main
  18:     0x7fa9f9029309 - __libc_start_main_alias_1
  19:     0x560ea9cd3925 - _start
  20:                0x0 - <unknown>

Seems like a SSL error, but not sure since I don't really master rust

cfdyndns fails when a `CAA` record (or any other unknown RR type) exists in the zone

Hey 👋,

I have been using cfdyndns for a while on my NixOS systems and it worked without any issues 👍.
Recently, I added a CAA record to my zone using the CloudFlare WebUI. Since I added this record of type CAA cfdyndns fails with an error:

Feb 22 14:25:00 MY-HOSTNAME cfdyndns-start[1661398]:  INFO  cfdyndns::ip > 93.XXX.XXX.XXX
Feb 22 14:25:00 MY-HOSTNAME cfdyndns-start[1661398]:  INFO  cfdyndns::ip > 2001:a61:YYYY:YYYY:YYYY:YYYY:YYYY:YYYY
Feb 22 14:25:03 MY-HOSTNAME cfdyndns-start[1661398]: Error: error decoding response body: unknown variant `CAA`, expected one of `A`, `AAAA`, `CNAME`, `NS`, `MX`, `TXT`, `SRV` at line 1 column 3357
Feb 22 14:25:03 MY-HOSTNAME systemd[1]: cfdyndns.service: Main process exited, code=exited, status=1/FAILURE

I redacted some fields for privacy reasons.

A quick search on the source code lead me to

cfdyndns/src/dns.rs

Lines 72 to 83 in bd02dd0

match self {
DnsContent::A { content: _ } => "A",
DnsContent::AAAA { content: _ } => "AAAA",
DnsContent::CNAME { content: _ } => "CNAME",
DnsContent::NS { content: _ } => "NS",
DnsContent::MX {
content: _,
priority: _,
} => "MX",
DnsContent::TXT { content: _ } => "TXT",
DnsContent::SRV { content: _ } => "SRV",
}

I assume extending this would suffice to address this issue.
Given sufficient time I might contribute a fix myself though for now I can not tell when that might be the case.

bug: missing field `multiple_railguns_allowed`

May 28 21:05:05 bro systemd[1]: Started CloudFlare Dynamic DNS Client.
░░ Subject: A start job for unit cfdyndns.service has finished successfully
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit cfdyndns.service has finished successfully.
░░
░░ The job identifier is 1078646.
May 28 21:05:06 bro cfdyndns-start[212683]:  INFO  cfdyndns::ip > XXX.XXX.XXX.XXX
May 28 21:05:07 bro cfdyndns-start[212683]: Error: error decoding response body: missing field `multiple_railguns_allowed` at line 1 column 578
May 28 21:05:07 bro systemd[1]: cfdyndns.service: Main process exited, code=exited, status=1/FAILURE

Seems like a change in Cloudflare's API?

Config: https://github.com/diogotcorreia/dotfiles/blob/bf6f0ee0fbf956d0983308f7270d7b7698e8d57d/hosts/bro/default.nix#L76-L80
Keep in mind that I'm using a patch from #56 as well.

cc @nrdxp

Should support a flag to set ip based off of NIC

I want to have private IPs with nice hostnames. So rather than using a DNS server to get the external ip, allow for deriving the "external IP" from a user-specified NIC.

(Scenario, I want a subdomain entry that routes to my machine on a private network but using public DNS because it's easier)

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.