From 4ba91d8cbe851523179b84ccbdc04bd9d2b31b63 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Mon, 17 Nov 2025 17:39:41 -0700 Subject: [PATCH 1/4] fix(DHCPServer): improve init interface qualifiers #781 Instead of expecting interface types, just check if the interface has a IPv4 literal assigned. --- .../files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc index bd254cd9..b36aad34 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc @@ -261,7 +261,7 @@ class DHCPServer extends Model { # Loop through each defined interface foreach ($this->get_config('interfaces', []) as $if_id => $if) { # Skip this interface if it is not a static interface or the subnet value is greater than or equal to 31 - if (empty($if['ipaddr']) or $if['ipaddr'] !== 'static' or $if->subnet->value >= 31) { + if (empty($if['ipaddr']) or !is_ipaddrv4($if['ipaddr']) or $if->subnet->value >= 31) { continue; } From eadf2aabd8b2c07cfd40e8359f0bccda722bdec6 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Mon, 17 Nov 2025 17:41:32 -0700 Subject: [PATCH 2/4] test(DHCPServer): ensure iface exemption test removes any previously initialized iface for opt1 --- .../local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc index 90173bf4..fb7196cd 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsDHCPServerTestCase.inc @@ -523,6 +523,9 @@ class APIModelsDHCPServerTestCase extends TestCase { * Ensures non-static interfaces are exempt from DHCP server initialization. This is a regression test for #781 */ public function test_non_static_interfaces_exempt_from_dhcp_server_initialization(): void { + # Ensure no config entry exists for the `opt1` DHCP server + Model::del_config('dhcpd/opt1'); + # Temporarily add a mock interface using pppoe for IPv4 Model::set_config('interfaces/opt1/ipaddr', 'pppoe'); From 195f2ebae12e9ff9c699af1709d30f697f82a90f Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Mon, 17 Nov 2025 17:43:56 -0700 Subject: [PATCH 3/4] feat(NativeSchema): include API version in native schema --- .../files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc index 75efcf1a..a42e2db3 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Schemas/NativeSchema.inc @@ -10,6 +10,7 @@ use RESTAPI\Core\Model; use RESTAPI\Core\Schema; use RESTAPI\Fields\ForeignModelField; use RESTAPI\Fields\NestedModelField; +use RESTAPI\Models\RESTAPIVersion; use function RESTAPI\Core\Tools\get_classes_from_namespace; /** @@ -129,7 +130,8 @@ class NativeSchema extends Schema { * @return string The full schema string for this Schema class in JSON format */ public function get_schema_str(): string { - $schema = ['endpoints' => [], 'models' => []]; + $version = new RESTAPIVersion(); + $schema = ['version' => $version->current_version->value, 'endpoints' => [], 'models' => []]; # Get all endpoint metadata foreach (get_classes_from_namespace('RESTAPI\Endpoints') as $endpoint_class) { From cda9ffc415a5af2af1c5bbcee32cd13fbb01a8f9 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Mon, 17 Nov 2025 17:47:43 -0700 Subject: [PATCH 4/4] docs(NativeSchema): include version in native schema example --- docs/NATIVE_SCHEMA.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/NATIVE_SCHEMA.md b/docs/NATIVE_SCHEMA.md index 6ef47ffd..192a6e4d 100644 --- a/docs/NATIVE_SCHEMA.md +++ b/docs/NATIVE_SCHEMA.md @@ -20,6 +20,7 @@ classes. Below is a basic outline of the schema's structure: ```json { + "version": "v0.0.0", "endpoints": { "/endpoint/url/path": { ...