def setupController(secrets, did, lei, witnessPort=5621, peerPort=5629, indirect=False): """ Setup and return doers list to run controller """ name = "ian" secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup databases for dependency injection ks = keeping.Keeper(name=name, temp=True) # not opened by default, doer opens ksDoer = keeping.KeeperDoer(keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=True) # not opened by default, doer opens dbDoer = basing.BaserDoer(baser=db) # doer do reopens if not opened and closes # setup habitat hab = habbing.Habitat(name=name, ks=ks, db=db, temp=True, secrecies=secrecies) habDoer = habbing.HabitatDoer(habitat=hab) # setup doer iss = issuing.Issuer(hab=hab, name=name, noBackers=True) issDoer = issuing.IssuerDoer(issuer=iss) # setup doers regDoer = basing.BaserDoer(baser=iss.reger) path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name=name, prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) witnessClient = clienting.Client(host='127.0.0.1', port=witnessPort, wl=wl) witnessClientDoer = clienting.ClientDoer(client=witnessClient) peerClient = clienting.Client(host='127.0.0.1', port=peerPort, wl=wl) peerClientDoer = clienting.ClientDoer(client=peerClient) director = IanDirector(hab=hab, issuer=iss, witnessClient=witnessClient, peerClient=peerClient, tock=0.125, recipientIdentifier=did, lei=lei) reactor = directing.Reactor(hab=hab, client=witnessClient, indirect=indirect) peerReactor = directing.Reactor(hab=hab, client=peerClient, indirect=indirect) logger.info("\nDirect Mode demo of %s:\nNamed %s to TCP port %s.\n\n", hab.pre, hab.name, witnessPort) return [ksDoer, dbDoer, habDoer, issDoer, regDoer, wireDoer, witnessClientDoer, director, reactor, peerClientDoer, peerReactor]
def setupController(secrets, vcfile, did, lei, remotePort=5621, indirect=False): """ Setup and return doers list to run controller """ secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup habitat hab = habbing.Habitat(name="ian", secrecies=secrecies, temp=True) logger.info("\nDirect Mode demo of %s:\nNamed %s to TCP port %s.\n\n", hab.pre, hab.name, remotePort) iss = issuing.Issuer(hab=hab, name="ian", noBackers=True) # setup doers ksDoer = keeping.KeeperDoer( keeper=hab.ks) # doer do reopens if not opened and closes dbDoer = basing.BaserDoer( baser=hab.db) # doer do reopens if not opened and closes regDoer = basing.BaserDoer(baser=iss.reger) path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name="ian", prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) client = clienting.Client(host='127.0.0.1', port=remotePort, wl=wl) clientDoer = doing.ClientDoer(client=client) director = IanDirector(hab=hab, issuer=iss, client=client, tock=0.125, vcfile=vcfile, recipientIdentifier=did, lei=lei) reactor = directing.Reactor(hab=hab, client=client, indirect=indirect) return [ksDoer, dbDoer, regDoer, wireDoer, clientDoer, director, reactor]
def __init__(self, name, opts, **kwa): ks = keeping.Keeper(name=name, temp=False) # not opened by default, doer opens self.ksDoer = keeping.KeeperDoer( keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=False) # not opened by default, doer opens self.dbDoer = basing.BaserDoer( baser=db) # doer do reopens if not opened and closes hab = habbing.Habitat(name=name, ks=ks, db=db, temp=False, transferable=opts.transferable, isith=opts.isith, icount=opts.icount, nsith=opts.nsith, ncount=opts.ncount, wits=opts.witnesses) self.habDoer = habbing.HabitatDoer(habitat=hab) # setup doer self.witDoer = agenting.WitnessReceiptor(hab=hab) doers = [ self.inceptDo, self.ksDoer, self.dbDoer, self.habDoer, self.witDoer ] self.hab = hab super(InceptDoer, self).__init__(doers=doers, **kwa)
def runAgent(controller, name="agent", httpPort=5620, tcp=5621, adminHttpPort=5623, adminTcpPort=5624, expire=0.0): """ Setup and run one agent """ logger = help.ogler.getLogger() ks = keeping.Keeper(name=name, temp=False) # not opened by default, doer opens ksDoer = keeping.KeeperDoer( keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=False, reload=True) # not opened by default, doer opens dbDoer = basing.BaserDoer( baser=db) # doer do reopens if not opened and closes # setup habitat hab = habbing.Habitat(name=name, ks=ks, db=db, temp=False, create=False) habDoer = habbing.HabitatDoer(habitat=hab) # setup doer # kvy = eventing.Kevery(db=hab.db, local=False) # setup doers server = tcpServing.Server(host="", port=tcp) tcpServerDoer = tcpServing.ServerDoer(server=server) directant = directing.Directant(hab=hab, server=server) wallet = walleting.Wallet(hab=hab, name=name) jsonSchema = scheming.JSONSchema(resolver=scheming.jsonSchemaCache) issueHandler = handling.IssueHandler(wallet=wallet, typ=jsonSchema) requestHandler = handling.RequestHandler(wallet=wallet, typ=jsonSchema) exchanger = exchanging.Exchanger(hab=hab, handlers=[issueHandler, requestHandler]) app = falcon.App() exnServer = httping.AgentExnServer(exc=exchanger, app=app) httpKelServer = httping.AgentKelServer(hab=hab, app=app) server = http.Server(port=httpPort, app=exnServer.app) httpServerDoer = http.ServerDoer(server=server) doers = [ ksDoer, dbDoer, habDoer, exchanger, directant, tcpServerDoer, exnServer, httpServerDoer, httpKelServer ] doers.extend(adminInterface(controller, hab, adminHttpPort, adminTcpPort)) try: tock = 0.03125 doist = doing.Doist(limit=expire, tock=tock, real=True) doist.do(doers=doers) except kering.ConfigurationError: print(f"prefix for {name} does not exist, incept must be run first", )
def __init__(self, name, target: int, **kwa): ks = keeping.Keeper(name=name, temp=False) # not opened by default, doer opens self.ksDoer = keeping.KeeperDoer(keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=False, reload=True) # not opened by default, doer opens self.dbDoer = basing.BaserDoer(baser=db) # doer do reopens if not opened and closes self.hab = habbing.Habitat(name=name, ks=ks, db=db, temp=False, create=False) self.habDoer = habbing.HabitatDoer(habitat=self.hab) # setup doer self.target = target self.client = clienting.Client(host="", port=self.target) self.clientDoer = clienting.ClientDoer(client=self.client) doers = [self.ksDoer, self.dbDoer, self.habDoer, self.sendDo, self.clientDoer] super(SenderDoer, self).__init__(doers=doers, **kwa)
def setupController(secrets, witnessPort=5631, localPort=5629, indirect=False): """ Setup and return doers list to run controller """ secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup habitat hab = habbing.Habitat(name="han", secrecies=secrecies, temp=True) logger.info( "\nDirect Mode demo of %s:\nNamed %s listening on TCP port %s, witness on TCP Port %s.\n\n", hab.pre, hab.name, localPort, witnessPort) wallet = walleting.Wallet(hab=hab, name="han") # setup doers ksDoer = keeping.KeeperDoer( keeper=hab.ks) # doer do reopens if not opened and closes dbDoer = basing.BaserDoer( baser=hab.db) # doer do reopens if not opened and closes pdbDoer = basing.BaserDoer( baser=wallet.db) # doer do reopens if not opened and closes path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name="han", prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) jsonSchema = scheming.JSONSchema(resolver=scheming.jsonSchemaCache) issueHandler = handling.IssueHandler(wallet=wallet, typ=jsonSchema) requestHandler = handling.RequestHandler(wallet=wallet, typ=jsonSchema) witnessClient = clienting.Client(host='127.0.0.1', port=witnessPort, wl=wl) witnessClientDoer = clienting.ClientDoer(client=witnessClient) excDoer = exchanging.Exchanger(hab=hab, handlers=[issueHandler, requestHandler]) director = HanDirector(hab=hab, client=witnessClient, exchanger=excDoer, tock=0.125, wallet=wallet) reactor = directing.Reactor(hab=hab, client=witnessClient, indirect=indirect) server = serving.Server(host="", port=localPort) serverDoer = serving.ServerDoer(server=server) directant = directing.Directant(hab=hab, server=server, exchanger=excDoer) return [ ksDoer, dbDoer, pdbDoer, excDoer, wireDoer, witnessClientDoer, director, reactor, serverDoer, directant ]
def setupController(secrets, witnessPort=5621, peerPort=5629, indirect=False): """ Setup and return doers list to run controller """ name = "vic" secrecies = [] for secret in secrets: # convert secrets to secrecies secrecies.append([secret]) # setup databases for dependency injection ks = keeping.Keeper(name=name, temp=True) # not opened by default, doer opens ksDoer = keeping.KeeperDoer( keeper=ks) # doer do reopens if not opened and closes db = basing.Baser(name=name, temp=True) # not opened by default, doer opens dbDoer = basing.BaserDoer( baser=db) # doer do reopens if not opened and closes # setup habitat hab = habbing.Habitat(name=name, ks=ks, db=db, temp=True, secrecies=secrecies) habDoer = habbing.HabitatDoer(habitat=hab) # setup doer verifier = verifying.Verifier(name=name, hab=hab) regDoer = basing.BaserDoer(baser=verifier.reger) # setup wirelog to create test vectors path = os.path.dirname(__file__) path = os.path.join(path, 'logs') wl = wiring.WireLog(samed=True, filed=True, name=name, prefix='demo', reopen=True, headDirPath=path) wireDoer = wiring.WireLogDoer(wl=wl) witnessClient = clienting.Client(host='127.0.0.1', port=witnessPort, wl=wl) witnessClientDoer = clienting.ClientDoer(client=witnessClient) peerClient = clienting.Client(host='127.0.0.1', port=peerPort, wl=wl) peerClientDoer = clienting.ClientDoer(client=peerClient) jsonSchema = scheming.JSONSchema(resolver=scheming.jsonSchemaCache) proofs = decking.Deck() proofHandler = handling.ProofHandler(typ=jsonSchema, proofs=proofs) excDoer = exchanging.Exchanger(hab=hab, handlers=[proofHandler]) director = VicDirector(hab=hab, verifier=verifier, witnessClient=witnessClient, peerClient=peerClient, exchanger=excDoer, jsonSchema=jsonSchema, proofs=proofs, tock=0.125) witnessReactor = directing.Reactor(hab=hab, client=witnessClient, verifier=verifier, indirect=indirect) peerReactor = directing.Reactor(hab=hab, client=peerClient, verifier=verifier, indirect=indirect, exchanger=excDoer) logger.info("\nDirect Mode demo of %s:\nNamed %s to TCP port %s.\n\n", hab.pre, hab.name, witnessPort) return [ ksDoer, dbDoer, habDoer, regDoer, excDoer, wireDoer, witnessClientDoer, director, witnessReactor, peerClientDoer, peerReactor ]