On Jun 25, 2015, at 10:57 AM, Adam Hammond <adam.hammond@wicoms.com> wrote:
Noting that this module has been removed in 3.x and that I should use unlang instead I have been trying to make this work and have got stuck. I haven't been able to find a solution looking through the list archives and I've probably misunderstood how unlang works somehow.
It's possible.
Here is my messy unlang attempt. Reject a request unless I can match the Calling-Station-Id. NOTE: I've expanded the attributes in the if statement to show you what I mean in the debug output below.
authorize { sql pap
update control { Auth-Type := "Reject" }
Delete that. The default is to reject unauthorized users
foreach &control:Calling-Station-Id { if ("%{request:Calling-Station-Id}" == "%{control:Calling-Station-Id}") {
That won't work. You're checking the first Calling-Station-Id in the request list against the first Calling-Station-Id in the control list. i.e. you're not using "foreach" at all... This should be: if (&request:Calling-Station-Id == "%{Foreach-Variable-0}") {
NOTE: 'break' doesn't seem to do what I'm expecting it to here (break out of the for loop)
It should.
Any pointers to what I'm doing wrong most appreciated.
Nothing. I've pushed a fix, and a test based on your use-case, to the v3.0.x branch on github. Alan DeKok.