Lua script context API - RADIUS sub-context
radius
RADIUS packet data.
Fields
| Field | Type | Description |
|---|---|---|
request | packet | RADIUS request packet |
reply | packet | RADIUS reply packet |
dynauth | packet | Dynamic authorization packet |
client | client? | RADIUS client info |
server | server? | RADIUS server info |
Packet Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
attr(name, tag?) | attribute name, optional tag | value? | Get first attribute value |
attr_last(name, tag?) | attribute name, optional tag | value? | Get last attribute value |
attr_all(name, tag?) | attribute name, optional tag | values? | Get all attribute values |
attrs() | - | table | Get all attributes as table |
append_attr(name, tag?, value) | name, tag, value | - | Append attribute (reply only) |
append_attrs(name, tag?, values) | name, tag, values | - | Append multiple values (reply only) |
set_attr(name, tag?, value) | name, tag, value | - | Set attribute if not exists (reply only) |
set_attrs(name, tag?, values) | name, tag, values | - | Set multiple values (reply only) |
Client Object
| Field | Type | Description |
|---|---|---|
name | string | Client name |
ip | string? | Client IP address |
Server Object
| Field | Type | Description |
|---|---|---|
name | string | Server name |
ip | string | Server IP address |
port | number | Server port |
tls | boolean | Is TLS enabled? |
Example
local context, previous = ...
local radius = context.radius
-- Read request attributes
local username = radius.request:attr("User-Name")
local nas_ip = radius.request:attr("NAS-IP-Address")
-- Add reply attributes
radius.reply:append_attr("Reply-Message", nil, "Welcome!")
radius.reply:set_attr("Session-Timeout", nil, 3600)
-- Check client
if radius.client then
local client_name = radius.client.name
local client_ip = radius.client.ip
end
return previous