Skip to content

Commit 340f440

Browse files
fix(HAProxyBackendServer): use a default callable to assign serverid default, not a fixed default
1 parent df4ee3a commit 340f440

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyBackendServer.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class HAProxyBackendServer extends Model {
8383
help_text: 'Enables or disables verifying the SSL/TLS certificate when forwarding to this backend server.',
8484
);
8585
$this->serverid = new IntegerField(
86-
default: rand(100, 1000), # TODO: Ensure this value is unique from Backends and Backend servers
86+
default_callable: 'get_serverid_default',
8787
editable: false,
8888
read_only: true,
8989
verbose_name: 'Server ID',
@@ -100,6 +100,14 @@ class HAProxyBackendServer extends Model {
100100
parent::__construct($id, $parent_id, $data, ...$options);
101101
}
102102

103+
/**
104+
* Obtains the random default for the serverid field
105+
* @returns int A random integer ID
106+
*/
107+
public function get_serverid_default(): int {
108+
return rand(100, 1000); # TODO: Ensure this value is unique from Backends and Backend servers
109+
}
110+
103111
/**
104112
* Ensures haproxy is marked as dirty before applying.
105113
*/

0 commit comments

Comments
 (0)