Skip to content

Commit

Permalink
more remove alternation
Browse files Browse the repository at this point in the history
this time where the second argument is just a string, and not
an attribute reference

perl -p -i -e 's/%{%{([^%{}]+)}:-([^%{}]+)}/%{\&$1 || $2}/g'  $(git grep -l ':-' raddb/)

and then re-build the antora docs from the raddb sources
  • Loading branch information
alandekok committed Oct 6, 2023
1 parent 11ed54c commit 8e900e4
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion doc/antora/modules/raddb/pages/mods-available/delay.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ delay {
# relative = no
}
delay delay_reject {
delay = "%{%{reply.FreeRADIUS-Response-Delay}:-1}"
delay = "%{&reply.FreeRADIUS-Response-Delay || 1}"
relative = yes
}
```
4 changes: 2 additions & 2 deletions doc/antora/modules/raddb/pages/mods-available/linelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ Don't log anything for other `link:https://freeradius.org/rfc/rfc2866.html#Acct-
linelog {
# delimiter = "\n"
format = "This is a log message for %{User-Name}"
reference = "messages.%{%{reply.Packet-Type}:-default}"
reference = "messages.%{&reply.Packet-Type || default}"
messages {
default = "Unknown packet type %{Packet-Type}"
Access-Accept = "Sent accept: %{User-Name}"
Expand Down Expand Up @@ -402,7 +402,7 @@ linelog log_accounting {
filename = ${logdir}/linelog-accounting
permissions = 0600
}
reference = "Accounting-Request.%{%{Acct-Status-Type}:-unknown}"
reference = "Accounting-Request.%{&Acct-Status-Type || unknown}"
Accounting-Request {
Start = "Connect: [%{User-Name}] (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} ip %{Framed-IP-Address})"
Stop = "Disconnect: [%{User-Name}] (did %{Called-Station-Id} cli %{Calling-Station-Id} port %{NAS-Port} ip %{Framed-IP-Address}) %{Acct-Session-Time} seconds"
Expand Down
6 changes: 3 additions & 3 deletions doc/antora/modules/raddb/pages/mods-available/rediswho.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ rediswho {
trim_count = 15
expire_time = 86400
Start {
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{%{Acct-Input-Gigawords}:-0},%{%{Acct-Output-Gigawords}:-0},%{%{Acct-Input-Octets}:-0},%{%{Acct-Output-Octets}:-0}"
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
trim = "LTRIM %{User-Name} 0 ${..trim_count}"
expire = "EXPIRE %{User-Name} ${..expire_time}"
}
Interim-Update {
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{%{Acct-Input-Gigawords}:-0},%{%{Acct-Output-Gigawords}:-0},%{%{Acct-Input-Octets}:-0},%{%{Acct-Output-Octets}:-0}"
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
trim = "LTRIM %{User-Name} 0 ${..trim_count}"
expire = "EXPIRE %{User-Name} ${..expire_time}"
}
Stop {
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{%{Acct-Input-Gigawords}:-0},%{%{Acct-Output-Gigawords}:-0},%{%{Acct-Input-Octets}:-0},%{%{Acct-Output-Octets}:-0}"
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
trim = "LTRIM %{User-Name} 0 ${..trim_count}"
expire = "EXPIRE %{User-Name} ${..expire_time}"
}
Expand Down
2 changes: 1 addition & 1 deletion raddb/mods-available/delay
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ delay {
# received.
#
delay delay_reject {
delay = "%{%{reply.FreeRADIUS-Response-Delay}:-1}"
delay = "%{&reply.FreeRADIUS-Response-Delay || 1}"
relative = yes
}
4 changes: 2 additions & 2 deletions raddb/mods-available/linelog
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ linelog {
#
# May be an attribute reference, e.g. `&User-Name`, or `xlat`, `literal` or `exec`.
#
reference = "messages.%{%{reply.Packet-Type}:-default}"
reference = "messages.%{&reply.Packet-Type || default}"

#
# messages { ... }::
Expand Down Expand Up @@ -392,7 +392,7 @@ linelog log_accounting {
permissions = 0600
}

reference = "Accounting-Request.%{%{Acct-Status-Type}:-unknown}"
reference = "Accounting-Request.%{&Acct-Status-Type || unknown}"

#
# Example for `Accounting-Request`.
Expand Down
6 changes: 3 additions & 3 deletions raddb/mods-available/rediswho
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ rediswho {
# ### Start
#
Start {
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{%{Acct-Input-Gigawords}:-0},%{%{Acct-Output-Gigawords}:-0},%{%{Acct-Input-Octets}:-0},%{%{Acct-Output-Octets}:-0}"
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
trim = "LTRIM %{User-Name} 0 ${..trim_count}"
expire = "EXPIRE %{User-Name} ${..expire_time}"
}
Expand All @@ -92,7 +92,7 @@ rediswho {
# ### Interim-Update
#
Interim-Update {
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{%{Acct-Input-Gigawords}:-0},%{%{Acct-Output-Gigawords}:-0},%{%{Acct-Input-Octets}:-0},%{%{Acct-Output-Octets}:-0}"
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
trim = "LTRIM %{User-Name} 0 ${..trim_count}"
expire = "EXPIRE %{User-Name} ${..expire_time}"
}
Expand All @@ -101,7 +101,7 @@ rediswho {
# ### Stop
#
Stop {
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{%{Acct-Input-Gigawords}:-0},%{%{Acct-Output-Gigawords}:-0},%{%{Acct-Input-Octets}:-0},%{%{Acct-Output-Octets}:-0}"
insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
trim = "LTRIM %{User-Name} 0 ${..trim_count}"
expire = "EXPIRE %{User-Name} ${..expire_time}"
}
Expand Down
4 changes: 2 additions & 2 deletions raddb/mods-config/sql/main/mysql/extras/wimax/queries.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Use Stripped-User-Name, if it's there.
# Else use User-Name, if it's there,
# Else use hard-coded string "DEFAULT" as the user name.
#sql_user_name = "%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}"
#sql_user_name = "%{%{Stripped-User-Name}:-%{&User-Name || DEFAULT}}"
#
sql_user_name = "%{User-Name}"

Expand All @@ -37,4 +37,4 @@ postauth_query = "INSERT INTO wimax \
VALUES ( \
'%{User-Name}', '%S' \
'%{&reply.WiMAX.MN-hHA-MIP4-SPI || &reply.WiMAX.MN-hHA-MIP6-SPI}', \
'%{&reply.WiMAX.MN-hHA-MIP4-Key || &reply.WiMAX.MN-hHA-MIP6-Key}', '%{%{reply.Session-Timeout}:-86400}' )"
'%{&reply.WiMAX.MN-hHA-MIP4-Key || &reply.WiMAX.MN-hHA-MIP6-Key}', '%{&reply.Session-Timeout || 86400}' )"
12 changes: 6 additions & 6 deletions raddb/mods-config/sql/main/postgresql/queries.conf
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ accounting {
AcctStopTime = ${....event_timestamp}, \
AcctUpdateTime = ${....event_timestamp}, \
AcctSessionTime = (${....event_timestamp_epoch} - EXTRACT(EPOCH FROM(AcctStartTime))), \
AcctTerminateCause = '%{%{Acct-Terminate-Cause}:-NAS-Reboot}', \
AcctTerminateCause = '%{&Acct-Terminate-Cause || NAS-Reboot}', \
Class = '%{Class}' \
WHERE AcctStopTime IS NULL \
AND NASIPAddress= '%{&NAS-IPv6-Address || &NAS-IP-Address}' \
Expand Down Expand Up @@ -353,7 +353,7 @@ accounting {
FramedIPv6Prefix = NULLIF('%{Framed-IPv6-Prefix}', '')::inet, \
FramedInterfaceId = NULLIF('%{Framed-Interface-Id}', ''), \
DelegatedIPv6Prefix = NULLIF('%{Delegated-IPv6-Prefix}', '')::inet, \
AcctSessionTime = %{%{Acct-Session-Time}:-NULL}, \
AcctSessionTime = %{&Acct-Session-Time || NULL}, \
AcctInterval = (${....event_timestamp_epoch} - EXTRACT(EPOCH FROM (COALESCE(AcctUpdateTime, AcctStartTime)))), \
AcctUpdateTime = ${....event_timestamp}, \
AcctInputOctets = %{(((uint64) &Acct-Input-Gigawords) << 32) | (uint64) &Acct-Input-Octets}, \
Expand All @@ -376,7 +376,7 @@ accounting {
${....event_timestamp}, \
${....event_timestamp}, \
NULL, \
%{%{Acct-Session-Time}:-NULL}, \
%{&Acct-Session-Time || NULL}, \
'%{Acct-Authentic}', \
'%{Connect-Info}', \
NULL, \
Expand All @@ -403,7 +403,7 @@ accounting {
SET \
AcctStopTime = ${....event_timestamp}, \
AcctUpdateTime = ${....event_timestamp}, \
AcctSessionTime = COALESCE(%{%{Acct-Session-Time}:-NULL}, \
AcctSessionTime = COALESCE(%{&Acct-Session-Time || NULL}, \
(${....event_timestamp_epoch} - EXTRACT(EPOCH FROM(AcctStartTime)))), \
AcctInputOctets = %{(((uint64) &Acct-Input-Gigawords) << 32) | (uint64) &Acct-Input-Octets}, \
AcctOutputOctets = %{(((uint64) &Acct-Output-Gigawords) << 32) | (uint64) &Acct-Output-Octets}, \
Expand All @@ -429,7 +429,7 @@ accounting {
'%{&NAS-IPv6-Address || &NAS-IP-Address}', \
NULLIF('%{&NAS-Port-ID || &NAS-Port}', ''), \
'%{NAS-Port-Type}', \
TO_TIMESTAMP(${....event_timestamp_epoch} - %{%{Acct-Session-Time}:-0}), \
TO_TIMESTAMP(${....event_timestamp_epoch} - %{&Acct-Session-Time || 0}), \
${....event_timestamp}, \
${....event_timestamp}, \
NULLIF('%{Acct-Session-Time}', '')::bigint, \
Expand Down Expand Up @@ -458,7 +458,7 @@ accounting {
SET \
AcctStopTime = ${....event_timestamp}, \
AcctUpdateTime = ${....event_timestamp}, \
AcctSessionTime = COALESCE(%{%{Acct-Session-Time}:-NULL}, \
AcctSessionTime = COALESCE(%{&Acct-Session-Time || NULL}, \
(${....event_timestamp_epoch} - EXTRACT(EPOCH FROM(AcctStartTime)))), \
AcctInputOctets = (%{(((uint64) &Acct-Input-Gigawords) << 32) | (uint64) &Acct-Input-Octets})::bigint, \
AcctOutputOctets = (%{(((uint64) &Acct-Output-Gigawords) << 32) | (uint64) &Acct-Output-Octets})::bigint, \
Expand Down
16 changes: 8 additions & 8 deletions raddb/mods-config/sql/main/sqlite/queries.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Use Stripped-User-Name, if it's there.
# Else use User-Name, if it's there,
# Else use hard-coded string "DEFAULT" as the user name.
#sql_user_name = "%{%{Stripped-User-Name}:-%{%{User-Name}:-DEFAULT}}"
#sql_user_name = "%{%{Stripped-User-Name}:-%{&User-Name || DEFAULT}}"
#
sql_user_name = "%{User-Name}"

Expand Down Expand Up @@ -345,15 +345,15 @@ accounting {
'%{NAS-IP-Address}', \
'%{&NAS-Port-ID || &NAS-Port}', \
'%{NAS-Port-Type}', \
(${....event_timestamp_epoch} - %{%{Acct-Session-Time}:-0}), \
(${....event_timestamp_epoch} - %{&Acct-Session-Time || 0}), \
${....event_timestamp}, \
NULL, \
%{%{Acct-Session-Time}:-NULL}, \
%{&Acct-Session-Time || NULL}, \
'%{Acct-Authentic}', \
'%{Connect-Info}', \
'', \
%{%{Acct-Input-Gigawords}:-0} << 32 | %{%{Acct-Input-Octets}:-0}, \
%{%{Acct-Output-Gigawords}:-0} << 32 | %{%{Acct-Output-Octets}:-0}, \
%{&Acct-Input-Gigawords || 0} << 32 | %{&Acct-Input-Octets || 0}, \
%{&Acct-Output-Gigawords || 0} << 32 | %{&Acct-Output-Octets || 0}, \
'%{Called-Station-Id}', \
'%{Calling-Station-Id}', \
'', \
Expand All @@ -374,7 +374,7 @@ accounting {
query = "\
UPDATE ${....acct_table2} SET \
acctstoptime = ${....event_timestamp}, \
acctsessiontime = %{%{Acct-Session-Time}:-NULL}, \
acctsessiontime = %{&Acct-Session-Time || NULL}, \
acctinputoctets = %{(((uint64) &Acct-Input-Gigawords) << 32) | (uint64) &Acct-Input-Octets}, \
acctoutputoctets = %{(((uint64) &Acct-Output-Gigawords) << 32) | (uint64) &Acct-Output-Octets}, \
acctterminatecause = '%{Acct-Terminate-Cause}', \
Expand All @@ -397,10 +397,10 @@ accounting {
'%{NAS-IP-Address}', \
'%{&NAS-Port-ID || &NAS-Port}', \
'%{NAS-Port-Type}', \
(${....event_timestamp_epoch} - %{%{Acct-Session-Time}:-0}), \
(${....event_timestamp_epoch} - %{&Acct-Session-Time || 0}), \
${....event_timestamp}, \
${....event_timestamp}, \
%{%{Acct-Session-Time}:-NULL}, \
%{&Acct-Session-Time || NULL}, \
'%{Acct-Authentic}', \
'', \
'%{Connect-Info}', \
Expand Down
4 changes: 2 additions & 2 deletions raddb/policy.d/accounting
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ insert_acct_class {
#
acct_counters64.preacct {
if (!&Acct-Input-Gigawords) {
&request.Acct-Input-Octets64 := "%{%{Acct-Input-Octets}:-0}"
&request.Acct-Input-Octets64 := "%{&Acct-Input-Octets || 0}"
}
else {
&request.Acct-Input-Octets64 = (((uint64) &Acct-Input-Gigawords) << 32) | (uint64) &Acct-Input-Octets
}
if (!&Acct-Output-Gigawords) {
&request.Acct-Output-Octets64 := "%{%{Acct-Output-Octets}:-0}"
&request.Acct-Output-Octets64 := "%{&Acct-Output-Octets || 0}"
}
else {
&request.Acct-Output-Octets64 = (((uint64) &Acct-Output-Gigawords) << 32) | (uint64) &Acct-Output-Octets
Expand Down

0 comments on commit 8e900e4

Please sign in to comment.