Skip to content

Commit

Permalink
unbound: fix migration 1.0.3 for #6550
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed May 8, 2023
1 parent c29cd77 commit 378d9a3
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Copyright (C) 2022 Deciso B.V.
* Copyright (C) 2022-2023 Deciso B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -33,7 +33,7 @@

class M1_0_3 extends BaseModelMigration
{
private $legacy_format = array(
private $legacy_format = [
'outgoing_num_tcp',
'incoming_num_tcp',
'num_queries_per_thread',
Expand All @@ -54,7 +54,7 @@ class M1_0_3 extends BaseModelMigration
'serveexpired',
'qnameminstrict',
'msgcachesize'
);
];

/**
* Migrate older models into shared model
Expand All @@ -63,19 +63,21 @@ class M1_0_3 extends BaseModelMigration
public function run($model)
{
$config = Config::getInstance()->object();
$legacy_config = [];

$legacy_config = array();
foreach ($config->unbound->children() as $key => $value) {
if (in_array($key, $this->legacy_format) && !empty((string)$value)) {
if ($key == 'msgcachesize') {
$legacy_config[$key] = (string)$value . 'm';
/* Mimic legacy behaviour for the msg cache size value (if applied) */
$legacy_config['rrsetcachesize'] = ($value * 2) . 'm';
continue;
}

if ($key == 'num_queries_per_thread') {
} elseif ($key == 'dnssecstripped') {
$legacy_config['dnssecstripped'] = empty((string)$value) ? 0 : 1;
continue;
} elseif ($key == 'num_queries_per_thread') {
$legacy_config['outgoingrange'] = $value * 2;
/* FALLTHROUGH */
}

/* handle differing keys, underscore got removed in model transition */
Expand Down

0 comments on commit 378d9a3

Please sign in to comment.