Skip to content

Commit 0d43c51

Browse files
Fixed bad file override for pfSense 2.5.0, fixed bug that prevented interfaces from being deleted on pfSense 2.5.0, fixed unbound host override issue that prevent IPv4 and IPv6 addresses, bumps version to v1.1.5
1 parent 066ec98 commit 0d43c51

16 files changed

Lines changed: 8132 additions & 58 deletions

File tree

pfSense-pkg-API/files/etc/inc/api/framework/APIResponse.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function get($id, $data=[], $all=false) {
278278
"status" => "bad request",
279279
"code" => 400,
280280
"return" => $id,
281-
"message" => "Unbound host override already exists"
281+
"message" => "Unbound host override already exists with this IP address type"
282282
],
283283
2011 => [
284284
"status" => "bad request",

pfSense-pkg-API/files/etc/inc/api/framework/APITools.inc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function create_jwt_server_key($rotate=false) {
119119
# Create a new server key if one is not set
120120
if (empty($api_config["server_key"]) or $rotate === true) {
121121
$config["installedpackages"]["package"][$pkg_index]["conf"]["server_key"] = bin2hex(random_bytes(32));
122-
write_config();
122+
write_config("API server key created");
123123
}
124124
}
125125

@@ -691,34 +691,36 @@ function unbound_reload_config() {
691691
}
692692

693693
// Check if a DNS Resolver (Unbound) host override already exists
694-
function is_unbound_fqdn($hostname, $domain, $instance_id=null) {
694+
function is_unbound_fqdn($hostname, $domain, $ip=null, $instance_id=null) {
695695
# Local variables
696696
global $config;
697697
$curr_hosts = (array_key_exists("hosts", $config["unbound"])) ? $config["unbound"]["hosts"] : [];
698-
$host_exists = false;
699698
$index = 0;
700699

701700
# Loop through each host override and check if the FQDN already exists
702-
foreach ($curr_hosts as $host_ent) {
701+
foreach ($curr_hosts as $ent) {
703702
# Check the FQDN matches this entry
704-
if ($host_ent["host"] === $hostname and $host_ent["domain"] === $domain) {
705-
# If we are working with an existing instance, allow existing FQDN if ID matches
706-
if ($index !== $instance_id) {
707-
return true;
703+
if ($ent["host"] === $hostname and $ent["domain"] === $domain) {
704+
# Host overrides are allowed an IPv4 and IPv6 address, check if it already has one.
705+
if (!$ip or (is_ipaddrv4($ent["ip"]) and is_ipaddrv4($ip)) or (is_ipaddrv6($ent["ip"]) and is_ipaddrv6($ip))){
706+
# If we are working with an existing instance, allow existing FQDN if ID matches
707+
if ($index !== $instance_id) {
708+
return true;
709+
}
708710
}
709711
}
710712

711713
# Check FQDN within host override aliases as well
712-
if (is_array($host_ent["aliases"])) {
713-
foreach ($host_ent["aliases"]["item"] as $alias_ent) {
714+
if (is_array($ent["aliases"])) {
715+
foreach ($ent["aliases"]["item"] as $alias_ent) {
714716
if ($alias_ent["host"] === $hostname and $alias_ent["domain"] === $domain) {
715717
return true;
716718
}
717719
}
718720
}
719721
$index++;
720722
}
721-
return $host_exists;
723+
return false;
722724
}
723725

724726
// Get a complete config list of ALL interfaces. Based off interfaces_assign.php

pfSense-pkg-API/files/etc/inc/api/framework/overrides/system.inc renamed to pfSense-pkg-API/files/etc/inc/api/framework/overrides/2.4.4-RELEASE/system.inc

File renamed without changes.

0 commit comments

Comments
 (0)