forked from indymedia/epicyon
Port numbers after domain
parent
6c85b39adc
commit
78a3e96434
15
daemon.py
15
daemon.py
|
@ -43,6 +43,9 @@ followsPerPage=12
|
||||||
# Whether to use https
|
# Whether to use https
|
||||||
useHttps=True
|
useHttps=True
|
||||||
|
|
||||||
|
# port number to use
|
||||||
|
usePort=80
|
||||||
|
|
||||||
def readFollowList(filename: str):
|
def readFollowList(filename: str):
|
||||||
"""Returns a list of ActivityPub addresses to follow
|
"""Returns a list of ActivityPub addresses to follow
|
||||||
"""
|
"""
|
||||||
|
@ -114,19 +117,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.GETbusy=False
|
self.GETbusy=False
|
||||||
return
|
return
|
||||||
# get outbox feed for a person
|
# get outbox feed for a person
|
||||||
outboxFeed=personOutboxJson(thisDomain,self.path,useHttps,maxPostsInFeed)
|
outboxFeed=personOutboxJson(thisDomain,usePort,self.path,useHttps,maxPostsInFeed)
|
||||||
if outboxFeed:
|
if outboxFeed:
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(outboxFeed).encode('utf-8'))
|
self.wfile.write(json.dumps(outboxFeed).encode('utf-8'))
|
||||||
self.GETbusy=False
|
self.GETbusy=False
|
||||||
return
|
return
|
||||||
following=getFollowingFeed(thisDomain,self.path,useHttps,followsPerPage)
|
following=getFollowingFeed(thisDomain,usePort,self.path,useHttps,followsPerPage)
|
||||||
if following:
|
if following:
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(following).encode('utf-8'))
|
self.wfile.write(json.dumps(following).encode('utf-8'))
|
||||||
self.GETbusy=False
|
self.GETbusy=False
|
||||||
return
|
return
|
||||||
followers=getFollowingFeed(thisDomain,self.path,useHttps,followsPerPage,'followers')
|
followers=getFollowingFeed(thisDomain,usePort,self.path,useHttps,followsPerPage,'followers')
|
||||||
if followers:
|
if followers:
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
self.wfile.write(json.dumps(followers).encode('utf-8'))
|
self.wfile.write(json.dumps(followers).encode('utf-8'))
|
||||||
|
@ -205,10 +208,14 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.wfile.write(json.dumps(message).encode('utf-8'))
|
self.wfile.write(json.dumps(message).encode('utf-8'))
|
||||||
self.POSTbusy=False
|
self.POSTbusy=False
|
||||||
|
|
||||||
def runDaemon(domain: str,port=80,fedList=[],useTor=False) -> None:
|
def runDaemon(domain: str,port=80,https=True,fedList=[],useTor=False) -> None:
|
||||||
global thisDomain
|
global thisDomain
|
||||||
global federationList
|
global federationList
|
||||||
|
global usePort
|
||||||
|
global useHttps
|
||||||
thisDomain=domain
|
thisDomain=domain
|
||||||
|
usePort=port
|
||||||
|
useHttps=https
|
||||||
federationList=fedList.copy()
|
federationList=fedList.copy()
|
||||||
|
|
||||||
if len(domain)==0:
|
if len(domain)==0:
|
||||||
|
|
|
@ -37,7 +37,7 @@ username='testuser'
|
||||||
#domain=socket.gethostname()
|
#domain=socket.gethostname()
|
||||||
domain='127.0.0.1'
|
domain='127.0.0.1'
|
||||||
port=6227
|
port=6227
|
||||||
https=True
|
https=False
|
||||||
useTor=False
|
useTor=False
|
||||||
session = createSession(useTor)
|
session = createSession(useTor)
|
||||||
|
|
||||||
|
@ -72,10 +72,10 @@ setPreferredUsername(username,domain,'badger')
|
||||||
setBio(username,domain,'Some personal info')
|
setBio(username,domain,'Some personal info')
|
||||||
#createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
|
#createPublicPost(username, domain, https, "G'day world!", False, True, None, None, 'Not suitable for Vogons')
|
||||||
#archivePosts(username,domain,4)
|
#archivePosts(username,domain,4)
|
||||||
#outboxJson=createOutbox(username,domain,https,2,True,None)
|
#outboxJson=createOutbox(username,domain,port,https,2,True,None)
|
||||||
#pprint(outboxJson)
|
#pprint(outboxJson)
|
||||||
|
|
||||||
runDaemon(domain,port,federationList,useTor)
|
runDaemon(domain,port,https,federationList,useTor)
|
||||||
|
|
||||||
#testHttpsig()
|
#testHttpsig()
|
||||||
#sys.exit()
|
#sys.exit()
|
||||||
|
|
|
@ -102,7 +102,7 @@ def getNoOfFollowers(username: str,domain: str) -> int:
|
||||||
"""
|
"""
|
||||||
return getNoOfFollows(username,domain,'followers.txt')
|
return getNoOfFollows(username,domain,'followers.txt')
|
||||||
|
|
||||||
def getFollowingFeed(domain: str,path: str,https: bool,followsPerPage=12,followFile='following') -> {}:
|
def getFollowingFeed(domain: str,port: int,path: str,https: bool,followsPerPage=12,followFile='following') -> {}:
|
||||||
"""Returns the following and followers feeds from GET requests
|
"""Returns the following and followers feeds from GET requests
|
||||||
"""
|
"""
|
||||||
if '/'+followFile not in path:
|
if '/'+followFile not in path:
|
||||||
|
@ -138,6 +138,9 @@ def getFollowingFeed(domain: str,path: str,https: bool,followsPerPage=12,followF
|
||||||
if not https:
|
if not https:
|
||||||
prefix='http'
|
prefix='http'
|
||||||
|
|
||||||
|
if port!=80 and port!=443:
|
||||||
|
domain=domain+':'+str(port)
|
||||||
|
|
||||||
if headerOnly:
|
if headerOnly:
|
||||||
following = {
|
following = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
|
|
@ -163,7 +163,7 @@ def personLookup(domain: str,path: str) -> {}:
|
||||||
personJson=commentjson.load(fp)
|
personJson=commentjson.load(fp)
|
||||||
return personJson
|
return personJson
|
||||||
|
|
||||||
def personOutboxJson(domain: str,path: str,https: bool,noOfItems: int) -> []:
|
def personOutboxJson(domain: str,port: int,path: str,https: bool,noOfItems: int) -> []:
|
||||||
"""Obtain the outbox feed for the given person
|
"""Obtain the outbox feed for the given person
|
||||||
"""
|
"""
|
||||||
if not '/outbox' in path:
|
if not '/outbox' in path:
|
||||||
|
@ -197,7 +197,7 @@ def personOutboxJson(domain: str,path: str,https: bool,noOfItems: int) -> []:
|
||||||
return None
|
return None
|
||||||
if not validUsername(username):
|
if not validUsername(username):
|
||||||
return None
|
return None
|
||||||
return createOutbox(username,domain,https,noOfItems,headerOnly,pageNumber)
|
return createOutbox(username,domain,port,https,noOfItems,headerOnly,pageNumber)
|
||||||
|
|
||||||
def setPreferredUsername(username: str, domain: str, preferredName: str) -> bool:
|
def setPreferredUsername(username: str, domain: str, preferredName: str) -> bool:
|
||||||
if len(preferredName)>32:
|
if len(preferredName)>32:
|
||||||
|
|
7
posts.py
7
posts.py
|
@ -383,13 +383,18 @@ def sendPost(session,username: str, domain: str, toUsername: str, toDomain: str,
|
||||||
thr.start()
|
thr.start()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def createOutbox(username: str,domain: str,https: bool,itemsPerPage: int,headerOnly: bool,pageNumber=None) -> {}:
|
def createOutbox(username: str,domain: str,port: int,https: bool,itemsPerPage: int,headerOnly: bool,pageNumber=None) -> {}:
|
||||||
"""Constructs the outbox feed
|
"""Constructs the outbox feed
|
||||||
"""
|
"""
|
||||||
prefix='https'
|
prefix='https'
|
||||||
if not https:
|
if not https:
|
||||||
prefix='http'
|
prefix='http'
|
||||||
|
|
||||||
outboxDir = createOutboxDir(username,domain)
|
outboxDir = createOutboxDir(username,domain)
|
||||||
|
|
||||||
|
if port!=80 and port!=443:
|
||||||
|
domain = domain+':'+str(port)
|
||||||
|
|
||||||
pageStr='?page=true'
|
pageStr='?page=true'
|
||||||
if pageNumber:
|
if pageNumber:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue