Dependencies

master
Bob Mottram 2019-07-02 18:11:59 +01:00
parent 3e15f3f94b
commit c7adc05cf2
4 changed files with 15 additions and 12 deletions

View File

@ -9,5 +9,6 @@ Also: https://raw.githubusercontent.com/w3c/activitypub/gh-pages/activitypub-tut
## Install ## Install
``` bash ``` 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
``` ```

View File

@ -92,7 +92,7 @@ class PubServer(BaseHTTPRequestHandler):
return True return True
def do_GET(self): def do_GET(self):
print('############### GET from '+self.server.baseDir) print('############### GET from '+self.server.baseDir+' path: '+self.path)
if self.server.GETbusy: if self.server.GETbusy:
currTimeGET=int(time.time()) currTimeGET=int(time.time())
if currTimeGET-self.server.lastGET<10: if currTimeGET-self.server.lastGET<10:
@ -223,13 +223,16 @@ class PubServer(BaseHTTPRequestHandler):
return return
pprint(messageJson) pprint(messageJson)
print('**************** POST get actor url from '+self.server.baseDir)
personUrl=messageJson['object']['attributedTo']
print('**************** POST create session') print('**************** POST create session')
currSessionTime=int(time.time()) currSessionTime=int(time.time())
if currSessionTime-self.server.sessionLastUpdate>600: if currSessionTime-self.server.sessionLastUpdate>1200:
self.server.sessionLastUpdate=currSessionTime self.server.sessionLastUpdate=currSessionTime
self.server.session = createSession(self.server.domain,self.server.port,self.server.useTor) 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) print('**************** POST get public key of '+personUrl+' from '+self.server.baseDir)
pubKey=getPersonPubKey(self.server.session,personUrl,self.server.personCache) pubKey=getPersonPubKey(self.server.session,personUrl,self.server.personCache)
if not pubKey: if not pubKey:
@ -276,8 +279,8 @@ def runDaemon(domain: str,port=80,https=True,fedList=[],useTor=False) -> None:
httpd.personCache={} httpd.personCache={}
httpd.cachedWebfingers={} httpd.cachedWebfingers={}
httpd.useTor=useTor httpd.useTor=useTor
httpd.session = createSession(domain,port,useTor) httpd.session = None
httpd.sessionLastUpdate=int(time.time()) httpd.sessionLastUpdate=0
httpd.lastGET=0 httpd.lastGET=0
httpd.lastPOST=0 httpd.lastPOST=0
httpd.GETbusy=False httpd.GETbusy=False

View File

@ -35,7 +35,6 @@ from follow import unfollowPerson
from follow import unfollowerOfPerson from follow import unfollowerOfPerson
from tests import testPostMessageBetweenServers from tests import testPostMessageBetweenServers
from tests import runAllTests from tests import runAllTests
from announce import announcePublic
runAllTests() runAllTests()
@ -85,11 +84,11 @@ setBio(baseDir,username,domain,'Some personal info')
#outboxJson=createOutbox(baseDir,username,domain,port,https,2,True,None) #outboxJson=createOutbox(baseDir,username,domain,port,https,2,True,None)
#pprint(outboxJson) #pprint(outboxJson)
#testPostMessageBetweenServers() testPostMessageBetweenServers()
#runDaemon(domain,port,https,federationList,useTor) #runDaemon(domain,port,https,federationList,useTor)
#testHttpsig() #testHttpsig()
#sys.exit() sys.exit()
#pprint(person) #pprint(person)
#print('\n') #print('\n')

View File

@ -15,8 +15,8 @@ baseDirectory=None
def createSession(domain: str, port: int, onionRoute: bool): def createSession(domain: str, port: int, onionRoute: bool):
session = requests.session() session = requests.session()
if domain.startswith('127.') or domain.startswith('192.') or domain.startswith('10.'): #if domain.startswith('127.') or domain.startswith('192.') or domain.startswith('10.'):
session.mount('http://', SourceAddressAdapter(domain)) # session.mount('http://', SourceAddressAdapter(domain))
#session.mount('http://', SourceAddressAdapter((domain, port))) #session.mount('http://', SourceAddressAdapter((domain, port)))
if onionRoute: if onionRoute:
session.proxies = {} session.proxies = {}