Skip to content

Commit

Permalink
Fixes logic when pfacct and radius-acct are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
fdurand committed Jun 5, 2024
1 parent b202bb7 commit d5069e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/pf/services/manager/pfacct.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use Template;
use pf::cluster;
use pf::config qw(
$management_network
%Config
);

extends 'pf::services::manager';
Expand Down Expand Up @@ -61,12 +62,19 @@ sub generate_container_environments {
my $management_ip = $management_network->tag('ip');

my $port = '1813';
if ($cluster_enabled) {
my $listeningIp = $management_ip;
if ($cluster_enabled || isenabled($Config{services}{radiusd_acct})) {
$port = '1823';
}
if ($cluster_enabled && isenabled($Config{services}{radiusd_acct})) {
$port = '1833';
}
if (isenabled($Config{services}{radiusd_acct})) {
$listeningIp = '127.0.0.1';
}
my $vars = {
env_dict => {
PFACCT_ADDRESS=> "$management_ip:$port",
PFACCT_ADDRESS=> "$listeningIp:$port",
},
};
$tt->process("/usr/local/pf/containers/environment.template", $vars, "/usr/local/pf/var/conf/acct.env") or die $tt->error();
Expand Down
12 changes: 10 additions & 2 deletions lib/pf/services/manager/radiusd_child.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,15 @@ EOT

if(isenabled($Config{services}{pfacct})) {
my $management_ip = defined($management_network->tag('vip')) ? $management_network->tag('vip') : $management_network->tag('ip');
$tags{'pfacct'} = <<"EOT";
my $port = '1813';
if ($cluster_enabled || isenabled($Config{services}{radiusd_acct})) {
$port = '1823';
}
if ($cluster_enabled && isenabled($Config{services}{radiusd_acct})) {
$port = '1833';
}

$tags{'pfacct'} = <<"EOT";
# pfacct configuration
realm pfacct {
Expand All @@ -1094,7 +1102,7 @@ home_server_pool pfacct_pool {
home_server pfacct_local {
type = acct
ipaddr = 127.0.0.1
port = 1813
port = $port
secret = '$local_secret'
src_ipaddr = $management_ip
}
Expand Down

0 comments on commit d5069e6

Please sign in to comment.