Add an instance identifier

master
Bob Mottram 2019-08-02 13:49:34 +01:00
parent b4cd2b926a
commit 0fb0f89462
3 changed files with 17 additions and 5 deletions

View File

@ -123,6 +123,7 @@ class PubServer(BaseHTTPRequestHandler):
if cookie: if cookie:
self.send_header('Cookie', cookie) self.send_header('Cookie', cookie)
self.send_header('Host', self.server.domainFull) self.send_header('Host', self.server.domainFull)
self.send_header('InstanceID', self.server.instanceId)
self.end_headers() self.end_headers()
def _redirect_headers(self,redirect: str,cookie: str) -> None: def _redirect_headers(self,redirect: str,cookie: str) -> None:
@ -132,6 +133,7 @@ class PubServer(BaseHTTPRequestHandler):
self.send_header('Cookie', cookie) self.send_header('Cookie', cookie)
self.send_header('Location', redirect) self.send_header('Location', redirect)
self.send_header('Host', self.server.domainFull) self.send_header('Host', self.server.domainFull)
self.send_header('InstanceID', self.server.instanceId)
self.end_headers() self.end_headers()
def _404(self) -> None: def _404(self) -> None:
@ -2101,7 +2103,8 @@ class PubServer(BaseHTTPRequestHandler):
self.end_headers() self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
def runDaemon(clientToServer: bool,baseDir: str,domain: str, \ def runDaemon(instanceId,clientToServer: bool, \
baseDir: str,domain: str, \
port=80,httpPrefix='https', \ port=80,httpPrefix='https', \
fedList=[],noreply=False,nolike=False,nopics=False, \ fedList=[],noreply=False,nolike=False,nopics=False, \
noannounce=False,cw=False,ocapAlways=False, \ noannounce=False,cw=False,ocapAlways=False, \
@ -2128,6 +2131,7 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
httpd.debug=debug httpd.debug=debug
httpd.federationList=fedList.copy() httpd.federationList=fedList.copy()
httpd.baseDir=baseDir httpd.baseDir=baseDir
httpd.instanceId=instanceId
httpd.personCache={} httpd.personCache={}
httpd.cachedWebfingers={} httpd.cachedWebfingers={}
httpd.useTor=useTor httpd.useTor=useTor

View File

@ -310,6 +310,13 @@ if args.domain:
domain=args.domain domain=args.domain
setConfigParam(baseDir,'domain',domain) setConfigParam(baseDir,'domain',domain)
# unique ID for the instance
instanceId=getConfigParam(baseDir,'instanceId')
if not instanceId:
instanceId=createPassword(32)
setConfigParam(baseDir,'instanceId',instanceId)
print('Instance ID: '+instanceId)
# get domain name from configuration # get domain name from configuration
configDomain=getConfigParam(baseDir,'domain') configDomain=getConfigParam(baseDir,'domain')
if configDomain: if configDomain:
@ -1196,7 +1203,8 @@ if args.testdata:
followerOfPerson(baseDir,nickname,domain,'drokk',domainFull,federationList,False) followerOfPerson(baseDir,nickname,domain,'drokk',domainFull,federationList,False)
followerOfPerson(baseDir,nickname,domain,'maxboardroom',domainFull,federationList,False) followerOfPerson(baseDir,nickname,domain,'maxboardroom',domainFull,federationList,False)
runDaemon(args.client,baseDir,domain,port,httpPrefix, \ runDaemon(instanceId,args.client,baseDir, \
domain,port,httpPrefix, \
federationList, \ federationList, \
args.noreply,args.nolike,args.nopics, \ args.noreply,args.nolike,args.nopics, \
args.noannounce,args.cw,ocapAlways, \ args.noannounce,args.cw,ocapAlways, \

View File

@ -181,7 +181,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
global testServerAliceRunning global testServerAliceRunning
testServerAliceRunning = True testServerAliceRunning = True
print('Server running: Alice') print('Server running: Alice')
runDaemon(False,path,domain,port,httpPrefix,federationList, \ runDaemon("instanceId",False,path,domain,port,httpPrefix,federationList, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \ useTor,maxReplies, \
domainMaxPostsPerDay,accountMaxPostsPerDay, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \
@ -233,7 +233,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
global testServerBobRunning global testServerBobRunning
testServerBobRunning = True testServerBobRunning = True
print('Server running: Bob') print('Server running: Bob')
runDaemon(False,path,domain,port,httpPrefix,federationList, \ runDaemon("instanceId",False,path,domain,port,httpPrefix,federationList, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \ useTor,maxReplies, \
domainMaxPostsPerDay,accountMaxPostsPerDay, \ domainMaxPostsPerDay,accountMaxPostsPerDay, \
@ -265,7 +265,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
global testServerEveRunning global testServerEveRunning
testServerEveRunning = True testServerEveRunning = True
print('Server running: Eve') print('Server running: Eve')
runDaemon(False,path,domain,port,httpPrefix,federationList, \ runDaemon("instanceId",False,path,domain,port,httpPrefix,federationList, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies,allowDeletion,True) useTor,maxReplies,allowDeletion,True)