mirror of
https://github.com/EV21/dynb.git
synced 2025-12-26 16:39:32 +01:00
Compare commits
10 Commits
0.3.3
...
2352d655a3
| Author | SHA1 | Date | |
|---|---|---|---|
|
2352d655a3
|
|||
|
341d535f21
|
|||
|
fc2c499daa
|
|||
|
39d5143108
|
|||
|
e58d87cf94
|
|||
|
9d41354695
|
|||
|
d8a298f58a
|
|||
|
3e89610e22
|
|||
|
faa9c371c1
|
|||
|
11fccf2f0e
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.env*
|
||||
docker-compose*
|
||||
.vscode
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,6 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
36
README.md
36
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,14 @@ 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. | ✔️ | ⛔ choose one of your owned domains |
|
||||
| INWX.com | DynDNS2 | 60 | specific dyndns `username` & `password` | ✔️ | ⛔ choose one of your owned domains per account |
|
||||
| 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` | ⛔ | ✔️ |
|
||||
|
||||
## 📦 Requirements
|
||||
|
||||
@@ -57,7 +51,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
|
||||
@@ -92,14 +86,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 +117,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
|
||||
@@ -179,9 +173,9 @@ services:
|
||||
## environment variables
|
||||
|
||||
| variable | default value | description |
|
||||
| --------------------- | --------------- | -------------------------------------------------------------------------------------------------------------- |
|
||||
|-----------------------|-----------------|----------------------------------------------------------------------------------------------------------------|
|
||||
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx` |
|
||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx`, `ddnss` |
|
||||
| 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 |
|
||||
|
||||
112
dynb.sh
112
dynb.sh
@@ -66,7 +66,7 @@ _response=
|
||||
_statusHostname=
|
||||
_statusUsername=
|
||||
_statusPassword=
|
||||
_version=0.3.3
|
||||
_version=0.3.4
|
||||
_userAgent="DynB/$_version github.com/EV21/dynb"
|
||||
_configFile=$HOME/.local/share/dynb/.env
|
||||
_statusFile=/tmp/dynb.status
|
||||
@@ -258,8 +258,7 @@ function updateRecord
|
||||
fi
|
||||
}
|
||||
|
||||
# using DynDNS2 protocol
|
||||
function dynupdate
|
||||
function select_update_base_url
|
||||
{
|
||||
# default parameter values
|
||||
myip_str=myip
|
||||
@@ -269,6 +268,7 @@ function dynupdate
|
||||
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&"
|
||||
DDNSS_DYNDNS_UPDATE_URL="https://ddnss.de/upd.php?key=$DYNB_TOKEN&host=$DYNB_DYN_DOMAIN&"
|
||||
|
||||
case $DYNB_SERVICE_PROVIDER in
|
||||
inwx* | INWX*)
|
||||
@@ -287,31 +287,29 @@ function dynupdate
|
||||
myip_str=ip
|
||||
myipv6_str=ipv6
|
||||
;;
|
||||
ddnss*)
|
||||
dyndns_update_url="${DDNSS_DYNDNS_UPDATE_URL}"
|
||||
## we are currently not using the syntax with ip auto detection
|
||||
myip_str=ip
|
||||
myipv6_str=ip6
|
||||
;;
|
||||
*)
|
||||
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}"
|
||||
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 ##
|
||||
function send_request
|
||||
{
|
||||
case $DYNB_SERVICE_PROVIDER in
|
||||
inwx* | INWX*)
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
return $?
|
||||
;;
|
||||
deSEC* | desec* | dedyn*)
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
@@ -319,41 +317,52 @@ function dynupdate
|
||||
--header "Authorization: Token $DYNB_TOKEN" \
|
||||
--get --data-urlencode "hostname=$DYNB_DYN_DOMAIN" \
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
return $?
|
||||
;;
|
||||
dynv6* | duckDNS* | duckdns*)
|
||||
dynv6* | duckDNS* | duckdns* | ddnss*)
|
||||
_response=$(
|
||||
curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
"${dyndns_update_url}"
|
||||
)
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
return $?
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function analyse_response
|
||||
{
|
||||
case $_response in
|
||||
good* | OK* | "addresses updated")
|
||||
good* | OK* | "addresses updated" | *Updated*hostname*)
|
||||
if [[ $_response == "good 127.0.0.1" ]]; then
|
||||
errorMessage "$_response: Request ignored."
|
||||
return 1
|
||||
else
|
||||
infoMessage "$_response: The DynDNS update has been executed."
|
||||
infoMessage "The DynDNS update has been executed."
|
||||
debugMessage "Response: $_response"
|
||||
_errorCounter=0
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
nochg*)
|
||||
infoMessage "$_response: Nothing has changed, IP addresses are still up to date."
|
||||
infoMessage "Nothing has changed, IP addresses are still up to date."
|
||||
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)
|
||||
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)
|
||||
@@ -368,8 +377,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)
|
||||
@@ -386,7 +396,7 @@ function dynupdate
|
||||
;;
|
||||
*)
|
||||
if [[ "$_response" == "$_status" ]]; then
|
||||
errorMessage "An unknown response code has been received. $_response"
|
||||
errorMessage "An unknown response code has been received: $_response"
|
||||
return 1
|
||||
else
|
||||
errorMessage "unknown respnse code: $_response"
|
||||
@@ -396,6 +406,32 @@ function dynupdate
|
||||
esac
|
||||
}
|
||||
|
||||
# using DynDNS2 protocol
|
||||
function dynupdate
|
||||
{
|
||||
select_update_base_url
|
||||
|
||||
# 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}"
|
||||
send_request
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]]
|
||||
then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}"
|
||||
send_request
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]]
|
||||
then
|
||||
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
||||
send_request
|
||||
fi
|
||||
request_status=$?
|
||||
debugMessage "Update URL was: $dyndns_update_url"
|
||||
return $request_status
|
||||
}
|
||||
|
||||
function setStatus
|
||||
{
|
||||
echo "_status=$1; _eventTime=$2; _errorCounter=$3; _statusHostname=$4; _statusUsername=$5; _statusPassword=$6" >/tmp/dynb.status
|
||||
@@ -408,7 +444,7 @@ function checkStatus
|
||||
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
|
||||
;;
|
||||
@@ -523,7 +559,7 @@ function ipHasChanged
|
||||
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"
|
||||
debugMessage "IPv6 from remote IP check server: $_new_IPv6, IPv6 from DNS: $dns_ip"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
@@ -777,11 +813,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
|
||||
@@ -795,6 +828,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"
|
||||
|
||||
Reference in New Issue
Block a user