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

feat: add support for deSEC as DynDNS2 provider

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

View File

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

View File

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

58
dynb.sh
View File

@@ -69,7 +69,7 @@ _version=0.0.1
_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
_debug=1 _debug=0
# Created by argbash-init v2.10.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. # 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() { function debugMessage() {
if debugMode; then if debugMode; then
echo "Debug: ${1}" echo "Debug: $*"
fi fi
} }
@@ -429,17 +429,28 @@ function dynupdate() {
myipv6_str=myipv6 myipv6_str=myipv6
INWX_DYNDNS_UPDATE_URL="https://dyndns.inwx.com/nic/update?" 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&" 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 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}" dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}"
myip_str=ipv4 myip_str=ipv4
myipv6_str=ipv6 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 if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]]; 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}"
fi fi
@@ -450,19 +461,29 @@ function dynupdate() {
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}" dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
fi fi
debugMessage "Update URL was: $dyndns_update_url" debugMessage "Update URL was: $dyndns_update_url"
## request ## ## request ##
if [[ $_serviceProvider == "dynv6" ]]; then case $_serviceProvider in
_response=$(curl --silent "$_interface_str" \ inwx | INWX )
--user-agent "$_userAgent" \
"${dyndns_update_url}"
)
fi
if [[ $_serviceProvider == "inwx" ]]; then
_response=$(curl --silent "$_interface_str" \ _response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \ --user-agent "$_userAgent" \
--user "$_username":"$_password" \ --user "$_username":"$_password" \
"${dyndns_update_url}" ) "${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 case $_response in
good* ) good* )
@@ -653,6 +674,9 @@ function handleParameters() {
if [[ $_arg_reset == "on" ]]; then if [[ $_arg_reset == "on" ]]; then
rm --verbose "$_statusFile" rm --verbose "$_statusFile"
exit 0 exit 0
fi
if [[ $_arg_debug == "on" ]]; then
_debug=1
fi fi
if [[ $_arg_update_method != "" ]]; then if [[ $_arg_update_method != "" ]]; then
_update_method=$_arg_update_method _update_method=$_arg_update_method
@@ -792,16 +816,18 @@ function dynb() {
fi fi
if [[ $changed -gt 0 ]]; then if [[ $changed -gt 0 ]]; then
if checkStatus; then if checkStatus; then
debugMessage "checkStatus has no errors" debugMessage "checkStatus has no errors, try update"
if dynupdate; then if dynupdate; then
debugMessage "DynDNS2 update success" debugMessage "DynDNS2 update success"
else else
debugMessage "Save new status after dynupdate has failed" 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 fi
else else
debugMessage "Skip DynDNS2 update, checkStatus fetched previous error." debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
fi fi
else
debugMessage "Skip DynDNS2 update, IPs are up to date"
fi fi
fi fi
doUnsets doUnsets

View File

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

View File

@@ -22,7 +22,7 @@
.. |OPTION_DOMAIN| replace:: dyndns.example.com .. |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 .. |OPTION_USERNAME| replace:: e.g. user42