diff --git a/README.md b/README.md index 2c4ed77c..f40f37b1 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,6 @@ Also: https://raw.githubusercontent.com/w3c/activitypub/gh-pages/activitypub-tut ## Install ``` bash -sudo pacman -S python-pysocks python-pycryptodome python-beautifulsoup4 python-requests-toolbelt +sudo pacman -S python-pip python-pysocks python-pycryptodome python-beautifulsoup4 python-requests-toolbelt +sudo pip install commentjson ``` \ No newline at end of file diff --git a/daemon.py b/daemon.py index 56e1d618..f5d8d89a 100644 --- a/daemon.py +++ b/daemon.py @@ -92,7 +92,7 @@ class PubServer(BaseHTTPRequestHandler): return True def do_GET(self): - print('############### GET from '+self.server.baseDir) + print('############### GET from '+self.server.baseDir+' path: '+self.path) if self.server.GETbusy: currTimeGET=int(time.time()) if currTimeGET-self.server.lastGET<10: @@ -223,13 +223,16 @@ class PubServer(BaseHTTPRequestHandler): return pprint(messageJson) - print('**************** POST get actor url from '+self.server.baseDir) - personUrl=messageJson['object']['attributedTo'] + print('**************** POST create session') currSessionTime=int(time.time()) - if currSessionTime-self.server.sessionLastUpdate>600: + if currSessionTime-self.server.sessionLastUpdate>1200: self.server.sessionLastUpdate=currSessionTime self.server.session = createSession(self.server.domain,self.server.port,self.server.useTor) + print('**************** POST started new session') + + print('**************** POST get actor url from '+self.server.baseDir) + personUrl=messageJson['actor'] print('**************** POST get public key of '+personUrl+' from '+self.server.baseDir) pubKey=getPersonPubKey(self.server.session,personUrl,self.server.personCache) if not pubKey: @@ -276,8 +279,8 @@ def runDaemon(domain: str,port=80,https=True,fedList=[],useTor=False) -> None: httpd.personCache={} httpd.cachedWebfingers={} httpd.useTor=useTor - httpd.session = createSession(domain,port,useTor) - httpd.sessionLastUpdate=int(time.time()) + httpd.session = None + httpd.sessionLastUpdate=0 httpd.lastGET=0 httpd.lastPOST=0 httpd.GETbusy=False diff --git a/epicyon.py b/epicyon.py index 3feb3249..aca226d3 100644 --- a/epicyon.py +++ b/epicyon.py @@ -35,7 +35,6 @@ from follow import unfollowPerson from follow import unfollowerOfPerson from tests import testPostMessageBetweenServers from tests import runAllTests -from announce import announcePublic runAllTests() @@ -85,11 +84,11 @@ setBio(baseDir,username,domain,'Some personal info') #outboxJson=createOutbox(baseDir,username,domain,port,https,2,True,None) #pprint(outboxJson) -#testPostMessageBetweenServers() +testPostMessageBetweenServers() #runDaemon(domain,port,https,federationList,useTor) #testHttpsig() -#sys.exit() +sys.exit() #pprint(person) #print('\n') diff --git a/session.py b/session.py index 795aa46e..ddea1f6d 100644 --- a/session.py +++ b/session.py @@ -15,8 +15,8 @@ baseDirectory=None def createSession(domain: str, port: int, onionRoute: bool): session = requests.session() - if domain.startswith('127.') or domain.startswith('192.') or domain.startswith('10.'): - session.mount('http://', SourceAddressAdapter(domain)) + #if domain.startswith('127.') or domain.startswith('192.') or domain.startswith('10.'): + # session.mount('http://', SourceAddressAdapter(domain)) #session.mount('http://', SourceAddressAdapter((domain, port))) if onionRoute: session.proxies = {}