Find a file
dependabot[bot] 217fd378ee
Bump async-trait from 0.1.64 to 0.1.65
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.64 to 0.1.65.
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.64...0.1.65)

---
updated-dependencies:
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-04 07:57:41 +00:00
.github Correct branch name in action filter 2022-11-13 15:47:02 -05:00
.vscode Add first test (#38) 2022-08-22 22:20:10 -04:00
Docker Rename binary, 1.0.0 release, docker images 2022-01-27 01:22:05 -05:00
Packaging Document AUR package & alternatives 2022-01-30 17:03:57 -05:00
src Do retry update after a failure & fix tests (#94) 2023-02-13 00:58:23 -05:00
.all-contributorsrc docs: add jannikac as a contributor for code (#73) 2022-12-18 10:35:09 -05:00
.clippy.toml Do retry update after a failure & fix tests (#94) 2023-02-13 00:58:23 -05:00
.codecov.yml Do retry update after a failure & fix tests (#94) 2023-02-13 00:58:23 -05:00
.gitignore ignore signature files 2022-08-23 01:32:57 -04:00
Cargo.lock Bump async-trait from 0.1.64 to 0.1.65 2023-03-04 07:57:41 +00:00
Cargo.toml Update to 1.8.0 2023-02-13 01:04:05 -05:00
example.toml Add new IP source "seeip" (#90) 2023-02-01 23:19:57 -05:00
LICENSE.txt add license 2022-01-23 22:43:06 -05:00
make-release.sh update build script 2023-02-01 23:57:01 -05:00
README.md Update readme file name 2023-02-01 23:58:47 -05:00
rust-toolchain.toml switch to stable toolchain 2022-04-03 21:38:20 -04:00

Gandi Live Dns Rust

Contributors tests Test coverage report lint checks Releases Docker Image Size MIT license

A program that can set the IP addresses for configured DNS entries in Gandi's domain configuration. Thanks to Gandi's LiveDNS API, this creates a dynamic DNS system.

If you want to host web services but you don't have a static IP address, this tool will allow you to keep your domains pointed at the right IP address. This program can update both IPv4 and IPv6 addresses for one or more domains and subdomains. It can be used as a one-shot tool managed with a systemd timer or cron, or a long-running process that reschedules itself.

Table of Contents

Usage

The Gandi Live DNS API is rate limited at 30 requests per minute. This program respects this rate limit: if you have more than 30 domains to update, the program will pause and wait for a minute, plus a random delay to ensure it doesn't hit the rate limit.

System packages

Packages are available for some linux distributions.

Contributions to release this for other distributions are welcome!

Prebuilt binaries

gandi-live-dns provides pre-built binaries with the releases. See the releases page to get the latest version. These binaries are statically linked, and provided for both Linux and Windows, including ARM architectures for the Linux version.

Download the latest version from the releases page, extract it from the archive, and place it somewhere in your $PATH to use it.

  • Create a file gandi.toml, then copy and paste the contents of example.toml
  • Follow the instructions in the example config to get your API key and put it in the config
  • Follow the examples in the config to set up the entries you want to update
  • Run gandi-live-dns inside the directory with the configration to update your DNS entries

With docker

Use the seriousbug/gandi-live-dns-rust Docker images, which are available for x86_64, arm64, armv6, and armv7 platforms. Follow the steps below to use these images.

  • Create a file gandi.toml, then copy and paste the contents of example.toml
  • Follow the instructions in the example config to get your API key and put it in the config
  • Follow the examples in the config to set up the entries you want to update
  • Run docker run --rm -it -v $(pwd)/gandi.toml:/gandi.toml:ro seriousbug/gandi-live-dns-rust:latest

Docker doesn't support IPv6 out of the box. If you need to update IPv6 addresses, check the linked page to enable IPv6 or use the prebuilt binaries directly.

If you get errors about not finding the config file, make sure your command has a full path to the config file ($(pwd)/gandi.toml part). Otherwise Docker will create a directory.

From source

This package is also published on crates.io as gandi-live-dns. If you would like to build it from source and you have a working rust install, you can use cargo install gandi-live-dns to build and install it.

Automation

By running as a background process

gandi-live-dns can run as a daemon, a background process, periodically perform the IP address updates. To do so, add the --repeat=<delay-in-seconds> command line option. When given, this tool will not quit after updating your IP address and instead will continue to perform periodic updates.

If you are using Docker, you can add this option when starting it:

# This will update your IP now, then repeat every 24 hours
docker run --rm -it -v $(pwd)/gandi.toml:/gandi.toml:ro seriousbug/gandi-live-dns-rust:latest --repeat=86400

Or with a docker-compose.yml file, add it in the arguments:

gandi-live-dns:
  image: seriousbug/gandi-live-dns-rust:latest
  restart: always
  volumes:
    - ./gandi.toml:/gandi.toml:ro
  # Repeat the update every day
  command: --repeat=86400

Skipped updates

In background process mode, the tool will avoid sending an update to Gandi if your IP address has not changed since the last update. This only works so long as the tool continues to run, it will send an update when restarted even if your IP address has not changed. You can also override this behavior by adding always_update = true to the top of your config file.

With a Systemd timer

The Packaging folder contains a Systemd service and timer, which you can use to automatically run this tool. By default it will update the IP addresses after every boot up, and at least once a day. You can adjust the timer to speed this up, but avoid unnecessarily overloading Gandi's servers.

  • Place gandi-live-dns.timer and gandi-live-dns.service into /etc/systemd/system
  • Put gandi-live-dns binary into /usr/bin/
    • You can also place it in /usr/local/bin or some other directory, just make sure to update the path in the service file
  • Create the folder /etc/gandi-live-dns, and place your gandi.toml into it
  • Create a user for the service: useradd --system gandi-live-dns --home-dir /etc/gandi-live-dns
  • Make sure only the service can access the config file: chown gandi-live-dns: /etc/gandi-live-dns/gandi.toml && chmod 600 /etc/gandi-live-dns/gandi.toml
  • Enable the timer with systemctl enable --now gandi-live-dns.timer

Development

Local builds

cargo build and cargo build --release are sufficient for development and release builds. No special instructions are needed.

Making a release

To make a release, first set up cross and docker. Make sure you log into Docker with docker login. Then follow these steps:

  • bump up the version in Cargo.toml according to semver
    • commit and push the changes
  • run ./make-release.sh

    This will build binaries, then package them into archives, as well as build and upload docker images.

  • Create a release on Github
    • Make sure to create a tag for the release version on master
    • Upload the binary archives to the Github release
  • Update the AUR version
  • Run cargo publish to update the crates.io version

Alternatives

Contributors

jannikac
jannikac

💻