pi-hole / web

Pi-hole Dashboard for stats and more
https://pi-hole.net
Other
2k stars 555 forks source link

Teleporter import adds "default" to all domainlist_by_group.json entries. #3020

Closed djadair closed 2 months ago

djadair commented 4 months ago

Versions

Platform

Expected behavior

Create new pihole docker instance and import teleporter file from existing instance. All black/white list domains should be assigned to proper groups.

Actual behavior / bug

Each whitelist domain is assigned to "Default" as well as the desired group.
See: Reddit thread

Steps to reproduce

Steps to reproduce the behavior:

  1. Stop pihole docker container.
  2. Remove all existing config
  3. Start container.
  4. Load transporter file that contains both whitelists and multiple groups.
  5. Each whitelist will be a member of both "Default" and groups specified in json file.

Debug Token

Screenshots

Additional context

Work-around seems to be to load the transporter file twice.

Debug log includes diff of transporter.php that corrected the issue. By processing the domainlist_by_group.json file LAST the group membership works properly.

root@photon-5 [ ~ ]# diff -Naur teleporter.orig teleporter.php
--- teleporter.orig     2024-05-08 20:07:55.000000000 +0000
+++ teleporter.php      2024-05-09 02:45:02.254828282 +0000
@@ -451,14 +451,6 @@
                 $importedsomething = true;
             }

-            if ((isset($_POST['whitelist']) || isset($_POST['regex_whitelist'])
-                || isset($_POST['blacklist']) || isset($_POST['regex_blacklist']))
-                && $file->getFilename() === 'domainlist_by_group.json') {
-                $num = archive_restore_table($file, 'domainlist_by_group', $flushtables);
-                echo 'Processed black-/whitelist group assignments ('.$num.noun($num).")<br>\n";
-                $importedsomething = true;
-            }
-
             if (isset($_POST['adlist']) && $file->getFilename() === 'adlist_by_group.json') {
                 $num = archive_restore_table($file, 'adlist_by_group', $flushtables);
                 echo 'Processed adlist group assignments ('.$num.noun($num).")<br>\n";
@@ -550,6 +542,18 @@
             }
         }

+        foreach (new RecursiveIteratorIterator($archive) as $file) {
+
+            if ((isset($_POST['whitelist']) || isset($_POST['regex_whitelist'])
+                || isset($_POST['blacklist']) || isset($_POST['regex_blacklist']))
+                && $file->getFilename() === 'domainlist_by_group.json') {
+                $num = archive_restore_table($file, 'domainlist_by_group', $flushtables);
+                echo 'Processed black-/whitelist group assignments ('.$num.noun($num).")<br>\n";
+                $importedsomething = true;
+            }
+
+       }
+
         // do we need a full restart of Pi-hole or reloading the lists?
         if ($fullpiholerestart) {
             pihole_execute('restartdns');
github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.