diff --git a/boards/config/default_settings.ini b/boards/config/default_settings.ini --- a/boards/config/default_settings.ini +++ b/boards/config/default_settings.ini @@ -19,6 +19,7 @@ Autoban = false DefaultTag = test MaxFileCount = 5 AdditionalSpoilerSpaces = false +BanWhitelist = 127.0.0.1 [Messages] # Thread bumplimit diff --git a/boards/settings.py b/boards/settings.py --- a/boards/settings.py +++ b/boards/settings.py @@ -27,3 +27,7 @@ def get_list_dict(section, name): return [item.split(':') for item in str_dict.split(',')] +def get_list(section, name): + str_list = get(section, name) + return str_list.split(',') + diff --git a/boards/views/base.py b/boards/views/base.py --- a/boards/views/base.py +++ b/boards/views/base.py @@ -1,7 +1,7 @@ from django.db import transaction from django.views.generic import View -from boards import utils +from boards import utils, settings from boards.models.user import Ban @@ -22,9 +22,11 @@ class BaseBoardView(View): """ ip = utils.get_client_ip(request) - ban, created = Ban.objects.get_or_create(ip=ip) - if created: - ban.can_read = False - ban.reason = BAN_REASON_SPAM - ban.save() + whitelist = settings.get_list('Forms', 'BanWhitelist') + if not ip in whitelist: + ban, created = Ban.objects.get_or_create(ip=ip) + if created: + ban.can_read = False + ban.reason = BAN_REASON_SPAM + ban.save()