1
0
mirror of https://github.com/EV21/dynb.git synced 2025-12-26 16:39:32 +01:00

add support for deSEC as DynDNS2 provider

This commit is contained in:
2021-04-04 11:19:36 +02:00
parent ab330e9731
commit b8565eb38f
5 changed files with 52 additions and 23 deletions

View File

@@ -5,6 +5,8 @@
### New
* :sparkles: add support for deSEC as DynDNS2 provider. [Eduard Veit]
* :sparkles: add completion. [Eduard Veit]
:sparkles: add man page

View File

@@ -26,6 +26,7 @@ The following update methods are currently implemented:
* INWX.com
* dynv6.com
* deSEC.io (dedyn.io)
## 📦 Requirements

58
dynb.sh
View File

@@ -69,7 +69,7 @@ _version=0.0.1
_userAgent="DynB/$_version github.com/EV21/dynb"
_configFile=$HOME/.local/share/dynb/.env
_statusFile=/tmp/dynb.status
_debug=1
_debug=0
# Created by argbash-init v2.10.0
# Rearrange the order of options below according to what you would like to see in the help message.
@@ -325,7 +325,7 @@ function debugMode() {
function debugMessage() {
if debugMode; then
echo "Debug: ${1}"
echo "Debug: $*"
fi
}
@@ -429,17 +429,28 @@ function dynupdate() {
myipv6_str=myipv6
INWX_DYNDNS_UPDATE_URL="https://dyndns.inwx.com/nic/update?"
DESEC_DYNDNS_UPDATE_URL="https://update.dedyn.io/?"
DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$_dyn_domain&token=$_token&"
if [[ $_serviceProvider == "inwx" ]]; then
case $_serviceProvider in
inwx | INWX )
dyndns_update_url=$INWX_DYNDNS_UPDATE_URL
fi
if [[ $_serviceProvider == "dynv6" ]]; then
;;
deSEC | desec* | dedyn* )
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
;;
dynv6 )
dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}"
myip_str=ipv4
myipv6_str=ipv6
fi
;;
* )
echoerr "$_serviceProvider 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
@@ -450,19 +461,29 @@ function dynupdate() {
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
fi
debugMessage "Update URL was: $dyndns_update_url"
## request ##
if [[ $_serviceProvider == "dynv6" ]]; then
_response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \
"${dyndns_update_url}"
)
fi
if [[ $_serviceProvider == "inwx" ]]; then
case $_serviceProvider in
inwx | INWX )
_response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \
--user "$_username":"$_password" \
"${dyndns_update_url}" )
fi
;;
deSEC | desec* | dedyn* )
_response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \
--header "Authorization: Token $_token" \
--get --data-urlencode "hostname=$_dyn_domain" \
"${dyndns_update_url}" )
;;
dynv6 )
_response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \
"${dyndns_update_url}"
)
;;
esac
case $_response in
good* )
@@ -653,6 +674,9 @@ function handleParameters() {
if [[ $_arg_reset == "on" ]]; then
rm --verbose "$_statusFile"
exit 0
fi
if [[ $_arg_debug == "on" ]]; then
_debug=1
fi
if [[ $_arg_update_method != "" ]]; then
_update_method=$_arg_update_method
@@ -792,16 +816,18 @@ function dynb() {
fi
if [[ $changed -gt 0 ]]; then
if checkStatus; then
debugMessage "checkStatus has no errors"
debugMessage "checkStatus has no errors, try update"
if dynupdate; then
debugMessage "DynDNS2 update success"
else
debugMessage "Save new status after dynupdate has failed"
setStatus "$_response" "$(date +%s)" $(( _errorCounter += 1 )) "$_dyn_domain" "${_username}${_token}"
setStatus "$_response" "$(date +%s)" $(( _errorCounter += 1 )) "$_dyn_domain" "${_username}" "${_password}${_token}"
fi
else
debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
fi
else
debugMessage "Skip DynDNS2 update, IPs are up to date"
fi
fi
doUnsets

View File

@@ -81,7 +81,7 @@ dyndns.example.com
.BI \-s \ SERVICE\-PROVIDER\fR,\fB \ \-\-service\-provider \ SERVICE\-PROVIDER
set your provider in case you are using DynDNS2.
.sp
inwx | dynv6
inwx | dynv6 | deSEC
.TP
.BI \-u \ USERNAME\fR,\fB \ \-\-username \ USERNAME
depends on your selected update method and your provider.

View File

@@ -22,7 +22,7 @@
.. |OPTION_DOMAIN| replace:: dyndns.example.com
.. |OPTION_SERVICE_PROVIDER| replace:: inwx | dynv6
.. |OPTION_SERVICE_PROVIDER| replace:: inwx | dynv6 | deSEC
.. |OPTION_USERNAME| replace:: e.g. user42