From 438b778dd3b10654b1d6cab4cce8cc20e6844783 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 5 Aug 2019 10:50:45 +0100 Subject: [PATCH] Remove unused flag --- daemon.py | 7 +++---- inbox.py | 54 +++++++++++++++++++++++++----------------------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/daemon.py b/daemon.py index b8a917ad..31c942d8 100644 --- a/daemon.py +++ b/daemon.py @@ -355,7 +355,7 @@ class PubServer(BaseHTTPRequestHandler): messageJson,self.server.debug) return True - def _updateInboxQueue(self,nickname: str,messageJson: {},postFromWebInterface: bool) -> int: + def _updateInboxQueue(self,nickname: str,messageJson: {}) -> int: """Update the inbox queue """ # Check if the queue is full @@ -376,7 +376,6 @@ class PubServer(BaseHTTPRequestHandler): self.headers['host'], self.headers['signature'], '/'+self.path.split('/')[-1], - postFromWebInterface, self.server.debug) if queueFilename: # add json to the queue @@ -2200,7 +2199,7 @@ class PubServer(BaseHTTPRequestHandler): else: self.postToNickname=pathUsersSection.split('/')[0] if self.postToNickname: - queueStatus=self._updateInboxQueue(self.postToNickname,messageJson,False) + queueStatus=self._updateInboxQueue(self.postToNickname,messageJson) if queueStatus==0: self.send_response(200) self.end_headers() @@ -2218,7 +2217,7 @@ class PubServer(BaseHTTPRequestHandler): else: if self.path == '/sharedInbox' or self.path == '/inbox': print('DEBUG: POST to shared inbox') - queueStatus=_updateInboxQueue('inbox',messageJson,False) + queueStatus=_updateInboxQueue('inbox',messageJson) if queueStatus==0: self.send_response(200) self.end_headers() diff --git a/inbox.py b/inbox.py index cc1ea526..01d12627 100644 --- a/inbox.py +++ b/inbox.py @@ -158,7 +158,7 @@ def validPublishedDate(published) -> bool: return False return True -def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str,postJsonObject: {},host: str,headers: str,postPath: str,postFromWebInterface: bool,debug: bool) -> str: +def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str,postJsonObject: {},host: str,headers: str,postPath: str,debug: bool) -> str: """Saves the give json to the inbox queue for the person keyId specifies the actor sending the post """ @@ -222,8 +222,7 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str 'path': postPath, 'post': postJsonObject, 'filename': filename, - 'destination': destination, - 'postFromWebInterface': postFromWebInterface + 'destination': destination } if debug: @@ -1054,8 +1053,6 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ pubKey=None keyId=None for tries in range(8): - if queueJson['postFromWebInterface']: - break keyId=None signatureParams=queueJson['headers'].split(',') for signatureItem in signatureParams: @@ -1079,31 +1076,30 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ print('DEBUG: Retry '+str(tries+1)+' obtaining public key for '+keyId) time.sleep(5) - if not queueJson['postFromWebInterface']: - if not pubKey: - if debug: - print('DEBUG: public key could not be obtained from '+keyId) - os.remove(queueFilename) - queue.pop(0) - continue - - # check the signature - verifyHeaders={ - 'host': queueJson['host'], - 'signature': queueJson['headers'] - } - if not verifyPostHeaders(httpPrefix, \ - pubKey, verifyHeaders, \ - queueJson['path'], False, \ - json.dumps(queueJson['post'])): - if debug: - print('DEBUG: Header signature check failed') - os.remove(queueFilename) - queue.pop(0) - continue - + if not pubKey: if debug: - print('DEBUG: Signature check success') + print('DEBUG: public key could not be obtained from '+keyId) + os.remove(queueFilename) + queue.pop(0) + continue + + # check the signature + verifyHeaders={ + 'host': queueJson['host'], + 'signature': queueJson['headers'] + } + if not verifyPostHeaders(httpPrefix, \ + pubKey, verifyHeaders, \ + queueJson['path'], False, \ + json.dumps(queueJson['post'])): + if debug: + print('DEBUG: Header signature check failed') + os.remove(queueFilename) + queue.pop(0) + continue + + if debug: + print('DEBUG: Signature check success') if receiveUndo(session, \ baseDir,httpPrefix,port, \