Ejemplo n.º 1
0
from src.Peer import Peer

if __name__ == "__main__":
    server = Peer("192.168.202.221", 5356, is_root=True)
    server.start_user_interface()

    server.run()

Ejemplo n.º 2
0
        port = parts_of_command[3]

        if not is_ip_correct(ip) or not is_port_ok(port):
            print('WRONG_COMMAND')
        else:
            if parts_of_command[1] == 'client':
                if len(parts_of_command) != 6:
                    print('WRONG COMMAND')
                else:
                    root_ip = parts_of_command[4]
                    if root_ip == '_': root_ip = '127.000.000.001'
                    root_port = parts_of_command[5]
                    if not is_ip_correct(root_ip) or not is_port_ok(root_port):
                        print('WRONG_COMMAND')
                    else:
                        client = Peer(ip,
                                      int(port),
                                      is_root=False,
                                      root_address=(root_ip, int(root_port)))
                        threading.Thread(target=client.run).start()
                        client.start_user_interface()
            elif parts_of_command[1] == 'root':
                if len(parts_of_command) != 4:
                    print('WRONG COMMAND')
                else:
                    root = Peer(ip, int(port), is_root=True)
                    threading.Thread(target=root.run).start()
                    root.start_user_interface()
            else:
                print('WRONG COMMAND')