Exemplo n.º 1
0
 def __init__(self,
              my_node,
              conf_path,
              routing_m_mod,
              lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level,
              bootsrap_mode=False,
              swift_port=0):
     logging_conf.setup(conf_path, debug_level)
     state_filename = os.path.join(conf_path, controller.STATE_FILENAME)
     self.controller = controller.Controller(
         VERSION_LABEL, my_node, state_filename, routing_m_mod,
         lookup_m_mod, experimental_m_mod, private_dht_name, bootsrap_mode)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop, my_node.addr[1],
         self.controller.on_datagram_received)
     self.reactor.start()
     self.swift_tracker_thread = None
     if swift_port:
         print 'Creating SwiftTracker'
         self.swift_tracker_thread = swift_tracker.SwiftTracker(
             self, swift_port)
         self.swift_tracker_thread.start()
     self.timestamps = []
     self.max_num_sec = 0
     self.max_num_min = 0
     self.max_num_10min = 0
Exemplo n.º 2
0
 def __init__(self,
              my_node,
              conf_path,
              routing_m_mod,
              lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level,
              auto_bootstrap=True,
              bootstrap_mode=False,
              swift_port=0):
     logging_conf.setup(conf_path, debug_level)
     self.controller = controller.Controller(
         VERSION_LABEL, my_node, conf_path, routing_m_mod, lookup_m_mod,
         experimental_m_mod, private_dht_name, bootstrap_mode)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop, my_node.addr[1],
         self.controller.on_datagram_received)
     if swift_port:
         print 'Creating SwiftTracker'
         swift_tracker.SwiftTracker(self, swift_port).start()
     self.timestamps = []
     self.max_num_sec = 0
     self.max_num_min = 0
     self.max_num_10min = 0
     if auto_bootstrap:
         # Overlay bootstrap
         self.get_peers(None, self.controller._my_id, None, 0)
     self.reactor.start()
Exemplo n.º 3
0
 def __init__(self, dht_addr, conf_path, routing_m_mod, lookup_m_mod,
              private_dht_name, debug_level):
     logging_conf.setup(conf_path, debug_level)
     self.controller = controller.Controller(dht_addr, conf_path,
                                             routing_m_mod, lookup_m_mod,
                                             private_dht_name)
     self.controller.start()
Exemplo n.º 4
0
 def __init__(self, dht_addr, conf_path,
              routing_m_mod, lookup_m_mod):
     logging_conf.setup(conf_path, logging.DEBUG)
     self.controller = controller.Controller(dht_addr, conf_path,
                                             routing_m_mod,
                                             lookup_m_mod)
     self.controller.start()
Exemplo n.º 5
0
 def __init__(self, my_node, conf_path,
              routing_m_mod, lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level,
              auto_bootstrap=True,
              bootstrap_mode=False,
              swift_port=0):
     logging_conf.setup(conf_path, debug_level)
     self.controller = controller.Controller(VERSION_LABEL,
                                             my_node, conf_path,
                                             routing_m_mod,
                                             lookup_m_mod,
                                             experimental_m_mod,
                                             private_dht_name,
                                             bootstrap_mode)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop,
         my_node.addr[1], self.controller.on_datagram_received)
     if swift_port:
         print 'Creating SwiftTracker'
         swift_tracker.SwiftTracker(self, swift_port).start()
     self.timestamps = []
     self.max_num_sec = 0
     self.max_num_min = 0
     self.max_num_10min = 0
     if auto_bootstrap:
         # Overlay bootstrap
         self.get_peers(None, self.controller._my_id, None, 0)
     self.reactor.start()
Exemplo n.º 6
0
 def __init__(self, my_node, conf_path,
              routing_m_mod, lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level,
              bootsrap_mode=False,
              swift_port=0):
     logging_conf.setup(conf_path, debug_level)
     state_filename = os.path.join(conf_path, controller.STATE_FILENAME)
     self.controller = controller.Controller(VERSION_LABEL,
                                             my_node, state_filename,
                                             routing_m_mod,
                                             lookup_m_mod,
                                             experimental_m_mod,
                                             private_dht_name,
                                             bootsrap_mode)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop,
         my_node.addr[1], self.controller.on_datagram_received)
     self.reactor.start()
     self.swift_tracker_thread = None
     if swift_port:
         print 'Creating SwiftTracker'
         self.swift_tracker_thread = swift_tracker.SwiftTracker(self, swift_port)
         self.swift_tracker_thread.start()
     self.timestamps = []
     self.max_num_sec = 0
     self.max_num_min = 0
     self.max_num_10min = 0
Exemplo n.º 7
0
 def __init__(self, dht_addr, conf_path,
              routing_m_mod, lookup_m_mod,
              private_dht_name,
              debug_level):
     logging_conf.setup(conf_path, debug_level)
     self.controller = controller.Controller(dht_addr, conf_path,
                                             routing_m_mod,
                                             lookup_m_mod,
                                             private_dht_name)
     self.controller.start()
Exemplo n.º 8
0
 def __init__(self, dht_addr, conf_path,
              routing_m_mod, lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level):
     logging_conf.setup(conf_path, debug_level)
     state_filename = os.path.join(conf_path, controller.STATE_FILENAME)
     self.controller = controller.Controller(dht_addr, state_filename,
                                             routing_m_mod,
                                             lookup_m_mod,
                                             experimental_m_mod,
                                             private_dht_name)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop,
         dht_addr[1], self.controller.on_datagram_received)
     self.reactor.start()
Exemplo n.º 9
0
 def __init__(self, my_node, conf_path,
              routing_m_mod, lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level, id_=None,
              bootsrap_mode=False):
     logging_conf.setup(conf_path, debug_level)
     state_filename = os.path.join(conf_path, controller.STATE_FILENAME)
     self.controller = controller.Controller(VERSION_LABEL,
                                             my_node, state_filename,
                                             routing_m_mod,
                                             lookup_m_mod,
                                             experimental_m_mod,
                                             private_dht_name,
                                             bootsrap_mode)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop,
         my_node.addr[1], self.controller.on_datagram_received)
     self.reactor.start()
Exemplo n.º 10
0
 def __init__(self,
              my_node,
              conf_path,
              routing_m_mod,
              lookup_m_mod,
              experimental_m_mod,
              private_dht_name,
              debug_level,
              id_=None,
              bootsrap_mode=False):
     logging_conf.setup(conf_path, debug_level)
     state_filename = os.path.join(conf_path, controller.STATE_FILENAME)
     self.controller = controller.Controller(
         VERSION_LABEL, my_node, state_filename, routing_m_mod,
         lookup_m_mod, experimental_m_mod, private_dht_name, bootsrap_mode)
     self.reactor = minitwisted.ThreadedReactor(
         self.controller.main_loop, my_node.addr[1],
         self.controller.on_datagram_received)
     self.reactor.start()
Exemplo n.º 11
0
def main(options, args):
    my_addr = (options.ip, options.port)
    logs_path = options.path
    logging_conf.setup(logs_path, logs_level)
    print 'Using the following plug-ins:'
    print '*', options.routing_m_file
    print '*', options.lookup_m_file
    routing_m_mod = __import__(options.routing_m_file[:-3])
    lookup_m_mod = __import__(options.lookup_m_file[:-3])
    dht = kadtracker.KadTracker(my_addr, logs_path,
                                routing_m_mod,
                                lookup_m_mod)
    try:
        info_hashes = open(options.infohash_file)
    except AttributeError:
        info_hashes = []
        print 'WARNING: no info_hashes file provided'

    try:
        print 'Warming up...',
        sys.stdout.flush()
        time.sleep(60)
        print 'DONE'
        print 'Type Control-C to exit.'
        for line in info_hashes:
            info_hash = identifier.Id(line.strip())
            print  '%s Getting peers for info_hash %r' % (
                time.asctime(), info_hash)
            dht.get_peers(info_hash, _on_peers_found)
            global start_ts
            start_ts = time.time()
            time.sleep(options.lookup_interval)

    except (KeyboardInterrupt):
        pass
    dht.stop()
    print '\nStopping DHT...',
    sys.stdout.flush()
    time.sleep(1)
    print 'DONE'
Exemplo n.º 12
0
    identifier.Id('9b16aecf952597f9bb051fecb7a0d8475d060fa0'),
    identifier.RandomId(),
    identifier.Id('24f2446365d3ef782ec16ad63aea1206df4b8d21'),
    identifier.RandomId(),
    identifier.Id('a91af3cde492e29530754591b862b1beecab10ff'),
    identifier.RandomId(),
    identifier.Id('3119baecadea3f31bed00de5e7e76db5cfea7ca1'),
    )
    
if len(sys.argv) == 4 and sys.argv[0] == 'server_dht.py':
    logging.critical('argv %r' % sys.argv)
    RUN_DHT = True
    my_addr = (sys.argv[1], int(sys.argv[2])) #('192.16.125.242', 7000)
    logs_path = sys.argv[3]
    print 'logs_path:', logs_path
    logging_conf.setup(logs_path, logs_level)
    dht = kadtracker.KadTracker(my_addr, logs_path)
else:
    RUN_DHT = False
    print 'usage: python server_dht.py dht_ip dht_port path'
    
try:
    print 'Type Control-C to exit.'
    i = 0
    while (RUN_DHT):
        for info_hash in info_hashes:
            #splitted_heap_str = str(hp.heap()).split()
            #print i, splitted_heap_str[10]
            dht.print_routing_table_stats()
            time.sleep(2 * 60)
            print 'Getting peers:', time.time()
Exemplo n.º 13
0
    identifier.Id('9b16aecf952597f9bb051fecb7a0d8475d060fa0'),
    identifier.RandomId(),
    identifier.Id('24f2446365d3ef782ec16ad63aea1206df4b8d21'),
    identifier.RandomId(),
    identifier.Id('a91af3cde492e29530754591b862b1beecab10ff'),
    identifier.RandomId(),
    identifier.Id('3119baecadea3f31bed00de5e7e76db5cfea7ca1'),
)

if len(sys.argv) == 4 and sys.argv[0] == 'server_dht.py':
    logging.critical('argv %r' % sys.argv)
    RUN_DHT = True
    my_addr = (sys.argv[1], int(sys.argv[2]))  #('192.16.125.242', 7000)
    logs_path = sys.argv[3]
    print 'logs_path:', logs_path
    logging_conf.setup(logs_path, logs_level)
    dht = kadtracker.KadTracker(my_addr, logs_path)
else:
    RUN_DHT = False
    print 'usage: python server_dht.py dht_ip dht_port path'

try:
    print 'Type Control-C to exit.'
    i = 0
    while (RUN_DHT):
        for info_hash in info_hashes:
            #splitted_heap_str = str(hp.heap()).split()
            #print i, splitted_heap_str[10]
            dht.print_routing_table_stats()
            time.sleep(2 * 60)
            print 'Getting peers:', time.time()
Exemplo n.º 14
0
 def __init__(self, dht_addr, logs_path):
     logging_conf.setup(logs_path, logging.DEBUG)
     self.controller = controller.Controller(dht_addr)
     self.controller.start()
Exemplo n.º 15
0
 def __init__(self, dht_addr, conf_path, routing_m_mod, lookup_m_mod):
     logging_conf.setup(conf_path, logging.DEBUG)
     self.controller = controller.Controller(dht_addr, conf_path,
                                             routing_m_mod, lookup_m_mod)
     self.controller.start()
Exemplo n.º 16
0
 def __init__(self, dht_addr, logs_path):
     logging_conf.setup(logs_path, logging.DEBUG)
     self.controller = controller.Controller(dht_addr)
     self.controller.start()