73def is_suspicious(network: IPv4Network | IPv6Network, request: flask.Request, renew: bool = 
False):
 
   74    """Checks whether a valid ping is exists for this (client) network, if not 
   75    this request is rated as *suspicious*.  If a valid ping exists and argument 
   76    ``renew`` is ``True`` the expire time of this ping is reset to 
   77    :py:obj:`PING_LIVE_TIME`. 
   80    valkey_client = valkeydb.get_valkey_client()
 
   82    if not valkey_client.get(ping_key):
 
   83        logger.info(
"missing ping (IP: %s) / request: %s", network.compressed, ping_key)
 
   87        valkey_client.set(ping_key, 1, ex=PING_LIVE_TIME)
 
   89    logger.debug(
"found ping for (client) network %s -> %s", network.compressed, ping_key)
 
 
   93def ping(request: flask.Request, token: str):
 
   94    """This function is called by a request to URL ``/client<token>.css``.  If 
   95    ``token`` is valid a :py:obj:`PING_KEY` for the client is stored in the DB. 
   96    The expire time of this ping-key is :py:obj:`PING_LIVE_TIME`. 
   99    valkey_client = valkeydb.get_valkey_client()
 
  100    cfg = config.get_global_cfg()
 
  105    real_ip = ip_address(request.remote_addr)  
 
  106    network = get_network(real_ip, cfg)
 
  110        "store ping_key for (client) network %s (IP %s) -> %s", network.compressed, real_ip.compressed, ping_key
 
  112    valkey_client.set(ping_key, 1, ex=PING_LIVE_TIME)
 
 
  135    """Returns current token.  If there is no currently active token a new token 
  136    is generated randomly and stored in the Valkey DB.  Without without a 
  137    database connection, string "12345678" is returned. 
  139    - :py:obj:`TOKEN_LIVE_TIME` 
  140    - :py:obj:`TOKEN_KEY` 
  144        valkey_client = valkeydb.get_valkey_client()
 
  150    token = valkey_client.get(TOKEN_KEY)
 
  152        token = token.decode(
'UTF-8')  
 
  154        token = 
''.join(random.choice(string.ascii_lowercase + string.digits) 
for _ 
in range(16))
 
  155        valkey_client.set(TOKEN_KEY, token, ex=TOKEN_LIVE_TIME)