コード例 #1
0
    def load_general_settings(self, general_settings_dict):
        polkit_support_switch = general_settings_dict["polkit_support_switch"]
        sudo_info_tooltip = general_settings_dict["sudo_info_tooltip"]
        setter = 0

        tooltip_msg = "Could not find PolKit installed on your system. For more information, please visit: \nhttps://github.com/ProtonVPN/linux-gui"

        username = get_config_value("USER", "username")
        tier = int(get_config_value("USER", "tier"))

        # Populate username
        general_settings_dict["username"].set_text(username)
        # Set tier
        general_settings_dict["pvpn_plan_combobox"].set_active(tier)

        polkit_support_switch.set_property('sensitive', False)

        if is_polkit_installed():
            if self.settings_service.polkit == 1:
                polkit_support_switch.set_state(True)

            polkit_support_switch.set_property('sensitive', True)
            use_cases = "\n-Update username and password (root protected file)\n-Enable/disable autoconnect (create/remove .service file)\n-Connect/disconnect to/from VPN (run CLI commands)"
            tooltip_msg = "Displays a window to enter sudo password, which is needed for the following cases:{}\n\nIt is recommended to enabled this if you don't want to use the GUI via the terminal.".format(
                use_cases)

        sudo_info_tooltip.set_tooltip_text(tooltip_msg)
コード例 #2
0
    def split_tunneling_switch_changed(self, switch, state):
        killswitch_protection = int(get_config_value("USER", "killswitch"))

        try:
            split_tunnel = int(get_config_value("USER", "split_tunnel"))
        except KeyError:
            gui_logger.debug("[!] Split tunneling has not been configured.")
            split_tunnel = 0

        if split_tunnel == 0:
            update_to = 1
        else:
            update_to = 0

        if state:
            self.split_tunnel_grid.show()
        else:
            self.split_tunnel_grid.hide()

        if (state and split_tunnel == 0) or (not state and split_tunnel != 0):
            if update_to == 1 and killswitch_protection >= 0:
                self.killswitch_switch.set_property('sensitive', False)
            else:
                self.killswitch_switch.set_property('sensitive', True)

            thread = Thread(
                target=self.settings_presenter.update_split_tunneling_status,
                args=[update_to])
            thread.daemon = True
            thread.start()
コード例 #3
0
    def last_connect_button_clicked(self, button):
        """Button/Event handler to reconnect to previously connected server
        """
        try:
            servername = get_config_value("metadata", "connected_server")
            protocol = get_config_value("metadata", "connected_proto")
        except KeyError:
            self.queue.put(
                dict(
                    action="display_dialog",
                    label=
                    "You have not previously connected to any server, please do first connect to a server before attempting to reconnect."
                ))
            gui_logger.debug(
                "[!] Attempted to connect to previously connected server without having made any previous connections."
            )
            return

        self.queue.put(
            dict(
                action="display_dialog",
                label=
                "Connecting to previously connected server <b>{0}</b> with <b>{1}</b>."
                .format(servername, protocol.upper()),
                spinner=True,
                hide_close_button=True))

        gui_logger.debug(">>> Starting \"last_connect\" thread.")

        thread = Thread(target=self.dashboard_presenter.on_last_connect,
                        kwargs=dict(connection_labels=self.connection_labels))
        thread.daemon = True
        thread.start()
コード例 #4
0
def load_advanced_settings(interface):
    # User values
    dns_leak_protection = get_config_value("USER", "dns_leak_protection")
    custom_dns = get_config_value("USER", "custom_dns")
    killswitch = get_config_value("USER", "killswitch")
    split_tunnel = 0

    try:
        split_tunnel = get_config_value("USER", "split_tunnel")
    except KeyError:
        pass

    # Object
    dns_leak_switch = interface.get_object("update_dns_leak_switch")
    killswitch_switch = interface.get_object("update_killswitch_switch")
    split_tunneling_switch = interface.get_object("split_tunneling_switch")
    split_tunneling_list = interface.get_object("split_tunneling_textview")

    # Set DNS Protection
    if dns_leak_protection == '1':
    # if dns_leak_protection == '1' or (dns_leak_protection != '1' and custom_dns.lower() != "none"):
        dns_leak_switch.set_state(True)
    else:
        dns_leak_switch.set_state(False)

    # Set Kill Switch
    if killswitch != '0':
        killswitch_switch.set_state(True)
    else:
        killswitch_switch.set_state(False)

    # Populate Split Tunelling
    # Check if killswtich is != 0, if it is then disable split tunneling Function
    if killswitch != '0':
        killswitch_switch.set_state(True)
    else:
        killswitch_switch.set_state(False)

    if split_tunnel != '0':
        split_tunneling_switch.set_state(True)
        if killswitch != '0':
            split_tunneling_list.set_property('sensitive', False)
            interface.get_object("update_split_tunneling_button").set_property('sensitive', False)
            
        split_tunneling_buffer = split_tunneling_list.get_buffer()
        content = ""
        try:
            with open(SPLIT_TUNNEL_FILE) as f:
                lines = f.readlines()

                for line in lines:
                    content = content + line

                split_tunneling_buffer.set_text(content)
        except FileNotFoundError:
            split_tunneling_buffer.set_text(content)
    else:
        split_tunneling_switch.set_state(False)  
コード例 #5
0
def load_general_settings(interface):
    username_field = interface.get_object("update_username_input")
    pvpn_plan_combobox = interface.get_object("update_tier_combobox")

    username = get_config_value("USER", "username")
    tier = int(get_config_value("USER", "tier"))

    # Populate username
    username_field.set_text(username)
    # Set tier
    pvpn_plan_combobox.set_active(tier)
コード例 #6
0
def random_connect(interface, messagedialog_label, messagedialog_spinner):
    """Function that connects to a random server.
    """
    protocol = get_config_value("USER", "default_protocol")

    gui_logger.debug(">>> Running \"reconnect\"")

    update_labels_dict = {
        "interface": interface,
        "servers": False,
        "disconnecting": False,
        "conn_info": False
    }

    result = subprocess.run(["protonvpn", "connect", "--random", "-p", protocol], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    
    server_protocol = get_server_protocol_from_cli(result, return_protocol=True)

    display_message = result.stdout.decode()

    if server_protocol:
        display_message = "You are connect to <b>{}</b> via <b>{}</b>!".format(server_protocol[0], server_protocol[1].upper())

    messagedialog_label.set_markup(display_message)
    messagedialog_spinner.hide()

    gui_logger.debug(">>> Result: \"{0}\"".format(result))

    update_labels_status(update_labels_dict)

    gui_logger.debug(">>> Ended tasks in \"random_c\" thread.")
コード例 #7
0
    def update_tier_combobox_changed(self, object):
        tier = int(get_config_value("USER", "tier"))
        
        tree_iter = object.get_active_iter()

        if tree_iter is not None:
            model = object.get_model()
            selected_tier, tier_display = model[tree_iter][:2]

            if selected_tier != tier:
                self.messagedialog_sub_label.hide()        
                self.messagedialog_label.set_markup("Updating ProtoVPN plan...")
                self.messagedialog_spinner.show()

                gui_logger.debug(">>> Starting \"update_tier_combobox_changed\" thread.")

                thread = Thread(target=update_pvpn_plan, args=[
                                                                self.interface, 
                                                                self.messagedialog_label, 
                                                                self.messagedialog_spinner, 
                                                                int(selected_tier+1),
                                                                tier_display])
                thread.daemon = True
                thread.start()

                self.messagedialog_window.show()
コード例 #8
0
    def split_tunneling_switch_changed(self, object, state):
        split_tunnel_grid = self.interface.get_object("split_tunneling_grid") 
        split_tunnel = get_config_value("USER", "split_tunnel")
        
        if split_tunnel == "0":
            update_to = "1"
        else:
            update_to = "0"

        if state:
            split_tunnel_grid.show()
        else:

            split_tunnel_grid.hide()

        if (state and split_tunnel == "0") or (not state and split_tunnel != "0"):
            self.messagedialog_sub_label.hide()        
            self.messagedialog_label.set_markup("Updating split tunneling settings...")
            self.messagedialog_spinner.show()
            thread = Thread(target=update_split_tunneling_status, args=[
                                                    self.messagedialog_label, 
                                                    self.messagedialog_spinner,
                                                    update_to])
            thread.daemon = True
            thread.start()

            self.messagedialog_window.show()
コード例 #9
0
def load_connection_settings(interface):
    # Set Autoconnect on boot combobox
    server_list = populate_autoconnect_list(interface, return_list=True)

    # Get objects
    update_autoconnect_combobox = interface.get_object(
        "update_autoconnect_combobox")
    update_quick_connect_combobox = interface.get_object(
        "update_quick_connect_combobox")
    update_protocol_combobox = interface.get_object("update_protocol_combobox")

    #Get values
    try:
        autoconnect_setting = get_gui_config("conn_tab", "autoconnect")
    except (KeyError, IndexError):
        autoconnect_setting = 0
    try:
        quick_connect_setting = get_gui_config("conn_tab", "quick_connect")
    except (KeyError, IndexError):
        quick_connect = 0
    default_protocol = get_config_value("USER", "default_protocol")

    # Get indexes
    autoconnect_index = list(server_list.keys()).index(autoconnect_setting)
    quick_connect_index = list(server_list.keys()).index(quick_connect_setting)

    # Set values
    update_autoconnect_combobox.set_active(autoconnect_index)
    update_quick_connect_combobox.set_active(quick_connect_index)

    if default_protocol == "tcp":
        update_protocol_combobox.set_active(0)
    else:
        update_protocol_combobox.set_active(1)
コード例 #10
0
def quick_connect(*args):
    """Function that connects to the quickest server.
    """
    protocol = get_config_value("USER", "default_protocol")
    display_message = ""

    gui_logger.debug(">>> Running \"fastest\".")

    result = subprocess.run(
        ["protonvpn", "connect", "--fastest", "-p", protocol],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)

    update_labels_dict = {
        "interface": args[0]["interface"],
        "servers": False,
        "disconnecting": False,
        "conn_info": False
    }
    server_protocol = get_server_protocol_from_cli(result)

    display_message = result.stdout.decode()

    if server_protocol:
        display_message = "You are connect to <b>{}</b> via <b>{}</b>!".format(
            server_protocol, protocol.upper())

    args[0]["messagedialog_label"].set_markup(display_message)
    args[0]["messagedialog_spinner"].hide()

    gui_logger.debug(">>> Result: \"{0}\"".format(result))

    update_labels_status(update_labels_dict)

    gui_logger.debug(">>> Ended tasks in \"fastest\" thread.")
コード例 #11
0
 def __init__(self, interface): 
     self.interface = interface
     self.messagedialog_window = self.interface.get_object("MessageDialog")
     self.messagedialog_label = self.interface.get_object("message_dialog_label")
     self.messagedialog_sub_label = self.interface.get_object("message_dialog_sub_label")
     self.messagedialog_spinner = self.interface.get_object("message_dialog_spinner")
     self.conn_disc_button_label = self.interface.get_object("main_conn_disc_button_label")
     self.messagedialog_sub_label.hide()
     self.main_initial_tab = 0
     self.settings_initial_tab = 0
     try:
         self.onload_dns_protection = get_config_value("USER", "dns_leak_protection")
         self.onload_dns_custom = get_config_value("USER", "custom_dns")
     except:
         self.onload_dns_protection = 0
         self.onload_dns_custom = "none"
コード例 #12
0
    def fastest_sc_by_country(self, country, protocol=None):
        """Connect to the fastest Secure Core server in a specific country."""
        pvpncli_logger.logger.debug("Starting fastest SC country connect")

        if not protocol:
            protocol = pvpncli_utils.get_config_value("USER",
                                                      "default_protocol")

        country_code = self.get_country_code(country)

        self.exec_cmd('protonvpn d')
        pvpncli_utils.pull_server_data(force=True)

        servers = pvpncli_utils.get_servers()

        # ProtonVPN Features: 1: SECURE-CORE, 2: TOR, 4: P2P
        server_pool = []
        for server in servers:
            if server["Features"] == 1 \
               and server["ExitCountry"] == country_code:
                server_pool.append(server)

        fastest_server = pvpncli_utils.get_fastest_server(server_pool)
        cmd = f'protonvpn c {fastest_server} -p {protocol}'
        Clock.schedule_once(partial(self.exec_cmd, cmd), 0.1)
コード例 #13
0
    def update_serverload(self, _):
        """Updates server load.
        """
        gui_logger.debug("TRAY >>> Updating server load in update_serverload.")

        connected_server = False
        load = False

        try:
            connected_server = get_config_value("metadata", "connected_server")
        except KeyError:
            gui_logger.debug("[!] Could not find specified key: ".format(KeyError))
            return True

        # force_pull servers
        try:
            pull_server_data(force=True)
        except:
            gui_logger.debug("[!] Could not pull from servers, possible due to unstable connection.")
            return True

        # get_servers
        servers = get_servers()

        # get server load
        try:
            load = get_server_value(connected_server, "Load", servers)
        except:
            gui_logger.debug("[!] Unable to get server load.")
            return True

        self.serverload_msg = "Load: {}%".format(load)
        
        return True
コード例 #14
0
 def initialize_application(self, *dt):
     """Initialize app's main screen and subsequent functionality."""
     # Indicator that app was just initialized.
     self.app_newly_initialized = True
     # Get default protocol (TCP or UDP) and User's account tier-level.
     self.default_protocol = pvpncli_utils.get_config_value(
         "USER",
         "default_protocol",
     )
     self.tier = int(pvpncli_utils.get_config_value(
         "USER",
         "tier",
     ))
     # Set Secure Core disabled based on Tier
     self.secure_core = self.ids.main_screen.ids.secure_core_switch
     # 0: Free, 1: Basic, 2: Plus/Visionary
     if self.tier < 2:
         self.secure_core.disabled = True
     # State of Secure Core Notification Popup
     self.sc_notification_open = False
     # Schedule check for connection change and trigger update if found.
     self.cnxn_check = Clock.schedule_interval(self.check_current_cnxn, 1)
     # Schedule refresh of data trans/recvd.
     self.data_trans = Clock.schedule_interval(self.get_data_up_down, 1)
     # Schedule refresh of connection time
     self.cnxn_time = Clock.schedule_interval(self.get_connection_time, 1)
     # Current connection status
     self.vpn_connected = self.is_connected()
     # Used for detecting connection changes
     self.last_known_connection = None
     # Schedule update of server tree every 5 min
     self.update_server_tree = (Clock.schedule_interval(
         self.update_server_tree_info, 300))
     # Set initial connection window button image based on connection status
     self.cnxn_wndw_btn = self.ids.main_screen.ids.connection_window_button
     if self.vpn_connected:
         self.cnxn_wndw_btn.normal_img = './images/disconnect.png'
         self.cnxn_wndw_btn.hover_img = './images/disconnect_hover.png'
         self.cnxn_wndw_btn.source = './images/disconnect.png'
     else:
         self.cnxn_wndw_btn.normal_img = './images/quick_connect.png'
         self.cnxn_wndw_btn.hover_img = './images/quick_connect_hover.png'
         self.cnxn_wndw_btn.source = './images/quick_connect.png'
     # Update current connection info in connection window.
     self.update_current_connection()
     # Initialize server tree.
     self.build_server_tree()
コード例 #15
0
    def check_split_tunneling(self):
        try:
            is_splitunn_enabled = True if get_config_value("USER", "split_tunnel") == "1" else False
        except (KeyError, IndexError) as e:
            gui_logger.debug(e)
            return False

        return is_splitunn_enabled
コード例 #16
0
    def get_diagnose_settings(self):
        # Check if there is internet connection
            # Depending on next questions, some actions might be suggested.
        has_internet = check_internet_conn(request_bool=True)
        
        # Check if killswitch is enabled
            # Advice to restore IP tables manually and restart netowrk manager.
        is_killswitch_enabled = True if get_config_value("USER", "killswitch") == 1 else False

        # Check if VPN is running
            # If there is a OpenVPN process running in the background, kill it.
        is_ovpnprocess_running = is_connected()

        # Check if custom DNS is enabled
            # If there is no VPN connection and also no internet, then it is a DNS issue.
        is_dns_protection_enabled = False if get_config_value("USER", "dns_leak_protection") == "0" or (not get_config_value("USER", "custom_dns") is None and get_config_value("USER", "dns_leak_protection") == "0") else True

        return has_internet, is_killswitch_enabled, is_ovpnprocess_running, is_dns_protection_enabled
コード例 #17
0
def custom_quick_connect(*args):
    """Make a custom quick connection 
    """
    quick_conn_pref = get_gui_config("conn_tab", "quick_connect")
    protocol = get_config_value("USER", "default_protocol")

    display_message = ""
    command = "--fastest"
    country = False

    if quick_conn_pref == "fast":
        command = "-f"
    elif quick_conn_pref == "rand":
        command = "-r"
    elif quick_conn_pref == "p2p":
        command = "--p2p"
    elif quick_conn_pref == "sc":
        command = "--sc"
    elif quick_conn_pref == "tor":
        command = "--tor"
    else:
        command = "--cc"
        country = quick_conn_pref.upper()

    command_list = ["protonvpn", "connect", command, "-p", protocol]
    if country:
        command_list = [
            "protonvpn", "connect", command, country, "-p", protocol
        ]

    result = subprocess.run(command_list,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)

    update_labels_dict = {
        "interface": args[0]["interface"],
        "servers": False,
        "disconnecting": False,
        "conn_info": False
    }

    server_protocol = get_server_protocol_from_cli(result)

    display_message = result.stdout.decode()

    if server_protocol:
        display_message = "You are connect to <b>{}</b> via <b>{}</b>!".format(
            server_protocol, protocol.upper())

    args[0]["messagedialog_label"].set_markup(display_message)
    args[0]["messagedialog_spinner"].hide()

    gui_logger.debug(">>> Result: \"{0}\"".format(result))

    update_labels_status(update_labels_dict)

    gui_logger.debug(">>> Ended tasks in \"custom_quick_connect\" thread.")
コード例 #18
0
    def update_killswitch_switch_changed(self, object, state):
        killswitch_protection = get_config_value("USER", "killswitch")
        if killswitch_protection == "0":
            update_to = "1"
        else:
            update_to = "0"

        if (state and killswitch_protection == "0") or (not state and killswitch_protection != "0"):
            thread = Thread(target=update_killswitch, args=[update_to])
            thread.daemon = True
            thread.start()
コード例 #19
0
    def update_dns_leak_switch_changed(self, object, state):
        dns_protection = get_config_value("USER", "dns_leak_protection")
        if dns_protection == "0":
            update_to = "1"
        elif dns_protection != "0":
            update_to = "0"

        if (state and dns_protection == "0") or (not state and dns_protection != "0"):
            thread = Thread(target=update_dns, args=[update_to])
            thread.daemon = True
            thread.start()
コード例 #20
0
 def connection_changed(self, *dt):
     """Compare current connection to last known; True = change."""
     # Gather details of current connected server.
     current_connection = pvpncli_utils.get_config_value(
         "metadata",
         "connected_server",
     )
     # Compare curren connection to last known connection.
     if current_connection != self.last_known_connection:
         return True
     else:
         return False
コード例 #21
0
    def get_current_values(self):
        """Get current VPN Settings values from pvpn-cli.cfg."""
        # Username
        self.username_val = pvpncli_utils.get_config_value("USER", "username")
        # Password
        cmd = f'/bin/cat {pvpncli_constants.PASSFILE}'
        user_passwd = subprocess.check_output(cmd, shell=True).decode()
        self.usr_val, self.passwd_val = user_passwd.split()
        # ProtonVPN Plan/Tier
        self.tier_val = int(pvpncli_utils.get_config_value("USER", "tier"))
        for opt, val in self.plan_options.items():
            if val == self.tier_val:
                self.tier_val = opt
        # Default Protocol
        self.prot_val = pvpncli_utils.get_config_value("USER",
                                                       "default_protocol")
        self.prot_val = self.prot_val.upper()
        # DNS Management
        # Check for custom_dns values.
        self.dns_ip_val = pvpncli_utils.get_config_value("USER", "custom_dns")
        # Determine selection for dns_leak_protection
        self.dns_val = int(
            pvpncli_utils.get_config_value("USER", "dns_leak_protection"))
        # If config dns_leak_protection is 0, determine if there's a
        # custom_dns value or not. If yes, set to 'Custom DNS Server'
        # else, set to "None".
        if self.dns_val == 0:
            if self.dns_ip_val != 'None':
                self.dns_val = 'Custom DNS Servers'
            else:
                self.dns_val = 'None'
        else:
            self.dns_val = 'Enable Leak Protection'

        # Kill Switch
        self.kill_switch_val = int(
            pvpncli_utils.get_config_value("USER", "killswitch"))
        for opt, val in self.kill_switch_options.items():
            if val == self.kill_switch_val:
                self.kill_switch_val = opt
        # Split Tunneling
        self.split_tunl_val = int(
            pvpncli_utils.get_config_value("USER", "split_tunnel"))
        for opt, val in self.split_tunnel_options.items():
            if val == self.split_tunl_val:
                self.split_tunl_val = opt

        self.split_tunnel_ips = ''
        if os.path.isfile(pvpncli_constants.SPLIT_TUNNEL_FILE):
            with open(pvpncli_constants.SPLIT_TUNNEL_FILE, "r") as f:
                content = f.readlines()
                for line in content:
                    line = line.rstrip("\n")
                    self.split_tunnel_ips += line
            self.split_tunneling_ip_list.text = self.split_tunnel_ips
コード例 #22
0
    def update_split_tunneling(self, **kwargs):
        """Function that updates split tunneling configurations.
        """
        gui_logger.debug(">>> Running \"set_split_tunnel\".")

        return_val = False
        split_tunneling_content = kwargs.get("split_tunneling_content")
        result = "Split tunneling configurations <b>updated</b>!\n"
        disabled_ks = False
        invalid_ip = False

        ip_list = self.settings_service.reformat_ip_list(
            split_tunneling_content)

        valid_ips = self.settings_service.check_valid_ips(ip_list)

        if not type(
                valid_ips) == bool and len(valid_ips) > 1 and not valid_ips[0]:
            result = "<b>{0}</b> is not valid!\nNone of the IP's were added, please try again with a different IP.".format(
                valid_ips[1])
            gui_logger.debug("[!] Invalid IP \"{0}\".".format(valid_ips[1]))
            invalid_ip = True

        if not invalid_ip:
            if len(ip_list) == 0:
                result = "unable to disable Split Tunneling !\n\n"
                if self.settings_service.set_split_tunneling(0):
                    result = "Split tunneling <b>disabled</b>!\n\n"
                    return_val = True
            else:
                result = result + "The following servers were added:\n\n{}".format(
                    [ip for ip in ip_list])
                return_val = True

                if int(get_config_value("USER", "killswitch")):
                    result = "Split Tunneling <b>can't</b> be used with Kill Switch.\nKill Switch could not be disabled, cancelling update!"
                    if self.settings_service.set_killswitch(0):
                        result = result + "Split Tunneling <b>can't</b> be used with Kill Switch.\nKill Switch has been <b>disabled</b>!\n\n"
                        disabled_ks = True

                if not disabled_ks and not self.settings_service.set_split_tunneling_ips(
                        ip_list):
                    result = "Unable to add IPs to Split Tunneling file!"
                    return_val = False

        self.queue.put(dict(action="update_dialog", label=result))

        gui_logger.debug(
            ">>> Ended tasks in \"set_split_tunnel\" thread. Result: \"{0}\"".
            format(result))

        return return_val
コード例 #23
0
ファイル: indicator.py プロジェクト: h3ronakam/linux-gui
    def time_connected(self):
        """Gets and returns the connection time length.
        """

        try:
            connected_time = get_config_value("metadata", "connected_time")
            connection_time = time.time() - int(connected_time)
            connection_time = str(datetime.timedelta(seconds=connection_time)).split(".")[0]
        except (KeyError, IndexError):
            connection_time = False
    
        connection_time = connection_time if connection_time else ""

        return connection_time
コード例 #24
0
def connect_to_selected_server(*args):
    """Function that either connects by selected server or selected country.
    """
    protocol = get_config_value("USER", "default_protocol")

    gui_logger.debug(">>> Running \"openvpn_connect\".")

    # Check if it should connect to country or server
    if "#" in args[0]["user_selected_server"]:
        result = subprocess.run([
            "protonvpn", "connect", args[0]["user_selected_server"], "-p",
            protocol
        ],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        gui_logger.debug(
            ">>> Log during connection to specific server: {}".format(result))
    else:
        for k, v in country_codes.items():
            if v == args[0]["user_selected_server"]:
                selected_country = k
                break
        result = subprocess.run(
            ["protonvpn", "connect", "--cc", selected_country, "-p", protocol],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        gui_logger.debug(
            ">>> Log during connection to country: {}".format(result))

    server_protocol = get_server_protocol_from_cli(result)

    display_message = result.stdout.decode()

    if server_protocol:
        display_message = "You are connect to <b>{}</b> via <b>{}</b>!".format(
            server_protocol, protocol.upper())

    args[0]["messagedialog_label"].set_markup(display_message)
    args[0]["messagedialog_spinner"].hide()

    update_labels_dict = {
        "interface": args[0]["interface"],
        "servers": False,
        "disconnecting": False,
        "conn_info": False
    }

    update_labels_status(update_labels_dict)

    gui_logger.debug(">>> Ended tasks in \"openvpn_connect\" thread.")
コード例 #25
0
 def update_protocol_combobox_changed(self, object):
     """Button/Event handler to update OpenVP Protocol  
     """
     autoconnect_setting = get_config_value("USER", "default_protocol")
     tree_iter = object.get_active_iter()
     if tree_iter is not None:
         model = object.get_model()
         index, protocol = model[tree_iter][:2]
         protocol = protocol.lower()
         if protocol.lower() != autoconnect_setting.lower():
             gui_logger.debug(">>> Starting \"update_protocol_combobox_changed\" thread.")
             thread = Thread(target=update_def_protocol, args=[protocol])
             thread.daemon = True
             thread.start()
コード例 #26
0
    def last_connect_button_clicked(self, button):
        """Button/Event handler to reconnect to previously connected server
        """   
        self.messagedialog_sub_label.hide()
        try:
            servername = get_config_value("metadata", "connected_server")
            protocol = get_config_value("metadata", "connected_proto")     
        except:
            self.messagedialog_label.set_markup("You have not previously connected to any server, please do that connect to a server first before attempting to reconnect.")
            self.messagedialog_spinner.hide()
            self.messagedialog_window.show()
            gui_logger.debug("[!] Attempted to connect to previously connected server without having made any previous connections.")
            return

        self.messagedialog_label.set_markup("Connecting to previously connected server <b>{0}</b> with <b>{1}</b>.".format(servername, protocol.upper()))
        self.messagedialog_spinner.show()

        gui_logger.debug(">>> Starting \"last_connect\" thread.")

        thread = Thread(target=last_connect, args=[self.interface, self.messagedialog_label, self.messagedialog_spinner])
        thread.daemon = True
        thread.start()

        self.messagedialog_window.show()
コード例 #27
0
def update_connection_time(dict_data):
    connection_time = False
    
    if dict_data["is_connected"]:
        try:
            connected_time = get_config_value("metadata", "connected_time")
            connection_time = time.time() - int(connected_time)
            connection_time = str(datetime.timedelta(seconds=connection_time)).split(".")[0]
        except KeyError:
            connection_time = False
    
    connection_time = connection_time if connection_time else ""
    dict_data["label"].set_markup('<span>{0}</span>'.format(connection_time))

    return True
コード例 #28
0
    def load_connection_settings(self, object_dict):
        # Set Autoconnect on boot combobox
        autoconnect_liststore = object_dict["autoconnect_liststore"]
        update_autoconnect_combobox = object_dict[
            "update_autoconnect_combobox"]
        update_quick_connect_combobox = object_dict[
            "update_quick_connect_combobox"]
        update_protocol_combobox = object_dict["update_protocol_combobox"]

        server_list = self.populate_autoconnect_list(autoconnect_liststore,
                                                     return_list=True)

        #Get values
        try:
            autoconnect_setting = get_gui_config("conn_tab", "autoconnect")
        except (KeyError, IndexError):
            autoconnect_setting = 0
        try:
            quick_connect_setting = get_gui_config("conn_tab", "quick_connect")
        except (KeyError, IndexError):
            quick_connect = 0
        default_protocol = get_config_value("USER", "default_protocol")

        # Get indexes
        try:
            autoconnect_index = list(
                server_list.keys()).index(autoconnect_setting)
        except ValueError:
            autoconnect_index = 0

        try:
            quick_connect_index = list(
                server_list.keys()).index(quick_connect_setting)
        except ValueError:
            quick_connect_index = 0

        # Set values
        update_autoconnect_combobox.set_active(autoconnect_index)
        update_quick_connect_combobox.set_active(quick_connect_index)

        if default_protocol == "tcp":
            update_protocol_combobox.set_active(0)
        else:
            update_protocol_combobox.set_active(1)
コード例 #29
0
def update_labels_status(update_labels_dict):
    """Function prepares data to update labels.
    """
    gui_logger.debug(">>> Running \"update_labels_status\" getting servers, is_connected and connected_server.")

    if not update_labels_dict["servers"]:
        servers = get_servers()
    else:
        servers = update_labels_dict["servers"]

    protonvpn_conn_check = is_connected()
    is_vpn_connected = True if protonvpn_conn_check else False

    try:
        connected_server = get_config_value("metadata", "connected_server")
    except:
        connected_server = False
        
    update_labels(update_labels_dict["interface"], servers, is_vpn_connected, connected_server, update_labels_dict["disconnecting"], conn_info=update_labels_dict["conn_info"])
コード例 #30
0
def update_split_tunneling_status(update_to):
    if update_to == "1":
        result = "Split tunneling has been <b>enabled</b>!\n"
    else:
        if os.path.isfile(SPLIT_TUNNEL_FILE):
            os.remove(SPLIT_TUNNEL_FILE)
        result = "Split tunneling has been <b>disabled</b>!\n"

    if int(get_config_value("USER", "killswitch")):
        set_config_value("USER", "killswitch", 0)

        result = result + "Split Tunneling <b>can't</b> be used with Kill Switch, Kill Switch has been <b>disabled</b>!\n\n"
        time.sleep(1)

    set_config_value("USER", "split_tunnel", update_to)

    gui_logger.debug(">>> Result: \"{0}\"".format(result))

    gui_logger.debug(">>> Ended tasks in \"set_split_tunnel\" thread.")