Swiftpack.co - ffittschen/DNSUpdater as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ffittschen.
ffittschen/DNSUpdater v0.1.0
DNS Updater using Vapor, Swift and DigitalOcean API
⭐️ 2
🕓 5 years ago
linux macOS iOS
.package(url: "https://github.com/ffittschen/DNSUpdater.git", from: "v0.1.0")

DNSUpdater

Docker Cloud Build Status MIT License Swift 4.2 Vapor 3

This package allows you to set up a service that updates DNS records using the DigitalOcean API. Its main purpose is being a target for other clients that only allow GET requests to send updates to DDNS services, e.g., routers like Fritz!Box.

Usage

You can either use the ffittschen/dns-updater image on DockerHub, or build the image on your own using the instructions below.

DockerHub

docker  run -it -d \
    -p 8080:80 \
    -e USERNAME=john_doe \
    -e PASSWORD=change_this_to_some_secure_password \
    -e API_KEY=your_digitalocean_api_key \
    -e ENVIRONMENT=production \
    --name dns-updater \
    ffittschen/dns-updater:latest

Alternatively, you can also create a .env file:

USERNAME=john_doe
PASSWORD=change_this_to_some_secure_password
API_KEY=your_digitalocean_api_key
ENVIRONMENT=production

And then change the command to the following to use the .env file:

docker  run -it -d \
    -p 8080:80 \
    --env-file .env \
    --name dns-updater \
    ffittschen/dns-updater:latest

Build from Source / GitHub

git clone https://github.com/ffittschen/DNSUpdater
git checkout master
cd DNSUpdater
cp .env.sample .env
$EDITOR .env
docker build -t ffittschen/dns-updater:latest .
docker run -it -d -p 8080:80 --env-file .env --name=dns-updater ffittschen/dns-updater:latest

Ports

Port Description
80/TCP API to update DNS records

API

DNSUpdater provides a very simple interface, it only has one path: /api/v1/domains/updateRecord. To update a DNS record of a domain, you need to execute a GET request targeting the mentioned path and provide a few query parameters:

Parameter Type Description
domain string The name of the domain as it is managed by DigitalOcean, e.g., example.com
recordName string The name of the A record of the domain. If your subdomain is foo.example.com, the record name is foo.
ip string The dynamic IP address to which the A record should point, e.g., 1.2.3.4

In addition to the query parameters, you need to authenticate the request using basic auth with the username and password provided as environment variables to the docker container:

Header Name Header Value
Authorization Basic am9obl9kb2U6c29tZV9zZWN1cmVfcGFzc3dvcmQ=

The header value is the username and password concatenated with a colon as separator and then encoded to base64. You can create the string by calling this command in your terminal:

echo -n john_doe:some_secure_password | base64

Prerequisites

Since this is a DNS Updater, you need to make sure that a record with the name that you pass as a query parameter already exists in your DigitalOcean account.

GitHub

link
Stars: 2
Last commit: 5 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

Initial Release
5 years ago

This is the initial release of DNSUpdater.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics