Skip to content

Commit

Permalink
mbdns v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rys committed May 15, 2022
1 parent 47529a4 commit e69282b
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 245 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src/mbdns
src/mbdns.conf
mbdns
mbdns.conf
mbdns-debug
bin/*
dist/*
8 changes: 7 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ Functioning implementation tested on `darwin-amd64`, `freebsd-amd64` and `linux-

+ [x] [docs for the UDM-SE](/doc/udm-se/README.md)
+ [x] added support for linux arm64/aarch64 builds for the UDM-SE
+ [x] rebuilt all `release-1.0.2` binaries with go1.18.1
+ [x] rebuilt all `release-1.0.2` binaries with go1.18.1

# 15-05-2022

+ [x] Support for the [Mythic Beasts Primary DNS API v2](https://www.mythic-beasts.com/support/api/dnsv2)
+ [x] Proper go module support
+ [x] Reworked documentation to suit the new implementation
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ We welcome contributions to `mbdns` of any kind, including documentation, functi

## Building mbdns

Run [src/build-test](/src/build-test) to build a single binary from your git checkout. `go build` will place it into `../bin/mbdns`.
Run [build-test](/src/build-test) to build a single binary from your git checkout. `go build` will place it into `../bin/mbdns`.

Run [src/build-rel RELEASE_NAME](/src/build-rel) if you'd like to build all supports binaries for a release. The release script will put the current git revision for `HEAD` into `BuildVersion` if you don't supply `RELEASE_NAME`. `go build` will place binaries into `../bin/RELEASE_NAME`.
Run [build-rel RELEASE_NAME](/src/build-rel) if you'd like to build all supports binaries for a release. The release script will put the current git revision for `HEAD` into `BuildVersion` if you don't supply `RELEASE_NAME`. `go build` will place binaries into `bin/RELEASE_NAME`.

## Current supported platform configs

Expand Down
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mbdns

`mbdns` is a dynamic DNS update client for the [Mythic Beasts](https://www.mythic-beasts.com/support/api/primary) Primary DNS v1 system, supporting their IPv4 and IPv6 endpoints. Written in [golang](https://golang.org), it supports common home network infrastructure operating systems (FreeBSD, EdgeOS, Linux) and common platform architectures (amd64, arm64 and MIPS).
`mbdns` is a dynamic DNS update client for the [Mythic Beasts](https://www.mythic-beasts.com/support/api/dnsv2) Primary DNS v2 system, supporting their IPv4 and IPv6 endpoints. Written in [golang](https://golang.org), it supports common home network infrastructure operating systems (FreeBSD, EdgeOS, UniFi OS, Linux) and common platform architectures (amd64, arm64 and MIPS).

## Configuring mbdns

Expand All @@ -9,34 +9,29 @@ Take [doc/mbdns.conf.sample](/doc/mbdns.conf.sample) and configure it to your ne
## Deploying mbdns

* Copy the `mbdns` binary (usually named `mbdns-VERSION-OS-ARCH`) and `mbdns.conf` to your target platform
* chmod 0400 mbdns.conf so the Mythic Beasts API tokens can only be read by the user you deploy as (ideally use a specific user). `mbdns` will check for you and fail to start if the config is insecurely readable.
* Run the `mbdns` binary. It will run until you kill it.
* chmod 0400 mbdns.conf so the Mythic Beasts API secrets can only be read by the user you deploy as (ideally use a specific user). `mbdns` will check for you and fail to start if the config is insecurely readable, unless you use `--insecure`.
* Run the `mbdns` binary, which will process its main update until you kill it
* By default the `mbdns` binary will look for `./mbdns.conf`. You can relocate it (and rename it) and tell `mbdns` with `--config`.
* `mbdns --config /etc/mbdns/mbdns.conf`

`mbdns` is written in golang and builds as a statically linked library with no dependencies.

## Practical running

`mbdns` logs to `stdout`. If your target OS supports it, redirect stdout to a file, logrotate that file, and run the binary in the background via the daemonising system of your choice. `mbdns` makes no attempt to daemonise itself.
`mbdns` logs to `stdout`. If your target OS supports we suggest you redirect stdout to a file, logrotate that file, and run the binary in the background via the daemonising system of your choice. `mbdns` makes no attempt to daemonise itself.

systemd will run it nicely if you use the `simple` service type, running the process for you and capturing `stdout`.
[systemd](https://systemd.io/) will run it nicely if you use the `simple` service type, running the process for you and capturing `stdout`.

`mbdns --version` prints the version information and exits immediately.

Running on a Unix-like might go something like this (assuming `mbdns` is in `$PATH`):

`nohup mbdns --config /etc/mbdns/mbdns.conf > /var/log/mbdns 2>&1 &`

## Logging

`mbdns` logs the following:

* version, build date and git commit SHA on startup
* the path to the config file
* the update command it is attempting to run for the host and domain
* success or failure including record type and TTL in both cases
* a small handful of at-startup failure messages if it can't run (no conf, invalid JSON, insecure conf)
* success or failure including record type
* a small handful of at-startup failure messages if it can't run (no config, invalid JSON in the config, insecure config)
* a message saying it is processing records if it can cleanly start

## Platform specific instructions
Expand Down
15 changes: 15 additions & 0 deletions build-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/local/bin/zsh

GIT_SHA=$(git rev-parse --short HEAD)
B=./bin
D=./dist

R=${1}
[[ -z ${R} ]] && R=${GIT_SHA}

binary=mbdns-debug

LDFLAGS="-X main.BuildVersion=${R} -X main.BuildDate=`date -u '+%Y%m%d'` -X main.GitRev=${GIT_SHA} -X main.BuildUser=${USER}"

go get -u
go build -ldflags ${LDFLAGS} -o ${binary} mbdns.go
12 changes: 6 additions & 6 deletions src/build-rel → build-rel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/local/bin/zsh

GIT_SHA=$(git rev-parse --short HEAD)
B=../bin
D=../dist
B=./bin
D=./dist

R=${1}
[[ -z ${R} ]] && R=${GIT_SHA}
Expand All @@ -14,7 +14,7 @@ binary=${bindir}/mbdns-${R}
[[ -d ${bindir} ]] && rm -rf ${bindir} && mkdir -p ${bindir}
[[ -d ${dists} ]] && rm -rf ${dists} && mkdir -p ${dists}

LDFLAGS="-X main.BuildVersion=${R} -X main.BuildDate=`date -u '+%Y%m%d'` -X main.GitRev=${GIT_SHA}"
LDFLAGS="-X main.BuildVersion=${R} -X main.BuildDate=`date -u '+%Y%m%d'` -X main.GitRev=${GIT_SHA} -X main.BuildUser=${USER}"

GOOS=linux GOARCH=arm GOARM=6 go build -ldflags ${LDFLAGS} -o ${binary}-linux-armv6 mbdns.go
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags ${LDFLAGS} -o ${binary}-linux-armv7 mbdns.go
Expand All @@ -28,9 +28,9 @@ for i (linux-armv6 linux-armv7 linux-mipsle darwin-amd64 freebsd-amd64 linux-amd
rel=mbdns-${R}-${i}
out=${dists}/${rel}
mkdir -p ${out}
cp ../doc/mbdns.conf.sample ${out}
cp ../README.md ${out}
cp ../LICENSE ${out}
cp ./doc/mbdns.conf.sample ${out}
cp ./README.md ${out}
cp ./LICENSE ${out}
cp ${binary}-${i} ${out}
tar czf ${out}.tar.gz -C ${dists} ${rel}
rm -rf ${out}
Expand Down
58 changes: 0 additions & 58 deletions doc/ARCHITECTURE.md

This file was deleted.

20 changes: 10 additions & 10 deletions doc/mbdns.conf.sample
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
{
"domain" : "yourdomain.com",
"token" : "domain_api_password",
"host" : "hostname",
"ttl" : "3600",
"record": "A"
"zone" : "yourdomain.com",
"host" : "host",
"key_id" : "<API key ID>",
"secret" : "<API key secret>",
"type": "A"
},
{
"domain" : "yourdomain.com",
"token" : "domain_api_password",
"host" : "hostname",
"ttl" : "3600",
"record": "AAAA"
"zone" : "yourdomain.com",
"host" : "host",
"key_id" : "<API key ID>",
"secret" : "<API key secret>",
"type": "AAAA"
}
]
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/rys/mbdns

go 1.18
Empty file added go.sum
Empty file.
Loading

0 comments on commit e69282b

Please sign in to comment.