Beispiel #1
0
def quick_connect(wait_connection=False, sleep_time=5):
    print("Trying to connect to the last server type")

    if os.geteuid() != 0:
        get_root_permissions_cli()

    if not correct_saved_settings():
        print(
            "No settings stored, connect to a server type with the gui, then try again"
        )
        return

    (server_type, protocol, country, server) = load_settings()
    protocol = int(protocol)

    # wait until a connection is established
    if wait_connection:
        import requests
        import time
        while True:
            try:
                requests.get("http://216.58.192.142")  # get google.com
                break
            except requests.exceptions.ConnectionError:
                time.sleep(sleep_time)

    server = get_recommended_server(server_type, country)

    startVPN(server, protocol, False)
Beispiel #2
0
    def __init__(self):
        super().__init__()
        self.wm_title("NordPY")

        # sets the icon
        self.__imgicon__ = PhotoImage(
            file=os.path.join(CURRENT_PATH + "media", "nordvpn.png"))
        self.tk.call('wm', 'iconphoto', self._w, self.__imgicon__)
        # getting color for background (some widget will need it)
        self.background_color = self.cget('background')

        if advanced_settings_are_correct():
            (self.scale_factor, self.nm_use) = advanced_settings_read()
        else:
            (self.scale_factor, self.nm_use) = (DEFAULT_SCALE_FACTOR,
                                                DEFAULT_NM_USE)

        self.settings_frame = SettingsFrame(self, self.scale_factor)
        self.manual_frame = ManualSelectionFrame(self, self.background_color,
                                                 self.scale_factor)
        self.optionsFrame = OptionFrame(self)
        self.__init_protocol__()
        self.__initStatus__()
        self.__initButtons__()

        self.center_window(DEFAUL_WIDTH, DEFAUL_HEIGHT, self.scale_factor,
                           self.optionsFrame.cget("font"))

        running_vpn = get_running_vpn()
        if running_vpn is not None:
            self.setStatusAlreadyConnected(running_vpn)
            self.running_connection = running_vpn
        else:
            self.setStatusDisconnected()
            self.running_connection = None

        if existing_corrected_saved_settings():
            serverType, protocol, country, self.previously_recommended_server = load_settings(
            )

            self.optionsFrame.set_selected_server(serverType)
            self.connectionProtocol.set(protocol)
            self.optionsFrame.set_selected_country(country)

        self.on_manual_change()

        # queue used to communicate with secondary thread
        self.queue = Queue()