1 # Copyright (C) 2009 Raul Jimenez
2 # Released under GNU LGPL 2.1
3 # See LICENSE.txt for more information
10 import logging, logging_conf
12 logs_level = logging.DEBUG # This generates HUGE (and useful) logs
13 #logs_level = logging.INFO # This generates some (useful) logs
14 #logs_level = logging.WARNING # This generates warning and error logs
15 #logs_level = logging.CRITICAL
23 def peers_found(peers):
24 print 'Peers found:', time.time()
35 identifier.RandomId(),
36 identifier.Id('28f2e5ea2bf87eae4bcd5e3fc9021844c01a4df9'),
37 identifier.RandomId(),
38 identifier.Id('dd5c25b4b8230e108fbf9d07f87a86c6b05c9b6d'),
39 identifier.RandomId(),
40 identifier.Id('bcbdb9c2e7b49c65c9057431b492cb7957c8a330'),
41 identifier.RandomId(),
42 identifier.Id('d93df7a507f3c9d2ebfbe49762a217ab318825bd'),
43 identifier.RandomId(),
44 identifier.Id('6807e5d151e2ac7ae92eabb76ddaf4237e4abb60'),
45 identifier.RandomId(),
46 identifier.Id('83c7b3b7d36da4df289670592be68f9dc7c7096e'),
47 identifier.RandomId(),
48 identifier.Id('9b16aecf952597f9bb051fecb7a0d8475d060fa0'),
49 identifier.RandomId(),
50 identifier.Id('24f2446365d3ef782ec16ad63aea1206df4b8d21'),
51 identifier.RandomId(),
52 identifier.Id('a91af3cde492e29530754591b862b1beecab10ff'),
53 identifier.RandomId(),
54 identifier.Id('3119baecadea3f31bed00de5e7e76db5cfea7ca1'),
57 if len(sys.argv) == 4 and sys.argv[0] == 'server_dht.py':
58 logging.critical('argv %r' % sys.argv)
60 my_addr = (sys.argv[1], int(sys.argv[2])) #('192.16.125.242', 7000)
61 logs_path = sys.argv[3]
62 print 'logs_path:', logs_path
63 logging_conf.setup(logs_path, logs_level)
64 dht = kadtracker.KadTracker(my_addr, logs_path)
67 print 'usage: python server_dht.py dht_ip dht_port path'
70 print 'Type Control-C to exit.'
73 for info_hash in info_hashes:
74 #splitted_heap_str = str(hp.heap()).split()
75 #print i, splitted_heap_str[10]
76 dht.print_routing_table_stats()
78 print 'Getting peers:', time.time()
79 dht.get_peers(info_hash, peers_found)
84 except (KeyboardInterrupt):