Sending dms to onion domains

merge-requests/6/head
Bob Mottram 2020-03-02 16:11:34 +00:00
parent 30eb7bcd6d
commit 63a5c76cbe
6 changed files with 30 additions and 10 deletions

View File

@ -684,7 +684,8 @@ class PubServer(BaseHTTPRequestHandler):
self.postToNickname=postToNickname
return postMessageToOutbox(messageJson,self.postToNickname, \
self.server,self.server.baseDir,self.server.httpPrefix, \
self.server.domain,self.server.domainFull,self.server.port, \
self.server.domain,self.server.domainFull, \
self.server.onionDomain,self.server.port, \
self.server.recentPostsCache,self.server.followersThreads, \
self.server.federationList,self.server.sendThreads, \
self.server.postLog,self.server.cachedWebfingers, \
@ -3521,8 +3522,10 @@ class PubServer(BaseHTTPRequestHandler):
if pageNumberStr.isdigit():
pageNumber=int(pageNumberStr)
searchPath=self.path.split('?page=')[0]
getPerson = personLookup(self.server.domain,searchPath.replace('/following',''), \
self.server.baseDir)
getPerson = \
personLookup(self.server.domain, \
searchPath.replace('/following',''), \
self.server.baseDir)
if getPerson:
if not self.server.session:
if self.server.debug:
@ -3623,8 +3626,9 @@ class PubServer(BaseHTTPRequestHandler):
self._benchmarkGETtimings(GETstartTime,GETtimings,52)
# look up a person
getPerson = personLookup(self.server.domain,self.path, \
self.server.baseDir)
getPerson = \
personLookup(self.server.domain,self.path, \
self.server.baseDir)
if getPerson:
if self._requestHTTP():
if not self.server.session:

View File

@ -1005,6 +1005,7 @@ if args.actor:
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
if '/channel/' in personUrl:
asHeader = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'}
personJson = getJson(session,personUrl,asHeader,None,__version__,httpPrefix,None)
if personJson:
pprint(personJson)

View File

@ -38,7 +38,8 @@ from shares import outboxUndoShareUpload
def postMessageToOutbox(messageJson: {},postToNickname: str, \
server,baseDir: str,httpPrefix: str, \
domain: str,domainFull: str,port: int, \
domain: str,domainFull: str,onionDomain: str, \
port: int, \
recentPostsCache: {},followersThreads: [], \
federationList: [],sendThreads: [], \
postLog: [],cachedWebfingers: {}, \
@ -313,7 +314,8 @@ def postMessageToOutbox(messageJson: {},postToNickname: str, \
else:
print('c2s sender: '+postToNickname+'@'+domain+':'+str(port))
sendToNamedAddresses(server.session,baseDir, \
postToNickname,domain,port, \
postToNickname, \
domain,onionDomain,port, \
httpPrefix, \
federationList, \
sendThreads, \

View File

@ -1704,7 +1704,8 @@ def addToField(activityType: str,postJsonObject: {},debug: bool) -> ({},bool):
return postJsonObject,False
def sendToNamedAddresses(session,baseDir: str, \
nickname: str, domain: str, port: int, \
nickname: str, \
domain: str,onionDomain: str,port: int, \
httpPrefix: str,federationList: [], \
sendThreads: [],postLog: [], \
cachedWebfingers: {},personCache: {}, \
@ -1810,11 +1811,21 @@ def sendToNamedAddresses(session,baseDir: str, \
toDomainFull=toDomain+':'+str(toPort)
print('DEBUG: Post sending s2s: '+nickname+'@'+domainFull+ \
' to '+toNickname+'@'+toDomainFull)
# if we have an alt onion domain and we are sending to
# another onion domain then switch the clearnet
# domain for the onion one
fromDomain=domain
fromHttpPrefix=httpPrefix
if onionDomain:
if toDomain.endswith('.onion'):
fromDomain=onionDomain
fromHttpPrefix='http'
cc=[]
sendSignedJson(postJsonObject,session,baseDir, \
nickname,domain,port, \
nickname,fromDomain,port, \
toNickname,toDomain,toPort, \
cc,httpPrefix,True,clientToServer, \
cc,fromHttpPrefix,True,clientToServer, \
federationList, \
sendThreads,postLog,cachedWebfingers, \
personCache,debug,projectVersion)

View File

@ -87,6 +87,7 @@ def updatePostSchedule(baseDir: str,handle: str,httpd,maxScheduledPosts: int) ->
httpd.httpPrefix, \
httpd.domain, \
httpd.domainFull, \
httpd.onionDomain, \
httpd.port, \
httpd.recentPostsCache, \
httpd.followersThreads, \

View File

@ -68,6 +68,7 @@ def loadJsonOnionify(filename: str,domain: str,onionDomain: str,delaySec=2) -> {
data=fp.read()
if data:
data=data.replace(domain,onionDomain).replace('https:','http:')
print('*****data: '+data)
jsonObject=json.loads(data)
break
except: