forked from indymedia/epicyon
Dependencies
parent
3e15f3f94b
commit
c7adc05cf2
|
@ -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
|
||||
```
|
15
daemon.py
15
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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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 = {}
|
||||
|
|
Loading…
Reference in New Issue