diff --git a/luci-app-omr-bypass/root/etc/init.d/omr-bypass b/luci-app-omr-bypass/root/etc/init.d/omr-bypass index 5304b1a06..92b0a6240 100755 --- a/luci-app-omr-bypass/root/etc/init.d/omr-bypass +++ b/luci-app-omr-bypass/root/etc/init.d/omr-bypass @@ -482,7 +482,7 @@ _bypass_proto_without_ndpi() { config_get proto $1 proto config_get intf $1 interface config_get enabled $1 enabled - config_get ndpi $1 ndpi + config_get ndpi $1 ndpi "0" config_get noipv6 $1 noipv6 config_get family $1 family [ "$enabled" = "0" ] && return @@ -499,7 +499,7 @@ _bypass_proto_without_ndpi() { ipset -q --exist restore <<-EOF create bypass_$proto hash:net hashsize 64 EOF - ALLIPS=$(sqlite3 omr-bypass.db "select ip from ipproto where proto='"$proto"';" ".exit") + ALLIPS=$(sqlite3 /usr/share/omr-bypass/omr-bypass.db "select ip from ipproto where proto='"$proto"';" ".exit") for ip in $ALLIPS; do ipset -q add bypass_$proto $ip done @@ -507,7 +507,7 @@ _bypass_proto_without_ndpi() { if [ "$family" = "ipv4" ] || [ "$family" = "ipv4ipv6" ]; then $IPTABLESRESTORE -w --wait=60 --noflush <<-EOF *mangle - -A omr-bypass-dpi -m set --match-set $proto -j MARK --set-mark 0x539 + -A omr-bypass-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x539 -A omr-bypass-dpi -m mark --mark 0x539 -j RETURN COMMIT EOF @@ -515,7 +515,7 @@ _bypass_proto_without_ndpi() { if [ "$disableipv6" = "0" ] && ([ "$family" = "ipv6" ] || [ "$family" = "ipv4ipv6" ]); then $IP6TABLESRESTORE -w --wait=60 --noflush <<-EOF *mangle - -A omr-bypass6-dpi -m set --match-set $proto -j MARK --set-mark 0x6539 + -A omr-bypass6-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x6539 -A omr-bypass6-dpi -m mark --mark 0x6539 -j RETURN COMMIT EOF @@ -524,7 +524,7 @@ _bypass_proto_without_ndpi() { if [ "$family" = "ipv4" ] || [ "$family" = "ipv4ipv6" ]; then $IPTABLESRESTORE -w --wait=60 --noflush <<-EOF *mangle - -A omr-bypass-dpi -m set --match-set $proto -j MARK --set-mark 0x539$intfid + -A omr-bypass-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x539$intfid -A omr-bypass-dpi -m mark --mark 0x539$intfid -j RETURN COMMIT EOF @@ -532,7 +532,7 @@ _bypass_proto_without_ndpi() { if [ "$disableipv6" = "0" ] && ([ "$family" = "ipv6" ] || [ "$family" = "ipv4ipv6" ]); then $IP6TABLESRESTORE -w --wait=60 --noflush <<-EOF *mangle - -A omr-bypass6-dpi -m set --match-set $proto -j MARK --set-mark 0x6539$intfid + -A omr-bypass6-dpi -m set --match-set bypass_$proto dst -j MARK --set-mark 0x6539$intfid -A omr-bypass6-dpi -m mark --mark 0x6539$intfid -j RETURN COMMIT EOF @@ -542,7 +542,7 @@ _bypass_proto_without_ndpi() { # Use dnsmasq ipset to bypass domains of the proto local domains #domains="$(cat /proc/net/xt_ndpi/host_proto | grep -i $proto: | sed -e "s/$proto://i" -e 's/*//' -e 's/,/ /g')" - domains=$(sqlite3 omr-bypass.db "select host from hostproto where proto='"$proto"';" ".exit") + domains=$(sqlite3 /usr/share/omr-bypass/omr-bypass.db "select host from hostproto where proto='"$proto"';" ".exit") 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 @@ -555,7 +555,7 @@ _bypass_proto_without_ndpi() { for tld in $tlds; do i=$((i+1)) # trim off header - if [ "$i" -lt "12" ] || [ "$i" -gt "50" ]; then + if [ "$i" -lt "2" ] || [ "${#tld}" -gt "3" ]; then continue fi # add to command @@ -566,7 +566,7 @@ _bypass_proto_without_ndpi() { | 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 \ + | sed '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 @@ -1006,8 +1006,7 @@ start_service() { sqlite3 /usr/share/omr-bypass/omr-bypass.db "select distinct(proto) from (select proto from hostproto union all select proto from ipproto) a order by proto;" ".exit" > /usr/share/omr-bypass/omr-bypass-proto.lst config_load omr-bypass config_foreach _add_proto_without_ndpi proto - sort -o /usr/share/omr-bypass/omr-bypass-proto.lst /usr/share/omr-bypass/omr-bypass-proto.lst - + sort < /usr/share/omr-bypass/omr-bypass-proto.lst > /usr/share/omr-bypass/omr-bypass-proto.lst logger -t "omr-bypass" "OMR-ByPass is running" }