Snake case

main
Bob Mottram 2021-12-25 18:27:11 +00:00
parent 2cd2857d57
commit 07aa04947c
4 changed files with 51 additions and 50 deletions

View File

@ -598,9 +598,9 @@ class PubServer(BaseHTTPRequestHandler):
return True
# is the User-Agent type blocked? eg. "Mastodon"
if self.server.userAgentsBlocked:
if self.server.user_agents_blocked:
blockedUA = False
for agentName in self.server.userAgentsBlocked:
for agentName in self.server.user_agents_blocked:
if agentName in agentStr:
blockedUA = True
break
@ -6395,26 +6395,27 @@ class PubServer(BaseHTTPRequestHandler):
newListsEnabled)
# save blocked user agents
userAgentsBlocked = []
if fields.get('userAgentsBlockedStr'):
userAgentsBlockedStr = \
fields['userAgentsBlockedStr']
userAgentsBlockedList = \
userAgentsBlockedStr.split('\n')
for ua in userAgentsBlockedList:
if ua in userAgentsBlocked:
user_agents_blocked = []
if fields.get('user_agents_blockedStr'):
user_agents_blockedStr = \
fields['user_agents_blockedStr']
user_agents_blockedList = \
user_agents_blockedStr.split('\n')
for ua in user_agents_blockedList:
if ua in user_agents_blocked:
continue
userAgentsBlocked.append(ua.strip())
if str(self.server.userAgentsBlocked) != \
str(userAgentsBlocked):
self.server.userAgentsBlocked = userAgentsBlocked
userAgentsBlockedStr = ''
for ua in userAgentsBlocked:
if userAgentsBlockedStr:
userAgentsBlockedStr += ','
userAgentsBlockedStr += ua
setConfigParam(base_dir, 'userAgentsBlocked',
userAgentsBlockedStr)
user_agents_blocked.append(ua.strip())
if str(self.server.user_agents_blocked) != \
str(user_agents_blocked):
self.server.user_agents_blocked = \
user_agents_blocked
user_agents_blockedStr = ''
for ua in user_agents_blocked:
if user_agents_blockedStr:
user_agents_blockedStr += ','
user_agents_blockedStr += ua
setConfigParam(base_dir, 'user_agents_blocked',
user_agents_blockedStr)
# save peertube instances list
peertubeInstancesFile = \
@ -13050,7 +13051,7 @@ class PubServer(BaseHTTPRequestHandler):
peertubeInstances,
self.server.textModeBanner,
city,
self.server.userAgentsBlocked,
self.server.user_agents_blocked,
accessKeys,
default_reply_interval_hrs,
self.server.CWlists,
@ -18405,7 +18406,7 @@ def runDaemon(content_license_url: str,
low_bandwidth: bool,
max_like_count: int,
shared_items_federated_domains: [],
userAgentsBlocked: [],
user_agents_blocked: [],
logLoginFailures: bool,
city: str,
showNodeInfoAccounts: bool,
@ -18561,7 +18562,7 @@ def runDaemon(content_license_url: str,
httpd.low_bandwidth = low_bandwidth
# list of blocked user agent types within the User-Agent header
httpd.userAgentsBlocked = userAgentsBlocked
httpd.user_agents_blocked = user_agents_blocked
httpd.unitTest = unitTest
httpd.allowLocalNetworkAccess = allowLocalNetworkAccess

View File

@ -3138,17 +3138,17 @@ low_bandwidth = \
if low_bandwidth is not None:
args.low_bandwidth = bool(low_bandwidth)
userAgentsBlocked = []
user_agents_blocked = []
if args.userAgentBlocks:
userAgentsBlockedStr = args.userAgentBlocks
setConfigParam(base_dir, 'userAgentsBlocked', userAgentsBlockedStr)
user_agents_blockedStr = args.userAgentBlocks
setConfigParam(base_dir, 'user_agents_blocked', user_agents_blockedStr)
else:
userAgentsBlockedStr = \
getConfigParam(base_dir, 'userAgentsBlocked')
if userAgentsBlockedStr:
agentBlocksList = userAgentsBlockedStr.split(',')
user_agents_blockedStr = \
getConfigParam(base_dir, 'user_agents_blocked')
if user_agents_blockedStr:
agentBlocksList = user_agents_blockedStr.split(',')
for agentBlockStr in agentBlocksList:
userAgentsBlocked.append(agentBlockStr.strip())
user_agents_blocked.append(agentBlockStr.strip())
lists_enabled = ''
if args.lists_enabled:
@ -3215,7 +3215,7 @@ if __name__ == "__main__":
args.default_reply_interval_hrs,
args.low_bandwidth, args.max_like_count,
shared_items_federated_domains,
userAgentsBlocked,
user_agents_blocked,
args.logLoginFailures,
args.city,
args.showNodeInfoAccounts,

View File

@ -790,7 +790,7 @@ def createServerAlice(path: str, domain: str, port: int,
showNodeInfoVersion = True
city = 'London, England'
logLoginFailures = False
userAgentsBlocked = []
user_agents_blocked = []
max_like_count = 10
default_reply_interval_hrs = 9999999999
lists_enabled = ''
@ -800,7 +800,7 @@ def createServerAlice(path: str, domain: str, port: int,
lists_enabled, default_reply_interval_hrs,
low_bandwidth, max_like_count,
shared_items_federated_domains,
userAgentsBlocked,
user_agents_blocked,
logLoginFailures, city,
showNodeInfoAccounts,
showNodeInfoVersion,
@ -932,7 +932,7 @@ def createServerBob(path: str, domain: str, port: int,
showNodeInfoVersion = True
city = 'London, England'
logLoginFailures = False
userAgentsBlocked = []
user_agents_blocked = []
max_like_count = 10
default_reply_interval_hrs = 9999999999
lists_enabled = ''
@ -942,7 +942,7 @@ def createServerBob(path: str, domain: str, port: int,
lists_enabled, default_reply_interval_hrs,
low_bandwidth, max_like_count,
shared_items_federated_domains,
userAgentsBlocked,
user_agents_blocked,
logLoginFailures, city,
showNodeInfoAccounts,
showNodeInfoVersion,
@ -1001,7 +1001,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
showNodeInfoVersion = True
city = 'London, England'
logLoginFailures = False
userAgentsBlocked = []
user_agents_blocked = []
max_like_count = 10
low_bandwidth = True
default_reply_interval_hrs = 9999999999
@ -1012,7 +1012,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
lists_enabled, default_reply_interval_hrs,
low_bandwidth, max_like_count,
shared_items_federated_domains,
userAgentsBlocked,
user_agents_blocked,
logLoginFailures, city,
showNodeInfoAccounts,
showNodeInfoVersion,
@ -1073,7 +1073,7 @@ def createServerGroup(path: str, domain: str, port: int,
showNodeInfoVersion = True
city = 'London, England'
logLoginFailures = False
userAgentsBlocked = []
user_agents_blocked = []
max_like_count = 10
low_bandwidth = True
default_reply_interval_hrs = 9999999999
@ -1084,7 +1084,7 @@ def createServerGroup(path: str, domain: str, port: int,
lists_enabled, default_reply_interval_hrs,
low_bandwidth, max_like_count,
shared_items_federated_domains,
userAgentsBlocked,
user_agents_blocked,
logLoginFailures, city,
showNodeInfoAccounts,
showNodeInfoVersion,

View File

@ -1592,7 +1592,7 @@ def _htmlEditProfileSharedItems(base_dir: str, nickname: str, domain: str,
def _htmlEditProfileFiltering(base_dir: str, nickname: str, domain: str,
userAgentsBlocked: str,
user_agents_blocked: str,
translate: {}, replyIntervalHours: int,
CWlists: {}, lists_enabled: str) -> str:
"""Filtering and blocking section of edit profile screen
@ -1759,14 +1759,14 @@ def _htmlEditProfileFiltering(base_dir: str, nickname: str, domain: str,
'<a href="/users/' + nickname + '/crawlers">' + \
translate['Known Web Crawlers'] + '</a><br>\n'
userAgentsBlockedStr = ''
for ua in userAgentsBlocked:
if userAgentsBlockedStr:
userAgentsBlockedStr += '\n'
userAgentsBlockedStr += ua
user_agents_blockedStr = ''
for ua in user_agents_blocked:
if user_agents_blockedStr:
user_agents_blockedStr += '\n'
user_agents_blockedStr += ua
editProfileForm += \
editTextArea(translate['Blocked User Agents'],
'userAgentsBlockedStr', userAgentsBlockedStr,
'user_agents_blockedStr', user_agents_blockedStr,
200, '', False)
CWlistsStr = ''
@ -2088,7 +2088,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
defaultTimeline: str, theme: str,
peertubeInstances: [],
textModeBanner: str, city: str,
userAgentsBlocked: str,
user_agents_blocked: str,
accessKeys: {},
default_reply_interval_hrs: int,
CWlists: {}, lists_enabled: str) -> str:
@ -2300,7 +2300,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
default_reply_interval_hrs)
editProfileForm += \
_htmlEditProfileFiltering(base_dir, nickname, domain,
userAgentsBlocked, translate,
user_agents_blocked, translate,
replyIntervalHours,
CWlists, lists_enabled)