case-statement regex
Using version 3.0.10. Can’t seem to implement regex matching with case statements. The request always results in “def” even though the string in the request contains “abc". switch DHCP-Subscriber-Id { case "/(abc)$/" { update control { &Pool-Name := “abc" } } case { update control { &Pool-Name := “def" } } } I have tried a bunch of different variations of the “case” without success. If I use the entire string in the case statement then I get the intended result “abc”. switch DHCP-Subscriber-Id { case 001122334455@abc { update control { &Pool-Name := “abc" } } case { update control { &Pool-Name := “def" } } } Does anyone have a suggestion on how to implement this? I haven’t been able to find examples in the documentation or google about doing this specifically. The same logic implemented with if/else works fine but I was hoping to use switch/case for performance. if (&DHCP-Subscriber-Id =~ /(abc)$/){ update control { &Pool-Name := “abc" } } else { update control { &Pool-Name := “def" } } Thanks, Ryan
On 6 Jan 2016, at 22:09, O'Connell, Ryan <ryan.oconnell@viasat.com> wrote:
Using version 3.0.10. Can’t seem to implement regex matching with case statements. The request always results in “def” even though the string in the request contains “abc".
Thanks for the feature request ;) -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 6 Jan 2016, at 22:46, Arran Cudbard-Bell <a.cudbardb@freeradius.org> wrote:
On 6 Jan 2016, at 22:09, O'Connell, Ryan <ryan.oconnell@viasat.com> wrote:
Using version 3.0.10. Can’t seem to implement regex matching with case statements. The request always results in “def” even though the string in the request contains “abc".
Thanks for the feature request ;)
It'd be case /(abc)/$ { if it worked, but i'm fairly certain it doesn't, unless Alan added at some point. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
Thanks Arran. Unfortunately the server fails to start with the case statement as: case /(abc)/$ { The error is: /etc/raddb/sites-enabled/dhcp[169]: Expecting section start brace '{' after "case /" I put the quotes around the regex in hopes that would help, allowing the server to start, but obviously it doesn’t resolve the issue. Thanks for taking a look. -Ryan
On 6 Jan 2016, at 22:46, Arran Cudbard-Bell wrote:
On 6 Jan 2016, at 22:09, O'Connell, Ryan wrote:
Using version 3.0.10. Can’t seem to implement regex matching with case statements. The request always results in “def” even though the string in the request contains “abc".
Thanks for the feature request ;)
It'd be case /(abc)/$ { if it worked, but i'm fairly certain it doesn't, unless Alan added at some point.
-Arran
Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team
FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 7 Jan 2016, at 12:43, O'Connell, Ryan <ryan.oconnell@viasat.com> wrote:
Thanks Arran. Unfortunately the server fails to start with the case statement as:
case /(abc)/$ {
The error is:
/etc/raddb/sites-enabled/dhcp[169]: Expecting section start brace '{' after "case /"
I put the quotes around the regex in hopes that would help, allowing the server to start, but obviously it doesn’t resolve the issue. Thanks for taking a look.
It's being discussed in: https://github.com/FreeRADIUS/freeradius-server/issues/1486#issuecomment-169... I think it's quite a useful feature, especially once we have fall-through. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
participants (2)
-
Arran Cudbard-Bell -
O'Connell, Ryan