Пример #1
0
def ping_nodes(idurl_list, timeout=15, channel='ping_nodes', keep_alive=True):
    from p2p import online_status
    l = []
    for idurl in idurl_list:
        if idurl:
            l.append(online_status.ping(idurl=idurl, ack_timeout=timeout, channel=channel, keep_alive=keep_alive))
    return DeferredList(l, consumeErrors=True)
Пример #2
0
def ping_customers(timeout=20):
    from p2p import online_status
    l = []
    for customer_idurl in contactsdb.customers():
        if customer_idurl:
            l.append(online_status.ping(idurl=customer_idurl, ack_timeout=timeout, channel='ping_customers', keep_alive=True))
    return DeferredList(l, consumeErrors=True)
Пример #3
0
def share_key(key_id,
              trusted_idurl,
              include_private=False,
              include_signature=False,
              timeout=20):
    """
    Method to be used to send given key to one trusted user.
    Make sure remote user is identified and connected.
    Returns deferred, callback will be fired with response Ack() packet argument.
    """
    result = Deferred()
    d = online_status.ping(
        idurl=trusted_idurl,
        ack_timeout=timeout,
        channel='share_key',
        keep_alive=False,
    )
    d.addCallback(lambda ok: _do_request_service_keys_registry(
        key_id,
        trusted_idurl,
        include_private,
        include_signature,
        timeout,
        result,
    ))
    d.addErrback(result.errback)
    return result
Пример #4
0
def ping_suppliers(customer_idurl=None, timeout=30):
    from p2p import online_status
    l = []
    for supplier_idurl in contactsdb.suppliers(customer_idurl=customer_idurl):
        if supplier_idurl:
            l.append(online_status.ping(idurl=supplier_idurl, ack_timeout=timeout, channel='ping_suppliers', keep_alive=True))
    return DeferredList(l, consumeErrors=True)
Пример #5
0
 def doSendMyIdentity(self, *args, **kwargs):
     """
     Action method.
     """
     d = online_status.ping(
         idurl=self.target_idurl,
         channel='supplier_finder',
         keep_alive=False,
     )
     d.addCallback(lambda ok: self.automat('ack-received', ok))
     d.addErrback(lambda err: self.automat('ping-failed'))
Пример #6
0
 def doPingRequestService(self, *args, **kwargs):
     """
     Action method.
     """
     ecc_map = kwargs.get('ecc_map')
     family_position = kwargs.get('family_position')
     family_snapshot = kwargs.get('family_snapshot')
     d = online_status.ping(
         idurl=self.supplier_idurl,
         channel='supplier_connector',
         keep_alive=True,
     )
     d.addCallback(lambda ok: self._do_request_supplier_service(
         ecc_map=ecc_map,
         family_position=family_position,
         family_snapshot=family_snapshot,
     ))
     d.addErrback(lambda err: self.automat('fail', err))
Пример #7
0
    def doSendMyIdentityToUser(self, *args, **kwargs):
        """
        Action method.
        """
        def _on_ack(response):
            self.ping_response = time.time()
            self.automat('ack', response)
            return response

        def _on_fail(err):
            self.automat('fail', err)
            return None

        d = online_status.ping(
            idurl=self.remote_idurl,
            channel='shared_access_donor',
            ping_retries=1,
            keep_alive=True,
        )
        d.addCallback(_on_ack)
        d.addErrback(_on_fail)