mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
Services / Unbound - add missing alias descriptions (including migration). while here also make the migration a bit more resilient for hostname validation issues. closes https://github.com/opnsense/core/issues/5695
This commit is contained in:
parent
626c3dbf55
commit
3a9763d527
@ -176,7 +176,7 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
}
|
||||
return $this->searchBase(
|
||||
'aliases.alias',
|
||||
['enabled', 'host', 'hostname', 'domain'],
|
||||
['enabled', 'host', 'hostname', 'domain', 'description'],
|
||||
"sequence",
|
||||
$filter_func
|
||||
);
|
||||
|
||||
@ -23,4 +23,10 @@
|
||||
<type>text</type>
|
||||
<help>Domain of the host, e.g. example.com</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>alias.description</id>
|
||||
<label>Description</label>
|
||||
<type>text</type>
|
||||
<help>You may enter a description here for your reference (not parsed)</help>
|
||||
</field>
|
||||
</form>
|
||||
|
||||
@ -61,8 +61,14 @@ class M1_0_1 extends BaseModelMigration
|
||||
'server' => $old_host->rr == 'A' || $old_host->rr == 'AAAA' ? $old_host->ip : null,
|
||||
'mxprio' => $old_host->rr == 'MX' ? $old_host->mxprio : null,
|
||||
'mx' => $old_host->rr == 'MX' ? $old_host->mx : null,
|
||||
'description' => !empty($old_host->descr) ? $old_host->descr : null
|
||||
'description' => !empty($old_host->descr) ? substr($old_host->descr, 0, 255) : null
|
||||
];
|
||||
if (strpos($host_data['hostname'], '_') !== false) {
|
||||
// legacy module accepted invalid hostnames with underscores.
|
||||
$host_data['enabled'] = 0;
|
||||
$host_data['hostname'] = str_replace('_', 'x', $host_data['hostname']);
|
||||
$host_data['description'] = sprintf("disabled invalid record %s", $host_data['hostname']);
|
||||
}
|
||||
|
||||
$new_host->setNodes($host_data);
|
||||
|
||||
@ -77,7 +83,8 @@ class M1_0_1 extends BaseModelMigration
|
||||
'enabled' => 1,
|
||||
'host' => $uuid,
|
||||
'domain' => !empty($old_alias->domain) ? $old_alias->domain : null,
|
||||
'hostname' => !empty($old_alias->host) ? $old_alias->host : null
|
||||
'hostname' => !empty($old_alias->host) ? $old_alias->host : null,
|
||||
'description' => !empty($old_alias->descr) ? substr($old_alias->descr, 0, 255) : null
|
||||
];
|
||||
$new_alias->setNodes($alias_data);
|
||||
}
|
||||
@ -91,7 +98,7 @@ class M1_0_1 extends BaseModelMigration
|
||||
'enabled' => 1,
|
||||
'domain' => $old_domain->domain,
|
||||
'server' => $old_domain->ip,
|
||||
'description' => !empty($old_domain->descr) ? $old_domain->descr : null
|
||||
'description' => !empty($old_domain->descr) ? substr($old_domain->descr, 0, 255) : null
|
||||
];
|
||||
$new_domain->setNodes($domain_data);
|
||||
}
|
||||
|
||||
@ -213,6 +213,11 @@
|
||||
<mask>/^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i</mask>
|
||||
<ValidationMessage>A valid domain must be specified.</ValidationMessage>
|
||||
</domain>
|
||||
<description type="TextField">
|
||||
<Required>N</Required>
|
||||
<mask>/^(.){1,255}$/u</mask>
|
||||
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
|
||||
</description>
|
||||
</alias>
|
||||
</aliases>
|
||||
<domains>
|
||||
|
||||
@ -246,6 +246,7 @@ $( document ).ready(function() {
|
||||
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
|
||||
<th data-column-id="hostname" data-type="string">{{ lang._('Host') }}</th>
|
||||
<th data-column-id="domain" data-type="string">{{ lang._('Domain') }}</th>
|
||||
<th data-column-id="description" data-type="string">{{ lang._('Description') }}</th>
|
||||
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user