mirror of
https://github.com/EV21/dynb.git
synced 2025-12-26 16:39:32 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c83b893fc8
|
|||
|
c9794f7c22
|
|||
|
b8bbce7ec2
|
|||
|
bd6f1336b2
|
|||
|
260bc7172f
|
|||
|
a85b2bf911
|
|||
|
a496acbebf
|
|||
|
c81da8846e
|
|||
|
122e08a42a
|
|||
|
2352d655a3
|
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,6 +1,29 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
|
||||||
|
## 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)
|
## 0.3.4 (2022-06-30)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ The following update methods are currently implemented:
|
|||||||
| DuckDNS.org | DynDNS2 | 60 | `token` | ⛔ | ✔️ |
|
| DuckDNS.org | DynDNS2 | 60 | `token` | ⛔ | ✔️ |
|
||||||
| dynv6.com | DynDNS2 | 60 | `token` | ✔️ | ✔️ |
|
| dynv6.com | DynDNS2 | 60 | `token` | ✔️ | ✔️ |
|
||||||
| ddnss.de | DynDNS2 | 10 | update key as `token` | ⛔ | ✔️ |
|
| ddnss.de | DynDNS2 | 10 | update key as `token` | ⛔ | ✔️ |
|
||||||
|
| IPv64.net | DynDNS2 | 60 | `DynDNS Updatehash` as `token` | ⛔ | ✔️ |
|
||||||
|
|
||||||
## 📦 Requirements
|
## 📦 Requirements
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
environment:
|
environment:
|
||||||
- DYNB_DYN_DOMAIN=dyndns.example.com
|
- DYNB_DYN_DOMAIN=dyndns.example.com
|
||||||
# Providers: deSec, duckDNS, dynv6, inwx
|
# Providers: deSec, DuckDNS, dynv6, inwx, ddnss, ipv64
|
||||||
- DYNB_SERVICE_PROVIDER=desec
|
- DYNB_SERVICE_PROVIDER=desec
|
||||||
# Possible update methods are: dyndns, domrobot
|
# Possible update methods are: dyndns, domrobot
|
||||||
- DYNB_UPDATE_METHOD=dyndns
|
- DYNB_UPDATE_METHOD=dyndns
|
||||||
@@ -175,7 +176,7 @@ services:
|
|||||||
| variable | default value | description |
|
| variable | default value | description |
|
||||||
|-----------------------|-----------------|----------------------------------------------------------------------------------------------------------------|
|
|-----------------------|-----------------|----------------------------------------------------------------------------------------------------------------|
|
||||||
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
||||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx`, `ddnss` |
|
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx`, `ddnss`, `ipv64` |
|
||||||
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
||||||
| DYNB_IP_MODE | undefined | required; `4`, `6` or `64` for both |
|
| 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_USERNAME | undefined | the requirement depends on your provider and the update method |
|
||||||
|
|||||||
99
dynb.sh
99
dynb.sh
@@ -66,7 +66,7 @@ _response=
|
|||||||
_statusHostname=
|
_statusHostname=
|
||||||
_statusUsername=
|
_statusUsername=
|
||||||
_statusPassword=
|
_statusPassword=
|
||||||
_version=0.3.4
|
_version=0.3.5
|
||||||
_userAgent="DynB/$_version github.com/EV21/dynb"
|
_userAgent="DynB/$_version github.com/EV21/dynb"
|
||||||
_configFile=$HOME/.local/share/dynb/.env
|
_configFile=$HOME/.local/share/dynb/.env
|
||||||
_statusFile=/tmp/dynb.status
|
_statusFile=/tmp/dynb.status
|
||||||
@@ -269,6 +269,7 @@ function select_update_base_url
|
|||||||
DUCKDNS_DYNDNS_UPDATE_URL="https://www.duckdns.org/update?domains=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
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&"
|
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&"
|
DDNSS_DYNDNS_UPDATE_URL="https://ddnss.de/upd.php?key=$DYNB_TOKEN&host=$DYNB_DYN_DOMAIN&"
|
||||||
|
IPV64NET_DYNDNS_UPDATE_URL="https://ipv64.net/nic/update?"
|
||||||
|
|
||||||
case $DYNB_SERVICE_PROVIDER in
|
case $DYNB_SERVICE_PROVIDER in
|
||||||
inwx* | INWX*)
|
inwx* | INWX*)
|
||||||
@@ -293,6 +294,11 @@ function select_update_base_url
|
|||||||
myip_str=ip
|
myip_str=ip
|
||||||
myipv6_str=ip6
|
myipv6_str=ip6
|
||||||
;;
|
;;
|
||||||
|
[Ii][Pp][Vv]64*)
|
||||||
|
dyndns_update_url="${IPV64NET_DYNDNS_UPDATE_URL}"
|
||||||
|
myip_str=ip
|
||||||
|
myipv6_str=ip6
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
errorMessage "$DYNB_SERVICE_PROVIDER is not supported"
|
errorMessage "$DYNB_SERVICE_PROVIDER is not supported"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -309,7 +315,7 @@ function send_request
|
|||||||
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
||||||
"${dyndns_update_url}")
|
"${dyndns_update_url}")
|
||||||
analyse_response
|
analyse_response
|
||||||
return $?
|
status_code=$?
|
||||||
;;
|
;;
|
||||||
deSEC* | desec* | dedyn*)
|
deSEC* | desec* | dedyn*)
|
||||||
_response=$(curl --silent "$_interface_str" \
|
_response=$(curl --silent "$_interface_str" \
|
||||||
@@ -318,44 +324,64 @@ function send_request
|
|||||||
--get --data-urlencode "hostname=$DYNB_DYN_DOMAIN" \
|
--get --data-urlencode "hostname=$DYNB_DYN_DOMAIN" \
|
||||||
"${dyndns_update_url}")
|
"${dyndns_update_url}")
|
||||||
analyse_response
|
analyse_response
|
||||||
return $?
|
status_code=$?
|
||||||
;;
|
;;
|
||||||
|
[Ii][Pp][Vv]64* )
|
||||||
|
_response=$(curl --silent "$_interface_str" \
|
||||||
|
--user-agent "$_userAgent" \
|
||||||
|
--header "Authorization: Bearer $DYNB_TOKEN" \
|
||||||
|
--request POST \
|
||||||
|
--form "domain=$DYNB_DYN_DOMAIN" \
|
||||||
|
"${dyndns_update_url}")
|
||||||
|
analyse_response
|
||||||
|
status_code=$?
|
||||||
|
;;
|
||||||
dynv6* | duckDNS* | duckdns* | ddnss*)
|
dynv6* | duckDNS* | duckdns* | ddnss*)
|
||||||
_response=$(
|
_response=$(
|
||||||
curl --silent "$_interface_str" \
|
curl --silent "$_interface_str" \
|
||||||
--user-agent "$_userAgent" \
|
--user-agent "$_userAgent" \
|
||||||
"${dyndns_update_url}")
|
"${dyndns_update_url}")
|
||||||
analyse_response
|
analyse_response
|
||||||
return $?
|
status_code=$?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
return $status_code
|
||||||
}
|
}
|
||||||
|
|
||||||
function analyse_response
|
function analyse_response
|
||||||
{
|
{
|
||||||
case $_response in
|
case $_response in
|
||||||
good* | OK* | "addresses updated" | *Updated*hostname*)
|
good* | OK* | "addresses updated" | *Updated*hostname* | *'"info":"good"'*)
|
||||||
if [[ $_response == "good 127.0.0.1" ]]; then
|
if [[ $_response == "good 127.0.0.1" ]]; then
|
||||||
errorMessage "$_response: Request ignored."
|
errorMessage "$_response: Request ignored."
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
infoMessage "The DynDNS update has been executed."
|
infoMessage "The DynDNS update has been executed."
|
||||||
debugMessage "Response: $_response"
|
debugMessage "Response: $_response"
|
||||||
_errorCounter=0
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
nochg*)
|
*nochg*)
|
||||||
infoMessage "Nothing has changed, IP addresses are still up to date."
|
infoMessage "Nothing has changed, IP addresses are still up to date."
|
||||||
debugMessage "Response: $_response"
|
debugMessage "Response: $_response"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
|
*'Bad Request'*)
|
||||||
|
errorMessage "Bad Request."
|
||||||
|
debugMessage "Response: $_response"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*'Too Many Requests'*)
|
||||||
|
errorMessage "Too Many Request."
|
||||||
|
debugMessage "Response: $_response"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
abuse)
|
abuse)
|
||||||
errorMessage "Username is blocked due to abuse."
|
errorMessage "Username is blocked due to abuse."
|
||||||
debugMessage "Response: $_response"
|
debugMessage "Response: $_response"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
*badauth* | 401)
|
*badauth* | 401 | *Unauthorized*)
|
||||||
errorMessage "Invalid token or username password combination."
|
errorMessage "Invalid token or username password combination."
|
||||||
debugMessage "Response: $_response"
|
debugMessage "Response: $_response"
|
||||||
return 1
|
return 1
|
||||||
@@ -416,18 +442,20 @@ function dynupdate
|
|||||||
then
|
then
|
||||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
||||||
send_request
|
send_request
|
||||||
|
request_status=$?
|
||||||
fi
|
fi
|
||||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]]
|
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]]
|
||||||
then
|
then
|
||||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}"
|
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}"
|
||||||
send_request
|
send_request
|
||||||
|
request_status=$?
|
||||||
fi
|
fi
|
||||||
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]]
|
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]]
|
||||||
then
|
then
|
||||||
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
||||||
send_request
|
send_request
|
||||||
|
request_status=$?
|
||||||
fi
|
fi
|
||||||
request_status=$?
|
|
||||||
debugMessage "Update URL was: $dyndns_update_url"
|
debugMessage "Update URL was: $dyndns_update_url"
|
||||||
return $request_status
|
return $request_status
|
||||||
}
|
}
|
||||||
@@ -441,7 +469,7 @@ function setStatus
|
|||||||
function checkStatus
|
function checkStatus
|
||||||
{
|
{
|
||||||
case $_status in
|
case $_status in
|
||||||
nochg*)
|
*nochg*)
|
||||||
if [[ _errorCounter -gt 1 ]]; then
|
if [[ _errorCounter -gt 1 ]]; then
|
||||||
errorMessage "The update client was spamming unnecessary update requests, something might be wrong with your IP-Check site."
|
errorMessage "The update client was spamming unnecessary update requests, something might be wrong with your IP-Check site."
|
||||||
errorMessage "Fix your config and then delete $_statusFile or restart your docker container"
|
errorMessage "Fix your config and then delete $_statusFile or restart your docker container"
|
||||||
@@ -456,8 +484,8 @@ function checkStatus
|
|||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
badauth | 401)
|
*badauth* | 401 | *Unauthorized*)
|
||||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && "$_statusPassword" == "$DYNB_PASSWORD" ]]; then
|
if [[ "$_statusUsername" == "$DYNB_USERNAME" && ("$_statusPassword" == "$DYNB_PASSWORD" || $_statusPassword == "$DYNB_TOKEN") ]]; then
|
||||||
errorMessage "Invalid username password combination."
|
errorMessage "Invalid username password combination."
|
||||||
return 1
|
return 1
|
||||||
else rm "$_statusFile"
|
else rm "$_statusFile"
|
||||||
@@ -466,8 +494,7 @@ function checkStatus
|
|||||||
;;
|
;;
|
||||||
badagent)
|
badagent)
|
||||||
errorMessage "Client is deactivated by provider."
|
errorMessage "Client is deactivated by provider."
|
||||||
echo "Fix your config and then manually remove $_statusFile to reset the client blockade."
|
echo "Please file an issue at GitHub or try another client :)"
|
||||||
echo "If it still fails file an issue at github or try another client :)"
|
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
!donator)
|
!donator)
|
||||||
@@ -482,7 +509,7 @@ function checkStatus
|
|||||||
echo "If it still fails file an issue at github or try another client :)"
|
echo "If it still fails file an issue at github or try another client :)"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
911 | 5*)
|
911 | 5* | *'Too Many Requests'*)
|
||||||
delta=$(($(date +%s) - _eventTime))
|
delta=$(($(date +%s) - _eventTime))
|
||||||
if [[ $delta -lt 1800 ]]
|
if [[ $delta -lt 1800 ]]
|
||||||
then
|
then
|
||||||
@@ -492,6 +519,14 @@ function checkStatus
|
|||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
*'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 rm "$_statusFile"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ _errorCounter -gt 1 ]]
|
if [[ _errorCounter -gt 1 ]]
|
||||||
then
|
then
|
||||||
@@ -590,7 +625,7 @@ function handleParameters
|
|||||||
then rm --verbose "$_statusFile"; exit 0
|
then rm --verbose "$_statusFile"; exit 0
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [[ $_arg_debug == "on" ]]
|
if [[ $_arg_debug == "on" ]] || [[ $DYNB_DEBUG == true ]]
|
||||||
then _debug=1
|
then _debug=1
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
@@ -650,9 +685,6 @@ function handleParameters
|
|||||||
then _is_IPv6_enabled=true
|
then _is_IPv6_enabled=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $DYNB_DEBUG == true ]]
|
|
||||||
then _debug=1
|
|
||||||
fi
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [[ -n $DYNB_IPv4_CHECK_SITE ]]
|
if [[ -n $DYNB_IPv4_CHECK_SITE ]]
|
||||||
then _ipv4_checker=$DYNB_IPv4_CHECK_SITE
|
then _ipv4_checker=$DYNB_IPv4_CHECK_SITE
|
||||||
@@ -738,6 +770,15 @@ function doDomrobotUpdates
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete_status_file
|
||||||
|
{
|
||||||
|
if test -f "$_statusFile"
|
||||||
|
then
|
||||||
|
debugMessage "Delete status file with previous errors"
|
||||||
|
rm "$_statusFile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function doDynDNS2Updates
|
function doDynDNS2Updates
|
||||||
{
|
{
|
||||||
changed=0
|
changed=0
|
||||||
@@ -753,14 +794,16 @@ function doDynDNS2Updates
|
|||||||
then
|
then
|
||||||
debugMessage "checkStatus has no errors, try update"
|
debugMessage "checkStatus has no errors, try update"
|
||||||
if dynupdate
|
if dynupdate
|
||||||
then debugMessage "DynDNS2 update success"
|
then
|
||||||
|
debugMessage "DynDNS2 update success"
|
||||||
|
delete_status_file
|
||||||
else
|
else
|
||||||
debugMessage "Save new status after dynupdate has failed"
|
debugMessage "Save new status after dynupdate has failed"
|
||||||
setStatus "$_response" "$(date +%s)" $((_errorCounter += 1)) "$DYNB_DYN_DOMAIN" "${DYNB_USERNAME}" "${DYNB_PASSWORD}${DYNB_TOKEN}"
|
setStatus "$_response" "$(date +%s)" $((_errorCounter += 1)) "$DYNB_DYN_DOMAIN" "${DYNB_USERNAME}" "${DYNB_PASSWORD}${DYNB_TOKEN}"
|
||||||
fi
|
fi
|
||||||
else debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
else debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
||||||
fi
|
fi
|
||||||
else debugMessage "Skip DynDNS2 update, IPs are up to date or there is a connection problem"
|
else debugMessage "Skip DynDNS2 update, IPs are up to date."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,11 +856,8 @@ function check_internet_connection
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function main
|
function read_config_file
|
||||||
{
|
{
|
||||||
# shellcheck disable=SC1091,SC1090
|
|
||||||
source "$(dirname "$(realpath "$0")")/dynb-parsing.sh"
|
|
||||||
|
|
||||||
# shellcheck source=.env
|
# shellcheck source=.env
|
||||||
if test -f "$_configFile"
|
if test -f "$_configFile"
|
||||||
then
|
then
|
||||||
@@ -831,6 +871,15 @@ function main
|
|||||||
source "$alternativeConfig"
|
source "$alternativeConfig"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function main
|
||||||
|
{
|
||||||
|
# shellcheck disable=SC1091,SC1090
|
||||||
|
source "$(dirname "$(realpath "$0")")/dynb-parsing.sh"
|
||||||
|
|
||||||
|
read_config_file
|
||||||
|
|
||||||
if test -f "$_statusFile"
|
if test -f "$_statusFile"
|
||||||
then
|
then
|
||||||
debugMessage "read previous status file"
|
debugMessage "read previous status file"
|
||||||
|
|||||||
Reference in New Issue
Block a user