From 6eaffd514dd0638e594d97da710505703b1a0e28 Mon Sep 17 00:00:00 2001 From: kaiyou Date: Sun, 5 Nov 2017 18:30:53 +0100 Subject: [PATCH] Make it possible to opt out of statistics --- core/admin/mailu/__init__.py | 12 +++++++----- docs/compose/.env.dist | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/admin/mailu/__init__.py b/core/admin/mailu/__init__.py index 1fdd4b9e..f34a75f1 100644 --- a/core/admin/mailu/__init__.py +++ b/core/admin/mailu/__init__.py @@ -41,7 +41,8 @@ default_config = { 'PASSWORD_SCHEME': 'SHA512-CRYPT', 'WEBMAIL': 'none', 'AUTH_RATELIMIT': '10/minute;1000/hour', - 'RATELIMIT_STORAGE_URL': 'redis://redis' + 'RATELIMIT_STORAGE_URL': 'redis://redis', + 'DISABLE_STATISTICS': 'False' } # Load configuration from the environment if available @@ -62,10 +63,11 @@ else: instance_id = str(uuid.uuid4()) with open(app.config["INSTANCE_ID_PATH"], "w") as handle: handle.write(instance_id) -try: - socket.gethostbyname(app.config["STATS_ENDPOINT"].format(instance_id)) -except: - pass +if app.config["DISABLE_STATISTICS"].lower() != "true": + try: + socket.gethostbyname(app.config["STATS_ENDPOINT"].format(instance_id)) + except: + pass # Debugging toolbar if app.config.get("DEBUG"): diff --git a/docs/compose/.env.dist b/docs/compose/.env.dist index 3d4a82b6..eb4d7e44 100644 --- a/docs/compose/.env.dist +++ b/docs/compose/.env.dist @@ -36,6 +36,9 @@ TLS_FLAVOR=cert # Authentication rate limit (per source IP address) AUTH_RATELIMIT=10/minute;1000/hour +# Opt-out of statistics, replace with "True" to opt out +DISABLE_STATISTICS=False + ################################### # Optional features ###################################