import sys import logging from ndn import appv2, types from ndn import encoding as enc from ndn.app_support import security_v2 as secv2 logging.basicConfig(format='[{asctime}]{levelname}:{message}', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO, style='{') if len(sys.argv) < 2: logging.fatal('Please input a KEY or CERT name') exit(0) app = appv2.NDNApp() async def main(): try: name = enc.Name.from_str(sys.argv[1]) can_be_prefix = not (len(name) > 4 and name[-4] == secv2.KEY_COMPONENT) print( f'Sending Interest {enc.Name.to_str(name)}, ' f'{enc.InterestParam(must_be_fresh=True, can_be_prefix=can_be_prefix, lifetime=6000)}' ) # TODO: Write a better validator data_name, content, pkt_context = await app.express( name, validator=appv2.pass_all, must_be_fresh=True,
async def comain(self): face = DummyFace(self.face_proc) self.signer = sec.DigestSha256Signer() self.app = app.NDNApp(face) face.app = self.app await self.app.main_loop(self.app_main())