Beispiel #1
0
 def reset_settings(self):
     answer = messagebox.askyesno(
         title='Confirm',
         message="Are you sure you want to reset connection settings?")
     if answer:
         self.parent.reset_settings()
         update_settings("", 0, "", "")
Beispiel #2
0
    def automatic_connection(self):
        selected_server_type = self.optionsFrame.get_selected_server()
        selected_country = self.optionsFrame.get_selected_country()

        # launching thread
        parallel_request = threading.Thread(
            target=self.parallel_get_recommended_server,
            args=(self, selected_server_type, selected_country))
        parallel_request.start()

        # updating gui
        self.set_status_requesting()
        self.update_idletasks()

        parallel_request.join()
        recommended_server = self.queue.get_nowait()

        if recommended_server == "RequestException":
            messagebox.showinfo(
                title="Info",
                message="Connection with nordvpn failed, using last server")
            recommended_server = self.previously_recommended_server
        elif recommended_server == "RequestsConnectionError":
            messagebox.showerror(
                title="Error",
                message=
                "No connection available, please reconnect and try again")
            self.setStatusDisconnected()
            return

        if recommended_server is None:
            messagebox.showwarning(
                title="Error",
                message=
                "Sorry, server not found! Please try a different server.")
            self.setStatusDisconnected()
            return

        protocol_selected = self.connectionProtocol.get()

        # check if recommended server exists. If it does not exists, download the needed files
        if protocol_selected != IKEV2_PROTOCOL_NUMBER and \
                not exists_conf_for(recommended_server, protocol_selected):
            update_conf_files()

            # if file does not exist then it is incorrect (extreme case)
            if not exists_conf_for(recommended_server, protocol_selected):
                messagebox.showwarning(
                    title="Error",
                    message="Retrieved a wrong server from NordVPN, try again")
                return

        # saving settings for the next opening
        update_settings(selected_server_type, protocol_selected,
                        selected_country, recommended_server)

        self.connect_to_VPN(recommended_server, protocol_selected)