World4You dns root parsing

This commit is contained in:
Lorenz Stechauner 2020-11-28 08:50:47 +01:00
parent f3987b453c
commit 9474933070

View File

@ -5,6 +5,8 @@
WORLD4YOU_API="https://my.world4you.com/en" WORLD4YOU_API="https://my.world4you.com/en"
PAKETNR='' PAKETNR=''
TLD=''
RECORD=''
################ Public functions ################ ################ Public functions ################
@ -16,9 +18,6 @@ dns_world4you_add() {
_debug fulldomain "$fqdn" _debug fulldomain "$fqdn"
_debug txtvalue "$value" _debug txtvalue "$value"
tld=$(echo "$fqdn" | _egrep_o '[^.]*\.[^.]*$')
record=$(echo "$fqdn" | cut -c"1-$((${#fqdn} - ${#tld} - 1))")
_login _login
if [ "$?" != 0 ]; then if [ "$?" != 0 ]; then
return 1 return 1
@ -26,8 +25,10 @@ dns_world4you_add() {
export _H1="Cookie: W4YSESSID=$sessid" export _H1="Cookie: W4YSESSID=$sessid"
form=$(_get "$WORLD4YOU_API/dashboard/paketuebersicht") form=$(_get "$WORLD4YOU_API/dashboard/paketuebersicht")
_get_paketnr "$tld" "$form" _get_paketnr "$fqdn" "$form"
paketnr="$PAKETNR" paketnr="$PAKETNR"
tld="$TLD"
record="$RECORD"
if [ -z "$paketnr" ]; then if [ -z "$paketnr" ]; then
_err "Unable to parse paketnr" _err "Unable to parse paketnr"
return 3 return 3
@ -82,8 +83,10 @@ dns_world4you_rm() {
export _H1="Cookie: W4YSESSID=$sessid" export _H1="Cookie: W4YSESSID=$sessid"
form=$(_get "$WORLD4YOU_API/dashboard/paketuebersicht") form=$(_get "$WORLD4YOU_API/dashboard/paketuebersicht")
_get_paketnr "$tld" "$form" _get_paketnr "$fqdn" "$form"
paketnr="$PAKETNR" paketnr="$PAKETNR"
tld="$TLD"
record="$RECORD"
if [ -z "$paketnr" ]; then if [ -z "$paketnr" ]; then
_err "Unable to parse paketnr" _err "Unable to parse paketnr"
return 3 return 3
@ -163,22 +166,25 @@ _login() {
fi fi
} }
# Usage _get_paketnr <tld> <form> # Usage _get_paketnr <fqdn> <form>
_get_paketnr() { _get_paketnr() {
tld="$1" fqdn="$1"
form="$2" form="$2"
domains=$(echo "$form" | _ggrep -E '^\s*([A-Za-z0-9_-]+\.)+[A-Za-z0-9_-]*$' | sed 's/^\s*\(\S*\)$/\1/') domains=$(echo "$form" | _ggrep -E '^\s*([A-Za-z0-9_-]+\.)+[A-Za-z0-9_-]*$' | sed 's/^\s*\(\S*\)$/\1/')
domain='' domain=''
for domain in $domains; do for domain in $domains; do
if echo "$domain" | grep -q "$tld\$"; then if echo "$fqdn" | grep -q "$domain\$"; then
break break
fi fi
domain=''
done done
if [ -z "$domain" ]; then if [ -z "$domain" ]; then
return 1 return 1
fi fi
TLD="$domain"
RECORD=$(echo "$fqdn" | cut -c"1-$((${#fqdn} - ${#TLD} - 1))")
PAKETNR=$(echo "$form" | _ggrep -B 3 "^\\s*$domain\$" | head -n 1 | sed 's/^.*>\([0-9][0-9]*\).*$/\1/') PAKETNR=$(echo "$form" | _ggrep -B 3 "^\\s*$domain\$" | head -n 1 | sed 's/^.*>\([0-9][0-9]*\).*$/\1/')
return 0 return 0
} }