diff --git a/ajax/adblock/update_blocklist.php b/ajax/adblock/update_blocklist.php index 86f326b44..796959f12 100644 --- a/ajax/adblock/update_blocklist.php +++ b/ajax/adblock/update_blocklist.php @@ -4,21 +4,50 @@ require_once '../../includes/config.php'; if (isset($_POST['blocklist_id'])) { - $blocklist_id = $_POST['blocklist_id']; - $notracking_url = "https://raw.githubusercontent.com/notracking/hosts-blocklists/master/"; + $blocklist_id = escapeshellcmd($_POST['blocklist_id']); switch ($blocklist_id) { - case "notracking-hostnames": - $file = "hostnames.txt"; - break; - case "notracking-domains": - $file = "domains.txt"; - break; + case "StevenBlack/hosts \(default\)": + $list_url = "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"; + $dest_file = "hostnames.txt"; + break; + case "badmojr/1Hosts \(Mini\)": + $list_url = "https://badmojr.github.io/1Hosts/mini/hosts.txt"; + $dest_file = "hostnames.txt"; + break; + case "badmojr/1Hosts \(Lite\)": + $list_url = "https://badmojr.github.io/1Hosts/Lite/hosts.txt"; + $dest_file = "hostnames.txt"; + break; + case "badmojr/1Hosts \(Pro\)": + $list_url = "https://badmojr.github.io/1Hosts/Pro/hosts.txt"; + $dest_file = "hostnames.txt"; + break; + case "badmojr/1Hosts \(Xtra\)": + $list_url = "https://badmojr.github.io/1Hosts/Xtra/hosts.txt"; + $dest_file = "hostnames.txt"; + break; + case "oisd/big \(default\)": + $list_url = "https://big.oisd.nl/dnsmasq"; + $dest_file = "domains.txt"; + break; + case "oisd/small": + $list_url = "https://small.oisd.nl/dnsmasq"; + $dest_file = "domains.txt"; + break; + case "oisd/nsfw": + $list_url = "https://nsfw.oisd.nl/dnsmasq"; + $dest_file = "domains.txt"; + break; } - $blocklist = $notracking_url . $file; + $blocklist = $list_url . $dest_file; + $dest = substr($dest_file, 0, strrpos($dest_file, ".")); - exec("sudo /etc/raspap/adblock/update_blocklist.sh $blocklist $file " .RASPI_ADBLOCK_LISTPATH, $return); - $jsonData = ['return'=>$return]; + exec("sudo /etc/raspap/adblock/update_blocklist.sh $list_url $dest_file " .RASPI_ADBLOCK_LISTPATH, $return); + $jsonData = ['return'=>$return,'list'=>$dest]; + echo json_encode($jsonData); +} else { + $jsonData = ['return'=>2,'output'=>['Error getting data']]; echo json_encode($jsonData); } diff --git a/app/js/custom.js b/app/js/custom.js index c18ea8cef..baa34c7a6 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -441,7 +441,8 @@ function setHardwareModeTooltip() { * Interface elements are updated to indicate current progress, status. */ function updateBlocklist() { - var blocklist_id = $('#cbxblocklist').val(); + var opt = $('#cbxblocklist option:selected'); + var blocklist_id = opt.val(); var csrfToken = $('meta[name=csrf_token]').attr('content'); if (blocklist_id == '') { return; } $('#cbxblocklist-status').find('i').removeClass('fas fa-check').addClass('fas fa-cog fa-spin'); @@ -451,7 +452,7 @@ function updateBlocklist() { if (jsonData['return'] == '0') { $('#cbxblocklist-status').find('i').removeClass('fas fa-cog fa-spin').addClass('fas fa-check'); $('#cbxblocklist-status').removeClass('check-progress').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700); - $('#'+blocklist_id).text("Just now"); + $('#blocklist-'+jsonData['list']).text("Just now"); } }) } diff --git a/config/blocklists.json b/config/blocklists.json index 5c76e464c..7138c451c 100644 --- a/config/blocklists.json +++ b/config/blocklists.json @@ -1,6 +1,17 @@ { - "notracking/hosts-blocklist": [ - "notracking-hostnames", - "notracking-domains" - ] + "StevenBlack/hosts": [ + "StevenBlack/hosts (default)" + ], + "badmojr/hosts": [ + "badmojr/1Hosts (Mini)", + "badmojr/1Hosts (Lite)", + "badmojr/1Hosts (Pro)", + "badmojr/1Hosts (Xtra)" + ], + "OISD/domains": [ + "oisd/big (default)", + "oisd/small", + "oisd/nsfw" + ] } + diff --git a/includes/adblock.php b/includes/adblock.php index 021f4d2c2..0d171e25f 100755 --- a/includes/adblock.php +++ b/includes/adblock.php @@ -84,7 +84,7 @@ function DisplayAdBlockConfig() $handle = fopen(RASPI_DHCPCD_LOG, "r"); if ($handle) { while (($line = fgets($handle)) !== false) { - if (preg_match('/(0.0.0.0)/', $line)) { + if (preg_match('/(is 0.0.0.0)|(using only locally-known addresses)/', $line)) { $adblock_log .= $line; } } diff --git a/installers/common.sh b/installers/common.sh index c6981f677..a98d0f84c 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -27,7 +27,8 @@ readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf" readonly raspap_network="$raspap_dir/networking/" readonly raspap_router="/etc/lighttpd/conf-available/50-raspap-router.conf" readonly rulesv4="/etc/iptables/rules.v4" -readonly notracking_url="https://raw.githubusercontent.com/notracking/hosts-blocklists/master/" +readonly blocklist_hosts="https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" +readonly blocklist_domains="https://big.oisd.nl/dnsmasq" webroot_dir="/var/www/html" if [ "$insiders" == 1 ]; then @@ -338,7 +339,7 @@ function _install_lighttpd_configs() { # Prompt to install ad blocking function _prompt_install_adblock() { - _install_log "Configure ad blocking (Beta)" + _install_log "Configure ad blocking" echo -n "Install ad blocking and enable list management? [Y/n]: " if [ "$assume_yes" == 0 ]; then read answer < /dev/tty @@ -354,7 +355,7 @@ function _prompt_install_adblock() { fi } -# Download notracking adblock lists and enable option +# Download adblock lists and enable option function _install_adblock() { _install_log "Creating ad blocking base configuration (Beta)" if [ ! -d "$raspap_dir/adblock" ]; then @@ -363,12 +364,12 @@ function _install_adblock() { fi if [ ! -f /tmp/hostnames.txt ]; then echo "Fetching latest hostnames list" - wget ${notracking_url}hostnames.txt -q --show-progress --progress=bar:force -O /tmp/hostnames.txt 2>&1 \ + wget ${blocklist_hosts} -q --show-progress --progress=bar:force -O /tmp/hostnames.txt 2>&1 \ || _install_status 1 "Unable to download notracking hostnames" fi if [ ! -f /tmp/domains.txt ]; then echo "Fetching latest domains list" - wget ${notracking_url}domains.txt -q --show-progress --progress=bar:force -O /tmp/domains.txt 2>&1 \ + wget ${blocklist_domains} -q --show-progress --progress=bar:force -O /tmp/domains.txt 2>&1 \ || _install_status 1 "Unable to download notracking domains" fi echo "Adding blocklists to $raspap_dir/adblock" diff --git a/installers/update_blocklist.sh b/installers/update_blocklist.sh index 81e3d931d..0ba729ae5 100755 --- a/installers/update_blocklist.sh +++ b/installers/update_blocklist.sh @@ -15,7 +15,7 @@ update_url=$1 file=$2 destination=$3 -wget -q ${update_url} -O ${destination}${file} &> /dev/null +wget -q --no-use-server-timestamps ${update_url} -O ${destination}${file} &> /dev/null echo "$?" diff --git a/templates/adblock/general.php b/templates/adblock/general.php index 22845e660..a6d144391 100644 --- a/templates/adblock/general.php +++ b/templates/adblock/general.php @@ -19,9 +19,9 @@
-