From b4f186fa8c89d33bf5c6afcb45d81c956ca120d7 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Thu, 18 Sep 2014 15:26:19 +0200 Subject: [PATCH] * Token-Fault on search with multiple pages fixed * DoS-mitigation wait time added --- agent/groupcal.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/agent/groupcal.py b/agent/groupcal.py index 07e7af7..5777381 100644 --- a/agent/groupcal.py +++ b/agent/groupcal.py @@ -12,16 +12,20 @@ from optparse import OptionParser import sqlite3 import datetime -from xml.dom.minidom import Document from pythonzimbra.communication import Communication from pythonzimbra.tools import auth from pythonzimbra.tools.dict import get_value -from pythonzimbra.tools.xmlserializer import dict_to_dom +import time SEARCH_LIMIT = 100 """ How many results to fetch in one SearchRequest """ +WAIT_AFTER_SEARCH = 0.5 + +""" How many seconds (may be a fracture) to wait between to search requests ( +for DoS-Filter mitigation) """ + if __name__ == '__main__': # Parse options @@ -486,6 +490,10 @@ ) ) + # Wait some time to mitigate the DoS-Filter + + time.sleep(WAIT_AFTER_SEARCH) + if appt_response.get_response()["SearchResponse"]["more"] == 1: # We have more pages. Rerun the search @@ -494,6 +502,8 @@ search_params["offset"] = current_offset appt_request.clean() + + appt_request.set_auth_token(user_token) appt_request.add_request( "SearchRequest", search_params,