Set broch mode on daemon start

merge-requests/18/merge
Bob Mottram 2021-02-16 09:50:50 +00:00
parent 1adc343ebd
commit 0f1b7eb67b
2 changed files with 7 additions and 4 deletions

View File

@ -378,6 +378,10 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
os.remove(allowFilename)
print('Broch mode turned off')
else:
if os.path.isfile(allowFilename):
lastModified = fileLastModified(allowFilename)
print('Broch mode already activated ' + lastModified)
return
# generate instance allow list
allowedDomains = [domainFull]
followFiles = ('following.txt', 'followers.txt')

View File

@ -4554,7 +4554,6 @@ class PubServer(BaseHTTPRequestHandler):
setBrochMode(self.server.baseDir,
self.server.domainFull,
brochMode)
self.server.brochMode = brochMode
setConfigParam(baseDir, "brochMode", brochMode)
# change moderators list
@ -14022,9 +14021,6 @@ def runDaemon(brochMode: bool,
# maximum number of posts to appear in the newswire on the right column
httpd.maxNewswirePosts = maxNewswirePosts
# whether to enable broch mode, which locks down the instance
httpd.brochMode = brochMode
# whether to require that all incoming posts have valid jsonld signatures
httpd.verifyAllSignatures = verifyAllSignatures
@ -14195,6 +14191,9 @@ def runDaemon(brochMode: bool,
# cache to store css files
httpd.cssCache = {}
# whether to enable broch mode, which locks down the instance
setBrochMode(baseDir, httpd.domainFull, brochMode)
if not os.path.isdir(baseDir + '/accounts/inbox@' + domain):
print('Creating shared inbox: inbox@' + domain)
createSharedInbox(baseDir, 'inbox', domain, port, httpPrefix)