moved limits to globals.py (fixes #233)

This commit is contained in:
Igor Chubin 2018-11-01 18:23:32 +01:00
parent 7303ae86ba
commit 95e1f61a40
2 changed files with 6 additions and 2 deletions

View file

@ -41,6 +41,10 @@ MALFORMED_RESPONSE_HTML_PAGE = open(os.path.join(STATIC, 'malformed-response.htm
GEOLOCATOR_SERVICE = 'http://localhost:8004' 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_HOST = ""
LISTEN_PORT = 8002 LISTEN_PORT = 8002

View file

@ -18,7 +18,7 @@ from globals import get_help_file, log, \
NOT_FOUND_LOCATION, \ NOT_FOUND_LOCATION, \
MALFORMED_RESPONSE_HTML_PAGE, \ MALFORMED_RESPONSE_HTML_PAGE, \
PLAIN_TEXT_AGENTS, PLAIN_TEXT_PAGES, \ PLAIN_TEXT_AGENTS, PLAIN_TEXT_PAGES, \
MY_EXTERNAL_IP MY_EXTERNAL_IP, QUERY_LIMITS
from location import is_location_blocked, location_processing from location import is_location_blocked, location_processing
from limits import Limits from limits import Limits
from wttr import get_wetter, get_moon 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)) os.makedirs(os.path.dirname(LOG_FILE))
logging.basicConfig(filename=LOG_FILE, level=logging.DEBUG, format='%(asctime)s %(message)s') 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): def show_text_file(name, lang):
""" """