-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from skibish/v4
BREAKING CHANGE: DDNS v4
- Loading branch information
Showing
286 changed files
with
2,482 additions
and
136,727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,45 @@ | ||
name: release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
name: release | ||
jobs: | ||
build: | ||
name: build binaries | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.15.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set outputs | ||
id: vars | ||
run: | | ||
echo ::set-output name=tag::${GITHUB_REF#refs/tags/} | ||
- name: Build | ||
env: | ||
RELEASE_TAG: ${{ steps.vars.outputs.tag }} | ||
run: | | ||
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.buildVersion=$RELEASE_TAG -X main.buildCommitHash=$GITHUB_SHA" -o bin/ddns-Linux-x86_64 . | ||
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.buildVersion=$RELEASE_TAG -X main.buildCommitHash=$GITHUB_SHA" -o bin/ddns-Darwin-x86_64 . | ||
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-X main.buildVersion=$RELEASE_TAG -X main.buildCommitHash=$GITHUB_SHA" -o bin/ddns-Linux-armv7l . | ||
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.buildVersion=$RELEASE_TAG -X main.buildCommitHash=$GITHUB_SHA" -o bin/ddns-Windows-x86_64.exe . | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
go-version: 1.16 | ||
|
||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
name: binaries | ||
path: bin/ | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
upload: | ||
name: Upload release assets | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Download build artefacts | ||
uses: actions/download-artifact@v2 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
name: binaries | ||
path: bin/ | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Upload release assets | ||
uses: skx/github-action-publish-binaries@master | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: './bin/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- 386 | ||
- amd64 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- 6 | ||
- 7 | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
- Merge pull request | ||
- Merge branch | ||
dockers: | ||
- image_templates: | ||
- 'skibish/ddns:{{ .Tag }}' | ||
- 'skibish/ddns:latest' | ||
dockerfile: Dockerfile | ||
use_buildx: true | ||
build_flag_templates: | ||
- "--pull" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- "--label=org.opencontainers.image.source={{.GitURL}}" | ||
- "--platform=linux/amd64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,8 @@ | ||
# To build: docker build -t ddns . | ||
# To run: docker run -v /path/to/config.yml:/config/.ddns.yml ddns -conf-file /config/.ddns.yml | ||
# Or if your .ddns.yml is in the current working directory and is named .ddns.yml | ||
# docker run -v ${PWD}:/config ddns | ||
FROM golang:1.16.3-alpine as builder | ||
FROM alpine:latest as builder | ||
|
||
WORKDIR /app | ||
|
||
# Cache dependencies | ||
COPY go.mod go.sum ./ | ||
RUN go mod download && go mod verify | ||
|
||
# Copy everything in and do the go build | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ddns . | ||
|
||
# Now create a new stage and only copy the binary we need (keeps the container small) | ||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /app/ddns / | ||
COPY ddns / | ||
|
||
ENTRYPOINT ["/ddns"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,22 @@ | |
|
||
Personal DDNS client with [Digital Ocean Networking](https://www.digitalocean.com/products/networking/) DNS as backend. | ||
|
||
*[Read about it in the Blog](https://sergeykibish.com/blog/your-personal-ddns)* | ||
*[Read about it in the Blog](https://sergeykibish.com/blog/ddns-v4)* | ||
|
||
## Motivation | ||
|
||
We have services like [DynDNS](http://dyn.com/dns/), [No-IP](http://www.noip.com/) to access PCs remotely. But do we need them? | ||
This project is your own DDNS solution and will work for free (thanks to [Digital Ocean Networking](https://www.digitalocean.com/products/networking/) DNS). | ||
There are services like [DynDNS](http://dyn.com/dns/), [No-IP](http://www.noip.com/) to access PCs remotely. | ||
But do we need them? | ||
This is your own DDNS solution which works for free (thanks to [Digital Ocean Networking](https://www.digitalocean.com/products/networking/) DNS). | ||
|
||
## What is DDNS | ||
|
||
*From [Wikipedia](https://en.wikipedia.org/wiki/Dynamic_DNS)* | ||
> Dynamic DNS (DDNS or DynDNS) is a method of automatically updating a name server in the Domain Name System (DNS), often in real time, with the active DDNS configuration of its configured hostnames, addresses or other information. | ||
> Dynamic DNS (DDNS) is a method of automatically updating a name server in the Domain Name System (DNS), often in real time, with the active DDNS configuration of its configured hostnames, addresses or other information. | ||
## Installation | ||
|
||
Download binary from [releases](https://github.com/skibish/ddns/releases) to `/usr/local/bin/ddns`. | ||
Download binary from [releases](https://github.com/skibish/ddns/releases). | ||
|
||
And start it as: | ||
|
||
|
@@ -32,105 +33,94 @@ Or you can download [Docker image](https://hub.docker.com/r/skibish/ddns) and us | |
|
||
```bash | ||
docker run \ | ||
-v /path/to/config.yml:/config/.ddns.yml \ | ||
skibish/ddns -conf-file /config/.ddns.yml | ||
-v /path/to/config.yml:/config/ddns.yml \ | ||
skibish/ddns -conf-file /config/ddns.yml | ||
``` | ||
|
||
## Documentation | ||
|
||
You can download binary for your OS from [releases page](https://github.com/skibish/ddns/releases). | ||
|
||
> **ATTENTION!** Currently tested on Linux and macOS. | ||
Run `ddns -h`, to see help. It will output: | ||
Run `ddns -h`, to see help. | ||
It will output: | ||
|
||
```text | ||
Usage of ./ddns: | ||
-check-period duration | ||
Check if IP has been changed period (default 5m0s) | ||
-conf-file string | ||
Location of the configuration file (default "$HOME/.ddns.yml") | ||
-req-timeout duration | ||
Request timeout to external resources (default 10s) | ||
-v Show version and exit | ||
Location of the configuration file. If not provided, searches current directory, then $HOME for ddns.yml file | ||
-ver | ||
Show version | ||
``` | ||
|
||
**Configuration should be supplied.** By default it is read from `$HOME/.ddns.yml`. | ||
|
||
You need to setup your domain in Digital Ocean Networks panel. | ||
|
||
In your domain name provider configuration point domain to Digital Ocean NS records. | ||
|
||
*Refer to: [How To Point to DigitalOcean Nameservers From Common Domain Registrars](https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars)* | ||
|
||
Configuration should be in the following format: | ||
Configuration file `ddns.yml`: | ||
|
||
```yaml | ||
token: "AMAZING TOKEN" # Digital Ocean token | ||
domains: # Domains to update | ||
- "example.com" | ||
forceIPV6: true # Use IPv6 address resolve (Default false and force IPv4) | ||
records: # Records of the domains to update | ||
- type: "A" # Record type | ||
name: "www" # Record name | ||
# DDNS configuration file. | ||
|
||
# Mandatory, DigitalOcean API token. | ||
# It can be also set using environment variable DDNS_TOKEN. | ||
token: "" | ||
|
||
# By default, IP check occurs every 5 minutes. | ||
# It can be also set using environment variable DDNS_CHECKPERIOD. | ||
checkPeriod: "5m" | ||
|
||
# By default, timeout to external resources is set to 10 seconds. | ||
# It can be also set using environment variable DDNS_REQUESTTIMEOUT. | ||
requestTimeout: "10s" | ||
|
||
# By default, IPv6 address is not requested. | ||
# IPv6 address can be forced by setting it to `true`. | ||
# It can be also set using environment variable DDNS_IPV6. | ||
ipv6: false | ||
|
||
# List of domains and their records to update. | ||
domains: | ||
example.com: | ||
# More details about the fields can be found here: | ||
# https://developers.digitalocean.com/documentation/v2/#create-a-new-domain-record | ||
- type: "A" | ||
name: "www" | ||
- type: "TXT" | ||
name: "demo" | ||
data: "My IP is {{.IP}} and I am {{.mood}}" # "data" key is optional. You can write here | ||
# what you want and reference values from "params". | ||
# Key "IP" is reserved. | ||
params: | ||
mood: "cool" | ||
notify: # Optional notifiers | ||
smtp: | ||
read: below | ||
telegram: | ||
read: below | ||
gotify: | ||
read: below | ||
``` | ||
### Notifications | ||
|
||
These notifications are based on [sirupsen/logrus hooks](https://github.com/sirupsen/logrus#hooks). | ||
Add them to the configuration file as: | ||
# By default, is set to "{{.IP}}" (key .IP is reserved). | ||
# Supports Go template engine. | ||
# Additional keys can be set in "params" block below. | ||
data: "My IP is {{.IP}} and I am {{.mood}}" | ||
|
||
```yaml | ||
# config part from the top | ||
#... | ||
# By default, 1800 seconds (5 minutes). | ||
ttl: 1800 | ||
|
||
notify: | ||
<name of notification>: | ||
# ...configuration | ||
``` | ||
# By default, params is empty. | ||
params: | ||
mood: "cool" | ||
|
||
List of supported notifications: | ||
# By default, notifications is empty. | ||
notifications: | ||
|
||
#### SMTP | ||
# Gotify (https://gotify.net) | ||
- type: "gotify" | ||
app_url: "https://gotify.example.com" | ||
app_token: "" | ||
title: "DDNS" | ||
|
||
```yaml | ||
smtp: | ||
# SMTP | ||
- type: "smtp" | ||
user: "[email protected]" | ||
password: "1234" | ||
host: "localhost" | ||
port: "22" | ||
port: "468" | ||
from: "[email protected]" | ||
to: "[email protected]" | ||
subject: "My DDNS sending me a message" | ||
secure: true # Optional flag. Set it, if you will send emails with SSL | ||
``` | ||
#### Telegram | ||
|
||
```yaml | ||
telegram: | ||
# Telegram (https://telegram.org) | ||
- type: "telegram" | ||
token: "telegram bot token" | ||
chat_id: "1234" | ||
``` | ||
#### Gotify | ||
```yaml | ||
gotify: | ||
app_url: "https://gotify.example.com" # url for gotify | ||
app_token: "" # token from gotify app | ||
title: "DDNS" #optional title of messages, defaults to DDNS | ||
``` |
Oops, something went wrong.