mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-14 19:41:51 +00:00
Allow wildcard domain in omr-bypass
This commit is contained in:
parent
4949749b55
commit
9b71441dfd
1 changed files with 28 additions and 1 deletions
|
@ -44,7 +44,34 @@ _bypass_domains() {
|
|||
config_get intf $1 interface
|
||||
config_get enabled $1 enabled
|
||||
[ "$enabled" = "0" ] && return
|
||||
_bypass_domain $domain $intf
|
||||
if [ "$(echo $domain | grep '\.$')" != "" ] || [ "$(echo $domain | grep '\.\*$')" != "" ]; then
|
||||
tlds=`curl --max-time 4 -s -k https://data.iana.org/TLD/tlds-alpha-by-domain.txt`
|
||||
domain="$(echo '"$domain"' | sed 's:*::')"
|
||||
domainlist=""
|
||||
# construct list of domains to query
|
||||
for tld in $tlds; do
|
||||
i=$((i+1))
|
||||
# trim off header
|
||||
if [ "$i" -lt "12" ] || [ "$i" -gt "50" ]; then
|
||||
continue
|
||||
fi
|
||||
# add to command
|
||||
domainlist="${domainlist} ${domain}${tld}"
|
||||
done
|
||||
domainlist="$(echo $domainlist `# Get the list of valid domains, pass it to awk` \
|
||||
| awk '{print tolower($0)}' `# awk lowercases the whole string and passes it to ` \
|
||||
| xargs -n8 -P12 `# xargs sends 8 arguments at a time to` \
|
||||
dig a +timeout=1 +tries=1 +retry=1 +nocmd +noall +answer `# dig, which passes results (if any) to` \
|
||||
| awk '{print $1}' `# awk, which outputs queried domain to` \
|
||||
| sed -e 's/.$//' `# sed, which trims off the trailing dot (google.com. -> google.com)` to \
|
||||
| grep $domain `# grep, only keep wanted domain` \
|
||||
| awk '{for (i=1;i<=NF;i++) if (!a[$i]++) printf("%s%s",$i,FS)}{printf("\n")}')" # deduplicate
|
||||
for validdomain in $domainlist; do
|
||||
_bypass_domain $validdomain $intf
|
||||
done
|
||||
else
|
||||
_bypass_domain $domain $intf
|
||||
fi
|
||||
}
|
||||
|
||||
_bypass_domain() {
|
||||
|
|
Loading…
Reference in a new issue