我使用 Coova Chilli 和 Freeradius 开展热点项目。我使用最新稳定版本 3.0.11 中的 FreeRADIUS。
我根据这篇文章创建了我的休息和启用站点的配置文件: 在 FreeRadius 中配置 rlm_rest 模块
遗憾的是,没有关于通过 rest 设置会计的信息,因此我尝试了以下操作:sites-enabled/default:
accounting {
rest
detail
unix
exec
attr_filter-accounting_response
}
已启用 mods/rest:
accounting {
uri = "${..connect_uri}/aaa/accounting/sessions/%{Acct-Unique-Session-ID}"
method = 'post'
body = 'json'
}
但是没有数据发送到我的 REST 服务。只给出了一个空字符串...
在 FreeRadius 调试模式(radiusd -X)下打印以下内容:
(10) accounting {
rlm_rest (rest): Reserved connection (13)
(10) rest: Expanding URI components
(10) rest: EXPAND http://SERVERIP:PORT
(10) rest: --> http://SERVERIP:PORT
(10) rest: EXPAND /radius/rest/aaa/accounting/sessions/%{Acct-Unique-Session-ID}
(10) rest: --> /radius/rest/aaa/accounting/sessions/8f7d662e6afaaa0427598e03cc908379
(10) rest: Sending HTTP POST to "http://SERVERIP:PORT/radius/rest/aaa/accounting/sessions/8f7d662e6afaaa0427598e03cc908379"
(10) rest: Encoding attribute "User-Name"
(10) rest: Encoding attribute "NAS-IP-Address"
(10) rest: Encoding attribute "Service-Type"
(10) rest: Encoding attribute "Called-Station-Id"
(10) rest: Encoding attribute "Calling-Station-Id"
(10) rest: Encoding attribute "NAS-Identifier"
(10) rest: Encoding attribute "NAS-Port-Type"
(10) rest: Encoding attribute "Acct-Status-Type"
(10) rest: Encoding attribute "Acct-Input-Octets"
(10) rest: Encoding attribute "Acct-Output-Octets"
(10) rest: Encoding attribute "Acct-Session-Id"
(10) rest: Encoding attribute "Acct-Session-Time"
(10) rest: Encoding attribute "Acct-Input-Packets"
(10) rest: Encoding attribute "Acct-Output-Packets"
(10) rest: Encoding attribute "Acct-Input-Gigawords"
(10) rest: Encoding attribute "Acct-Output-Gigawords"
(10) rest: Encoding attribute "Event-Timestamp"
(10) rest: Encoding attribute "ChilliSpot-Version"
(10) rest: Returning 1022 bytes of JSON data (buffer full or chunk exceeded)
(10) rest: Encoding attribute "ChilliSpot-Max-Total-Gigawords"
(10) rest: Encoding attribute "FreeRADIUS-Acct-Session-Start-Time"
(10) rest: Encoding attribute "WISPr-Location-ID"
(10) rest: Encoding attribute "WISPr-Location-Name"
(10) rest: Encoding attribute "Acct-Unique-Session-Id"
(10) rest: Encoding attribute "Attr-26.14559.40"
(10) rest: Encoding attribute "Attr-26.14559.41"
(10) rest: Encoding attribute "Attr-26.14559.42"
(10) rest: Processing response header
(10) rest: Status : 100 (Continue)
(10) rest: Continuing...
(10) rest: Processing response header
(10) rest: ERROR: Malformed HTTP header: Missing HTTP version
(10) rest: ERROR: Received 19 bytes of response data: Content-Length: 0
(10) rest: ERROR: Request failed: 23 - Failed writing received data to disk/application
(10) rest: ERROR: Server returned no data
rlm_rest (rest): Released connection (13)
rlm_rest (rest): Need 1 more connections to reach 10 spares
rlm_rest (rest): Opening additional connection (15), 1 of 30 pending slots used
rlm_rest (rest): Connecting to "http://SERVERIP:PORT/radius/rest"
(10) [rest] = fail
(10) } # accounting = fail
如果我尝试这样的测试(只是 rest 模块的 JSON 规范中的一个不完整的示例):
curl -X POST -H "Content-Type: application/json" --data '{ "User-Name": {"type":"string","value":["elise"]}, "NAS-IP-Address": {"type":"ipaddr","value":["10.1.0.1"]}, "NAS-Port": {"type":"integer","value":["1"]}, "Framed-IP-Address": {"type":"ipaddr","value":["10.1.0.177"]}, "Called-Station-Id": {"type":"string","value":["B8-AC-6F-8D-00-CA"]}, "NAS-Identifier": {"type":"string","value":["nas01"]}, "Acct-Status-Type": {"type":"integer","value":[1]}, "Acct-Session-Id": {"type":"string","value":["56f00f8100000000"]}, "Event-Timestamp": {"type":"date","value":["Jul 29 2015 16:06:40 CEST"]}, "WISPr-Location-ID": {"type":"string","value":["isocc=,cc=,ac=,network=MeteringService_GmbH,"]}, "WISPr-Location-Name": {"type":"string","value":["KomDSL_Hotspot"]}, "Acct-Unique-Session-Id": {"type":"string","value":["8f7d662e6afaaa0427598e03cc908379"]} } ' http://SERVER_PATH/aaa/accounting/sessions/8f7d662e6afaaa0427598e03cc908379
一切都很好,所以我的 REST 服务似乎可以正常工作......
其他部分(身份验证等)使用 method='get' 并且一切正常。
有人实现了这个功能并能帮助我吗?
根据 serverfaul.com 上的答案,也许 Arran Cudbard-Bell 有一个答案?
我期待您的帮助!
答案1
data
其余配置中缺少该属性。
在 mods-enabled/rest 中:
accounting {
uri = "${..connect_uri}/aaa/accounting/sessions/%{Acct-Unique-Session-ID}"
method = 'post'
body = 'json'
data = '{ "User-Name": {"type":"string","value":["elise"]}, "NAS-IP-Address": {"type":"ipaddr","value":["10.1.0.1"]}, "NAS-Port": {"type":"integer","value":["1"]}, "Framed-IP-Address": {"type":"ipaddr","value":["10.1.0.177"]}, "Called-Station-Id": {"type":"string","value":["B8-AC-6F-8D-00-CA"]}, "NAS-Identifier": {"type":"string","value":["nas01"]}, "Acct-Status-Type": {"type":"integer","value":[1]}, "Acct-Session-Id": {"type":"string","value":["56f00f8100000000"]}, "Event-Timestamp": {"type":"date","value":["Jul 29 2015 16:06:40 CEST"]}, "WISPr-Location-ID": {"type":"string","value":["isocc=,cc=,ac=,network=MeteringService_GmbH,"]}, "WISPr-Location-Name": {"type":"string","value":["KomDSL_Hotspot"]}, "Acct-Unique-Session-Id": {"type":"string","value":["8f7d662e6afaaa0427598e03cc908379"]} }'
}
笔记您必须用 FreeRadius 提供的属性替换示例数据,例如%{User-Name}