mirror of
https://github.com/openwrt/packages.git
synced 2025-12-10 12:41:22 +00:00
ddns-scripts: drop split_FQDN()
The function is unused - it can be removed. Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
committed by
Florian Eckert
parent
9cdd1a1660
commit
38e02fbd57
@@ -37,7 +37,6 @@ UPDFILE="" # store UPTIME of last update
|
||||
DATFILE="" # save stdout data of WGet and other external programs called
|
||||
ERRFILE="" # save stderr output of WGet and other external programs called
|
||||
IPFILE="" # store registered IP for read by LuCI status
|
||||
TLDFILE=/usr/share/public_suffix_list.dat.gz # TLD file used by split_FQDN
|
||||
|
||||
CHECK_SECONDS=0 # calculated seconds out of given
|
||||
FORCE_SECONDS=0 # interval and unit
|
||||
@@ -1153,78 +1152,6 @@ trap_handler() {
|
||||
[ $1 -gt 0 ] && kill -$1 $$
|
||||
}
|
||||
|
||||
split_FQDN() {
|
||||
# $1 FQDN to split
|
||||
# $2 name of variable to store TLD
|
||||
# $3 name of variable to store (reg)Domain
|
||||
# $4 name of variable to store Host/Subdomain
|
||||
|
||||
[ $# -ne 4 ] && write_log 12 "Error calling 'split_FQDN()' - wrong number of parameters"
|
||||
[ -z "$1" ] && write_log 12 "Error calling 'split_FQDN()' - missing FQDN to split"
|
||||
[ -f $TLDFILE ] || write_log 12 "Error calling 'split_FQDN()' - missing file '$TLDFILE'"
|
||||
|
||||
local _HOST _FDOM _CTLD _FTLD
|
||||
local _SET="$@" # save given function parameters
|
||||
|
||||
local _PAR=$(echo "$1" | tr [A-Z] [a-z] | tr "." " ") # to lower and replace DOT with SPACE
|
||||
set -- $_PAR # set new as function parameters
|
||||
_PAR="" # clear variable for later reuse
|
||||
while [ -n "$1" ] ; do # as long we have parameters
|
||||
_PAR="$1 $_PAR" # invert order of parameters
|
||||
shift
|
||||
done
|
||||
set -- $_PAR # use new as function parameters
|
||||
_PAR="" # clear variable
|
||||
|
||||
while [ -n "$1" ] ; do # as long we have parameters
|
||||
if [ -z "$_CTLD" ]; then # first loop
|
||||
_CTLD="$1" # CURRENT TLD to look at
|
||||
shift
|
||||
else
|
||||
_CTLD="$1.$_CTLD" # Next TLD to look at
|
||||
shift
|
||||
fi
|
||||
# check if TLD exact match in tld_names.dat, save TLD
|
||||
zcat $TLDFILE | grep -E "^$_CTLD$" >/dev/null 2>&1 && {
|
||||
_FTLD="$_CTLD" # save found
|
||||
_FDOM="$1" # save domain next step might be invalid
|
||||
continue
|
||||
}
|
||||
# check if match any "*" in tld_names.dat,
|
||||
zcat $TLDFILE | grep -E "^\*.$_CTLD$" >/dev/null 2>&1 && {
|
||||
[ -z "$1" ] && break # no more data break
|
||||
# check if next level TLD match excludes "!" in tld_names.dat
|
||||
if zcat $TLDFILE | grep -E "^!$1.$_CTLD$" >/dev/null 2>&1 ; then
|
||||
_FTLD="$_CTLD" # Yes
|
||||
else
|
||||
_FTLD="$1.$_CTLD"
|
||||
shift
|
||||
fi
|
||||
_FDOM="$1"; shift
|
||||
}
|
||||
[ -n "$_FTLD" ] && break # we have something valid, break
|
||||
done
|
||||
|
||||
# the leftover parameters are the HOST/SUBDOMAIN
|
||||
while [ -n "$1" ]; do
|
||||
_HOST="$1 $_HOST" # remember we need to invert
|
||||
shift
|
||||
done
|
||||
_HOST=$(echo $_HOST | tr " " ".") # insert DOT
|
||||
|
||||
set -- $_SET # set back parameters from function call
|
||||
[ -n "$_FTLD" ] && {
|
||||
eval "$2=$_FTLD" # set TLD
|
||||
eval "$3=$_FDOM" # set registrable domain
|
||||
eval "$4=$_HOST" # set HOST/SUBDOMAIN
|
||||
return 0
|
||||
}
|
||||
eval "$2=''" # clear TLD
|
||||
eval "$3=''" # clear registrable domain
|
||||
eval "$4=''" # clear HOST/SUBDOMAIN
|
||||
return 1
|
||||
}
|
||||
|
||||
expand_ipv6() {
|
||||
# Original written for bash by
|
||||
#.Author: Florian Streibelt <florian@f-streibelt.de>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# using following options from /etc/config/ddns
|
||||
# option username - your cloudflare e-mail
|
||||
# option password - cloudflare api key, you can get it from cloudflare.com/my-account/
|
||||
# option domain - "hostname@yourdomain.TLD" # syntax changed to remove split_FQDN() function and tld_names.dat.gz
|
||||
# option domain - "hostname@yourdomain.TLD"
|
||||
#
|
||||
# The proxy status would not be changed by this script. Please change it in Cloudflare dashboard manually.
|
||||
#
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# using following options from /etc/config/ddns
|
||||
# option username - huaweicloud Access Key Id
|
||||
# option password - huaweicloud Secret Access Key,AK、SK documentation from https://support.huaweicloud.com/devg-apisign/api-sign-provide-aksk.html
|
||||
# option domain - "hostname@yourdomain.TLD" # syntax changed to remove split_FQDN() function and tld_names.dat.gz
|
||||
# option domain - "hostname@yourdomain.TLD"
|
||||
#
|
||||
|
||||
# Check inputs
|
||||
|
||||
Reference in New Issue
Block a user