Ejemplo n.º 1
0
def __main__(argv):
	min_key_len = 1024

	if(len(argv) != 14):
		raise ValueError, "Usage: %s id key_len round_id n_nodes my_ip my_port leader_ip leader_port dnstr_ip dnstr_port upstr_ip upstr_port msg_len" % (argv[0])

	logger = logging.getLogger()
	logger.setLevel(logging.DEBUG)
	debug("Starting node")

	id = int(argv[1])
	key_len = int(argv[2])
	round_id = int(argv[3])
	n_nodes = int(argv[4])
	my_addr = (argv[5], int(argv[6]))
	leader_addr = (argv[7], int(argv[8]))
	up_addr = (argv[9], int(argv[10]))
	dn_addr = (argv[11], int(argv[12]))
	msg_len = int(argv[13])

	msg_file = AnonCrypto.random_file(msg_len)

	node = bulk_node.bulk_node(id, key_len, round_id, n_nodes,
			my_addr, leader_addr, up_addr, dn_addr, msg_file)
	cProfile.runctx('mynode.run_protocol()', {'mynode': node}, {})
#node.run_protocol()
	fnames = node.output_filenames()

	for i in xrange(0, len(fnames)):
		copyfile(fnames[i], "data/node%04d-%04d.out" % (id, i))

	return
Ejemplo n.º 2
0
def __main__(argv):
    min_key_len = 1024

    if (len(argv) != 14):
        raise ValueError, "Usage: %s id key_len round_id n_nodes my_ip my_port leader_ip leader_port dnstr_ip dnstr_port upstr_ip upstr_port msg_len" % (
            argv[0])

    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    debug("Starting node")

    id = int(argv[1])
    key_len = int(argv[2])
    round_id = int(argv[3])
    n_nodes = int(argv[4])
    my_addr = (argv[5], int(argv[6]))
    leader_addr = (argv[7], int(argv[8]))
    up_addr = (argv[9], int(argv[10]))
    dn_addr = (argv[11], int(argv[12]))
    msg_len = int(argv[13])

    msg_file = AnonCrypto.random_file(msg_len)

    node = bulk_node.bulk_node(id, key_len, round_id, n_nodes, my_addr,
                               leader_addr, up_addr, dn_addr, msg_file)
    cProfile.runctx('mynode.run_protocol()', {'mynode': node}, {})
    #node.run_protocol()
    fnames = node.output_filenames()

    for i in xrange(0, len(fnames)):
        copyfile(fnames[i], "data/node%04d-%04d.out" % (id, i))

    return
Ejemplo n.º 3
0
    def start_node(self, down_index, up_index, participants_vector, my_id):
        n_nodes = len(participants_vector)
        leader_addr = (participants_vector[0][1], int(participants_vector[0][3]))
        my_addr = (participants_vector[my_id][1], int(participants_vector[my_id][3]))
        dn_addr = (participants_vector[down_index][1], int(participants_vector[down_index][3]))
        up_addr = (participants_vector[up_index][1], int(participants_vector[up_index][3]))
        round_id = 1
        key_len = KEY_LENGTH

        """ if distrusted peer is participating, then don't share file (if one is chosen) """
        self.DEBUG("Distrusted peers: %s" % self.distrusted_peers)
        msg_file = None
        trusted = True
        if os.path.exists(self.shared_filename):
            for peer in participants_vector:
                for distrusted_peer in self.distrusted_peers:
                    (d_ip, d_port) = distrusted_peer
                    (p_ip, p_port) = peer[1], peer[2]
                    if d_ip == p_ip and str(d_port) == str(p_port):
                        self.DEBUG("Not sharing my file because peer %s:%s is participating" % (p_ip, p_port))
                        trusted = False
                        break
                if not trusted: break

        # create random file if none has been shared
        if trusted and os.path.exists(self.shared_filename):
            msg_file = self.shared_filename
        else:
            msg_file = AnonCrypto.random_file(DEFAULT_LENGTH)

        # initialize node
        self.node = bulk_node.bulk_node(my_id, key_len, round_id, n_nodes, \
                my_addr, leader_addr, dn_addr, up_addr, msg_file, participants_vector, self.privgenkey1, self.privgenkey2)
        self.DEBUG("round_id: %s id: %s n_nodes: %s my_addr: %s leader_addr: %s dn_addr: %s up_addr: %s msg_file: %s" % \
                (round_id, my_id, n_nodes, my_addr, leader_addr, dn_addr, up_addr, msg_file))
Ejemplo n.º 4
0
    def start_node(self, down_index, up_index, participants_vector, my_id):
        n_nodes = len(participants_vector)
        leader_addr = (participants_vector[0][1], int(participants_vector[0][3]))
        my_addr = (participants_vector[my_id][1], int(participants_vector[my_id][3]))
        dn_addr = (participants_vector[down_index][1], int(participants_vector[down_index][3]))
        up_addr = (participants_vector[up_index][1], int(participants_vector[up_index][3]))
        round_id = 1
        key_len = KEY_LENGTH

        """ if distrusted peer is participating, then don't share file (if one is chosen) """
        self.DEBUG("Distrusted peers: %s" % self.distrusted_peers)
        msg_file = None
        trusted = True
        if os.path.exists(self.shared_filename):
            for peer in participants_vector:
                for distrusted_peer in self.distrusted_peers:
                    (d_ip, d_port) = distrusted_peer
                    (p_ip, p_port) = peer[1], peer[2]
                    if d_ip == p_ip and str(d_port) == str(p_port):
                        self.DEBUG("Not sharing my file because peer %s:%s is participating" % (p_ip, p_port))
                        trusted = False
                        break
                if not trusted:
                    break

        # create random file if none has been shared
        if trusted and os.path.exists(self.shared_filename):
            msg_file = self.shared_filename
        else:
            msg_file = AnonCrypto.random_file(DEFAULT_LENGTH)

        # initialize node
        self.node = bulk_node.bulk_node(
            my_id,
            key_len,
            round_id,
            n_nodes,
            my_addr,
            leader_addr,
            dn_addr,
            up_addr,
            msg_file,
            participants_vector,
            self.privgenkey1,
            self.privgenkey2,
        )
        self.DEBUG(
            "round_id: %s id: %s n_nodes: %s my_addr: %s leader_addr: %s dn_addr: %s up_addr: %s msg_file: %s"
            % (round_id, my_id, n_nodes, my_addr, leader_addr, dn_addr, up_addr, msg_file)
        )