def start(self):
     from p2p import lookup
     lookup.init(lookup_method=self.lookup_in_dht,
                 observe_method=self.observe_dht_node,
                 process_method=self.process_idurl)
     lookup.start(count=5, consume=False)
     return True
 def start(self):
     from p2p import lookup
     lookup.init(lookup_method=lookup.lookup_in_dht,
                 observe_method=lookup.observe_dht_node,
                 process_method=lookup.process_idurl)
     lookup.start(count=2, consume=False)
     return True
示例#3
0
 def doDHTFindRandomUser(self, arg):
     """
     Action method.
     """
     t = lookup.start()
     t.result_defer.addCallback(self._nodes_lookup_finished)
     t.result_defer.addErrback(lambda err: self.automat('users-not-found'))
示例#4
0
 def doDHTFindRandomUser(self, arg):
     """
     Action method.
     """
     d = lookup.start()
     d.addCallback(self._nodes_lookup_finished)
     d.addErrback(lambda err: self.automat('users-not-found'))
示例#5
0
 def _find_random_node(self):
     # DEBUG
     # self.automat('found-one-node', 'http://p2p-id.ru/seed0_cb67.xml')
     # self.automat('found-one-node', 'https://bitdust.io:8084/seed2_b17a.xml')
     # self.automat('found-one-node', 'http://datahaven.net/seed2_916e.xml')
     # self.automat('found-one-node', 'http://bitdust.ai/seed1_c2c2.xml')
     # return
     preferred_routers = []
     preferred_routers_raw = config.conf().getData('services/proxy-transport/preferred-routers').strip()
     if preferred_routers_raw:
         preferred_routers_list = re.split('\n|,|;| ', preferred_routers_raw)
         preferred_routers.extend(preferred_routers_list)
     if preferred_routers:
         known_router = random.choice(preferred_routers)
         if _Debug:
             lg.out(_DebugLevel, 'proxy_receiver._find_random_node selected random item from preferred_routers: %s' % known_router)
         d = propagate.PingContact(known_router, timeout=5)
         d.addCallback(lambda resp_tuple: self.automat('found-one-node', known_router))
         d.addErrback(lambda err: self.automat('nodes-not-found'))
         # d.addErrback(lg.errback)
         # self.automat('found-one-node', known_router)
         return
     if _Debug:
         lg.out(_DebugLevel, 'proxy_receiver._find_random_node will start DHT lookup')
     tsk = lookup.start()
     if tsk:
         tsk.result_defer.addCallback(self._on_nodes_lookup_finished)
         tsk.result_defer.addErrback(lambda err: self.automat('nodes-not-found'))
     else:
         self.automat('nodes-not-found')
示例#6
0
 def _find_random_node(self):
     # DEBUG
     # self.automat('found-one-node', 'http://p2p-id.ru/seed0_cb67.xml')
     # self.automat('found-one-node', 'https://bitdust.io:8084/seed2_b17a.xml')
     # self.automat('found-one-node', 'http://datahaven.net/seed2_916e.xml')
     # return
     preferred_routers_raw = config.conf().getData(
         'services/proxy-transport/preferred-routers').strip()
     preferred_routers = []
     if preferred_routers_raw:
         preferred_routers.extend(preferred_routers_raw.split('\n'))
     if preferred_routers:
         known_router = random.choice(preferred_routers)
         if _Debug:
             lg.out(
                 _DebugLevel,
                 'proxy_receiver._find_random_node selected random item from preferred_routers: %s'
                 % known_router)
         self.automat('found-one-node', known_router)
         return
     if _Debug:
         lg.out(_DebugLevel, 'proxy_receiver._find_random_node')
     tsk = lookup.start()
     if tsk:
         tsk.result_defer.addCallback(self._on_nodes_lookup_finished)
         tsk.result_defer.addErrback(
             lambda err: self.automat('nodes-not-found'))
     else:
         self.automat('nodes-not-found')
示例#7
0
 def doLookupRandomNode(self, *args, **kwargs):
     """
     Action method.
     """
     self.lookup_task = lookup.start()
     if self.lookup_task.result_defer:
         self.lookup_task.result_defer.addCallback(self._nodes_lookup_finished)
         self.lookup_task.result_defer.addErrback(lambda err: self.automat('users-not-found'))
     else:
         self.automat('users-not-found')
示例#8
0
 def _find_random_node(self):
     d = lookup.start()
     d.addCallback(self._on_nodes_lookup_finished)
     d.addErrback(lambda err: self.automat('users-not-found'))