session timeout eval random only during night hours
Matthew Newton
mcn at freeradius.org
Thu Mar 14 23:26:23 CET 2019
On Thu, 2019-03-14 at 16:02 -0400, Alan DeKok wrote:
> On Mar 14, 2019, at 3:35 PM, Krzysztof Drewicz <
> krzysztofdrewicz at gmail.com> wrote:
> >
> > basically what i have is:
> >
> > Session-Timeout = 24*60*60 (secons so = one day)
> >
> > what i whould like to eval this timeout every time user gets ack/ok
> > reply
> > to be (randomly) in hours let's say 0200 - 0600 hours.
>
> That's a little unusual, and therefore a bit more difficult.
>
> There are a few things going on here. What do you want to do
> *during* that time? i.e. what happens if the user logs in between
> 0200-0600?
>
> If there's outside of that time, it's a bit simpler. Just
> calculate how far away 0200 is, and then add 0-(4*3600) random
> seconds.
This may work, if I understood the question correctly:
update reply {
&Session-Timeout := "%{expr:((%l / 86400) * 86400) + 93600 + %{rand:14400} - %l}"
}
Request time (%l) / 86400 * 86400 in integer arithmetic gets midnight
of last night.
"+ 93600" adds on 26 hours (2am tomorrow)
"+ %{rand:14400}" adds on between 0-4 hours (i.e. 2am-6am)
"- %l" takes current time off, to get seconds remaining.
--
Matthew
More information about the Freeradius-Users
mailing list