Snake case

main
Bob Mottram 2021-12-25 18:38:19 +00:00
parent 091b576d3c
commit b028216dfd
7 changed files with 47 additions and 47 deletions

View File

@ -320,7 +320,7 @@ def isBlockedDomain(base_dir: str, domain: str,
shortDomain = _getShortDomain(domain)
if not brochModeIsActive(base_dir):
if not broch_modeIsActive(base_dir):
if blockedCache:
for blockedStr in blockedCache:
if '*@' + domain in blockedStr:
@ -368,7 +368,7 @@ def isBlocked(base_dir: str, nickname: str, domain: str,
if blockNickname and blockDomain:
blockHandle = blockNickname + '@' + blockDomain
if not brochModeIsActive(base_dir):
if not broch_modeIsActive(base_dir):
# instance level block list
if blockedCache:
for blockedStr in blockedCache:
@ -873,7 +873,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
print('DEBUG: post undo mute via c2s - ' + postFilename)
def brochModeIsActive(base_dir: str) -> bool:
def broch_modeIsActive(base_dir: str) -> bool:
"""Returns true if broch mode is active
"""
allowFilename = base_dir + '/accounts/allowedinstances.txt'
@ -943,10 +943,10 @@ def setBrochMode(base_dir: str, domainFull: str, enabled: bool) -> None:
print('EX: Broch mode not enabled due to file write ' + str(ex))
return
setConfigParam(base_dir, "brochMode", enabled)
setConfigParam(base_dir, "broch_mode", enabled)
def brochModeLapses(base_dir: str, lapseDays: int) -> bool:
def broch_modeLapses(base_dir: str, lapseDays: int) -> bool:
"""After broch mode is enabled it automatically
elapses after a period of time
"""
@ -959,7 +959,7 @@ def brochModeLapses(base_dir: str, lapseDays: int) -> bool:
modifiedDate = \
datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
except BaseException:
print('EX: brochModeLapses date not parsed ' + str(lastModified))
print('EX: broch_modeLapses date not parsed ' + str(lastModified))
return False
if not modifiedDate:
return False
@ -971,10 +971,10 @@ def brochModeLapses(base_dir: str, lapseDays: int) -> bool:
os.remove(allowFilename)
removed = True
except OSError:
print('EX: brochModeLapses allow file not deleted ' +
print('EX: broch_modeLapses allow file not deleted ' +
str(allowFilename))
if removed:
setConfigParam(base_dir, "brochMode", False)
setConfigParam(base_dir, "broch_mode", False)
print('Broch mode has elapsed')
return True
return False

View File

@ -134,7 +134,7 @@ from blocking import updateBlockedCache
from blocking import mutePost
from blocking import unmutePost
from blocking import setBrochMode
from blocking import brochModeIsActive
from blocking import broch_modeIsActive
from blocking import addBlock
from blocking import removeBlock
from blocking import addGlobalBlock
@ -1061,7 +1061,7 @@ class PubServer(BaseHTTPRequestHandler):
print('mastodon api v1: nickname ' + str(nickname))
self._updateKnownCrawlers(uaStr)
brochMode = brochModeIsActive(base_dir)
broch_mode = broch_modeIsActive(base_dir)
sendJson, sendJsonStr = mastoApiV1Response(path,
callingDomain,
uaStr,
@ -1078,7 +1078,7 @@ class PubServer(BaseHTTPRequestHandler):
projectVersion,
customEmoji,
show_node_info_accounts,
brochMode)
broch_mode)
if sendJson is not None:
msg = json.dumps(sendJson).encode('utf-8')
@ -1133,14 +1133,14 @@ class PubServer(BaseHTTPRequestHandler):
# For example, if this or allied instances are being attacked
# then numbers of accounts may be changing as people
# migrate, and that information may be useful to an adversary
brochMode = brochModeIsActive(self.server.base_dir)
broch_mode = broch_modeIsActive(self.server.base_dir)
nodeInfoVersion = self.server.projectVersion
if not self.server.show_node_info_version or brochMode:
if not self.server.show_node_info_version or broch_mode:
nodeInfoVersion = '0.0.0'
show_node_info_accounts = self.server.show_node_info_accounts
if brochMode:
if broch_mode:
show_node_info_accounts = False
instanceUrl = self._getInstanceUrl(callingDomain)
@ -5571,18 +5571,18 @@ class PubServer(BaseHTTPRequestHandler):
setConfigParam(base_dir, "verifyAllSignatures",
verifyAllSignatures)
brochMode = False
if fields.get('brochMode'):
if fields['brochMode'] == 'on':
brochMode = True
broch_mode = False
if fields.get('broch_mode'):
if fields['broch_mode'] == 'on':
broch_mode = True
currBrochMode = \
getConfigParam(base_dir, "brochMode")
if brochMode != currBrochMode:
getConfigParam(base_dir, "broch_mode")
if broch_mode != currBrochMode:
setBrochMode(self.server.base_dir,
self.server.domainFull,
brochMode)
setConfigParam(base_dir, "brochMode",
brochMode)
broch_mode)
setConfigParam(base_dir, "broch_mode",
broch_mode)
# shared item federation domains
siDomainUpdated = False
@ -18411,7 +18411,7 @@ def runDaemon(content_license_url: str,
city: str,
show_node_info_accounts: bool,
show_node_info_version: bool,
brochMode: bool,
broch_mode: bool,
verifyAllSignatures: bool,
sendThreadsTimeoutMins: int,
dormantMonths: int,
@ -18755,7 +18755,7 @@ def runDaemon(content_license_url: str,
metadataCustomEmoji(base_dir, http_prefix, httpd.domainFull)
# whether to enable broch mode, which locks down the instance
setBrochMode(base_dir, httpd.domainFull, brochMode)
setBrochMode(base_dir, httpd.domainFull, broch_mode)
if not os.path.isdir(base_dir + '/accounts/inbox@' + domain):
print('Creating shared inbox: inbox@' + domain)

View File

@ -377,8 +377,8 @@ parser.add_argument("--verifyAllSignatures",
const=True, default=False,
help="Whether to require that all incoming " +
"posts have valid jsonld signatures")
parser.add_argument("--brochMode",
dest='brochMode',
parser.add_argument("--broch_mode",
dest='broch_mode',
type=str2bool, nargs='?',
const=True, default=False,
help="Enable broch mode")
@ -3113,10 +3113,10 @@ verifyAllSignatures = \
if verifyAllSignatures is not None:
args.verifyAllSignatures = bool(verifyAllSignatures)
brochMode = \
getConfigParam(base_dir, 'brochMode')
if brochMode is not None:
args.brochMode = bool(brochMode)
broch_mode = \
getConfigParam(base_dir, 'broch_mode')
if broch_mode is not None:
args.broch_mode = bool(broch_mode)
log_login_failures = \
getConfigParam(base_dir, 'log_login_failures')
@ -3220,7 +3220,7 @@ if __name__ == "__main__":
args.city,
args.show_node_info_accounts,
args.show_node_info_version,
args.brochMode,
args.broch_mode,
args.verifyAllSignatures,
args.sendThreadsTimeoutMins,
args.dormantMonths,

View File

@ -84,7 +84,7 @@ from bookmarks import updateBookmarksCollection
from bookmarks import undoBookmarksCollectionEntry
from blocking import isBlocked
from blocking import isBlockedDomain
from blocking import brochModeLapses
from blocking import broch_modeLapses
from filters import isFiltered
from utils import updateAnnounceCollection
from utils import undoAnnounceCollectionEntry
@ -4127,7 +4127,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
heartBeatCtr += 1
if heartBeatCtr >= 10:
# turn off broch mode after it has timed out
if brochModeLapses(base_dir, brochLapseDays):
if broch_modeLapses(base_dir, brochLapseDays):
brochLapseDays = random.randrange(7, 14)
print('>>> Heartbeat Q:' + str(len(queue)) + ' ' +
'{:%F %T}'.format(datetime.datetime.now()))

View File

@ -94,7 +94,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
projectVersion: str,
customEmoji: [],
show_node_info_accounts: bool,
brochMode: bool) -> ({}, str):
broch_mode: bool) -> ({}, str):
"""This is a vestigil mastodon API for the purpose
of returning an empty result to sites like
https://mastopeek.app-dist.eu
@ -215,7 +215,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
domainFull = i2pDomain
http_prefix = 'http'
if brochMode:
if broch_mode:
show_node_info_accounts = False
sendJson = \

View File

@ -785,7 +785,7 @@ def createServerAlice(path: str, domain: str, port: int,
sendThreadsTimeoutMins = 30
maxFollowers = 10
verifyAllSignatures = True
brochMode = False
broch_mode = False
show_node_info_accounts = True
show_node_info_version = True
city = 'London, England'
@ -804,7 +804,7 @@ def createServerAlice(path: str, domain: str, port: int,
log_login_failures, city,
show_node_info_accounts,
show_node_info_version,
brochMode,
broch_mode,
verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts,
@ -927,7 +927,7 @@ def createServerBob(path: str, domain: str, port: int,
sendThreadsTimeoutMins = 30
maxFollowers = 10
verifyAllSignatures = True
brochMode = False
broch_mode = False
show_node_info_accounts = True
show_node_info_version = True
city = 'London, England'
@ -946,7 +946,7 @@ def createServerBob(path: str, domain: str, port: int,
log_login_failures, city,
show_node_info_accounts,
show_node_info_version,
brochMode,
broch_mode,
verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts,
@ -996,7 +996,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
sendThreadsTimeoutMins = 30
maxFollowers = 10
verifyAllSignatures = True
brochMode = False
broch_mode = False
show_node_info_accounts = True
show_node_info_version = True
city = 'London, England'
@ -1016,7 +1016,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
log_login_failures, city,
show_node_info_accounts,
show_node_info_version,
brochMode,
broch_mode,
verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts,
@ -1068,7 +1068,7 @@ def createServerGroup(path: str, domain: str, port: int,
sendThreadsTimeoutMins = 30
maxFollowers = 10
verifyAllSignatures = True
brochMode = False
broch_mode = False
show_node_info_accounts = True
show_node_info_version = True
city = 'London, England'
@ -1088,7 +1088,7 @@ def createServerGroup(path: str, domain: str, port: int,
log_login_failures, city,
show_node_info_accounts,
show_node_info_version,
brochMode,
broch_mode,
verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts,

View File

@ -1375,12 +1375,12 @@ def _htmlEditProfileInstance(base_dir: str, translate: {},
'verifyallsignatures', False)
instanceStr += translate['Enabling broch mode'] + '<br>\n'
if getConfigParam(base_dir, "brochMode"):
if getConfigParam(base_dir, "broch_mode"):
instanceStr += \
editCheckBox(translate['Broch mode'], 'brochMode', True)
editCheckBox(translate['Broch mode'], 'broch_mode', True)
else:
instanceStr += \
editCheckBox(translate['Broch mode'], 'brochMode', False)
editCheckBox(translate['Broch mode'], 'broch_mode', False)
# Instance type
instanceStr += \
' <br><label class="labels">' + \