forked from indymedia/epicyon
Optionally use onion address when fetching keys
parent
4b46b1f7f5
commit
b93f5dd10b
|
@ -378,7 +378,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
getPersonPubKey(self.server.baseDir,self.server.session,keyId, \
|
getPersonPubKey(self.server.baseDir,self.server.session,keyId, \
|
||||||
self.server.personCache,self.server.debug, \
|
self.server.personCache,self.server.debug, \
|
||||||
__version__,self.server.httpPrefix, \
|
__version__,self.server.httpPrefix, \
|
||||||
self.server.domain)
|
self.server.domain,self.server.onionDomain)
|
||||||
if not pubKey:
|
if not pubKey:
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: Authenticated fetch failed to obtain public key for '+ \
|
print('DEBUG: Authenticated fetch failed to obtain public key for '+ \
|
||||||
|
|
42
inbox.py
42
inbox.py
|
@ -176,7 +176,8 @@ def validInboxFilenames(baseDir: str,nickname: str,domain: str, \
|
||||||
|
|
||||||
def getPersonPubKey(baseDir: str,session,personUrl: str, \
|
def getPersonPubKey(baseDir: str,session,personUrl: str, \
|
||||||
personCache: {},debug: bool, \
|
personCache: {},debug: bool, \
|
||||||
projectVersion: str,httpPrefix: str,domain: str) -> str:
|
projectVersion: str,httpPrefix: str, \
|
||||||
|
domain: str,onionDomain: str) -> str:
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
return None
|
return None
|
||||||
personUrl=personUrl.replace('#main-key','')
|
personUrl=personUrl.replace('#main-key','')
|
||||||
|
@ -188,8 +189,15 @@ def getPersonPubKey(baseDir: str,session,personUrl: str, \
|
||||||
if not personJson:
|
if not personJson:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Obtaining public key for '+personUrl)
|
print('DEBUG: Obtaining public key for '+personUrl)
|
||||||
asHeader = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'}
|
personDomain=domain
|
||||||
personJson = getJson(session,personUrl,asHeader,None,projectVersion,httpPrefix,domain)
|
if '.onion/' in personUrl:
|
||||||
|
personDomain=onionDomain
|
||||||
|
asHeader = {
|
||||||
|
'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'
|
||||||
|
}
|
||||||
|
personJson = \
|
||||||
|
getJson(session,personUrl,asHeader,None,projectVersion, \
|
||||||
|
httpPrefix,personDomain)
|
||||||
if not personJson:
|
if not personJson:
|
||||||
return None
|
return None
|
||||||
pubKey=None
|
pubKey=None
|
||||||
|
@ -1207,7 +1215,7 @@ def receiveDelete(session,handle: str,isGroup: bool,baseDir: str, \
|
||||||
|
|
||||||
def receiveAnnounce(recentPostsCache: {}, \
|
def receiveAnnounce(recentPostsCache: {}, \
|
||||||
session,handle: str,isGroup: bool,baseDir: str, \
|
session,handle: str,isGroup: bool,baseDir: str, \
|
||||||
httpPrefix: str,domain :str,port: int, \
|
httpPrefix: str,domain :str,onionDomain: str,port: int, \
|
||||||
sendThreads: [],postLog: [],cachedWebfingers: {}, \
|
sendThreads: [],postLog: [],cachedWebfingers: {}, \
|
||||||
personCache: {},messageJson: {},federationList: [], \
|
personCache: {},messageJson: {},federationList: [], \
|
||||||
debug : bool) -> bool:
|
debug : bool) -> bool:
|
||||||
|
@ -1298,7 +1306,8 @@ def receiveAnnounce(recentPostsCache: {}, \
|
||||||
pubKey= \
|
pubKey= \
|
||||||
getPersonPubKey(baseDir,session,lookupActor, \
|
getPersonPubKey(baseDir,session,lookupActor, \
|
||||||
personCache,debug, \
|
personCache,debug, \
|
||||||
__version__,httpPrefix,domain)
|
__version__,httpPrefix, \
|
||||||
|
domain,onionDomain)
|
||||||
if pubKey:
|
if pubKey:
|
||||||
print('DEBUG: public key obtained for announce: '+lookupActor)
|
print('DEBUG: public key obtained for announce: '+lookupActor)
|
||||||
break
|
break
|
||||||
|
@ -1487,7 +1496,7 @@ def validPostContent(baseDir: str,nickname: str,domain: str, \
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
|
def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
|
||||||
domain: str,personCache: {}, \
|
domain: str,onionDomain: str,personCache: {}, \
|
||||||
postJsonObject: {},debug: bool) -> None:
|
postJsonObject: {},debug: bool) -> None:
|
||||||
"""Tries to obtain the actor for the person being replied to
|
"""Tries to obtain the actor for the person being replied to
|
||||||
so that their avatar can later be shown
|
so that their avatar can later be shown
|
||||||
|
@ -1520,7 +1529,8 @@ def obtainAvatarForReplyPost(session,baseDir: str,httpPrefix: str, \
|
||||||
pubKey= \
|
pubKey= \
|
||||||
getPersonPubKey(baseDir,session,lookupActor, \
|
getPersonPubKey(baseDir,session,lookupActor, \
|
||||||
personCache,debug, \
|
personCache,debug, \
|
||||||
__version__,httpPrefix,domain)
|
__version__,httpPrefix, \
|
||||||
|
domain,onionDomain)
|
||||||
if pubKey:
|
if pubKey:
|
||||||
print('DEBUG: public key obtained for reply: '+lookupActor)
|
print('DEBUG: public key obtained for reply: '+lookupActor)
|
||||||
break
|
break
|
||||||
|
@ -1737,7 +1747,8 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
session,keyId: str,handle: str,messageJson: {}, \
|
session,keyId: str,handle: str,messageJson: {}, \
|
||||||
baseDir: str,httpPrefix: str,sendThreads: [], \
|
baseDir: str,httpPrefix: str,sendThreads: [], \
|
||||||
postLog: [],cachedWebfingers: {},personCache: {}, \
|
postLog: [],cachedWebfingers: {},personCache: {}, \
|
||||||
queue: [],domain: str,port: int,useTor: bool, \
|
queue: [],domain: str,onionDomain: str, \
|
||||||
|
port: int,useTor: bool, \
|
||||||
federationList: [],ocapAlways: bool,debug: bool, \
|
federationList: [],ocapAlways: bool,debug: bool, \
|
||||||
acceptedCaps: [], \
|
acceptedCaps: [], \
|
||||||
queueFilename :str,destinationFilename :str, \
|
queueFilename :str,destinationFilename :str, \
|
||||||
|
@ -1811,7 +1822,7 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
if receiveAnnounce(recentPostsCache, \
|
if receiveAnnounce(recentPostsCache, \
|
||||||
session,handle,isGroup, \
|
session,handle,isGroup, \
|
||||||
baseDir,httpPrefix, \
|
baseDir,httpPrefix, \
|
||||||
domain,port, \
|
domain,onionDomain,port, \
|
||||||
sendThreads,postLog, \
|
sendThreads,postLog, \
|
||||||
cachedWebfingers, \
|
cachedWebfingers, \
|
||||||
personCache, \
|
personCache, \
|
||||||
|
@ -1930,7 +1941,9 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
updateIndexList.append('tlblogs')
|
updateIndexList.append('tlblogs')
|
||||||
|
|
||||||
# get the avatar for a reply/announce
|
# get the avatar for a reply/announce
|
||||||
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,postJsonObject,debug)
|
obtainAvatarForReplyPost(session,baseDir, \
|
||||||
|
httpPrefix,domain,onionDomain, \
|
||||||
|
personCache,postJsonObject,debug)
|
||||||
|
|
||||||
# save the post to file
|
# save the post to file
|
||||||
if saveJson(postJsonObject,destinationFilename):
|
if saveJson(postJsonObject,destinationFilename):
|
||||||
|
@ -2149,7 +2162,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
pubKey= \
|
pubKey= \
|
||||||
getPersonPubKey(baseDir,session,keyId, \
|
getPersonPubKey(baseDir,session,keyId, \
|
||||||
personCache,debug, \
|
personCache,debug, \
|
||||||
projectVersion,httpPrefix,domain)
|
projectVersion,httpPrefix, \
|
||||||
|
domain,onionDomain)
|
||||||
if pubKey:
|
if pubKey:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: public key: '+str(pubKey))
|
print('DEBUG: public key: '+str(pubKey))
|
||||||
|
@ -2345,7 +2359,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
baseDir,httpPrefix, \
|
baseDir,httpPrefix, \
|
||||||
sendThreads,postLog, \
|
sendThreads,postLog, \
|
||||||
cachedWebfingers, \
|
cachedWebfingers, \
|
||||||
personCache,queue,domain, \
|
personCache,queue, \
|
||||||
|
domain,onionDomain, \
|
||||||
port,useTor, \
|
port,useTor, \
|
||||||
federationList,ocapAlways, \
|
federationList,ocapAlways, \
|
||||||
debug,acceptedCaps, \
|
debug,acceptedCaps, \
|
||||||
|
@ -2365,7 +2380,8 @@ def runInboxQueue(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
baseDir,httpPrefix, \
|
baseDir,httpPrefix, \
|
||||||
sendThreads,postLog, \
|
sendThreads,postLog, \
|
||||||
cachedWebfingers, \
|
cachedWebfingers, \
|
||||||
personCache,queue,domain, \
|
personCache,queue, \
|
||||||
|
domain,onionDomain, \
|
||||||
port,useTor, \
|
port,useTor, \
|
||||||
federationList,ocapAlways, \
|
federationList,ocapAlways, \
|
||||||
debug,acceptedCaps, \
|
debug,acceptedCaps, \
|
||||||
|
|
2
tests.py
2
tests.py
|
@ -1169,7 +1169,7 @@ def testClientToServer():
|
||||||
httpPrefix, \
|
httpPrefix, \
|
||||||
cachedWebfingers,personCache, \
|
cachedWebfingers,personCache, \
|
||||||
True,__version__)
|
True,__version__)
|
||||||
for t in range(10):
|
for t in range(25):
|
||||||
if os.path.isfile(bobDir+'/accounts/bob@'+bobDomain+'/followers.txt'):
|
if os.path.isfile(bobDir+'/accounts/bob@'+bobDomain+'/followers.txt'):
|
||||||
if 'alice@'+aliceDomain+':'+str(alicePort) in open(bobDir+'/accounts/bob@'+bobDomain+'/followers.txt').read():
|
if 'alice@'+aliceDomain+':'+str(alicePort) in open(bobDir+'/accounts/bob@'+bobDomain+'/followers.txt').read():
|
||||||
if os.path.isfile(aliceDir+'/accounts/alice@'+aliceDomain+'/following.txt'):
|
if os.path.isfile(aliceDir+'/accounts/alice@'+aliceDomain+'/following.txt'):
|
||||||
|
|
Loading…
Reference in New Issue