コード例 #1
0
ファイル: addon.py プロジェクト: rrosajp/service.vpn.manager
def changeConnection():
    # Connect, or display status if we're already using selected VPN profile
    # If there is no profile, then skip this as the user has selected something non-selectable
    debugTrace("Changing connection to " + params + " from " +
               getVPNProfile() + ", connected:" + str(isVPNConnected()))
    addon = xbmcaddon.Addon(getID())
    ignore = False
    user_text = ""
    vpn_provider = addon.getSetting("vpn_provider")
    if isAlternative(vpn_provider):
        # Convert the friendly name to a file name, or an error message
        _, ovpn_connection, user_text, ignore = getAlternativeLocation(
            vpn_provider, params, 0, True)
    else:
        # Just extract the ovpn name from the URL for regular providers
        ovpn_connection = params
    # Try and connect if we've got a connection name.  If we're already connection, display the status
    if not ignore:
        if not user_text == "":
            xbmcgui.Dialog().ok(addon_name, user_text)
        elif isVPNConnected() and ovpn_connection == getVPNProfile(
        ) and not allowReconnection(vpn_provider) and not addon.getSetting(
                "allow_cycle_reconnect") == "true":
            displayStatus()
        else:
            connectVPN("0", ovpn_connection)
    return
コード例 #2
0
def postConnectNordVPN(vpn_provider):
    # Post connect, might need to update the systemd config
    addon = xbmcaddon.Addon(getID())
    if ((addon.getSetting("1_vpn_validated") == getVPNProfile()) and (addon.getSetting("vpn_connect_before_boot") == "true")):
        if xbmcvfs.exists(getSystemdPath("openvpn.config")) or fakeSystemd():
            copySystemdFiles()
    return    
コード例 #3
0
                # Build a list of all ovpn files using the current active filter
                if not isAlternative(vpn_provider):
                    all_connections = getAddonList(addon.getSetting("vpn_provider_validated"), "*.ovpn")
                    location_connections = getFilteredProfileList(all_connections, addon.getSetting("vpn_protocol"), None)
                    location_connections.sort()
                else:
                    location_connections = getAlternativeLocations(vpn_provider, False)
                    connections = getAlternativeFriendlyLocations(vpn_provider, False)
            else:
                # Build a list of all validated connections
                location_connections = getValidatedList(addon, "")
            # Build the friendly list, displaying any active connection in blue
            if isAlternative(vpn_provider) and addon.getSetting("table_display_type") == "All connections":
                connections = getAlternativeFriendlyProfileList(connections, getVPNProfileFriendly(), "ff00ff00")
            else:
                connections = getFriendlyProfileList(location_connections, getVPNProfile(), "ff00ff00")
            if getVPNState() == "started":
                title = "Connected - " + getVPNProfileFriendly()
                connections.insert(0, disconnect_text)
            else:
                title = "Disconnected"
                connections.insert(0, disconnected_text)
            
            connections.append(cancel_text)

            i = xbmcgui.Dialog().select(title, connections)
            if connections[i] == disconnect_text or connections[i] == disconnected_text:
                setAPICommand("Disconnect")
            elif not connections[i] == cancel_text:
                if getVPNProfile() == location_connections[i-1] and (allowReconnection(vpn_provider) or addon.getSetting("allow_cycle_reconnect") == "true"):
                    setAPICommand("Reconnect")
コード例 #4
0
    # Copy the log file
    elif action == "log":
        log_path = ""
        dest_path = ""
        try:
            log_path = getLogPath()
            start_dir = ""
            dest_folder = xbmcgui.Dialog().browse(
                0, "Select folder to copy log file into", "files", "", False,
                False, start_dir, False)
            dest_path = "kodi " + datetime.datetime.now().strftime(
                "%y-%m-%d %H-%M-%S") + ".log"
            dest_path = dest_folder + dest_path.replace(" ", "_")
            # Write VPN log to log before copying
            writeVPNConfiguration(getVPNProfile())
            writeVPNLog()
            debugTrace("Copying " + log_path + " to " + dest_path)
            addon = xbmcaddon.Addon(getID())
            infoTrace(
                "managefiles.py", "Copying log file to " + dest_path +
                ".  Using version " + addon.getSetting("version_number"))
            xbmcvfs.copy(log_path, dest_path)
            if not xbmcvfs.exists(dest_path):
                raise IOError('Failed to copy log ' + log_path + " to " +
                              dest_path)
            dialog_message = "Copied log file to: " + dest_path
        except:
            errorTrace(
                "managefiles.py",
                "Failed to copy log from " + log_path + " to " + dest_path)