Exemplo n.º 1
0
def filter_by_area(area, type_country_filtered):
    remaining_servers = []
    resolved_locations = locations.get_unique_locations(list_of_servers=type_country_filtered)
    for aServer in type_country_filtered:
        for item in resolved_locations:
            if aServer["location"]["lat"] == item[1]["lat"] and \
                    aServer["location"]["long"] == item[1]["long"] and area in item[2]:
                aServer["location_names"] = item[2]  # add location info to server
                # print(aServer)
                remaining_servers.append(aServer)
    return remaining_servers
Exemplo n.º 2
0
def filter_by_area(area: str, type_country_filtered: List) -> List:
    remaining_servers = []
    resolved_locations = locations.get_unique_locations(list_of_servers=type_country_filtered)
    for aServer in type_country_filtered:
        for item in resolved_locations:
            lower_case_areas = [x.lower() for x in item[2]]
            if aServer["location"]["lat"] == item[1]["lat"] and \
                    aServer["location"]["long"] == item[1]["long"] and \
                    area.lower() in lower_case_areas:
                aServer["location_names"] = item[2]  # add location info to server
                # logger.debug(aServer)
                remaining_servers.append(aServer)
    return remaining_servers
Exemplo n.º 3
0
def display_servers(list_servers: List, port: str, area: str, p2p: bool, dedicated: bool, double_vpn: bool,
                    tor_over_vpn: bool, anti_ddos: bool, netflix: bool, location: float) -> None:
    servers_on_web = set()      # servers shown on the website

    # if list_servers was not a specific country it would be "all"
    json_res_list = api.get_data_from_api(
        country_code=list_servers, area=area, p2p=p2p, dedicated=dedicated,
        double_vpn=double_vpn, tor_over_vpn=tor_over_vpn, anti_ddos=anti_ddos,
        netflix=netflix, location=location)
    # logger.debug(json_res_list)

    print(Style.BRIGHT + Fore.BLUE + "The NordVPN Servers In", Fore.GREEN +
          list_servers.upper() + Fore.BLUE, end=" ")
    if area:
        print("Area ", Fore.GREEN + area + Fore.BLUE, end=" ")
    if p2p:
        print("with " + Fore.GREEN + "p2p" + Fore.BLUE + " support", end=" ")
    if dedicated:
        print("with " + Fore.GREEN + "dedicated" + Fore.BLUE + " support", end=" ")
    if double_vpn:
        print("with " + Fore.GREEN + "double_vpn" + Fore.BLUE + " support", end=" ")
    if tor_over_vpn:
        print("with " + Fore.GREEN + "tor_over_vpn" + Fore.BLUE + " support", end=" ")
    if anti_ddos:
        print("with " + Fore.GREEN + "anti_ddos" + Fore.BLUE + " support", end=" ")
    if netflix:
        print("with " + Fore.GREEN + "netflix" + Fore.BLUE + " support", end=" ")
    print("Are:\n" + Style.RESET_ALL)

    # add server names to "servers_on_web" set
    for res in json_res_list:
        print("Server =", res["domain"][:res["domain"].find(".")], ", Load =", res["load"],
              ", Country =", res["country"], ", Features", res["categories"], "\n")
        servers_on_web.add(res["domain"][:res["domain"].find(".")])

    if not area:
        locations_in_country = locations.get_unique_locations(list_of_servers=json_res_list)
        print("The available Locations in country", list_servers.upper(), "are :")
        for eachLocation in locations_in_country:
            print(eachLocation[2])
        print("")

    if list_servers != "all" and not p2p and not dedicated and not double_vpn \
            and not tor_over_vpn and not anti_ddos and not netflix and not area:
            # else not applicable.
        print_latest_servers(list_servers=list_servers, port=port, server_set=servers_on_web)
Exemplo n.º 4
0
def display_servers(list_servers, area, p2p, dedicated, double_vpn,
                    tor_over_vpn, anti_ddos):
    servers_on_web = set()  # servers shown on the website

    # if list_servers was not a specific country it would be "all"
    json_res_list = get_data_from_api(country_code=list_servers,
                                      area=area,
                                      p2p=p2p,
                                      dedicated=dedicated,
                                      double_vpn=double_vpn,
                                      tor_over_vpn=tor_over_vpn,
                                      anti_ddos=anti_ddos)
    # print(json_res_list)

    if area:
        print("The NordVPN Servers In", list_servers.upper(), "Area", area,
              "Are :")
    else:
        print("The NordVPN Servers In", list_servers.upper(), "Are :")

    # add server names to "servers_on_web" set
    for res in json_res_list:
        print("Server =", res["domain"][:res["domain"].find(".")], ", Load =",
              res["load"], ", Country =", res["country"], ", Features",
              res["categories"], '\n')
        servers_on_web.add(res["domain"][:res["domain"].find(".")])

    if not area:
        locations_in_country = locations.get_unique_locations(
            list_of_servers=json_res_list)
        print("The available Locations in country", list_servers.upper(),
              "are :")
        for location in locations_in_country:
            print(location[2])

    if list_servers != "all" and p2p is False and dedicated is False and double_vpn is False \
            and tor_over_vpn is False and anti_ddos is False and area is False:
        # else not applicable.
        print_latest_servers(server_set=servers_on_web)
    sys.exit()