##// END OF EJS Templates
Whitelist of IPs that will not be banned (starting from localhost)
neko259 -
r1993:564f7dbe default
parent child Browse files
Show More
@@ -1,50 +1,51 b''
1 [Version]
1 [Version]
2 Version = 4.7.1 Elon
2 Version = 4.7.1 Elon
3 SiteName = Neboard DEV
3 SiteName = Neboard DEV
4
4
5 [Cache]
5 [Cache]
6 # Timeout for caching, if cache is used
6 # Timeout for caching, if cache is used
7 CacheTimeout = 600
7 CacheTimeout = 600
8
8
9 [Forms]
9 [Forms]
10 # Max post length in characters
10 # Max post length in characters
11 MaxTextLength = 30000
11 MaxTextLength = 30000
12 MaxFileSize = 8000000
12 MaxFileSize = 8000000
13 LimitFirstPosting = true
13 LimitFirstPosting = true
14 LimitPostingSpeed = false
14 LimitPostingSpeed = false
15 PowDifficulty = 0
15 PowDifficulty = 0
16 # Delay in seconds
16 # Delay in seconds
17 PostingDelay = 30
17 PostingDelay = 30
18 Autoban = false
18 Autoban = false
19 DefaultTag = test
19 DefaultTag = test
20 MaxFileCount = 5
20 MaxFileCount = 5
21 AdditionalSpoilerSpaces = false
21 AdditionalSpoilerSpaces = false
22 BanWhitelist = 127.0.0.1
22
23
23 [Messages]
24 [Messages]
24 # Thread bumplimit
25 # Thread bumplimit
25 MaxPostsPerThread = 10
26 MaxPostsPerThread = 10
26 ThreadArchiveDays = 300
27 ThreadArchiveDays = 300
27 AnonymousMode = false
28 AnonymousMode = false
28
29
29 [View]
30 [View]
30 DefaultTheme = md
31 DefaultTheme = md
31 DefaultImageViewer = simple
32 DefaultImageViewer = simple
32 LastRepliesCount = 3
33 LastRepliesCount = 3
33 ThreadsPerPage = 3
34 ThreadsPerPage = 3
34 PostsPerPage = 10
35 PostsPerPage = 10
35 ImagesPerPageGallery = 20
36 ImagesPerPageGallery = 20
36 MaxFavoriteThreads = 20
37 MaxFavoriteThreads = 20
37 MaxLandingThreads = 20
38 MaxLandingThreads = 20
38 Themes=md:Mystic Dark,md_centered:Mystic Dark (centered),sw:Snow White,pg:Photon Grey,ad:Amanita Dark,iw:Inocibe White
39 Themes=md:Mystic Dark,md_centered:Mystic Dark (centered),sw:Snow White,pg:Photon Grey,ad:Amanita Dark,iw:Inocibe White
39 ImageViewers=simple:Simple,popup:Popup
40 ImageViewers=simple:Simple,popup:Popup
40
41
41 [Storage]
42 [Storage]
42 # Enable archiving threads instead of deletion when the thread limit is reached
43 # Enable archiving threads instead of deletion when the thread limit is reached
43 ArchiveThreads = true
44 ArchiveThreads = true
44
45
45 [RSS]
46 [RSS]
46 MaxItems = 20
47 MaxItems = 20
47
48
48 [External]
49 [External]
49 ImageSearchHost=
50 ImageSearchHost=
50 SourceFetcherTripcode=
51 SourceFetcherTripcode=
@@ -1,29 +1,33 b''
1 import configparser
1 import configparser
2
2
3
3
4 CONFIG_DEFAULT_SETTINGS = 'boards/config/default_settings.ini'
4 CONFIG_DEFAULT_SETTINGS = 'boards/config/default_settings.ini'
5 CONFIG_SETTINGS = 'boards/config/settings.ini'
5 CONFIG_SETTINGS = 'boards/config/settings.ini'
6
6
7
7
8 config = configparser.ConfigParser()
8 config = configparser.ConfigParser()
9 config.read(CONFIG_DEFAULT_SETTINGS)
9 config.read(CONFIG_DEFAULT_SETTINGS)
10 config.read(CONFIG_SETTINGS)
10 config.read(CONFIG_SETTINGS)
11
11
12
12
13 def get(section, name):
13 def get(section, name):
14 return config[section][name]
14 return config[section][name]
15
15
16
16
17 def get_int(section, name):
17 def get_int(section, name):
18 return int(get(section, name))
18 return int(get(section, name))
19
19
20
20
21 def get_bool(section, name):
21 def get_bool(section, name):
22 return get(section, name) == 'true'
22 return get(section, name) == 'true'
23
23
24
24
25 def get_list_dict(section, name):
25 def get_list_dict(section, name):
26 str_dict = get(section, name)
26 str_dict = get(section, name)
27 return [item.split(':') for item in str_dict.split(',')]
27 return [item.split(':') for item in str_dict.split(',')]
28
28
29
29
30 def get_list(section, name):
31 str_list = get(section, name)
32 return str_list.split(',')
33
@@ -1,30 +1,32 b''
1 from django.db import transaction
1 from django.db import transaction
2 from django.views.generic import View
2 from django.views.generic import View
3
3
4 from boards import utils
4 from boards import utils, settings
5 from boards.models.user import Ban
5 from boards.models.user import Ban
6
6
7
7
8 BAN_REASON_SPAM = 'Autoban: spam bot'
8 BAN_REASON_SPAM = 'Autoban: spam bot'
9
9
10 CONTEXT_FORM = 'form'
10 CONTEXT_FORM = 'form'
11
11
12
12
13 class BaseBoardView(View):
13 class BaseBoardView(View):
14
14
15 def get_context_data(self, **kwargs):
15 def get_context_data(self, **kwargs):
16 return dict()
16 return dict()
17
17
18 @transaction.atomic
18 @transaction.atomic
19 def _ban_current_user(self, request):
19 def _ban_current_user(self, request):
20 """
20 """
21 Add current user to the IP ban list
21 Add current user to the IP ban list
22 """
22 """
23
23
24 ip = utils.get_client_ip(request)
24 ip = utils.get_client_ip(request)
25 ban, created = Ban.objects.get_or_create(ip=ip)
25 whitelist = settings.get_list('Forms', 'BanWhitelist')
26 if created:
26 if not ip in whitelist:
27 ban.can_read = False
27 ban, created = Ban.objects.get_or_create(ip=ip)
28 ban.reason = BAN_REASON_SPAM
28 if created:
29 ban.save()
29 ban.can_read = False
30 ban.reason = BAN_REASON_SPAM
31 ban.save()
30
32
General Comments 0
You need to be logged in to leave comments. Login now