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

add support for Duck DNS as DynDNS2 provider

This commit is contained in:
2021-04-04 14:39:19 +02:00
parent b8565eb38f
commit 4d28f55ce9
5 changed files with 24 additions and 15 deletions

27
dynb.sh
View File

@@ -12,7 +12,7 @@
_dyn_domain=
## service provider could be inwx
## service provider could be deSEC, duckdns, dynv6, inwx
_serviceProvider=
## update method options: domrobot, dyndns
@@ -287,6 +287,7 @@ parse_commandline "$@"
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
# The generated argbash help message does not look as nice as this:
_help_message="$(cat << 'EOF'
dynb - dynamic DNS update script for bash
@@ -430,20 +431,26 @@ function dynupdate() {
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=$_dyn_domain&token=$_token&"
DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$_dyn_domain&token=$_token&"
case $_serviceProvider in
inwx | INWX )
inwx* | INWX* )
dyndns_update_url=$INWX_DYNDNS_UPDATE_URL
;;
deSEC | desec* | dedyn* )
deSEC* | desec* | dedyn* )
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
;;
dynv6 )
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
;;
* )
echoerr "$_serviceProvider is not supported"
exit 1
@@ -464,20 +471,20 @@ function dynupdate() {
## request ##
case $_serviceProvider in
inwx | INWX )
inwx* | INWX* )
_response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \
--user "$_username":"$_password" \
"${dyndns_update_url}" )
;;
deSEC | desec* | dedyn* )
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 )
dynv6* | duckDNS* | duckdns* )
_response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \
"${dyndns_update_url}"
@@ -486,7 +493,7 @@ function dynupdate() {
esac
case $_response in
good* )
good* | OK* )
if [[ $_response == "good 127.0.0.1" ]]; then
echoerr "Error: $_response: Request ignored."
return 1
@@ -645,10 +652,10 @@ function ipHasChanged() {
if [[ ${1} == 4 ]]; then
_new_IPv4=$remote_ip
#echo "New IPv4: $_new_IPv4 old was: $dns_ip"
debugMessage "New IPv4: $_new_IPv4 old was: $dns_ip"
else
_new_IPv6=$remote_ip
#echo "New IPv6: $_new_IPv6 old was: $dns_ip"
debugMessage "New IPv6: $_new_IPv6 old was: $dns_ip"
fi
if [[ "$remote_ip" == "$dns_ip" ]]; then