예제 #1
0
def plant_tree_req(handler, request):
    loop = asyncio.get_event_loop()
    # TODO
    """
    if not handler.io_transport:
        handler.io_transport, _ = \
            loop.create_unix_connection(proto.PomaresIOProtocol,
                                        config.io_sock_file)
    """
    new_msg = proto.encode(proto.Ack(b'plant reply ' + request.tree))
    new_msg = handler.box.encrypt(new_msg)
    handler.send_data(proto.compress_buff(new_msg))
예제 #2
0
파일: routes.py 프로젝트: cbraz/pomares
def plant_tree_req(handler, request):
    loop = asyncio.get_event_loop()
    # TODO
    """
    if not handler.io_transport:
        handler.io_transport, _ = \
            loop.create_unix_connection(proto.PomaresIOProtocol,
                                        config.io_sock_file)
    """
    new_msg = proto.encode(proto.Ack(b'plant reply ' + request.tree))
    new_msg = handler.box.encrypt(new_msg)
    handler.send_data(proto.compress_buff(new_msg))
예제 #3
0
파일: server.py 프로젝트: cbraz/pomares
    def do_handshake(self, handler, msg):
        logger.debug('do_handshake()')
        try:
            # receive client pubkey and create my init_box
            handler.init_box = CryptoBox(self.keyobj)
            logger.debug("server init_box pk: {}".format(self.keyobj.pk))
            logger.debug("server init_box sk: {}".format(self.keyobj.sk))

            # init box with client's pubkey
            handler.init_box.box_with(msg.key)

            # create and send secret
            handler.box = SecretBox()
            sk_msg = encode(PubKeyReply(handler.box.sk))
            sk_msg = handler.init_box.encrypt(sk_msg)
            handler.send_data(compress_buff(sk_msg))

            handler.handshaked = True
            logger.info('HANDSHAKED1')
        except:
            raise BadHandshake()
예제 #4
0
    def do_handshake(self, handler, msg):
        logger.debug('do_handshake()')
        try:
            # receive client pubkey and create my init_box
            handler.init_box = CryptoBox(self.keyobj)
            logger.debug("server init_box pk: {}".format(self.keyobj.pk))
            logger.debug("server init_box sk: {}".format(self.keyobj.sk))

            # init box with client's pubkey
            handler.init_box.box_with(msg.key)

            # create and send secret
            handler.box = SecretBox()
            sk_msg = encode(PubKeyReply(handler.box.sk))
            sk_msg = handler.init_box.encrypt(sk_msg)
            handler.send_data(compress_buff(sk_msg))

            handler.handshaked = True
            logger.info('HANDSHAKED1')
        except:
            raise BadHandshake()
예제 #5
0
def echo(handler, request):
    new_msg = proto.encode(proto.Ack(b'echo ' + request.value))
    new_msg = handler.box.encrypt(new_msg)
    handler.send_data(proto.compress_buff(new_msg))
예제 #6
0
파일: routes.py 프로젝트: cbraz/pomares
def echo(handler, request):
    new_msg = proto.encode(proto.Ack(b'echo ' + request.value))
    new_msg = handler.box.encrypt(new_msg)
    handler.send_data(proto.compress_buff(new_msg))
예제 #7
0
 def send_command(self, handler):
     new_msg = encode(self.command)
     new_msg = handler.box.encrypt(new_msg)
     handler.send_data(compress_buff(new_msg))
예제 #8
0
 def do_handshake_init(self):
     logger.debug('do_handshake_init()')
     # send my pubkey to server
     handshk_payload = compress_buff(encode(PubKeyReply(self.keyobj.pk)))
     self.client_prot = PomaresProtocol(handshk_payload)