mirror of https://gitlab.com/bashrc2/epicyon
Set default capabilities with options
parent
639403a37e
commit
21a72b59fc
|
@ -36,7 +36,7 @@ This project is currently *pre alpha* and not recommended for any real world use
|
|||
|
||||
This is one proposed way that OCAP could work.
|
||||
|
||||
* Works from person to person, not instance to instance.
|
||||
* Works from person to person, not instance to instance. Actor-oriented capabilities.
|
||||
* Produces negligible additional network traffic
|
||||
* Works in the same way between people on different instances or the same instance
|
||||
* People can alter what their followers can do on an individual basis
|
||||
|
|
|
@ -55,9 +55,9 @@ def createAcceptReject(baseDir: str,federationList: [], \
|
|||
def createAccept(baseDir: str,federationList: [], \
|
||||
nickname: str,domain: str,port: int, \
|
||||
toUrl: str,ccUrl: str,httpPrefix: str, \
|
||||
objectJson: {}) -> {}:
|
||||
objectJson: {},acceptedCaps=["inbox:write","objects:read"]) -> {}:
|
||||
# create capabilities accept
|
||||
ocapNew=capabilitiesAccept(baseDir,httpPrefix,nickname,domain,port,toUrl,True)
|
||||
ocapNew=capabilitiesAccept(baseDir,httpPrefix,nickname,domain,port,toUrl,True,acceptedCaps)
|
||||
return createAcceptReject(baseDir,federationList, \
|
||||
nickname,domain,port, \
|
||||
toUrl,ccUrl,httpPrefix, \
|
||||
|
|
|
@ -497,7 +497,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.POSTbusy=False
|
||||
|
||||
def runDaemon(baseDir: str,domain: str,port=80,httpPrefix='https', \
|
||||
fedList=[],ocapAlways=False, \
|
||||
fedList=[],noreply=False,nolike=False,ocapAlways=False, \
|
||||
useTor=False,debug=False) -> None:
|
||||
if len(domain)==0:
|
||||
domain='localhost'
|
||||
|
@ -528,6 +528,11 @@ def runDaemon(baseDir: str,domain: str,port=80,httpPrefix='https', \
|
|||
httpd.sendThreads=[]
|
||||
httpd.postLog=[]
|
||||
httpd.ocapAlways=ocapAlways
|
||||
httpd.acceptedCaps=["inbox:write","objects:read"]
|
||||
if noreply:
|
||||
httpd.acceptedCaps.append('inbox:noreply')
|
||||
if nolike:
|
||||
httpd.acceptedCaps.append('inbox:nolike')
|
||||
print('Running ActivityPub daemon on ' + domain + ' port ' + str(port))
|
||||
httpd.thrInboxQueue= \
|
||||
threadWithTrace(target=runInboxQueue, \
|
||||
|
@ -536,6 +541,6 @@ def runDaemon(baseDir: str,domain: str,port=80,httpPrefix='https', \
|
|||
httpd.personCache,httpd.inboxQueue, \
|
||||
domain,port,useTor,httpd.federationList, \
|
||||
httpd.ocapAlways, \
|
||||
debug),daemon=True)
|
||||
debug,httpd.acceptedCaps),daemon=True)
|
||||
httpd.thrInboxQueue.start()
|
||||
httpd.serve_forever()
|
||||
|
|
|
@ -117,6 +117,12 @@ parser.add_argument("--testdata", type=str2bool, nargs='?', \
|
|||
parser.add_argument("--ocap", type=str2bool, nargs='?', \
|
||||
const=True, default=False, \
|
||||
help="Always strictly enforce object capabilities")
|
||||
parser.add_argument("--noreply", type=str2bool, nargs='?', \
|
||||
const=True, default=False, \
|
||||
help="Default capabilities don't allow replies on posts")
|
||||
parser.add_argument("--nolike", type=str2bool, nargs='?', \
|
||||
const=True, default=False, \
|
||||
help="Default capabilities don't allow likes/favourites on posts")
|
||||
args = parser.parse_args()
|
||||
|
||||
debug=False
|
||||
|
@ -410,4 +416,4 @@ if args.testdata:
|
|||
createPublicPost(baseDir,nickname,domain,port,httpPrefix,"another mystery solved hey",False,True,False)
|
||||
createPublicPost(baseDir,nickname,domain,port,httpPrefix,"let's go bowling",False,True,False)
|
||||
|
||||
runDaemon(baseDir,domain,port,httpPrefix,federationList,ocapAlways,useTor,debug)
|
||||
runDaemon(baseDir,domain,port,httpPrefix,federationList,args.noreply,args.nolike,ocapAlways,useTor,debug)
|
||||
|
|
|
@ -221,7 +221,8 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
|
|||
port: int,sendThreads: [],postLog: [], \
|
||||
cachedWebfingers: {},personCache: {}, \
|
||||
messageJson: {},federationList: [], \
|
||||
debug : bool) -> bool:
|
||||
debug : bool, \
|
||||
acceptedCaps=["inbox:write","objects:read"]) -> bool:
|
||||
"""Receives a follow request within the POST section of HTTPServer
|
||||
"""
|
||||
if not messageJson['type'].startswith('Follow'):
|
||||
|
@ -283,7 +284,7 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
|
|||
personUrl=messageJson['actor']
|
||||
acceptJson=createAccept(baseDir,federationList, \
|
||||
nicknameToFollow,domainToFollow,port, \
|
||||
personUrl,'',httpPrefix,messageJson)
|
||||
personUrl,'',httpPrefix,messageJson,acceptedCaps)
|
||||
if debug:
|
||||
pprint(acceptJson)
|
||||
print('DEBUG: sending follow Accept from '+ \
|
||||
|
|
5
inbox.py
5
inbox.py
|
@ -347,7 +347,7 @@ def receiveUpdate(session,baseDir: str, \
|
|||
return True
|
||||
return False
|
||||
|
||||
def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [],cachedWebfingers: {},personCache: {},queue: [],domain: str,port: int,useTor: bool,federationList: [],ocapAlways: bool,debug: bool) -> None:
|
||||
def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [],cachedWebfingers: {},personCache: {},queue: [],domain: str,port: int,useTor: bool,federationList: [],ocapAlways: bool,debug: bool,acceptedCaps=["inbox:write","objects:read"]) -> None:
|
||||
"""Processes received items and moves them to
|
||||
the appropriate directories
|
||||
"""
|
||||
|
@ -438,7 +438,8 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [],cache
|
|||
personCache,
|
||||
queueJson['post'], \
|
||||
federationList, \
|
||||
debug):
|
||||
debug, \
|
||||
acceptedCaps=["inbox:write","objects:read"]):
|
||||
if debug:
|
||||
print('DEBUG: Follow accepted from '+keyId)
|
||||
os.remove(queueFilename)
|
||||
|
|
12
tests.py
12
tests.py
|
@ -125,6 +125,8 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [],hasFoll
|
|||
useTor=False
|
||||
clientToServer=False
|
||||
password='alicepass'
|
||||
noreply=False
|
||||
nolike=False
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||
deleteAllPosts(path,nickname,domain,'inbox')
|
||||
deleteAllPosts(path,nickname,domain,'outbox')
|
||||
|
@ -138,7 +140,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [],hasFoll
|
|||
global testServerAliceRunning
|
||||
testServerAliceRunning = True
|
||||
print('Server running: Alice')
|
||||
runDaemon(path,domain,port,httpPrefix,federationList,ocapAlways,useTor,True)
|
||||
runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,ocapAlways,useTor,True)
|
||||
|
||||
def createServerBob(path: str,domain: str,port: int,federationList: [],hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
||||
print('Creating test server: Bob on port '+str(port))
|
||||
|
@ -151,6 +153,8 @@ def createServerBob(path: str,domain: str,port: int,federationList: [],hasFollow
|
|||
useTor=False
|
||||
clientToServer=False
|
||||
password='bobpass'
|
||||
noreply=False
|
||||
nolike=False
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||
deleteAllPosts(path,nickname,domain,'inbox')
|
||||
deleteAllPosts(path,nickname,domain,'outbox')
|
||||
|
@ -164,7 +168,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [],hasFollow
|
|||
global testServerBobRunning
|
||||
testServerBobRunning = True
|
||||
print('Server running: Bob')
|
||||
runDaemon(path,domain,port,httpPrefix,federationList,ocapAlways,useTor,True)
|
||||
runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,ocapAlways,useTor,True)
|
||||
|
||||
def createServerEve(path: str,domain: str,port: int,federationList: [],hasFollows: bool,hasPosts :bool,ocapAlways :bool):
|
||||
print('Creating test server: Eve on port '+str(port))
|
||||
|
@ -177,13 +181,15 @@ def createServerEve(path: str,domain: str,port: int,federationList: [],hasFollow
|
|||
useTor=False
|
||||
clientToServer=False
|
||||
password='evepass'
|
||||
noreply=False
|
||||
nolike=False
|
||||
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||
deleteAllPosts(path,nickname,domain,'inbox')
|
||||
deleteAllPosts(path,nickname,domain,'outbox')
|
||||
global testServerEveRunning
|
||||
testServerEveRunning = True
|
||||
print('Server running: Eve')
|
||||
runDaemon(path,domain,port,httpPrefix,federationList,ocapAlways,useTor,True)
|
||||
runDaemon(path,domain,port,httpPrefix,federationList,noreply,nolike,ocapAlways,useTor,True)
|
||||
|
||||
def testPostMessageBetweenServers():
|
||||
print('Testing sending message from one server to the inbox of another')
|
||||
|
|
Loading…
Reference in New Issue