Przeglądaj źródła

Adding users to the blocklist

Bob Mottram 7 lat temu
rodzic
commit
cbcdc4dd40
1 zmienionych plików z 11 dodań i 8 usunięć
  1. 11
    8
      src/freedombone-utils-firewall

+ 11
- 8
src/freedombone-utils-firewall Wyświetl plik

@@ -465,6 +465,7 @@ function firewall_block_domain {
465 465
     blocked_domain="$1"
466 466
     if [[ "$blocked_domain" == *'@'* ]]; then
467 467
         # Don't try to block email/microblog addresses
468
+        echo "${blocked_domain}" >> $FIREWALL_DOMAINS
468 469
         return
469 470
     fi
470 471
     if ! grep -q "$blocked_domain" $FIREWALL_DOMAINS; then
@@ -538,15 +539,17 @@ function firewall_refresh_blocklist {
538 539
 function firewall_unblock_domain {
539 540
     unblocked_domain="$1"
540 541
     if grep -q "${unblocked_domain}" $FIREWALL_DOMAINS; then
541
-        hexstr=$(domain_to_hex_string $unblocked_domain)
542
-        iptables -D INPUT -p udp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
543
-        iptables -D INPUT -p tcp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
544
-        iptables -D OUTPUT -p udp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
545
-        iptables -D OUTPUT -p tcp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
546
-        iptables -D FORWARD -p udp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
547
-        iptables -D FORWARD -p tcp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
542
+        if [[ "${unblocked_domain}" != *'@'* ]]; then
543
+            hexstr=$(domain_to_hex_string $unblocked_domain)
544
+            iptables -D INPUT -p udp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
545
+            iptables -D INPUT -p tcp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
546
+            iptables -D OUTPUT -p udp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
547
+            iptables -D OUTPUT -p tcp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
548
+            iptables -D FORWARD -p udp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
549
+            iptables -D FORWARD -p tcp --dport 53 -m string --hex-string "$hexstr" --algo bm -j DROP
550
+            save_firewall_settings
551
+        fi
548 552
         sed -i "/${unblocked_domain}/d" $FIREWALL_DOMAINS
549
-        save_firewall_settings
550 553
     fi
551 554
 }
552 555