From 03577ba3ca185bad62b8e9e07c2ccb045508a1b2 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 4 Mar 2025 09:32:24 +0100 Subject: [PATCH] Services: Unbound DNS - fix model migration, between versions the "domain" container was moved to "dots", which means we can only move items into the new spot during migrations of old configurations. closes https://github.com/opnsense/core/issues/8395 This is certainly a downside of data migrations in general, when looking at the actual target, we don't have all the versions in between available. which means breakage is possible when skipping a lot of versions on our end. --- .../OPNsense/Unbound/Migrations/M1_0_1.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/opnsense/mvc/app/models/OPNsense/Unbound/Migrations/M1_0_1.php b/src/opnsense/mvc/app/models/OPNsense/Unbound/Migrations/M1_0_1.php index 6b6637526..588e10ce7 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Unbound/Migrations/M1_0_1.php +++ b/src/opnsense/mvc/app/models/OPNsense/Unbound/Migrations/M1_0_1.php @@ -93,14 +93,16 @@ class M1_0_1 extends BaseModelMigration if (!empty($config->unbound->domainoverrides)) { foreach ($config->unbound->domainoverrides as $old_domain) { - $new_domain = $model->domains->domain->add(); - $domain_data = [ - 'enabled' => 1, - 'domain' => $old_domain->domain, - 'server' => $old_domain->ip, - 'description' => !empty($old_domain->descr) ? substr($old_domain->descr, 0, 255) : null - ]; - $new_domain->setNodes($domain_data); + $new_item = $model->dots->dot->add(); + $new_item->enabled = '1'; + $new_item->type = 'forward'; + $new_item->domain = (string)$domain->domain; + $parts = explode('@', (string)$old_domain->ip); + $new_item->server = $parts[0]; + if (isset($parts[1])) { + $new_item->port = $parts[1]; + } + $new_item->description = !empty($old_domain->descr) ? substr($old_domain->descr, 0, 255) : ''; } } }