mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Merge pull request #28 from cr3ative/parallel-bypass
Potential performance improvement for omr-bypass with ndpi global gTLD rules
This commit is contained in:
commit
bc359a687f
2 changed files with 31 additions and 11 deletions
9
contributors/cr3ative.md
Normal file
9
contributors/cr3ative.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
2020-11-10
|
||||
|
||||
I hereby agree to the terms of the "OpenMPTCProuter Individual Contributor License Agreement", with MD5 checksum bc827a07eb93611d793ddb7c75083c00.
|
||||
|
||||
I furthermore declare that I am authorized and able to make this agreement and sign this declaration.
|
||||
|
||||
Signed,
|
||||
|
||||
Paul Curry https://github.com/cr3ative
|
|
@ -331,21 +331,32 @@ _bypass_proto() {
|
|||
local domains
|
||||
domains="$(cat /proc/net/xt_ndpi/host_proto | grep -i $proto: | sed -e "s/$proto://i" -e 's/*//' -e 's/,/ /g')"
|
||||
if [ -n "$domains" ]; then
|
||||
tlds=`curl --max-time 4 -s -k https://data.iana.org/TLD/tlds-alpha-by-domain.txt`
|
||||
for domain in $domains; do
|
||||
if [ -n "$domain" ]; then
|
||||
domain="$(echo $domain | sed 's/^\.//')"
|
||||
if [ "$(echo $domain | grep '\.$')" != "" ]; then
|
||||
tlds=`curl --max-time 4 -s -k https://data.iana.org/TLD/tlds-alpha-by-domain.txt`
|
||||
if [ -n "tlds" ]; then
|
||||
i=0
|
||||
for tld in $tlds; do
|
||||
i=$((i+1))
|
||||
tld="$(echo $tld | awk '{print tolower($0)}')"
|
||||
if [ "$i" -gt "11" ] && [ "$(dig a +timeout=1 +tries=1 +retry=1 +nocmd +noall +answer ${domain}${tld})" != "" ]; then
|
||||
_bypass_domain ${domain}${tld} $intf
|
||||
fi
|
||||
done
|
||||
fi
|
||||
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 `# xargs sends 8 arguments at a time to` \
|
||||
dig a +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)` \
|
||||
| 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue