Login  Register

Re: which file holds the Web Filter setting

Posted by hans2 on Feb 16, 2016; 7:40pm
URL: https://itus.accessinnov.com/which-file-holds-the-Web-Filter-setting-tp74p87.html

 sh /etc/update_blacklist.sh :

#!/bin/sh
#set +x
# Get block redirect domain ip address
ip_regex="[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"
blockdomain_ip=$(uci get network.blockdomain.ipaddr)
blacklist_ip=`head -1 /etc/itus/lists/ads | cut -d'/' -f3`

if [[ `echo $blockdomain_ip | grep -o $ip_regex` && `echo $blacklist_ip | grep -o $ip_regex` && "$blockdomain_ip" != "$blacklist_ip" ]]
then
        #Process blacklist in parallel to increase performance
        blacklist=`echo "porn drugs gambling proxies dating blasphemy racism malicious piracy social ads illegal"`
        for list in ${blacklist}
        do
                sed -i -E "s/\/[0-9]+.[0-9]+.[0-9]+.[0-9]+$|\/$/\/$blockdomain_ip/g" /etc/itus/lists/$list &
        done

        # Wait for the last process to complete before exiting
        wait
        logger -s "update_blacklist" -t "Updated redirect ip address: $blockdomain_ip"
fi

this will update all list files (see var blacklist) no matter the settings in Service>Web Filter>Content filtering -and- all the read/writes with it.


Please check this changed script:
#!/bin/sh
#set +x
# Get block redirect domain ip address
ip_regex="[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+"
blockdomain_ip=$(uci get network.blockdomain.ipaddr)
blacklist_ip=`head -1 /etc/itus/lists/ads | cut -d'/' -f3`

if [[ `echo $blockdomain_ip | grep -o $ip_regex` && `echo $blacklist_ip | grep -o $ip_regex` && "$blockdomain_ip" != "$blacklist_ip" ]]
then
        #Process blacklist in parallel to increase performance
        #        blacklist=`echo "porn drugs gambling proxies dating blasphemy racism malicious piracy social ads illegal"`
        #        for list in ${blacklist}
        blacklist=`grep content_ /etc/config/e2guardian | grep \'1\' | cut -d "_" -f 2 | cut -d ' ' -f 1`
        for list in $blacklist
        do
                sed -i -E "s/\/[0-9]+.[0-9]+.[0-9]+.[0-9]+$|\/$/\/$blockdomain_ip/g" /etc/itus/lists/$list &
        done

        # Wait for the last process to complete before exiting
        wait
        logger -s "update_blacklist" -t "Updated redirect ip address: $blockdomain_ip"
fi

based on /etc/itus/write-categories.sh.
No more: Shield Pro v1, Chaos Calmer, FW 1.51 SP1