Blocked user agents list

main
Bob Mottram 2021-07-02 22:14:20 +01:00
parent ba126be369
commit cc6ce5ee2b
1 changed files with 12 additions and 8 deletions

View File

@ -5183,22 +5183,26 @@ class PubServer(BaseHTTPRequestHandler):
# save blocked user agents # save blocked user agents
# This is admin lebel and global to the instance # This is admin lebel and global to the instance
if path.startswith('/users/' + adminNickname + '/'): if path.startswith('/users/' + adminNickname + '/'):
userAgentsBlocked = '' userAgentsBlocked = []
if fields.get('userAgentsBlockedStr'): if fields.get('userAgentsBlockedStr'):
userAgentsBlockedStr = \ userAgentsBlockedStr = \
fields['userAgentsBlockedStr'] fields['userAgentsBlockedStr']
userAgentsBlockedList = \ userAgentsBlockedList = \
userAgentsBlockedStr.split('\n') userAgentsBlockedStr.split('\n')
for ua in userAgentsBlockedList: for ua in userAgentsBlockedList:
if userAgentsBlocked: if ua in userAgentsBlocked:
userAgentsBlocked += ',' continue
userAgentsBlocked += ua.strip() userAgentsBlocked.append(ua.strip())
else: if str(self.server.userAgentsBlocked) != \
userAgentsBlocked = '' str(userAgentsBlocked):
if self.server.userAgentsBlocked != userAgentsBlocked:
self.server.userAgentsBlocked = userAgentsBlocked self.server.userAgentsBlocked = userAgentsBlocked
userAgentsBlockedStr = ''
for ua in userAgentsBlocked:
if userAgentsBlockedStr:
userAgentsBlockedStr += ','
userAgentsBlockedStr += ua
setConfigParam(baseDir, 'userAgentsBlocked', setConfigParam(baseDir, 'userAgentsBlocked',
userAgentsBlocked) userAgentsBlockedStr)
# save peertube instances list # save peertube instances list
peertubeInstancesFile = \ peertubeInstancesFile = \