From 86b00d6a6dd226aeb3bb510caa5dc721613ff565 Mon Sep 17 00:00:00 2001 From: Durand Fabrice Date: Tue, 14 Jan 2025 14:15:13 -0500 Subject: [PATCH] PfacctRateLimitCacheTtl is a string --- go/cmd/pfacct/pfacct.go | 10 ++++++---- go/pfconfigdriver/structs.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/go/cmd/pfacct/pfacct.go b/go/cmd/pfacct/pfacct.go index d5f05f87ae5..5b61f9b86ee 100644 --- a/go/cmd/pfacct/pfacct.go +++ b/go/cmd/pfacct/pfacct.go @@ -174,10 +174,12 @@ func (pfAcct *PfAcct) SetupConfig(ctx context.Context) { pfconfigdriver.FetchDecodeSocket(ctx, &RadiusConfiguration) pfAcct.ProcessBandwidthAcct = sharedutils.IsEnabled(RadiusConfiguration.ProcessBandwidthAccounting) pfAcct.RateLimit = sharedutils.IsEnabled(RadiusConfiguration.PfacctRateLimit) - pfAcct.PfacctRateLimitCacheTtl = RadiusConfiguration.PfacctRateLimitCacheTtl - pfAcct.RateLimitCache = cache.New(time.Duration(RadiusConfiguration.PfacctRateLimitCacheTtl)*time.Minute, 10*time.Minute) - pfAcct.MacNasCache = cache.New(time.Duration(RadiusConfiguration.PfacctRateLimitCacheTtl)*time.Minute, 10*time.Minute) - + pfAcct.PfacctRateLimitCacheTtl = 5 + if i, err := strconv.Atoi(RadiusConfiguration.PfacctRateLimitCacheTtl); err != nil { + pfAcct.PfacctRateLimitCacheTtl = i + } + pfAcct.RateLimitCache = cache.New(time.Duration(pfAcct.PfacctRateLimitCacheTtl)*time.Minute, 10*time.Minute) + pfAcct.MacNasCache = cache.New(time.Duration(pfAcct.PfacctRateLimitCacheTtl)*time.Minute, 10*time.Minute) if !pfAcct.ProcessBandwidthAcct { logInfo(ctx, "Not processing bandwidth accounting records. To enable set radius_configuration.process_bandwidth_accounting = enabled") } diff --git a/go/pfconfigdriver/structs.go b/go/pfconfigdriver/structs.go index 023e43b6074..e6c7752c552 100644 --- a/go/pfconfigdriver/structs.go +++ b/go/pfconfigdriver/structs.go @@ -712,7 +712,7 @@ type PfConfRadiusConfiguration struct { PfacctWorkers string `json:"pfacct_workers"` PfacctWorkQueueSize string `json:"pfacct_work_queue_size"` PfacctRateLimit string `json:"pfacct_rate_limit"` - PfacctRateLimitCacheTtl int `json:"pfacct_rate_limit_cache_ttl"` + PfacctRateLimitCacheTtl string `json:"pfacct_rate_limit_cache_ttl"` } type PfQueueConfig struct {