From: Alan T. DeKok Date: Wed, 15 Nov 2023 15:30:53 +0000 (-0500) Subject: use local dictionary X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a2687a2311cf695360f07f3f8ddb8a914155d77;p=thirdparty%2Ffreeradius-server.git use local dictionary --- diff --git a/raddb/sites-available/coa-relay b/raddb/sites-available/coa-relay index fbe55d091d5..2dff27c0942 100644 --- a/raddb/sites-available/coa-relay +++ b/raddb/sites-available/coa-relay @@ -101,6 +101,11 @@ server coa { } } + dictionary { + uint32 sent-counter + string user-session + } + # # Receive a CoA request # @@ -127,25 +132,24 @@ server coa { # # Example MySQL lookup # -# &control.Tmp-String-0 := %sql("SELECT IFNULL(GROUP_CONCAT(CONCAT(nasipaddress,'#',acctsessionid) separator '|'),'') FROM (SELECT * FROM radacct WHERE ('%{User-Name}'='' OR UserName='%{User-Name}') AND ('%{Acct-Session-Id}'='' OR acctsessionid = '%{Acct-Session-Id}') AND AcctStopTime IS NULL) a") +# &control.user-session := %sql("SELECT IFNULL(GROUP_CONCAT(CONCAT(nasipaddress,'#',acctsessionid) separator '|'),'') FROM (SELECT * FROM radacct WHERE ('%{User-Name}'='' OR UserName='%{User-Name}') AND ('%{Acct-Session-Id}'='' OR acctsessionid = '%{Acct-Session-Id}') AND AcctStopTime IS NULL) a") # # Example PostgreSQL lookup # -# &control.Tmp-String-0 := %sql("SELECT STRING_AGG(CONCAT(nasipaddress,'#',acctsessionid),'|') FROM (SELECT * FROM radacct WHERE ('%{User-Name}'='' OR UserName='%{User-Name}') AND ('%{Acct-Session-Id}'='' OR acctsessionid = '%{Acct-Session-Id}') AND AcctStopTime IS NULL) a") +# &control.user-session := %sql("SELECT STRING_AGG(CONCAT(nasipaddress,'#',acctsessionid),'|') FROM (SELECT * FROM radacct WHERE ('%{User-Name}'='' OR UserName='%{User-Name}') AND ('%{Acct-Session-Id}'='' OR acctsessionid = '%{Acct-Session-Id}') AND AcctStopTime IS NULL) a") # # Keep a count of what we send. # - &control.Tmp-Integer-0 := 0 + &control.sent-counter := 0 # # Split the string and split into pieces. # - if ("%explode(&control.Tmp-String-0, '|')") { - - foreach &control.Tmp-String-0 { + if ("%explode(&control.user-session, '|')") { + foreach &control.user-session { # # Send an update for each session we find. # @@ -210,7 +214,7 @@ server coa { # # Increment count of sent updates # - &parent.control.Tmp-Integer-0 += 1 + &parent.control.sent-counter += 1 radius-originate-coa-192.0.2.1 @@ -237,9 +241,9 @@ server coa { # # Report what we did # - if (&control.Tmp-Integer-0) { + if (&control.sent-counter) { &reply += { - &Reply-Message = "Sent updates for %{control.Tmp-Integer-0} active sessions" + &Reply-Message = "Sent updates for %{control.sent-counter} active sessions" } ok