diff --git a/lib/globals.py b/lib/globals.py index 7412b8c..ccbdd9b 100644 --- a/lib/globals.py +++ b/lib/globals.py @@ -41,6 +41,10 @@ MALFORMED_RESPONSE_HTML_PAGE = open(os.path.join(STATIC, 'malformed-response.htm GEOLOCATOR_SERVICE = 'http://localhost:8004' +# number of queries from the same IP address is limited +# (minute, hour, day) limitations: +QUERY_LIMITS = (300, 3600, 24*3600) + LISTEN_HOST = "" LISTEN_PORT = 8002 diff --git a/lib/wttr_srv.py b/lib/wttr_srv.py index 6eb3e64..68a5e5d 100644 --- a/lib/wttr_srv.py +++ b/lib/wttr_srv.py @@ -18,7 +18,7 @@ from globals import get_help_file, log, \ NOT_FOUND_LOCATION, \ MALFORMED_RESPONSE_HTML_PAGE, \ PLAIN_TEXT_AGENTS, PLAIN_TEXT_PAGES, \ - MY_EXTERNAL_IP + MY_EXTERNAL_IP, QUERY_LIMITS from location import is_location_blocked, location_processing from limits import Limits from wttr import get_wetter, get_moon @@ -28,7 +28,7 @@ if not os.path.exists(os.path.dirname(LOG_FILE)): os.makedirs(os.path.dirname(LOG_FILE)) logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG, format='%(asctime)s %(message)s') -LIMITS = Limits(whitelist=[MY_EXTERNAL_IP], limits=(30, 60, 100)) +LIMITS = Limits(whitelist=[MY_EXTERNAL_IP], limits=QUERY_LIMITS) def show_text_file(name, lang): """