session timeout eval random only during night hours
Arran Cudbard-Bell
a.cudbardb at freeradius.org
Sat Mar 16 02:47:33 CET 2019
> On Mar 15, 2019, at 6:26 AM, Matthew Newton <mcn at freeradius.org> wrote:
>
> 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.
or
update reply {
&Session-Time := "%{expr:%{nexttime:1d} + 7200 + %{rand:14400}}"
}
- %{nexttime:1d} - Number of seconds until tomorrow.
- + 7200 - Plus two hours
- + %{rand:14400} random value between 0-4 hours.
-Arran
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20190316/cefffc20/attachment-0001.sig>
More information about the Freeradius-Users
mailing list