polyfemos.front.trafficmonitor — polyfemos 0.3.29 documentation

# polyfemos.front.trafficmonitor

Monitors and limits website usage

copyright

  2019, University of Oulu, Sodankyla Geophysical Observatory

license

  GNU Lesser General Public License v3.0 or later (https://spdx.org/licenses/LGPL-3.0-or-later.html)

Public Functions

`polyfemos.front.trafficmonitor.` `check_permission`(access_level, limit_network=False)

  The users and their access levels are defined in YAML config files. See `users()` for more info.

  The local user (ip=’127.0.0.1’) has the maximum access level (1). An unidentified user will have the minimum access level (the function always returns `False`).

  Parameters

    - access_level (int) – requested access level

    - limit_network (bool, optional) – Defaults to `False`. If `True`, the allowed networks of the user are checked in addition to access level.

  Return type

    bool

  Returns

    Returns `True` if the users access level is smaller or equal to requested access level (`access_level`).

`polyfemos.front.trafficmonitor.` `gip`()
  Return type

    str

  Returns

    IP address of the user

`polyfemos.front.trafficmonitor.` `gun`()
  Return type

    str

  Returns

    Username of the user

`polyfemos.front.trafficmonitor.` `limit_access`(access_level=2, limit_network=True)

  A decorator used limit access of users. Users with access level equal or greater than 3 are not permitted to enter the site.

  The access level check made by calling `check_permission()`.

  Parameters

    - access_level (int, optional) – requested access level, defaults to `2`

    - limit_network (bool, optional) – Defaults to `True`. If `True`, the allowed networks of the user are checked in addition to access level.

  Return type

    func

  Returns

    a decorator to limit access

`polyfemos.front.trafficmonitor.` `limited`(ipstorage)

  A function call limiter. The functions with limited decorator may only be called one at the time per IP address. Use as a decorator with arguments. This applies to users with access level equal or more than 2.

  The access level check made by calling `check_permission()`.

  Parameters

    ipstorage (`IPStorage`) –

  Return type

    func

  Returns

    A decorator using `IPStorage`

`polyfemos.front.trafficmonitor.` `logged`(func_)

  A decorator used to log usage of the functions Logs the time, IP address and username of the user and the function (`func_`) used.

  Parameters

    func_ (func) –

  Return type

    func

  Returns

Classes

`IPStorage`() | A class which handles IP addresses of the users