-
Notifications
You must be signed in to change notification settings - Fork 118
/
wooooooodworm.py
61 lines (51 loc) · 1.65 KB
/
wooooooodworm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#_*_ coding: utf-8 _*_
__author__ = 'NanYoMy'
import logging
import time
from conf import *
from btdht import DHT
from btdht import Parser
if __name__ == "__main__":
# Enable logging
stdLogLevel = logging.ERROR
fileLogLevel = logging.DEBUG
#formatter = logging.Formatter("[%(levelname)s@%(created)s] %(message)s")
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
stdout_handler = logging.StreamHandler()
stdout_handler.setFormatter(formatter)
file_handler = logging.FileHandler("HASH.log")
file_handler.setFormatter(formatter)
logging.getLogger("btdht").setLevel(fileLogLevel)
logging.getLogger("btdht").addHandler(file_handler)
logging.getLogger("std").setLevel(stdLogLevel)
logging.getLogger("std").addHandler(stdout_handler)
#thread number
threadNumb=THREAD_NUMBER
#working time for threads
workingTime=WORKINGTIME
#threads pool
threads=[]
for i in xrange(threadNumb):
i=i+9500
thread = DHT(host='0.0.0.0', port=i)
thread.start()
thread.bootstrap('router.bittorrent.com',6881)
CurrentMagnet = "4CDE5B50A8930315B479931F6872A3DB59575366"
thread.ht.add_hash(CurrentMagnet.decode("hex"))
threads.append(thread)
print "start node %d"%i
#time.sleep(2)
time.sleep(workingTime)
for i in threads:
print "stop thread "+i.name
i.stop()
i.join()
#i.rt.saveAllPeer(i.name)
#i.ht.saveHashInfo(i.name)
i.rt.nodes.clear()
i.ht.hashes.clear()
print 'finish thread'+i.name
'''
dht.ht.hashes.clear()
dht.rt.nodes.clear()
'''