mirror of
https://github.com/EV21/dynb.git
synced 2025-12-26 16:39:32 +01:00
Compare commits
43 Commits
756c17d117
...
0.5.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
7d66155cc1
|
|||
|
fdd4d03e74
|
|||
|
e743532664
|
|||
|
3d76946db5
|
|||
|
0448d698ae
|
|||
|
2ac50d326f
|
|||
|
327e896754
|
|||
|
d44f76e1ef
|
|||
|
6d16b0807e
|
|||
|
05a58af921
|
|||
|
0eec80f604
|
|||
|
15ea0345bd
|
|||
|
c1869343f6
|
|||
|
b683937e59
|
|||
|
3eb90f61f7
|
|||
|
c83b893fc8
|
|||
|
c9794f7c22
|
|||
|
b8bbce7ec2
|
|||
|
bd6f1336b2
|
|||
|
260bc7172f
|
|||
|
a85b2bf911
|
|||
|
a496acbebf
|
|||
|
c81da8846e
|
|||
|
122e08a42a
|
|||
|
2352d655a3
|
|||
|
341d535f21
|
|||
|
fc2c499daa
|
|||
|
39d5143108
|
|||
|
e58d87cf94
|
|||
|
9d41354695
|
|||
|
d8a298f58a
|
|||
|
3e89610e22
|
|||
|
faa9c371c1
|
|||
|
11fccf2f0e
|
|||
|
75715cb0a8
|
|||
|
6313ee4347
|
|||
|
f37230401f
|
|||
|
d6c98c04ad
|
|||
|
64a5a76b6d
|
|||
|
05120c25e4
|
|||
|
dcb3d7436b
|
|||
|
fa60312c0d
|
|||
|
ba6e91bbd6
|
@@ -158,7 +158,7 @@ body_process = ReSub(r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$', r'') | strip
|
||||
##
|
||||
## Available constructs are those listed in ``body_process`` doc.
|
||||
subject_process = (strip |
|
||||
ReSub(r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') |
|
||||
ReSub(r'^([cC]hg|[fF]ix|[nN]ew|[dD]oc|[fF]eat|[aA]dd|[cC]hange)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') |
|
||||
SetIfEmpty("No commit message.") | ucfirst | final_dot)
|
||||
|
||||
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.env*
|
||||
docker-compose*
|
||||
.vscode
|
||||
236
CHANGELOG.md
236
CHANGELOG.md
@@ -1,127 +1,221 @@
|
||||
# Changelog
|
||||
|
||||
|
||||
## 0.5.2 (2023-02-26)
|
||||
|
||||
### Fix
|
||||
|
||||
* Incorrect dns ip handling via domrobot. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.5.1 (2022-11-21)
|
||||
|
||||
### Features
|
||||
|
||||
* Use provider checkip API. [Eduard Veit]
|
||||
|
||||
### Fix
|
||||
|
||||
* Handle some curl exit codes. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.5.0 (2022-11-10)
|
||||
|
||||
### Features
|
||||
|
||||
* Use provider DNS servers. [Eduard Veit]
|
||||
|
||||
* Temporarily disable an ip version if the connectivity/routing does not work. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 update default values in table. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.4.0 (2022-11-07)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add support for dynu.com as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 add dynu.com as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.5 (2022-11-03)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add support for IPv64.net as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
### Fix
|
||||
|
||||
* Delete status file after success. [Eduard Veit]
|
||||
|
||||
* More status file issues. [Eduard Veit]
|
||||
|
||||
* Incorrect status code handling. [Eduard Veit]
|
||||
|
||||
no persistent status file was written in case of an error as the return status code was always 0
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 change TTL to 60 for IPv64.net. [Eduard Veit]
|
||||
|
||||
* 📝 add IPv64.net as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.4 (2022-06-30)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add support for ddnss.de as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 update providers in README. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.3 (2022-06-07)
|
||||
|
||||
### Fix
|
||||
|
||||
* Wrong parameter name for DuckDNS. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 add comments to docker-compose.yml example. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.2 (2022-05-26)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add tzdata to Dockerfile for timezone config. [Eduard Veit]
|
||||
|
||||
You can now set your timezone with the environment variable
|
||||
`TZ="Europe/Berlin"`
|
||||
|
||||
|
||||
## 0.3.1 (2022-05-26)
|
||||
|
||||
### Fix
|
||||
|
||||
* 🐛 curl/libcurl doesn't support dns-server option. [Eduard Veit]
|
||||
|
||||
the latest alpine we are using for the docker image
|
||||
does also drops the support for that option like debian/ubuntu/etc
|
||||
|
||||
|
||||
## 0.3.0 (2022-05-26)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ validate ip address respons from ip check web service. [Eduard Veit]
|
||||
|
||||
* ✨ check internet connection for selected ip versions. [Eduard Veit]
|
||||
|
||||
* 🎨 colorful info, debug and error messages. [Eduard Veit]
|
||||
|
||||
### Fix
|
||||
|
||||
* Abort on all dig errors. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 add labels to Dockerfile. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.2.0 (2021-09-24)
|
||||
|
||||
### New
|
||||
### Features
|
||||
|
||||
* :sparkles: enable parameter extensions for `docker run --interactive` [Eduard Veit]
|
||||
* ✨ enable parameter extensions for `docker run --interactive` [Eduard Veit]
|
||||
|
||||
* :sparkles: add pre-commit hooks for markdown. [Eduard Veit]
|
||||
### Changed
|
||||
|
||||
* :sparkles: change git hooks and add shfmt. [Eduard Veit]
|
||||
|
||||
* :sparkles: add pre-commit git hook for shellcheck. [Eduard Veit]
|
||||
|
||||
### Changes
|
||||
|
||||
* :wrench: remove md-toc from pre-commit. [Eduard Veit]
|
||||
|
||||
* :wrench: handle dns server selection. [Eduard Veit]
|
||||
* Handle dns server selection. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* :memo: update CHANGELOG.md. [Eduard Veit]
|
||||
* 📝 update CHANGELOG.md. [Eduard Veit]
|
||||
|
||||
* :memo: document docker parameters. [Eduard Veit]
|
||||
* 📝 document docker parameters. [Eduard Veit]
|
||||
|
||||
* :memo: change default dns server setting. [Eduard Veit]
|
||||
* 📝 change default dns server setting. [Eduard Veit]
|
||||
|
||||
* :memo: update CHANGELOG. [Eduard Veit]
|
||||
* 📝 update CHANGELOG. [Eduard Veit]
|
||||
|
||||
* :memo: update README.md. [Eduard Veit]
|
||||
|
||||
### Other
|
||||
|
||||
* :art: lint README.md. [Eduard Veit]
|
||||
|
||||
* :art: add shfmt params to pre-commit check. [Eduard Veit]
|
||||
|
||||
* :art: fix shell style. [Eduard Veit]
|
||||
|
||||
* :recycle: seperate parsing logic. [Eduard Veit]
|
||||
|
||||
* :recycle: normalizing pre-commit configuration to a top-level map. [Eduard Veit]
|
||||
|
||||
* :recycle: refactorings. [Eduard Veit]
|
||||
|
||||
* Refactor: :recycle: remove unused help message. [Eduard Veit]
|
||||
* 📝 update README.md. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.1.2 (2021-04-23)
|
||||
|
||||
### Documentation
|
||||
|
||||
* :memo: document environment variables. [Eduard Veit]
|
||||
|
||||
### Other
|
||||
|
||||
* :recycle: refactor: method extractions and other beautifications. [Eduard Veit]
|
||||
* 📝 document environment variables. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.1.1 (2021-04-23)
|
||||
|
||||
### Fix
|
||||
|
||||
* :bug: fix loop and error handling in case of connection issues. [Eduard Veit]
|
||||
* 🐛 fix loop and error handling in case of connection issues. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.1.0 (2021-04-22)
|
||||
|
||||
### New
|
||||
### Features
|
||||
|
||||
* :sparkles: add Dockerfile. [Eduard Veit]
|
||||
* ✨ add Dockerfile. [Eduard Veit]
|
||||
|
||||
* :sparkles: add loop mode. [Eduard Veit]
|
||||
* ✨ add loop mode. [Eduard Veit]
|
||||
|
||||
* :sparkles: add support for Duck DNS as DynDNS2 provider. [Eduard Veit]
|
||||
* ✨ add support for Duck DNS as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
* :sparkles: add support for deSEC as DynDNS2 provider. [Eduard Veit]
|
||||
* ✨ add support for deSEC as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
* :sparkles: add completion. [Eduard Veit]
|
||||
* ✨ add completion. [Eduard Veit]
|
||||
|
||||
:sparkles: add man page
|
||||
✨ add man page
|
||||
|
||||
* :sparkles: replace getopt with argbash. [Eduard Veit]
|
||||
* 🔃 replace getopt with argbash. [Eduard Veit]
|
||||
|
||||
* :sparkles: add interpretaton of status codes and act accordingly. [Eduard Veit]
|
||||
* ✨ add interpretaton of status codes and act accordingly. [Eduard Veit]
|
||||
|
||||
* :sparkles: make network interface configurable. [Eduard Veit]
|
||||
* ✨ make network interface configurable. [Eduard Veit]
|
||||
|
||||
* :sparkles: add DynDNS2 support for dynv6.com. [Eduard Veit]
|
||||
* ✨ add DynDNS2 support for dynv6.com. [Eduard Veit]
|
||||
|
||||
* :sparkles: add .gitchangelog.rc. [Eduard Veit]
|
||||
### Added
|
||||
|
||||
* :sparkles: add dynb.sh. [Eduard Veit]
|
||||
* 📝 README.md. [Eduard Veit]
|
||||
|
||||
* ✨ dynb.sh. [Eduard Veit]
|
||||
|
||||
### Changed
|
||||
|
||||
* 🔃 rename environment variables. [Eduard Veit]
|
||||
|
||||
### Fix
|
||||
|
||||
* :bug: fix sourcing of config file. [Eduard Veit]
|
||||
* 🐛 fix error handling. [Eduard Veit]
|
||||
|
||||
:recycle: do some shellcheck fixes
|
||||
* 🐛 fix sourcing of config file. [Eduard Veit]
|
||||
|
||||
♻️ do some shellcheck fixes
|
||||
|
||||
### Documentation
|
||||
|
||||
* :memo: document example of an docker-compose.yml file. [Eduard Veit]
|
||||
* 📝 document example of an docker-compose.yml file. [Eduard Veit]
|
||||
|
||||
* :memo: document loop mode and dig as requirement. [Eduard Veit]
|
||||
* 📝 document `loop mode` and mention `dig` as requirement. [Eduard Veit]
|
||||
|
||||
* :memo: update example of .env in README.md. [Eduard Veit]
|
||||
* 📝 update example of .env in README.md. [Eduard Veit]
|
||||
|
||||
* :memo: add CHANGELOG.md. [Eduard Veit]
|
||||
* 📝 CHANGELOG.md. [Eduard Veit]
|
||||
|
||||
* :memo: add example.env. [Eduard Veit]
|
||||
|
||||
* :memo: write README.md. [Eduard Veit]
|
||||
|
||||
### Other
|
||||
|
||||
* :recycle: refactor: rename environment variables. [Eduard Veit]
|
||||
|
||||
* :recycle: refactor, fix and debug error handling. [Eduard Veit]
|
||||
|
||||
* :recycle: refactor main code. [Eduard Veit]
|
||||
|
||||
* Initial commit. [EV21]
|
||||
* 📝 add example.env. [Eduard Veit]
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ apk add \
|
||||
bash \
|
||||
curl \
|
||||
jq \
|
||||
bind-tools
|
||||
bind-tools \
|
||||
tzdata
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
||||
82
README.md
82
README.md
@@ -7,8 +7,6 @@ IPv4 (A) and IPv6 (AAAA) record updates are supported.
|
||||
<!-- TOC -->
|
||||
|
||||
- [✨ Update Methods](#-update-methods)
|
||||
- [APIs](#apis)
|
||||
- [DynDNS2](#dyndns2)
|
||||
- [📦 Requirements](#-requirements)
|
||||
- [🚀 Installation](#-installation)
|
||||
- [⚙ Configuration](#-configuration)
|
||||
@@ -25,18 +23,16 @@ IPv4 (A) and IPv6 (AAAA) record updates are supported.
|
||||
|
||||
The following update methods are currently implemented:
|
||||
|
||||
### APIs
|
||||
|
||||
- INWX.com Domrobot JSON-RPC-API\
|
||||
Limitations:
|
||||
- minimum TTL is 300 (5 minutes)
|
||||
|
||||
### DynDNS2
|
||||
|
||||
- INWX.com
|
||||
- deSEC.io (dedyn.io)
|
||||
- DuckDNS.org
|
||||
- dynv6.com
|
||||
| Provider | API | TTL in seconds | Credentials | own domain via NS record | free (sub-) domain |
|
||||
|---------------------|-----------------------|----------------|----------------------------------------------------------------------------------------------|------------------------------------------|--------------------------------------|
|
||||
| INWX.com | Domrobot JSON-RPC-API | 300 | customer login `username` & `password`. Mobile TAN (OTP) is currently not supported by DynB. | ✔️ 🆓 for your registered domains @ inwx | ⛔ for your registered domains @ inwx |
|
||||
| INWX.com | DynDNS2 | 60 | specific dyndns `username` & `password` | ✔️ 🆓 for your registered domains @ inwx | ⛔ for your registered domains @ inwx |
|
||||
| deSEC.io (dedyn.io) | DynDNS2 | 60 | `token` | ✔️ 🆓 | ✔️ |
|
||||
| DuckDNS.org | DynDNS2 | 60 | `token` | ⛔ | ✔️ |
|
||||
| dynv6.com | DynDNS2 | 60 | `token` | ✔️ 🆓 | ✔️ |
|
||||
| ddnss.de | DynDNS2 | 10 | `update key` as `token` | ⛔ | ✔️ |
|
||||
| IPv64.net | DynDNS2 | 60 | `DynDNS Updatehash` as `token` | ✔️ 💲 | ✔️ |
|
||||
| dynu.com | DynDNS2 | 30 | `username` & `password` | ✔️ 🆓 | ✔️ |
|
||||
|
||||
## 📦 Requirements
|
||||
|
||||
@@ -57,7 +53,7 @@ or simply clone this repo
|
||||
git clone https://github.com/EV21/dynb.git
|
||||
```
|
||||
|
||||
If you want to add the script to you PATH, run :point_down:
|
||||
If you want to add the script to you PATH, run 👇
|
||||
|
||||
```shell
|
||||
bash dynb.sh --link
|
||||
@@ -79,7 +75,7 @@ DYNB_SERVICE_PROVIDER=inwx
|
||||
## update method options: domrobot, dyndns
|
||||
DYNB_UPDATE_METHOD=domrobot
|
||||
|
||||
## ip mode could be either: 4, 6 or dual for dualstack
|
||||
## ip mode could be either: 4, 6 or 64 for dualstack
|
||||
DYNB_IP_MODE=64
|
||||
|
||||
## If you are using the DomRobot RPC-API enter your credentials for the web interface login here
|
||||
@@ -92,14 +88,14 @@ DYNB_TOKEN=
|
||||
|
||||
## 🏃 Run
|
||||
|
||||
If you have a config file just run :point_down:
|
||||
If you have a config file just run 👇
|
||||
|
||||
```bash
|
||||
dynb
|
||||
```
|
||||
|
||||
Alternatively you can use parameters if your system meets the relevant requirements. This example shows the long form parameter, there are also short ones.\
|
||||
Call the help function :point_down:
|
||||
Call the help function 👇
|
||||
|
||||
```bash
|
||||
dynb --help
|
||||
@@ -123,13 +119,13 @@ Just use the parameter `--interval 60` or the environment variable `DYNB_INTERVA
|
||||
|
||||
### crontab
|
||||
|
||||
execute :point_down:
|
||||
execute 👇
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
then enter :point_down: to run dynb every five minutes.
|
||||
then add the following line 👇 to run dynb every five minutes.
|
||||
|
||||
```bash
|
||||
*/5 * * * * $HOME/.local/bin/dynb >> $HOME/.local/share/dynb/dynb-cron.log
|
||||
@@ -155,32 +151,40 @@ services:
|
||||
image: ev21/dynb
|
||||
container_name: dynb
|
||||
network_mode: host
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
- DYNB_DYN_DOMAIN=dyndns.example.com
|
||||
- DYNB_SERVICE_PROVIDER=inwx
|
||||
# Providers: deSec, DuckDNS, dynv6, inwx, ddnss, ipv64
|
||||
- DYNB_SERVICE_PROVIDER=desec
|
||||
# Possible update methods are: dyndns, domrobot
|
||||
- DYNB_UPDATE_METHOD=dyndns
|
||||
# IP modes: 4 (IPv4 only), 6 (IPv6 only), 64 both
|
||||
- DYNB_IP_MODE=64
|
||||
# If your provider uses tokens use DYNB_TOKEN instead of DYNB_USERNAME and DYNB_PASSWORD
|
||||
- DYNB_USERNAME=User42
|
||||
- DYNB_PASSWORD=SuperSecretPassword
|
||||
- DYNB_INTERVAL=60
|
||||
# The interval in seconds is the time the script waits before executing it again
|
||||
- DYNB_INTERVAL=300
|
||||
# TZ: Timezone setting for correct log time
|
||||
- TZ=Europe/Berlin
|
||||
# TERM: For colorful console output (attached mode)
|
||||
- TERM=xterm-256color
|
||||
```
|
||||
|
||||
## environment variables
|
||||
|
||||
| variable | default value | description |
|
||||
| --------------------- | --------------- | -------------------------------------------------------------------------------------------------------------- |
|
||||
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx` |
|
||||
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
||||
| DYNB_IP_MODE | undefined | required; `4`, `6` or `64` for both |
|
||||
| DYNB_USERNAME | undefined | the requirement depends on your provider and the update method |
|
||||
| DYNB_PASSWORD | undefined | the requirement depends on your provider and the update method |
|
||||
| DYNB_TOKEN | undefined | the requirement depends on your provider and the update method |
|
||||
| DYNB_INTERVAL | undefined | without this setting the script/docker container will run one time and exits |
|
||||
| DYNB_DEBUG | undefined | more console outputs |
|
||||
| DYNB_IPv4_CHECK_SITE | api64.ipify.org | You need a website or Web-API that outputs your remote IP |
|
||||
| DYNB_IPv6_CHECK_SITE | api64.ipify.org | You need a website or Web-API that outputs your remote IP |
|
||||
| DYNB_DNS_CHECK_SERVER | undefined | If you are using a local DNS Resolver/Server make sure it answers with the public answer or set another server |
|
||||
| variable | default value | description |
|
||||
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
|
||||
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx`, `ddnss`, `ipv64` |
|
||||
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
||||
| DYNB_IP_MODE | undefined | required; `4`, `6` or `64` for both |
|
||||
| DYNB_USERNAME | undefined | the requirement depends on your provider and the update method |
|
||||
| DYNB_PASSWORD | undefined | the requirement depends on your provider and the update method |
|
||||
| DYNB_TOKEN | undefined | the requirement depends on your provider and the update method |
|
||||
| DYNB_INTERVAL | undefined | without this setting the script/docker container will run one time and exits |
|
||||
| DYNB_DEBUG | undefined | more console outputs |
|
||||
| DYNB_IPv4_CHECK_SITE | tries in this order `ip64.ev21.de` (anonymous logging for 7 days), `api64.ipify.org`, `api.my-ip.io/ip`, `ip.anysrc.net/plain` | You need a website or Web-API that outputs your remote IP |
|
||||
| DYNB_IPv6_CHECK_SITE | tries in this order `ip64.ev21.de` (anonymous logging for 7 days), `api64.ipify.org`, `api.my-ip.io/ip`, `ip.anysrc.net/plain` | You need a website or Web-API that outputs your remote IP |
|
||||
| DYNB_DNS_CHECK_SERVER | using the DynDNS2 providers DNS servers | If you are using a local DNS Resolver/Server make sure it answers with the public answer or set another server |
|
||||
|
||||
689
dynb.sh
689
dynb.sh
@@ -12,67 +12,76 @@
|
||||
|
||||
#DYNB_DYN_DOMAIN=
|
||||
|
||||
## service provider could be deSEC, duckdns, dynv6, inwx
|
||||
# service provider could be deSEC, duckdns, dynv6, inwx
|
||||
#DYNB_SERVICE_PROVIDER=
|
||||
|
||||
## update method options: domrobot, dyndns
|
||||
#DYNB_UPDATE_METHOD=
|
||||
|
||||
## ip mode could be either: 4, 6 or dual for dualstack
|
||||
# ip mode could be either: 4, 6 or dual for dualstack
|
||||
#DYNB_IP_MODE=
|
||||
|
||||
## If you are using the DomRobot RPC-API enter your credentials for the web interface login here
|
||||
## If you are using the DynDNS2 protocol enter your credentials here
|
||||
# If you are using the DomRobot RPC-API enter your credentials for the web interface login here
|
||||
# If you are using the DynDNS2 protocol enter your credentials here
|
||||
#DYNB_USERNAME=
|
||||
#DYNB_PASSWORD=
|
||||
## or use a token
|
||||
# or use a token
|
||||
#DYNB_TOKEN=
|
||||
|
||||
## TTL (time to live) for the DNS record
|
||||
## This setting is only relevant for API based record updates (not DnyDNS2!)
|
||||
## minimum allowed TTL value by inwx is 300 (5 minutes)
|
||||
# TTL (time to live) for the DNS record
|
||||
# This setting is only relevant for API based record updates (not DnyDNS2!)
|
||||
# minimum allowed TTL value by inwx is 300 (5 minutes)
|
||||
TTL=300
|
||||
|
||||
## The IP-Check sites (some sites have different urls for v4 and v6)
|
||||
## Pro tip: use your own ip check server for privacy
|
||||
## it could be as simple as that...
|
||||
## create an index.php with <?php echo $_SERVER'REMOTE_ADDR'; ?>
|
||||
_ipv4_checker=api64.ipify.org
|
||||
_ipv6_checker=api64.ipify.org
|
||||
# The IP-Check sites (some sites have different urls for v4 and v6)
|
||||
# Pro tip: use your own ip check server for privacy
|
||||
# it could be as simple as that...
|
||||
# create an index.php with <?php echo $_SERVER'REMOTE_ADDR'; ?>
|
||||
#DYNB_IPv4_CHECK_SITE=
|
||||
#DYNB_IPv6_CHECK_SITE=
|
||||
|
||||
## An exernal DNS check server prevents wrong info from local DNS servers/resolvers
|
||||
_DNS_checkServer=
|
||||
# An exernal DNS check server prevents wrong info from local DNS servers/resolvers
|
||||
#DYNB_DNS_CHECK_SERVER=9.9.9.9
|
||||
|
||||
## if you are actively using multiple network interfaces you might want to specify this
|
||||
## normally the default value is okay
|
||||
# if you are actively using multiple network interfaces you might want to specify this
|
||||
# normally the default value is okay
|
||||
#_network_interface=eth0
|
||||
_network_interface=
|
||||
|
||||
######################################################
|
||||
## You don't need to change the following variables ##
|
||||
|
||||
_INWX_JSON_API_URL=https://api.domrobot.com/jsonrpc/
|
||||
_internet_connectivity_test_server=https://www.google.de
|
||||
_new_IPv4=
|
||||
_new_IPv6=
|
||||
_default_check_ip_servers=("ip64.ev21.de" "api64.ipify.org" "api.my-ip.io/ip" "ip.anysrc.net/plain")
|
||||
_ipv4_checker=
|
||||
_ipv6_checker=
|
||||
_DNS_checkServer=
|
||||
_remote_IPv4=
|
||||
_remote_IPv6=
|
||||
_dns_records=
|
||||
_main_domain=
|
||||
_is_IPv4_enabled=false
|
||||
_is_IPv6_enabled=false
|
||||
_interface_str=
|
||||
_status=
|
||||
_eventTime=0
|
||||
_errorCounter=0
|
||||
_response=
|
||||
_statusHostname=
|
||||
_statusUsername=
|
||||
_statusPassword=
|
||||
_version=0.3.0
|
||||
_version=0.5.1
|
||||
_userAgent="DynB/$_version github.com/EV21/dynb"
|
||||
_configFile=$HOME/.local/share/dynb/.env
|
||||
_statusFile=/tmp/dynb.status
|
||||
_debug=0
|
||||
_debug=false
|
||||
_minimum_looptime=60
|
||||
_loopMode=0
|
||||
_loopMode=false
|
||||
_remote_ip=
|
||||
_dns_ip=
|
||||
_has_remote_ip_error=
|
||||
_has_remote_ip4=false
|
||||
_has_remote_ip6=false
|
||||
|
||||
# Ansi color code variables
|
||||
yellow_color="\e[0;33m"
|
||||
@@ -103,9 +112,30 @@ function is_IPv6_address
|
||||
fi
|
||||
}
|
||||
|
||||
## is_ip_address A B
|
||||
# parameters required
|
||||
# 1. param: ip_version
|
||||
# 2. param: ip_address
|
||||
function is_ip_address
|
||||
{
|
||||
local ip_version=$1
|
||||
local ip_address=$2
|
||||
case $ip_version in
|
||||
4)
|
||||
is_IPv4_address "$ip_address"
|
||||
result=$?
|
||||
;;
|
||||
6)
|
||||
is_IPv6_address "$ip_address"
|
||||
result=$?
|
||||
;;
|
||||
esac
|
||||
return "$result"
|
||||
}
|
||||
|
||||
function loopMode
|
||||
{
|
||||
if [[ $_loopMode -eq 1 ]]
|
||||
if [[ $_loopMode == "true" ]]
|
||||
then return 0
|
||||
else return 1
|
||||
fi
|
||||
@@ -113,7 +143,7 @@ function loopMode
|
||||
|
||||
function debugMode
|
||||
{
|
||||
if [[ $_debug -eq 1 ]]
|
||||
if [[ $_debug == "true" ]]
|
||||
then return 0
|
||||
else return 1
|
||||
fi
|
||||
@@ -186,6 +216,7 @@ function fetchDNSRecords
|
||||
_dns_records=$(echo "$_response" | jq '.resData.record[]')
|
||||
}
|
||||
|
||||
## getRecordID
|
||||
# requires parameter A or AAAA
|
||||
# result to stdout
|
||||
function getRecordID
|
||||
@@ -194,34 +225,136 @@ function getRecordID
|
||||
jq "select(.type == \"${1}\") | .id"
|
||||
}
|
||||
|
||||
# requires parameter A or AAAA
|
||||
# result to stdout
|
||||
function getDNSIP() {
|
||||
echo "$_dns_records" |
|
||||
jq --raw-output "select(.type == \"${1}\") | .content"
|
||||
## do_dig_request A B
|
||||
# sets variable: _dns_ip
|
||||
#
|
||||
# requires parameter
|
||||
# 1. param: dns server address
|
||||
# 2. param: A or AAAA
|
||||
function do_dig_request
|
||||
{
|
||||
local dns_server=$1
|
||||
local record_type=$2
|
||||
dig_response=$(dig @"$dns_server" in "$record_type" +short "$DYNB_DYN_DOMAIN" 2>&1)
|
||||
dig_exitcode=$?
|
||||
if [[ $dig_exitcode -gt 0 ]]
|
||||
then
|
||||
errorMessage "DNS request for $record_type @ $dns_server failed with exit code: $dig_exitcode $dig_response"
|
||||
unset _dns_ip
|
||||
return 1
|
||||
else
|
||||
case $record_type in
|
||||
A) is_ip_address 4 "$dig_response"
|
||||
;;
|
||||
AAAA) is_ip_address 6 "$dig_response"
|
||||
;;
|
||||
esac
|
||||
if test $? -gt 0
|
||||
then
|
||||
test -n "$dig_response" || debugMessage "dig response: $dig_response"
|
||||
unset _dns_ip
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
# If the dns resolver lists multiple records in the answer section we filter the first line
|
||||
# using short option "-n" and not "--lines" because of alpines limited BusyBox head command
|
||||
_dns_ip=$(echo "$dig_response" | head -n 1)
|
||||
return 0
|
||||
}
|
||||
|
||||
## getDNSIP A
|
||||
# sets variable: _dns_ip
|
||||
#
|
||||
# requires parameter
|
||||
# 1. param: A or AAAA
|
||||
function getDNSIP() {
|
||||
local record_type=$1
|
||||
if [[ $DYNB_UPDATE_METHOD == domrobot ]]
|
||||
then
|
||||
_dns_ip=$(echo "$_dns_records" |
|
||||
jq --raw-output "select(.type == \"${record_type}\") | .content")
|
||||
else
|
||||
for current_dns_server in "${provider_dns_servers[@]}"
|
||||
do
|
||||
debugMessage "try dig DNS request with record type $record_type @$current_dns_server"
|
||||
if do_dig_request "$current_dns_server" "$record_type"
|
||||
then break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
## getRemoteIP A
|
||||
# sets variable: _remote_ip,
|
||||
#
|
||||
# requires parameter
|
||||
# 1. param: 4 or 6 for ip version
|
||||
# 2. param: IP check server address
|
||||
#
|
||||
# result to stdout
|
||||
function getRemoteIP
|
||||
{
|
||||
local ip_version=$1
|
||||
local ip_check_server=$2
|
||||
if [[ -n $_DNS_checkServer ]]
|
||||
then
|
||||
curl --silent "$_interface_str" --user-agent "$_userAgent" \
|
||||
--ipv"${ip_version}" --dns-servers "$_DNS_checkServer" --location "${ip_check_server}"
|
||||
else
|
||||
curl --silent "$_interface_str" --user-agent "$_userAgent" \
|
||||
--ipv"${ip_version}" --location "${ip_check_server}"
|
||||
fi
|
||||
# shellcheck disable=2181
|
||||
if [[ $? -gt 0 ]]; then
|
||||
errorMessage "IPCheck (getRemoteIP ${1}) request failed"
|
||||
exit 1
|
||||
|
||||
if test -n "$_provider_check_ip"
|
||||
then ip_check_servers=("$_provider_check_ip" "${_default_check_ip_servers[@]}")
|
||||
fi
|
||||
case $ip_version in
|
||||
4)
|
||||
if test -n "$_ipv4_checker"
|
||||
then ip_check_servers=("$_ipv4_checker" "${_default_check_ip_servers[@]}")
|
||||
else ip_check_servers=("${_default_check_ip_servers[@]}")
|
||||
fi
|
||||
;;
|
||||
6)
|
||||
if test -n "$_ipv6_checker"
|
||||
then ip_check_servers=("$_ipv6_checker" "${_default_check_ip_servers[@]}")
|
||||
else ip_check_servers=("${_default_check_ip_servers[@]}")
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
for current_check_server in "${ip_check_servers[@]}"
|
||||
do
|
||||
debugMessage "try getting remote IPv$ip_version via $current_check_server"
|
||||
response=$(curl --silent "$_interface_str" --user-agent "$_userAgent" \
|
||||
--ipv"${ip_version}" --location "${current_check_server}")
|
||||
curls_status_code=$?
|
||||
# shellcheck disable=2181
|
||||
if [[ $curls_status_code -gt 0 ]]
|
||||
then
|
||||
errorMessage "Remote IPv$ip_version request @ ${current_check_server} failed with curl status code: $curls_status_code"
|
||||
_has_remote_ip_error=true
|
||||
return_value=1
|
||||
else
|
||||
if is_ip_address "$ip_version" "$response"
|
||||
then
|
||||
_has_remote_ip_error=false
|
||||
_remote_ip="$response"
|
||||
return_value=0
|
||||
break
|
||||
else
|
||||
errorMessage "The response from the IP check server $current_check_server is not an IPv$ip_version address: $response"
|
||||
_has_remote_ip_error=true
|
||||
return_value=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
case $ip_version in
|
||||
4)
|
||||
if [[ $_has_remote_ip_error == true ]]
|
||||
then _has_remote_ip4=false
|
||||
else _has_remote_ip4=true
|
||||
fi
|
||||
;;
|
||||
6)
|
||||
if [[ $_has_remote_ip_error == true ]]
|
||||
then export _has_remote_ip6=false
|
||||
else export _has_remote_ip6=true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
return "$return_value"
|
||||
}
|
||||
|
||||
# requires parameter
|
||||
@@ -232,12 +365,12 @@ function updateRecord
|
||||
if [[ ${ip_version} == 4 ]]
|
||||
then
|
||||
ID=$(getRecordID A)
|
||||
IP=$_new_IPv4
|
||||
IP=$_remote_IPv4
|
||||
fi
|
||||
if [[ ${ip_version} == 6 ]]
|
||||
then
|
||||
ID=$(getRecordID AAAA)
|
||||
IP=$_new_IPv6
|
||||
IP=$_remote_IPv6
|
||||
fi
|
||||
if [[ $IP != "" ]]
|
||||
then
|
||||
@@ -263,102 +396,160 @@ function updateRecord
|
||||
fi
|
||||
}
|
||||
|
||||
# using DynDNS2 protocol
|
||||
function dynupdate
|
||||
function prepare_request_parameters
|
||||
{
|
||||
# default parameter values
|
||||
myip_str=myip
|
||||
myipv6_str=myipv6
|
||||
|
||||
INWX_DYNDNS_UPDATE_URL="https://dyndns.inwx.com/nic/update?"
|
||||
DESEC_DYNDNS_UPDATE_URL="https://update.dedyn.io/?"
|
||||
DUCKDNS_DYNDNS_UPDATE_URL="https://www.duckdns.org/update?domains=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
||||
DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
||||
ipv4_parameter_name=myip
|
||||
ipv6_parameter_name=myipv6
|
||||
curl_parameters=("--user-agent" "$_userAgent")
|
||||
|
||||
case $DYNB_SERVICE_PROVIDER in
|
||||
inwx* | INWX*)
|
||||
dyndns_update_url=$INWX_DYNDNS_UPDATE_URL
|
||||
;;
|
||||
deSEC* | desec* | dedyn*)
|
||||
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
|
||||
;;
|
||||
dynv6*)
|
||||
dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}"
|
||||
myip_str=ipv4
|
||||
myipv6_str=ipv6
|
||||
;;
|
||||
DuckDNS* | duckdns*)
|
||||
dyndns_update_url="${DUCKDNS_DYNDNS_UPDATE_URL}"
|
||||
myip_str=ipv4
|
||||
myipv6_str=ipv6
|
||||
;;
|
||||
[Ii][Nn][Ww][Xx]*)
|
||||
# inwx.de
|
||||
# in case of dualstack use you need to request both parameters with the same request
|
||||
# otherwise inwx will delete the not requested record type
|
||||
curl_parameters+=("--user" "$DYNB_USERNAME:$DYNB_PASSWORD")
|
||||
curl_parameters+=("--get") # inwx will ignore the ipv6 parameter if you don't put it into the url
|
||||
dyndns_update_url="https://dyndns.inwx.com/nic/update"
|
||||
provider_dns_servers=("ns.inwx.de" "ns2.inwx.de" "ns3.inwx.eu")
|
||||
;;
|
||||
[Dd][Yy][Nn][Uu]*)
|
||||
curl_parameters+=("--user" "$DYNB_USERNAME:$DYNB_PASSWORD")
|
||||
curl_parameters+=("--get")
|
||||
dyndns_update_url="https://api.dynu.com/nic/update"
|
||||
provider_dns_servers=("NS11.dynu.com" "NS10.dynu.com" "NS12.dynu.com")
|
||||
;;
|
||||
[Dd][Ee][Ss][Ee][Cc]* | [Dd][Ee][Dd][Yy][Nn]* )
|
||||
# deSEC.de / dedyn.io
|
||||
curl_parameters+=("--header" "Authorization: Token $DYNB_TOKEN")
|
||||
curl_parameters+=("--get")
|
||||
curl_parameters+=("--data-urlencode" "hostname=$DYNB_DYN_DOMAIN")
|
||||
dyndns_update_url="https://update.dedyn.io"
|
||||
provider_dns_servers=("ns1.desec.io" "ns2.desec.org")
|
||||
_provider_check_ip="https://checkip.dedyn.io" # checkipv4 and checkipv6 is also available
|
||||
;;
|
||||
[Dd][Yy][Nn][Vv]6*)
|
||||
# dynv6.com
|
||||
ipv4_parameter_name=ipv4
|
||||
ipv6_parameter_name=ipv6
|
||||
curl_parameters+=("--get")
|
||||
curl_parameters+=("--data-urlencode" "zone=$DYNB_DYN_DOMAIN")
|
||||
curl_parameters+=("--data-urlencode" "token=$DYNB_TOKEN")
|
||||
dyndns_update_url="https://dynv6.com/api/update"
|
||||
provider_dns_servers=("ns1.dynv6.com" "ns2.dynv6.com" "ns3.dynv6.com")
|
||||
;;
|
||||
[Dd][Uu][Cc][Kk][Dd][Nn][Ss]*)
|
||||
# DuckDNS.org
|
||||
ipv4_parameter_name=ip
|
||||
ipv6_parameter_name=ipv6
|
||||
curl_parameters+=("--get")
|
||||
curl_parameters+=("--data-urlencode" "domains=$DYNB_DYN_DOMAIN")
|
||||
curl_parameters+=("--data-urlencode" "token=$DYNB_TOKEN")
|
||||
dyndns_update_url="https://www.duckdns.org/update"
|
||||
provider_dns_servers=("ns1.duckdns.org" "ns2.duckdns.org")
|
||||
;;
|
||||
[Dd][Dd][Nn][Ss][Ss]*)
|
||||
# ddnss.de
|
||||
ipv4_parameter_name=ip
|
||||
ipv6_parameter_name=ip6
|
||||
curl_parameters+=("--get")
|
||||
curl_parameters+=("--data-urlencode" "host=$DYNB_DYN_DOMAIN")
|
||||
curl_parameters+=("--data-urlencode" "key=$DYNB_TOKEN")
|
||||
dyndns_update_url="https://ddnss.de/upd.php"
|
||||
provider_dns_servers=("ns1.ddnss.de" "ns2.ddnss.de" "ns3.ddnss.de")
|
||||
;;
|
||||
[Ii][Pp][Vv]64*)
|
||||
# IPv64.net
|
||||
ipv4_parameter_name=ip
|
||||
ipv6_parameter_name=ip6
|
||||
curl_parameters+=("--request" "POST")
|
||||
curl_parameters+=("--header" "Authorization: Bearer $DYNB_TOKEN")
|
||||
curl_parameters+=("--data-urlencode" "domain=$DYNB_DYN_DOMAIN")
|
||||
dyndns_update_url="https://ipv64.net/nic/update"
|
||||
provider_dns_servers=("ns1.IPv64.net" "ns2.IPv64.net")
|
||||
;;
|
||||
*)
|
||||
errorMessage "$DYNB_SERVICE_PROVIDER is not supported"
|
||||
exit 1
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
|
||||
# pre encode ip parameters
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]]; then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
||||
if test -n "$_DNS_checkServer"
|
||||
then provider_dns_servers=("$_DNS_checkServer" "${provider_dns_servers[@]}")
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]]; then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}"
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]]; then
|
||||
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
||||
fi
|
||||
debugMessage "Update URL was: $dyndns_update_url"
|
||||
}
|
||||
|
||||
## request ##
|
||||
case $DYNB_SERVICE_PROVIDER in
|
||||
inwx* | INWX*)
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
||||
"${dyndns_update_url}")
|
||||
;;
|
||||
deSEC* | desec* | dedyn*)
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
--header "Authorization: Token $DYNB_TOKEN" \
|
||||
--get --data-urlencode "hostname=$DYNB_DYN_DOMAIN" \
|
||||
"${dyndns_update_url}")
|
||||
;;
|
||||
dynv6* | duckDNS* | duckdns*)
|
||||
_response=$(
|
||||
curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
"${dyndns_update_url}"
|
||||
)
|
||||
;;
|
||||
esac
|
||||
function prepare_ip_flag_parameters
|
||||
{
|
||||
debugMessage "IPv4 enabled: $_is_IPv4_enabled; IPv6 enabled: $_is_IPv6_enabled; has remote IPv4: $_has_remote_ip4; has remote IPv6: $_has_remote_ip6"
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]] && [[ $_has_remote_ip4 == true ]] && [[ $_has_remote_ip6 == true ]]
|
||||
then
|
||||
ip_flag_parameters=("--data-urlencode" "${ipv4_parameter_name}=${_remote_IPv4}" "--data-urlencode" "${ipv6_parameter_name}=${_remote_IPv6}")
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]] || [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]] && [[ $_has_remote_ip4 == true ]] && [[ $_has_remote_ip6 == false ]]
|
||||
then
|
||||
ip_flag_parameters=("--data-urlencode" "${ipv4_parameter_name}=${_remote_IPv4}")
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]] || [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]] && [[ $_has_remote_ip4 == false ]] && [[ $_has_remote_ip6 == true ]]
|
||||
then
|
||||
ip_flag_parameters=("--data-urlencode" "${ipv6_parameter_name}=${_remote_IPv6}")
|
||||
fi
|
||||
}
|
||||
|
||||
case $_response in
|
||||
good* | OK* | "addresses updated")
|
||||
function send_request
|
||||
{
|
||||
local _response
|
||||
debugMessage "curl parameters: ${curl_parameters[*]} ${dyndns_update_url}"
|
||||
_response=$(
|
||||
curl --silent "$_interface_str" \
|
||||
"${curl_parameters[@]}" \
|
||||
"${dyndns_update_url}")
|
||||
_curl_exit_code=$?
|
||||
analyse_response
|
||||
status_code=$?
|
||||
return $status_code
|
||||
}
|
||||
|
||||
function analyse_response
|
||||
{
|
||||
case $_response in
|
||||
good* | OK* | "addresses updated" | *Updated*hostname* | *'"info":"good"'*)
|
||||
if [[ $_response == "good 127.0.0.1" ]]; then
|
||||
errorMessage "$_response: Request ignored."
|
||||
return 1
|
||||
else
|
||||
infoMessage "$_response: The DynDNS update has been executed."
|
||||
_errorCounter=0
|
||||
infoMessage "The DynDNS update has been executed."
|
||||
debugMessage "Response: $_response"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
nochg*)
|
||||
infoMessage "$_response: Nothing has changed, IP addresses are still up to date."
|
||||
*nochg*)
|
||||
infoMessage "Nothing has changed, IP addresses are still up to date."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
400* | *'Bad Request'*)
|
||||
errorMessage "Bad Request."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
*'Too Many Requests'*)
|
||||
errorMessage "Too Many Request."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
abuse)
|
||||
errorMessage "$_response: Username is blocked due to abuse."
|
||||
errorMessage "Username is blocked due to abuse."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
badauth | 401)
|
||||
errorMessage "$_response: Invalid username password combination."
|
||||
*badauth* | 401 | *Unauthorized*)
|
||||
errorMessage "Invalid token or username password combination."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
badagent)
|
||||
errorMessage "$_response: Client disabled. Something is very wrong!"
|
||||
errorMessage "Client disabled. Something is very wrong!"
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
!donator)
|
||||
@@ -373,8 +564,9 @@ function dynupdate
|
||||
errorMessage "$_response: Hostname $DYNB_DYN_DOMAIN is invalid"
|
||||
return 1
|
||||
;;
|
||||
nohost)
|
||||
errorMessage "$_response: Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
||||
*nohost*)
|
||||
errorMessage "Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
numhost)
|
||||
@@ -385,13 +577,17 @@ function dynupdate
|
||||
errorMessage "$_response: There is an internal error in the dyndns update system. Retry update no sooner than 30 minutes."
|
||||
return 1
|
||||
;;
|
||||
911 | 5*)
|
||||
servererror | 911 | 5*)
|
||||
errorMessage "$_response: A fatal error on provider side such as a database outage. Retry update no sooner than 30 minutes."
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
if [[ "$_response" == "$_status" ]]; then
|
||||
errorMessage "An unknown response code has been received. $_response"
|
||||
if test $_curl_exit_code -gt 0
|
||||
then
|
||||
analyse_curl_exit_code $_curl_exit_code
|
||||
return $?
|
||||
elif test -n "$_response" && [[ "$_response" == "$_previous_response_was" ]]; then
|
||||
errorMessage "An unknown response code has been received: $_response"
|
||||
return 1
|
||||
else
|
||||
errorMessage "unknown respnse code: $_response"
|
||||
@@ -401,19 +597,59 @@ function dynupdate
|
||||
esac
|
||||
}
|
||||
|
||||
function analyse_curl_exit_code
|
||||
{
|
||||
local current_curl_exit_code=$1
|
||||
case $current_curl_exit_code in
|
||||
6)
|
||||
errorMessage "curl exit code: $_curl_exit_code; Couldn't resolve host: $dyndns_update_url"
|
||||
;;
|
||||
7)
|
||||
errorMessage "curl exit code: $_curl_exit_code; Failed to connect to host: $dyndns_update_url"
|
||||
;;
|
||||
22)
|
||||
errorMessage "curl exit code: $_curl_exit_code HTTP error code being 400 or above"
|
||||
;;
|
||||
*)
|
||||
errorMessage "curl exit code: $_curl_exit_code"
|
||||
;;
|
||||
esac
|
||||
return "$current_curl_exit_code"
|
||||
}
|
||||
|
||||
# using DynDNS2 protocol
|
||||
function dynupdate
|
||||
{
|
||||
prepare_ip_flag_parameters
|
||||
curl_parameters+=("${ip_flag_parameters[@]}")
|
||||
send_request
|
||||
request_status=$?
|
||||
return $request_status
|
||||
}
|
||||
|
||||
function setStatus
|
||||
{
|
||||
echo "_status=$1; _eventTime=$2; _errorCounter=$3; _statusHostname=$4; _statusUsername=$5; _statusPassword=$6" >/tmp/dynb.status
|
||||
echo "_curl_exit_code_was=$1; _previous_response_was=$2 _eventTime=$3; _errorCounter=$4; _statusHostname=$5; _statusUsername=$6; _statusPassword=$7" >/tmp/dynb.status
|
||||
}
|
||||
|
||||
declare _previous_response_was
|
||||
declare _curl_exit_code_was
|
||||
|
||||
# handle errors from past update requests
|
||||
function checkStatus
|
||||
{
|
||||
case $_status in
|
||||
nochg*)
|
||||
if [[ _errorCounter -gt 1 ]]; then
|
||||
local check_string
|
||||
if [[ -z "${_previous_response_was}" ]]
|
||||
then check_string=$_curl_exit_code_was
|
||||
else check_string=$_previous_response_was
|
||||
fi
|
||||
|
||||
case $check_string in
|
||||
*nochg*)
|
||||
if [[ _errorCounter -gt 1 ]]
|
||||
then
|
||||
errorMessage "The update client was spamming unnecessary update requests, something might be wrong with your IP-Check site."
|
||||
errorMessage "Fix your config an then delete $_statusFile or restart your docker container"
|
||||
errorMessage "Fix your config and then delete $_statusFile or restart your docker container"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
@@ -421,22 +657,21 @@ function checkStatus
|
||||
if [[ "$_statusHostname" == "$DYNB_DYN_DOMAIN" && ("$_statusUsername" == "$DYNB_USERNAME" || $_statusUsername == "$DYNB_TOKEN") ]]; then
|
||||
errorMessage "Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
||||
return 1
|
||||
else rm "$_statusFile"
|
||||
else delete_status_file
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
badauth | 401)
|
||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && "$_statusPassword" == "$DYNB_PASSWORD" ]]; then
|
||||
*badauth* | 401 | *Unauthorized*)
|
||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && ("$_statusPassword" == "$DYNB_PASSWORD" || $_statusPassword == "$DYNB_TOKEN") ]]; then
|
||||
errorMessage "Invalid username password combination."
|
||||
return 1
|
||||
else rm "$_statusFile"
|
||||
else delete_status_file
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
badagent)
|
||||
errorMessage "Client is deactivated by provider."
|
||||
echo "Fix your config and then manually remove $_statusFile to reset the client blockade."
|
||||
echo "If it still fails file an issue at github or try another client :)"
|
||||
echo "Please file an issue at GitHub or try another client :)"
|
||||
return 1
|
||||
;;
|
||||
!donator)
|
||||
@@ -451,94 +686,88 @@ function checkStatus
|
||||
echo "If it still fails file an issue at github or try another client :)"
|
||||
return 1
|
||||
;;
|
||||
911 | 5*)
|
||||
delta=$(($(date +%s) - _eventTime))
|
||||
if [[ $delta -lt 1800 ]]
|
||||
servererror | 911 | 5* | *'Too Many Requests'*)
|
||||
if check_delay 30
|
||||
then
|
||||
errorMessage "$_status: The provider currently has an fatal error. DynB will wait for next update until 30 minutes have passed since last request, $(date --date=@$delta -u +%M) minutes already passed."
|
||||
delete_status_file
|
||||
return 0
|
||||
else
|
||||
errorMessage "$_previous_response_was: The provider currently has a fatal error."
|
||||
return 1
|
||||
else rm "$_statusFile"
|
||||
fi
|
||||
;;
|
||||
*'Bad Request'*)
|
||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && ("$_statusPassword" == "$DYNB_PASSWORD" || $_statusPassword == "$DYNB_TOKEN") ]]
|
||||
then
|
||||
errorMessage "Bad Request: Please check your credentials, maybe your token is invalid."
|
||||
return 1
|
||||
else delete_status_file
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
if [[ _errorCounter -gt 1 ]]
|
||||
if [[ $_errorCounter -gt 1 ]] && [[ "$_curl_exit_code_was" -eq 0 ]]
|
||||
then
|
||||
errorMessage "An unknown response code has repeatedly been received. $_response"
|
||||
return 1
|
||||
elif [[ $_errorCounter -gt 1 ]] && [[ "$_curl_exit_code_was" -eq 7 ]]
|
||||
then
|
||||
if check_delay 15
|
||||
then
|
||||
delete_status_file
|
||||
return 0
|
||||
else return 1
|
||||
fi
|
||||
else return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function check_delay
|
||||
{
|
||||
local minutes=$1
|
||||
local seconds=$(( minutes * 60 ))
|
||||
delta=$(($(date +%s) - _eventTime))
|
||||
if [[ $delta -lt $seconds ]]
|
||||
then
|
||||
errorMessage "DynB only executes an update when $minutes minutes have passed since the last failed request, $(date --date=@$delta -u +%M) minutes have already passed."
|
||||
if loopMode
|
||||
then sleep $seconds
|
||||
else return 1
|
||||
fi
|
||||
else return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# requires parameter
|
||||
# 1. param: 4 or 6 for IP version
|
||||
function ipHasChanged
|
||||
{
|
||||
local ip_version=$1
|
||||
getRemoteIP "$ip_version"
|
||||
if test $? -gt 0
|
||||
then return 1
|
||||
fi
|
||||
case ${ip_version} in
|
||||
4)
|
||||
remote_ip=$(getRemoteIP 4 $_ipv4_checker)
|
||||
if ! is_IPv4_address "$remote_ip"
|
||||
then
|
||||
errorMessage "The response from the IP check server is not an IPv4 address: $remote_ip"
|
||||
return 1
|
||||
fi
|
||||
if [[ $DYNB_UPDATE_METHOD == domrobot ]]
|
||||
then dns_ip=$(getDNSIP A)
|
||||
else
|
||||
if [[ -n $_DNS_checkServer ]]
|
||||
then dig_response=$(dig @"${_DNS_checkServer}" in a +short "$DYNB_DYN_DOMAIN")
|
||||
else dig_response=$(dig in a +short "$DYNB_DYN_DOMAIN")
|
||||
fi
|
||||
if [[ $dig_response == ";; connection timed out; no servers could be reached" ]]
|
||||
then
|
||||
errorMessage "DNS request failed $dig_response"
|
||||
return 1
|
||||
fi
|
||||
# If the dns resolver lists multiple records in the answer section we filter the first line
|
||||
# using short option "-n" and not "--lines" because of alpines limited BusyBox head command
|
||||
dns_ip=$(echo "$dig_response" | head -n 1)
|
||||
fi
|
||||
_new_IPv4=$remote_ip
|
||||
debugMessage "IPv4 from remote IP check server: $_new_IPv4, IPv4 from DNS: $dns_ip"
|
||||
;;
|
||||
getDNSIP A
|
||||
_remote_IPv4=$_remote_ip
|
||||
debugMessage "IPv4 from remote IP check server: $_remote_IPv4, IPv4 from DNS: $_dns_ip"
|
||||
;;
|
||||
6)
|
||||
remote_ip=$(getRemoteIP 6 $_ipv6_checker)
|
||||
if ! is_IPv6_address "$remote_ip"
|
||||
then
|
||||
errorMessage "The response from the IP check server is not an IPv6 address: $remote_ip"
|
||||
return 1
|
||||
fi
|
||||
if [[ $DYNB_UPDATE_METHOD == domrobot ]]
|
||||
then dns_ip=$(getDNSIP AAAA)
|
||||
else
|
||||
if [[ -n $_DNS_checkServer ]]
|
||||
then dig_response=$(dig @"${_DNS_checkServer}" in aaaa +short "$DYNB_DYN_DOMAIN")
|
||||
else dig_response=$(dig in aaaa +short "$DYNB_DYN_DOMAIN")
|
||||
fi
|
||||
exitcode=$?
|
||||
if [[ $exitcode -gt 0 ]]
|
||||
then
|
||||
errorMessage "DNS request failed with exit code: $exitcode $dig_response"
|
||||
return 1
|
||||
fi
|
||||
# If the dns server lists multiple records in the answer section we filter the first line
|
||||
dns_ip=$(echo "$dig_response" | head -n 1)
|
||||
fi
|
||||
_new_IPv6=$remote_ip
|
||||
debugMessage "IPv6 from remote IP check server: $_new_IPv6, IPv4 from DNS: $dns_ip"
|
||||
;;
|
||||
*) ;;
|
||||
getDNSIP AAAA
|
||||
_remote_IPv6=$_remote_ip
|
||||
debugMessage "IPv6 from remote IP check server: $_remote_IPv6, IPv6 from DNS: $_dns_ip"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$remote_ip" == "$dns_ip" ]]
|
||||
if [[ "$_remote_ip" == "$_dns_ip" ]]
|
||||
then return 1
|
||||
else
|
||||
case ${ip_version} in
|
||||
4) infoMessage "New IPv4: $_new_IPv4 old was: $dns_ip";;
|
||||
6) infoMessage "New IPv6: $_new_IPv6 old was: $dns_ip";;
|
||||
4) infoMessage "Remote IPv4: $_remote_IPv4 DNS IPv4: $_dns_ip";;
|
||||
6) infoMessage "Remote IPv6: $_remote_IPv6 DNS IPv6: $_dns_ip";;
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
@@ -559,8 +788,8 @@ function handleParameters
|
||||
then rm --verbose "$_statusFile"; exit 0
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
if [[ $_arg_debug == "on" ]]
|
||||
then _debug=1
|
||||
if [[ $_arg_debug == "on" ]] || [[ $DYNB_DEBUG == true ]]
|
||||
then _debug=true
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
if [[ $_arg_update_method != "" ]]
|
||||
@@ -600,8 +829,8 @@ function handleParameters
|
||||
elif [[ $DYNB_INTERVAL -lt _minimum_looptime ]]
|
||||
then
|
||||
DYNB_INTERVAL=$_minimum_looptime
|
||||
_loopMode=1
|
||||
else _loopMode=1
|
||||
_loopMode=true
|
||||
else _loopMode=true
|
||||
fi
|
||||
if [[ $_network_interface != "" ]]
|
||||
then _interface_str="--interface $_network_interface"
|
||||
@@ -619,9 +848,6 @@ function handleParameters
|
||||
then _is_IPv6_enabled=true
|
||||
fi
|
||||
|
||||
if [[ $DYNB_DEBUG == true ]]
|
||||
then _debug=1
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
if [[ -n $DYNB_IPv4_CHECK_SITE ]]
|
||||
then _ipv4_checker=$DYNB_IPv4_CHECK_SITE
|
||||
@@ -671,8 +897,8 @@ function doUnsets
|
||||
unset _is_IPv4_enabled
|
||||
unset _is_IPv6_enabled
|
||||
unset _main_domain
|
||||
unset _new_IPv4
|
||||
unset _new_IPv6
|
||||
unset _remote_IPv4
|
||||
unset _remote_IPv6
|
||||
unset _version
|
||||
unset DYNB_DYN_DOMAIN
|
||||
unset DYNB_USERNAME
|
||||
@@ -707,8 +933,25 @@ function doDomrobotUpdates
|
||||
fi
|
||||
}
|
||||
|
||||
function delete_status_file
|
||||
{
|
||||
if test -f "$_statusFile"
|
||||
then
|
||||
debugMessage "Delete status file with previous errors"
|
||||
rm "$_statusFile"
|
||||
unset _curl_exit_code_was
|
||||
unset _previous_response_was
|
||||
unset _eventTime
|
||||
unset _errorCounter
|
||||
unset _statusHostname
|
||||
unset _statusUsername
|
||||
unset _statusPassword
|
||||
fi
|
||||
}
|
||||
|
||||
function doDynDNS2Updates
|
||||
{
|
||||
prepare_request_parameters
|
||||
changed=0
|
||||
if [[ $_is_IPv4_enabled == true ]] && ipHasChanged 4
|
||||
then ((changed += 1))
|
||||
@@ -722,14 +965,16 @@ function doDynDNS2Updates
|
||||
then
|
||||
debugMessage "checkStatus has no errors, try update"
|
||||
if dynupdate
|
||||
then debugMessage "DynDNS2 update success"
|
||||
then
|
||||
debugMessage "DynDNS2 update success"
|
||||
delete_status_file
|
||||
else
|
||||
debugMessage "Save new status after dynupdate has failed"
|
||||
setStatus "$_response" "$(date +%s)" $((_errorCounter += 1)) "$DYNB_DYN_DOMAIN" "${DYNB_USERNAME}" "${DYNB_PASSWORD}${DYNB_TOKEN}"
|
||||
setStatus "$_curl_exit_code" "$_response" "$(date +%s)" $((_errorCounter += 1)) "$DYNB_DYN_DOMAIN" "${DYNB_USERNAME}" "${DYNB_PASSWORD}${DYNB_TOKEN}"
|
||||
fi
|
||||
else debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
||||
fi
|
||||
else debugMessage "Skip DynDNS2 update, IPs are up to date or there is a connection problem"
|
||||
else debugMessage "Skip DynDNS2 update"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -744,17 +989,20 @@ function doUpdates
|
||||
|
||||
function ipv6_is_not_working
|
||||
{
|
||||
curl --ipv6 --head --silent --max-time 5 $_internet_connectivity_test_server > /dev/null
|
||||
status_code=$?
|
||||
if test $status_code -gt 0
|
||||
then return 0
|
||||
else return 1
|
||||
fi
|
||||
execute_connectivity_check 6
|
||||
return $?
|
||||
}
|
||||
|
||||
function ipv4_is_not_working
|
||||
{
|
||||
curl --ipv4 --head --silent --max-time 5 $_internet_connectivity_test_server > /dev/null
|
||||
execute_connectivity_check 4
|
||||
return $?
|
||||
}
|
||||
|
||||
function execute_connectivity_check
|
||||
{
|
||||
local ip_version=$1
|
||||
curl --ipv"$ip_version" --head --silent --max-time 5 $_internet_connectivity_test_server > /dev/null
|
||||
status_code=$?
|
||||
if test $status_code -gt 0
|
||||
then return 0
|
||||
@@ -782,11 +1030,8 @@ function check_internet_connection
|
||||
fi
|
||||
}
|
||||
|
||||
function main
|
||||
function read_config_file
|
||||
{
|
||||
# shellcheck disable=SC1091,SC1090
|
||||
source "$(dirname "$(realpath "$0")")/dynb-parsing.sh"
|
||||
|
||||
# shellcheck source=.env
|
||||
if test -f "$_configFile"
|
||||
then
|
||||
@@ -800,6 +1045,15 @@ function main
|
||||
source "$alternativeConfig"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function main
|
||||
{
|
||||
# shellcheck disable=SC1091,SC1090
|
||||
source "$(dirname "$(realpath "$0")")/dynb-parsing.sh"
|
||||
|
||||
read_config_file
|
||||
|
||||
if test -f "$_statusFile"
|
||||
then
|
||||
debugMessage "read previous status file"
|
||||
@@ -817,7 +1071,8 @@ function main
|
||||
while :
|
||||
do
|
||||
doUpdates
|
||||
sleep $DYNB_INTERVAL
|
||||
debugMessage "wait $DYNB_INTERVAL seconds until next check"
|
||||
sleep "$DYNB_INTERVAL"
|
||||
done
|
||||
else doUpdates
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user