mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
2cd2857d57
commit
07aa04947c
49
daemon.py
49
daemon.py
|
@ -598,9 +598,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# is the User-Agent type blocked? eg. "Mastodon"
|
# is the User-Agent type blocked? eg. "Mastodon"
|
||||||
if self.server.userAgentsBlocked:
|
if self.server.user_agents_blocked:
|
||||||
blockedUA = False
|
blockedUA = False
|
||||||
for agentName in self.server.userAgentsBlocked:
|
for agentName in self.server.user_agents_blocked:
|
||||||
if agentName in agentStr:
|
if agentName in agentStr:
|
||||||
blockedUA = True
|
blockedUA = True
|
||||||
break
|
break
|
||||||
|
@ -6395,26 +6395,27 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
newListsEnabled)
|
newListsEnabled)
|
||||||
|
|
||||||
# save blocked user agents
|
# save blocked user agents
|
||||||
userAgentsBlocked = []
|
user_agents_blocked = []
|
||||||
if fields.get('userAgentsBlockedStr'):
|
if fields.get('user_agents_blockedStr'):
|
||||||
userAgentsBlockedStr = \
|
user_agents_blockedStr = \
|
||||||
fields['userAgentsBlockedStr']
|
fields['user_agents_blockedStr']
|
||||||
userAgentsBlockedList = \
|
user_agents_blockedList = \
|
||||||
userAgentsBlockedStr.split('\n')
|
user_agents_blockedStr.split('\n')
|
||||||
for ua in userAgentsBlockedList:
|
for ua in user_agents_blockedList:
|
||||||
if ua in userAgentsBlocked:
|
if ua in user_agents_blocked:
|
||||||
continue
|
continue
|
||||||
userAgentsBlocked.append(ua.strip())
|
user_agents_blocked.append(ua.strip())
|
||||||
if str(self.server.userAgentsBlocked) != \
|
if str(self.server.user_agents_blocked) != \
|
||||||
str(userAgentsBlocked):
|
str(user_agents_blocked):
|
||||||
self.server.userAgentsBlocked = userAgentsBlocked
|
self.server.user_agents_blocked = \
|
||||||
userAgentsBlockedStr = ''
|
user_agents_blocked
|
||||||
for ua in userAgentsBlocked:
|
user_agents_blockedStr = ''
|
||||||
if userAgentsBlockedStr:
|
for ua in user_agents_blocked:
|
||||||
userAgentsBlockedStr += ','
|
if user_agents_blockedStr:
|
||||||
userAgentsBlockedStr += ua
|
user_agents_blockedStr += ','
|
||||||
setConfigParam(base_dir, 'userAgentsBlocked',
|
user_agents_blockedStr += ua
|
||||||
userAgentsBlockedStr)
|
setConfigParam(base_dir, 'user_agents_blocked',
|
||||||
|
user_agents_blockedStr)
|
||||||
|
|
||||||
# save peertube instances list
|
# save peertube instances list
|
||||||
peertubeInstancesFile = \
|
peertubeInstancesFile = \
|
||||||
|
@ -13050,7 +13051,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
peertubeInstances,
|
peertubeInstances,
|
||||||
self.server.textModeBanner,
|
self.server.textModeBanner,
|
||||||
city,
|
city,
|
||||||
self.server.userAgentsBlocked,
|
self.server.user_agents_blocked,
|
||||||
accessKeys,
|
accessKeys,
|
||||||
default_reply_interval_hrs,
|
default_reply_interval_hrs,
|
||||||
self.server.CWlists,
|
self.server.CWlists,
|
||||||
|
@ -18405,7 +18406,7 @@ def runDaemon(content_license_url: str,
|
||||||
low_bandwidth: bool,
|
low_bandwidth: bool,
|
||||||
max_like_count: int,
|
max_like_count: int,
|
||||||
shared_items_federated_domains: [],
|
shared_items_federated_domains: [],
|
||||||
userAgentsBlocked: [],
|
user_agents_blocked: [],
|
||||||
logLoginFailures: bool,
|
logLoginFailures: bool,
|
||||||
city: str,
|
city: str,
|
||||||
showNodeInfoAccounts: bool,
|
showNodeInfoAccounts: bool,
|
||||||
|
@ -18561,7 +18562,7 @@ def runDaemon(content_license_url: str,
|
||||||
httpd.low_bandwidth = low_bandwidth
|
httpd.low_bandwidth = low_bandwidth
|
||||||
|
|
||||||
# list of blocked user agent types within the User-Agent header
|
# 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.unitTest = unitTest
|
||||||
httpd.allowLocalNetworkAccess = allowLocalNetworkAccess
|
httpd.allowLocalNetworkAccess = allowLocalNetworkAccess
|
||||||
|
|
18
epicyon.py
18
epicyon.py
|
@ -3138,17 +3138,17 @@ low_bandwidth = \
|
||||||
if low_bandwidth is not None:
|
if low_bandwidth is not None:
|
||||||
args.low_bandwidth = bool(low_bandwidth)
|
args.low_bandwidth = bool(low_bandwidth)
|
||||||
|
|
||||||
userAgentsBlocked = []
|
user_agents_blocked = []
|
||||||
if args.userAgentBlocks:
|
if args.userAgentBlocks:
|
||||||
userAgentsBlockedStr = args.userAgentBlocks
|
user_agents_blockedStr = args.userAgentBlocks
|
||||||
setConfigParam(base_dir, 'userAgentsBlocked', userAgentsBlockedStr)
|
setConfigParam(base_dir, 'user_agents_blocked', user_agents_blockedStr)
|
||||||
else:
|
else:
|
||||||
userAgentsBlockedStr = \
|
user_agents_blockedStr = \
|
||||||
getConfigParam(base_dir, 'userAgentsBlocked')
|
getConfigParam(base_dir, 'user_agents_blocked')
|
||||||
if userAgentsBlockedStr:
|
if user_agents_blockedStr:
|
||||||
agentBlocksList = userAgentsBlockedStr.split(',')
|
agentBlocksList = user_agents_blockedStr.split(',')
|
||||||
for agentBlockStr in agentBlocksList:
|
for agentBlockStr in agentBlocksList:
|
||||||
userAgentsBlocked.append(agentBlockStr.strip())
|
user_agents_blocked.append(agentBlockStr.strip())
|
||||||
|
|
||||||
lists_enabled = ''
|
lists_enabled = ''
|
||||||
if args.lists_enabled:
|
if args.lists_enabled:
|
||||||
|
@ -3215,7 +3215,7 @@ if __name__ == "__main__":
|
||||||
args.default_reply_interval_hrs,
|
args.default_reply_interval_hrs,
|
||||||
args.low_bandwidth, args.max_like_count,
|
args.low_bandwidth, args.max_like_count,
|
||||||
shared_items_federated_domains,
|
shared_items_federated_domains,
|
||||||
userAgentsBlocked,
|
user_agents_blocked,
|
||||||
args.logLoginFailures,
|
args.logLoginFailures,
|
||||||
args.city,
|
args.city,
|
||||||
args.showNodeInfoAccounts,
|
args.showNodeInfoAccounts,
|
||||||
|
|
16
tests.py
16
tests.py
|
@ -790,7 +790,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
showNodeInfoVersion = True
|
showNodeInfoVersion = True
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
logLoginFailures = False
|
logLoginFailures = False
|
||||||
userAgentsBlocked = []
|
user_agents_blocked = []
|
||||||
max_like_count = 10
|
max_like_count = 10
|
||||||
default_reply_interval_hrs = 9999999999
|
default_reply_interval_hrs = 9999999999
|
||||||
lists_enabled = ''
|
lists_enabled = ''
|
||||||
|
@ -800,7 +800,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
lists_enabled, default_reply_interval_hrs,
|
lists_enabled, default_reply_interval_hrs,
|
||||||
low_bandwidth, max_like_count,
|
low_bandwidth, max_like_count,
|
||||||
shared_items_federated_domains,
|
shared_items_federated_domains,
|
||||||
userAgentsBlocked,
|
user_agents_blocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
showNodeInfoAccounts,
|
showNodeInfoAccounts,
|
||||||
showNodeInfoVersion,
|
showNodeInfoVersion,
|
||||||
|
@ -932,7 +932,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
showNodeInfoVersion = True
|
showNodeInfoVersion = True
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
logLoginFailures = False
|
logLoginFailures = False
|
||||||
userAgentsBlocked = []
|
user_agents_blocked = []
|
||||||
max_like_count = 10
|
max_like_count = 10
|
||||||
default_reply_interval_hrs = 9999999999
|
default_reply_interval_hrs = 9999999999
|
||||||
lists_enabled = ''
|
lists_enabled = ''
|
||||||
|
@ -942,7 +942,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
lists_enabled, default_reply_interval_hrs,
|
lists_enabled, default_reply_interval_hrs,
|
||||||
low_bandwidth, max_like_count,
|
low_bandwidth, max_like_count,
|
||||||
shared_items_federated_domains,
|
shared_items_federated_domains,
|
||||||
userAgentsBlocked,
|
user_agents_blocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
showNodeInfoAccounts,
|
showNodeInfoAccounts,
|
||||||
showNodeInfoVersion,
|
showNodeInfoVersion,
|
||||||
|
@ -1001,7 +1001,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
showNodeInfoVersion = True
|
showNodeInfoVersion = True
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
logLoginFailures = False
|
logLoginFailures = False
|
||||||
userAgentsBlocked = []
|
user_agents_blocked = []
|
||||||
max_like_count = 10
|
max_like_count = 10
|
||||||
low_bandwidth = True
|
low_bandwidth = True
|
||||||
default_reply_interval_hrs = 9999999999
|
default_reply_interval_hrs = 9999999999
|
||||||
|
@ -1012,7 +1012,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
lists_enabled, default_reply_interval_hrs,
|
lists_enabled, default_reply_interval_hrs,
|
||||||
low_bandwidth, max_like_count,
|
low_bandwidth, max_like_count,
|
||||||
shared_items_federated_domains,
|
shared_items_federated_domains,
|
||||||
userAgentsBlocked,
|
user_agents_blocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
showNodeInfoAccounts,
|
showNodeInfoAccounts,
|
||||||
showNodeInfoVersion,
|
showNodeInfoVersion,
|
||||||
|
@ -1073,7 +1073,7 @@ def createServerGroup(path: str, domain: str, port: int,
|
||||||
showNodeInfoVersion = True
|
showNodeInfoVersion = True
|
||||||
city = 'London, England'
|
city = 'London, England'
|
||||||
logLoginFailures = False
|
logLoginFailures = False
|
||||||
userAgentsBlocked = []
|
user_agents_blocked = []
|
||||||
max_like_count = 10
|
max_like_count = 10
|
||||||
low_bandwidth = True
|
low_bandwidth = True
|
||||||
default_reply_interval_hrs = 9999999999
|
default_reply_interval_hrs = 9999999999
|
||||||
|
@ -1084,7 +1084,7 @@ def createServerGroup(path: str, domain: str, port: int,
|
||||||
lists_enabled, default_reply_interval_hrs,
|
lists_enabled, default_reply_interval_hrs,
|
||||||
low_bandwidth, max_like_count,
|
low_bandwidth, max_like_count,
|
||||||
shared_items_federated_domains,
|
shared_items_federated_domains,
|
||||||
userAgentsBlocked,
|
user_agents_blocked,
|
||||||
logLoginFailures, city,
|
logLoginFailures, city,
|
||||||
showNodeInfoAccounts,
|
showNodeInfoAccounts,
|
||||||
showNodeInfoVersion,
|
showNodeInfoVersion,
|
||||||
|
|
|
@ -1592,7 +1592,7 @@ def _htmlEditProfileSharedItems(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
|
|
||||||
def _htmlEditProfileFiltering(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,
|
translate: {}, replyIntervalHours: int,
|
||||||
CWlists: {}, lists_enabled: str) -> str:
|
CWlists: {}, lists_enabled: str) -> str:
|
||||||
"""Filtering and blocking section of edit profile screen
|
"""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">' + \
|
'<a href="/users/' + nickname + '/crawlers">' + \
|
||||||
translate['Known Web Crawlers'] + '</a><br>\n'
|
translate['Known Web Crawlers'] + '</a><br>\n'
|
||||||
|
|
||||||
userAgentsBlockedStr = ''
|
user_agents_blockedStr = ''
|
||||||
for ua in userAgentsBlocked:
|
for ua in user_agents_blocked:
|
||||||
if userAgentsBlockedStr:
|
if user_agents_blockedStr:
|
||||||
userAgentsBlockedStr += '\n'
|
user_agents_blockedStr += '\n'
|
||||||
userAgentsBlockedStr += ua
|
user_agents_blockedStr += ua
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
editTextArea(translate['Blocked User Agents'],
|
editTextArea(translate['Blocked User Agents'],
|
||||||
'userAgentsBlockedStr', userAgentsBlockedStr,
|
'user_agents_blockedStr', user_agents_blockedStr,
|
||||||
200, '', False)
|
200, '', False)
|
||||||
|
|
||||||
CWlistsStr = ''
|
CWlistsStr = ''
|
||||||
|
@ -2088,7 +2088,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
defaultTimeline: str, theme: str,
|
defaultTimeline: str, theme: str,
|
||||||
peertubeInstances: [],
|
peertubeInstances: [],
|
||||||
textModeBanner: str, city: str,
|
textModeBanner: str, city: str,
|
||||||
userAgentsBlocked: str,
|
user_agents_blocked: str,
|
||||||
accessKeys: {},
|
accessKeys: {},
|
||||||
default_reply_interval_hrs: int,
|
default_reply_interval_hrs: int,
|
||||||
CWlists: {}, lists_enabled: str) -> str:
|
CWlists: {}, lists_enabled: str) -> str:
|
||||||
|
@ -2300,7 +2300,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
|
||||||
default_reply_interval_hrs)
|
default_reply_interval_hrs)
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
_htmlEditProfileFiltering(base_dir, nickname, domain,
|
_htmlEditProfileFiltering(base_dir, nickname, domain,
|
||||||
userAgentsBlocked, translate,
|
user_agents_blocked, translate,
|
||||||
replyIntervalHours,
|
replyIntervalHours,
|
||||||
CWlists, lists_enabled)
|
CWlists, lists_enabled)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue