53 lines
1.4 KiB
Django/Jinja
53 lines
1.4 KiB
Django/Jinja
# -*- text -*-
|
|
##
|
|
## sites-available/coa -- Receive CoA/Disconnect and proxy to NAS
|
|
##
|
|
## Managed by Ansible — do not edit manually.
|
|
##
|
|
## gaiia sends CoA-Request or Disconnect-Request with User-Name
|
|
## and/or Acct-Session-Id. This server looks up the active session
|
|
## in radacct, finds the NAS, and proxies the request to it.
|
|
##
|
|
|
|
listen {
|
|
type = coa
|
|
ipaddr = *
|
|
port = 3799
|
|
virtual_server = coa
|
|
}
|
|
|
|
server coa {
|
|
recv-coa {
|
|
#
|
|
# Try to find the NAS shortname from the active session.
|
|
# Lookup by Acct-Session-Id first (most specific), then User-Name.
|
|
#
|
|
{% if freeradius_sql_dialect == 'mysql' -%}
|
|
update control {
|
|
&Tmp-String-0 := "%{sql:SELECT nas.shortname FROM radacct INNER JOIN nas ON radacct.nasipaddress = nas.nasname WHERE radacct.acctsessionid = '%{Acct-Session-Id}' AND radacct.AcctStopTime IS NULL LIMIT 1}"
|
|
}
|
|
if (control:Tmp-String-0 == "") {
|
|
update control {
|
|
&Tmp-String-0 := "%{sql:SELECT nas.shortname FROM radacct INNER JOIN nas ON radacct.nasipaddress = nas.nasname WHERE radacct.username = '%{User-Name}' AND radacct.AcctStopTime IS NULL LIMIT 1}"
|
|
}
|
|
}
|
|
{% endif -%}
|
|
|
|
#
|
|
# If we found a NAS, set the home_server_pool and proxy to it.
|
|
#
|
|
if (control:Tmp-String-0 != "") {
|
|
update request {
|
|
&Home-Server-Pool := "coa-pool-%{control:Tmp-String-0}"
|
|
}
|
|
}
|
|
else {
|
|
# No active session found — reject
|
|
reject
|
|
}
|
|
}
|
|
|
|
send-coa {
|
|
ok
|
|
}
|
|
}
|