Ejemplo n.º 1
0
def selfLookup(STS, threads_inner, result):
    global recursiveNodes
    time.sleep(3)
    nodeData = message.Messages().returnResponse(result)

    tempNodes = OrderedDict()
    if nodeData is not None:
        message.Messages().removeRequest(result)
        recursiveNodes = RT.PopulateRoutingTable(nodeData)
        final = False
        while not final:
            for key, value in recursiveNodes.items():
                tempNodes[key] = value
            for _, nodeTuple in tempNodes.items():
                t = Thread(target=recursiveLookup, args=[STS, nodeTuple])
                threads_inner.append(t)
                t.start()
            for t1 in threads_inner:
                t1.join()
            if recursiveNodes == tempNodes:
                final = True

        for _, values in recursiveNodes.items():
            values.append(time.time())

        RT.BuildTable(recursiveNodes)

    else:
        message.Messages().removeRequest(result)
Ejemplo n.º 2
0
def recursiveLookup(STS, nodeTuple):
    global recursiveNodes
    results = request.KademliaProtocol(STS).findNode(
        packet.xxhashUser('netsec41'),
        (packet.constructIP(nodeTuple[0]), nodeTuple[1]))
    time.sleep(3)
    nodeData = message.Messages().returnResponse(results)
    if nodeData is not None:
        message.Messages().removeRequest(results)
        for key, value in RT.PopulateRoutingTable(nodeData).items():
            recursiveNodes[key] = value
    else:
        message.Messages().removeRequest(results)
Ejemplo n.º 3
0
	def __init__( self, scr ):

		self.scr = scr
		self.ulist = [  ]
		self.mrel = pg.mouse.get_rel(  )
		self.msg = message.Messages( self.scr )

		for x in range( 16 ):
			x = self.Unit( ( 200, 25 * x, 20, 20 ), self )
			self.ulist.append( x )
Ejemplo n.º 4
0
Archivo: run.py Proyecto: xhalo32/advpy
    def __init__(self):

        from game import Game
        self.scr = pg.display.set_mode((800, 600), pg.RESIZABLE)
        self.WFPS = 50

        self.game = Game(self.scr, self)
        self.run = True
        self.toreset = 0
        self.msg = message.Messages(self.scr)
Ejemplo n.º 5
0
def storeOnNodes(STS):
    global StoreData
    while True:
        file = open("/home/netsec41/dht_data", "r")
        StoreData.expireCache()
        for line in file:
            data = base64.b64decode(line.strip())
            key = packet.hashData(data)
            kClosestNodes = RT.Kclosest(key)
            for nodeTuple in kClosestNodes:
                server = packet.constructIP(nodeTuple[0])
                port = nodeTuple[1]
                result = request.KademliaProtocol(STS).store(
                    data, (server, port))
                message.Messages().removeRequest(result)
        file.close()
        STS.cleanConnectionStates()
        time.sleep(300)
Ejemplo n.º 6
0
 def pingCheck(self, IP, port):
     nonce = request.KademliaProtocol(self.STS).ping((IP, port))
     time.sleep(3)
     result = message.Messages().returnResponse(nonce)
     message.Messages().removeRequest(nonce)
     return result
Ejemplo n.º 7
0
def messageRemove(data):
    message.Messages().removeRequest(packet.nonceExtract(data))
Ejemplo n.º 8
0
def messageCheck(data):
    if message.Messages().checkResponse(packet.nonceExtract(data)):
        message.Messages().insertResponse(packet.nonceExtract(data), data)
        return True
    return False
Ejemplo n.º 9
0
def basic_protocol_request(firstByte):
    nonce = nonceGen()
    message.Messages().insertRequest(nonce)
    return struct.pack('>BIHIH', firstByte, 2, xxhashUser('netsec41'), 2, nonce)