Feat: rename ztdns -> zerotier-dns, remove docker compose

This commit is contained in:
Matthew Edwards
2019-12-20 16:40:18 +13:00
parent e41e676b34
commit c4188818c9
10 changed files with 61 additions and 73 deletions
+8 -8
View File
@@ -36,27 +36,27 @@ jobs:
echo ${PASSWORD} | docker login -u ${USERNAME} --password-stdin
- name: Fetch dependencies
run: |
docker pull mjenz/ztdns:builder || true
docker pull mjenz/zerotier-dns:builder || true
DOCKER_BUILDKIT=1 docker build \
--target builder \
--cache-from mjenz/ztdns:builder \
-t mjenz/ztdns:builder \
--cache-from mjenz/zerotier-dns:builder \
-t mjenz/zerotier-dns:builder \
.
docker push mjenz/ztdns:builder
docker push mjenz/zerotier-dns:builder
- name: Build image
run: |
DOCKER_BUILDKIT=1 docker build \
--cache-from mjenz/ztdns:builder \
-t mjenz/ztdns:latest \
--cache-from mjenz/zerotier-dns:builder \
-t mjenz/zerotier-dns:latest \
.
- name: Push image
if: github.ref == 'master'
run: |
docker push mjenz/ztdns:latest
docker push mjenz/zerotier-dns:latest
- name: Update Docker Hub description
if: github.ref == 'master'
uses: peter-evans/dockerhub-description@v2.1.0
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKERHUB_REPOSITORY: mjenz/ztdns
DOCKERHUB_REPOSITORY: mjenz/zerotier-dns
+3 -3
View File
@@ -1,10 +1,10 @@
ztdns.yml
ztdns.toml
zerotier-dns.yml
zerotier-dns.toml
.vscode/
# Binaries for programs and plugins
/ztdns
/zerotier-dns
*.exe
*.exe~
*.dll
+6 -6
View File
@@ -1,9 +1,9 @@
ARG GO_VERSION=1.13
FROM golang:${GO_VERSION} AS builder
RUN useradd ztdns
RUN useradd zerotier-dns
WORKDIR /go/src/github.com/mje-nz/ztdns
WORKDIR /go/src/github.com/mje-nz/zerotier-dns
# Fetch and cache dependencies
COPY ./go.mod ./go.sum ./
@@ -14,7 +14,7 @@ COPY . .
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-w -s" && \
# NB Only works on BuildKit
# https://github.com/moby/moby/issues/35699
setcap cap_net_bind_service=+ep /go/bin/ztdns
setcap cap_net_bind_service=+ep /go/bin/zerotier-dns
@@ -27,10 +27,10 @@ COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
WORKDIR /app
COPY --from=builder /go/bin/ztdns .
COPY --from=builder /go/bin/zerotier-dns .
USER ztdns
USER zerotier-dns
ENTRYPOINT ["./ztdns"]
ENTRYPOINT ["./zerotier-dns"]
CMD ["server"]
EXPOSE 53/udp
+32 -34
View File
@@ -1,5 +1,5 @@
<h1 align="center">
ztdns
zerotier-dns
</h1>
<h4 align="center">
@@ -7,8 +7,8 @@
</h4>
<p align="center">
<a href="https://github.com/mje-nz/ztdns">
<img src="https://github.com/mje-nz/ztdns/workflows/Check/badge.svg"
<a href="https://github.com/mje-nz/zerotier-dns">
<img src="https://github.com/mje-nz/zerotier-dns/workflows/Check/badge.svg"
alt="Github Actions">
</a>
</p>
@@ -34,8 +34,8 @@ To start the server using the Docker image:
```bash
docker run --rm \
-p 53:53/udp \
--volume $(pwd)/ztdns.yml:/app/ztdns.yml \
mjenz/ztdns server --api-key API_KEY --network NETWORK_ID
--volume $(pwd)/zerotier-dns.yml:/app/zerotier-dns.yml \
mjenz/zerotier-dns server --api-key API_KEY --network NETWORK_ID
```
where `API_KEY` is a ZeroTier API token and `NETWORK_ID` is a ZeroTier network ID.
@@ -45,7 +45,7 @@ It is recommended to use a configuration file instead of these command-line argu
Once the server is running you will be able to resolve ZeroTier member names by querying it directly:
```bash
dig @<server address> <member name>.<ztdns domain>
dig @<server address> <member name>.<domain>
;; QUESTION SECTION:
;matthews-mbp.zt. IN A
@@ -57,7 +57,7 @@ matthews-mbp.zt. 3600 IN A 192.168.192.120
Note that the DNS name is based on the ZeroTier member name (as shown in [ZeroTier Central](https://my.zerotier.com/network)), not the hostname of the member.
In order to resolve names normally, you need to get the server into the DNS lookup chain on all of your machines.
In practise this means either configuring the system resolver on each machine to use your `ztdns` instance for your chosen domain (see instructions for [Linux](https://learn.hashicorp.com/consul/security-networking/forwarding#systemd-resolved-setup) or [macOS](https://learn.hashicorp.com/consul/security-networking/forwarding#macos-setup)), or configuring the DNS server each machine uses to delegate to your `ztdns` instance for your chosen domain (see instructions for [dnsmasq](https://learn.hashicorp.com/consul/security-networking/forwarding#dnsmasq-setup) or [bind](https://learn.hashicorp.com/consul/security-networking/forwarding#bind-setup)).
In practise this means either configuring the system resolver on each machine to use your `zerotier-dns` instance for your chosen domain (see instructions for [Linux](https://learn.hashicorp.com/consul/security-networking/forwarding#systemd-resolved-setup) or [macOS](https://learn.hashicorp.com/consul/security-networking/forwarding#macos-setup)), or configuring the DNS server each machine uses to delegate to your `zerotier-dns` instance for your chosen domain (see instructions for [dnsmasq](https://learn.hashicorp.com/consul/security-networking/forwarding#dnsmasq-setup) or [bind](https://learn.hashicorp.com/consul/security-networking/forwarding#bind-setup)).
@@ -65,17 +65,17 @@ In practise this means either configuring the system resolver on each machine to
To build from source:
``` bash
go get -u github.com/mje-nz/ztdns/
go get -u github.com/mje-nz/zerotier-dns/
# or
git clone https://github.com/mje-nz/ztdns.git
cd ztdns
git clone https://github.com/mje-nz/zerotier-dns.git
cd zerotier-dns
go install
# then
ztdns server --api-key API_KEY --network NETWORK_ID
zerotier-dns server --api-key API_KEY --network NETWORK_ID
```
If you are running on Linux, run `sudo setcap cap_net_bind_service=+ep /go/bin/ztdns` to enable non-root users to bind privileged ports.
On other operating systems, `ztdns` may need to be run as an administrator.
If you are running on Linux, run `sudo setcap cap_net_bind_service=+ep /go/bin/zerotier-dns` to enable non-root users to bind privileged ports.
On other operating systems, `zerotier-dns` may need to be run as an administrator.
This does not apply to the Docker image.
@@ -90,24 +90,24 @@ To install the server as a service using the Docker image:
```bash
docker run --detach \
-p 53:53/udp \
--volume $(pwd)/ztdns.yml:/app/ztdns.yml \
--volume $(pwd)/zerotier-dns.yml:/app/zerotier-dns.yml \
--restart=unless-stopped \
--name=ztdns mjenz/ztdns
--name=zerotier-dns mjenz/zerotier-dns
```
### Systemd
To install the server as a `systemd` service, create a file `/etc/systemd/system/ztdns.service` containing:
To install the server as a `systemd` service, create a file `/etc/systemd/system/zerotier-dns.service` containing:
```ini
[Unit]
Description=Zerotier DNS Server
Description=ZeroTier DNS Server
After=network-online.target
Wants=network-online.target
[Service]
WorkingDirectory=<path containing config file>
ExecStart=ztdns server
ExecStart=zerotier-dns server
Restart=on-failure
RestartSec=5
@@ -122,19 +122,19 @@ Then, to install the service:
```bash
# Reload service files
sudo systemctl daemon-reload
# Set ztdns service to start on boot
sudo systemctl enable ztdns.service
# Also start ztdns service right now
sudo systemctl start ztdns.service
# Set zerotier-dns service to start on boot
sudo systemctl enable zerotier-dns.service
# Also start zerotier-dns service right now
sudo systemctl start zerotier-dns.service
```
To uninstall the service:
```bash
# Stop ztdns service
sudo systemctl stop ztdns.service
# Stop ztdns service from starting on boot
sudo systemctl disable ztdns.service
# Stop zerotier-dns service
sudo systemctl stop zerotier-dns.service
# Stop zerotier-dns service from starting on boot
sudo systemctl disable zerotier-dns.service
```
@@ -144,13 +144,11 @@ sudo systemctl disable ztdns.service
### Command-line options:
```bash
$ ztdns server --help
Server (ztdns server) will start the DNS server.
Example: ztdns server
$ zerotier-dns server --help
Start the zerotier-dns DNS server.
Usage:
ztdns server [flags]
zerotier-dns server [flags]
Flags:
--api-key string ZeroTier API key
@@ -164,14 +162,14 @@ Flags:
--refresh int how often to poll the ZeroTier controller in minutes (default 30)
Global Flags:
--config string config file (default is ztdns.yml)
--config string config file (default is zerotier-dns.yml)
--debug enable debug messages
```
### Config file
`ztdns` looks for `ztdns.yml` in the current working directory or `$HOME`.
There is a `ztdns.example.yml` example config file with all supported options and their default values:
`zerotier-dns` looks for `zerotier-dns.yml` in the current working directory or `$HOME`.
There is a `zerotier-dns.example.yml` example config file with all supported options and their default values:
```yaml
# Network interface to bind to (or "" to bind to all interfaces). By default, only
+6 -6
View File
@@ -1,6 +1,6 @@
// Copyright © 2017 uxbh
// Package cmd implments the ztdns command-line interface.
// Package cmd implments the zerotier-dns command-line interface.
package cmd
import (
@@ -15,9 +15,9 @@ import (
var cfgFile string
var RootCmd = &cobra.Command{
Use: "ztdns",
Short: "Zerotier DNS Server",
Long: `ztDNS is a DNS server for ZeroTier virtual networks.
Use: "zerotier-dns",
Short: "ZeroTier DNS Server",
Long: `zerotier-dns is a DNS server for ZeroTier virtual networks.
This application will serve DNS requests for the members of a ZeroTier
network for both A (IPv4) and AAAA (IPv6) requests`,
}
@@ -32,7 +32,7 @@ func Execute() {
func init() {
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().Bool("debug", false, "enable debug messages")
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ztdns.yml)")
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is zerotier-dns.yml)")
viper.BindPFlag("debug", RootCmd.PersistentFlags().Lookup("debug"))
}
@@ -43,7 +43,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find config file in current directory or $HOME
viper.SetConfigName("ztdns")
viper.SetConfigName("zerotier-dns")
viper.AddConfigPath(".")
viper.AddConfigPath("$HOME")
}
+4 -4
View File
@@ -12,15 +12,15 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/mje-nz/ztdns/dnssrv"
"github.com/mje-nz/ztdns/ztapi"
"github.com/mje-nz/zerotier-dns/dnssrv"
"github.com/mje-nz/zerotier-dns/ztapi"
)
// serverCmd represents the server command.
var serverCmd = &cobra.Command{
Use: "server",
Short: "Run ztdns server",
Long: `Start the ztdns DNS server.`,
Short: "Run zerotier-dns server",
Long: `Start the zerotier-dns DNS server.`,
PreRunE: func(cmd *cobra.Command, args []string) error {
// Check config and bail if anything important is missing.
if viper.GetBool("debug") {
-10
View File
@@ -1,10 +0,0 @@
version: '2'
services:
ztdns:
build: .
restart: always
ports:
- "5356:53/udp"
volumes:
- .ztdns.toml:/app/.config.toml
command: ["--debug", "server", "--config", "/app/.config.toml"]
+1 -1
View File
@@ -1,4 +1,4 @@
module github.com/mje-nz/ztdns
module github.com/mje-nz/zerotier-dns
go 1.12
+1 -1
View File
@@ -20,7 +20,7 @@
package main
import "github.com/mje-nz/ztdns/cmd"
import "github.com/mje-nz/zerotier-dns/cmd"
func main() {
cmd.Execute()