def displayStatus(): _, ip, country, isp = getIPInfo(addon) if isVPNConnected(): debugTrace("VPN is connected, displaying the connection info") if fakeConnection(): xbmcgui.Dialog().ok( addon_name, "Faked connection to a VPN in " + country + "\nUsing profile " + getVPNProfileFriendly() + "\nExternal IP address is " + ip + "\nService Provider is " + isp) else: server = getVPNServer() if not server == "": server = ", " + server + "\n" else: server = "\n" xbmcgui.Dialog().ok( addon_name, "Connected to a VPN in " + country + "\nUsing profile " + getVPNProfileFriendly() + server + "External IP address is " + ip + "\nService Provider is " + isp) else: debugTrace("VPN is not connected, displaying the connection info") xbmcgui.Dialog().ok( addon_name, "Disconnected from VPN.\nNetwork location is " + country + ".\nIP address is " + ip + ".\nService Provider is " + isp) return
def listConnections(): # Start with the disconnect option url = base_url + "?disconnect" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("[COLOR ffff0000](Disconnected)[/COLOR]") li.setArt({"icon":getIconPath()+"disconnected.png"}) else: li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]") li.setArt({"icon":getIconPath()+"unlocked.png"}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) # We should have a VPN set up by now, but don't list if we haven't. vpn_provider = addon.getSetting("vpn_provider") debugTrace("Listing the connections available for " + vpn_provider) if not vpn_provider == "": # Get the list of connections and add them to the directory if not isAlternative(vpn_provider): all_connections = getAddonList(vpn_provider, "*.ovpn") ovpn_connections = getFilteredProfileList(all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(ovpn_connections, "", "") else: ovpn_connections = getAlternativeLocations(vpn_provider, False) connections = getAlternativeFriendlyLocations(vpn_provider, False) inc = 0 for connection in ovpn_connections: if not isAlternative(vpn_provider): # Regular connections have the ovpn filename added ot the URL url = base_url + "?change?" + ovpn_connections[inc] else: # Alternative connections use the friendly name which can then be resolved later url = base_url + "?change?" + connections[inc] conn_text = "" conn_primary = "" i=1 # Adjust 10 and 11 below if changing number of conn_max while (i < 11): if addon.getSetting(str(i) + "_vpn_validated_friendly") == connections[inc].strip(" ") : conn_primary = " (" + str(i) + ")" i = 10 i=i+1 if getVPNProfileFriendly() == connections[inc].strip(" ") and isVPNConnected(): conn_text = "[COLOR ff00ff00]" + connections[inc] + conn_primary + " (Connected)[/COLOR]" if fakeConnection(): icon = getIconPath()+"faked.png" else: icon = getIconPath()+"connected.png" else: if not conn_primary == "": conn_text = "[COLOR ff0099ff]" + connections[inc] + conn_primary + "[/COLOR]" else: conn_text = connections[inc] + conn_primary icon = getIconPath()+"locked.png" li = xbmcgui.ListItem(conn_text) li.setArt({"icon":icon}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
def listConnections(): # Start with the disconnect option url = base_url + "?disconnect" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("[COLOR ffff0000](Disconnected)[/COLOR]", iconImage=getIconPath() + "disconnected.png") else: li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]", iconImage=getIconPath() + "unlocked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) # We should have a VPN set up by now, but don't list if we haven't. vpn_provider = addon.getSetting("vpn_provider") debugTrace("Listing the connections available for " + vpn_provider) if vpn_provider != "": # Get the list of connections and add them to the directory all_connections = getAddonList(vpn_provider, "*.ovpn") ovpn_connections = getFilteredProfileList( all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(ovpn_connections, "", "") inc = 0 for connection in ovpn_connections: url = base_url + "?change?" + ovpn_connections[inc] conn_text = "" conn_primary = "" i = 1 # Adjust 10 and 11 below if changing number of conn_max while (i < 11): if addon.getSetting( str(i) + "_vpn_validated_friendly") == connections[inc]: conn_primary = " (" + str(i) + ")" i = 10 i = i + 1 if getVPNProfileFriendly() == connections[inc] and isVPNConnected( ): conn_text = "[COLOR ff00ff00]" + connections[ inc] + conn_primary + " (Connected)[/COLOR]" if fakeConnection(): icon = getIconPath() + "faked.png" else: icon = getIconPath() + "connected.png" else: if not conn_primary == "": conn_text = "[COLOR ff0099ff]" + connections[ inc] + conn_primary + "[/COLOR]" else: conn_text = connections[inc] + conn_primary icon = getIconPath() + "locked.png" li = xbmcgui.ListItem(conn_text, iconImage=icon) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
def listConnections(): # We should have a VPN set up by now, but don't list if we haven't. vpn_provider = addon.getSetting("vpn_provider") debugTrace("Listing the connections available for " + vpn_provider) if vpn_provider != "": # Get the list of connections and add them to the directory all_connections = getProfileList(vpn_provider) ovpn_connections = getFilteredProfileList( all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(vpn_provider, ovpn_connections) inc = 0 for connection in ovpn_connections: url = base_url + "?change?" + ovpn_connections[inc] conn_text = "" conn_primary = "" if getVPNProfileFriendly() == connections[inc] and isVPNConnected( ): conn_text = "[COLOR ff00ff00]" + connections[ inc] + conn_primary + " (Connected)[/COLOR]" icon = getIconPath() + "connected.png" else: conn_text = connections[inc] + conn_primary icon = getIconPath() + "locked.png" li = xbmcgui.ListItem(conn_text, iconImage=icon) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
def displayStatus(): # Create a busy dialog whilst the data is retrieved. It # could take a while to deduce that the network is bad... xbmc.executebuiltin('ActivateWindow(busydialognocancel)') try: _, ip, country, isp = getIPInfo(addon) if isVPNConnected(): debugTrace("VPN is connected, displaying the connection info") xbmc.executebuiltin('Dialog.Close(busydialognocancel)') # Display the server if enhanced system info is switched on server = "" if addon.getSetting("vpn_server_info") == "true": server = getVPNURL() if not server == "": server = "\nServer is " + server + "\n" else: server = "\n" ovpn_name = getVPNProfileFriendly() if fakeConnection(): xbmcgui.Dialog().ok(addon_name, "[B]Faked connection to a VPN[/B]\nProfile is " + ovpn_name + server + "Using " + ip + ", located in " + country + "\nService Provider is " + isp) else: xbmcgui.Dialog().ok(addon_name, "[B]Connected to a VPN[/B]\nProfile is " + ovpn_name + server + "Using " + ip + ", located in " + country + "\nService Provider is " + isp) else: debugTrace("VPN is not connected, displaying the connection info") xbmc.executebuiltin('Dialog.Close(busydialognocancel)') xbmcgui.Dialog().ok(addon_name, "[B]Disconnected from VPN[/B]\nUsing " + ip + ", located in " + country +"+\nService Provider is " + isp) except Exception: xbmc.executebuiltin('Dialog.Close(busydialognocancel)') return
def listConnections(): # Start with the disconnect option url = base_url + "?disconnect" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("[COLOR ffff0000](Disconnected)[/COLOR]", iconImage=getIconPath()+"disconnected.png") else: li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]", iconImage=getIconPath()+"unlocked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) # We should have a VPN set up by now, but don't list if we haven't. vpn_provider = addon.getSetting("vpn_provider") debugTrace("Listing the connections available for " + vpn_provider) if vpn_provider != "": # Get the list of connections and add them to the directory all_connections = getAddonList(vpn_provider, "*.ovpn") ovpn_connections = getFilteredProfileList(all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(ovpn_connections) inc = 0 for connection in ovpn_connections: url = base_url + "?change?" + ovpn_connections[inc] conn_text = "" conn_primary = "" i=1 # Adjust 10 and 11 below if changing number of conn_max while (i < 11): if addon.getSetting(str(i) + "_vpn_validated_friendly") == connections[inc] : conn_primary = " (" + str(i) + ")" i = 10 i=i+1 if getVPNProfileFriendly() == connections[inc] and isVPNConnected(): conn_text = "[COLOR ff00ff00]" + connections[inc] + conn_primary + " (Connected)[/COLOR]" icon = getIconPath()+"connected.png" else: if not conn_primary == "": conn_text = "[COLOR ff0099ff]" + connections[inc] + conn_primary + "[/COLOR]" else: conn_text = connections[inc] + conn_primary icon = getIconPath()+"locked.png" li = xbmcgui.ListItem(conn_text, iconImage=icon) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
def displayStatus(): xbmc.executebuiltin("ActivateWindow(busydialog)") _, ip, country, isp = getIPInfo(addon) if isVPNConnected(): debugTrace("VPN is connected, displaying the connection info") xbmcgui.Dialog().ok( addon_name, "Connected to PureVPN in " + country + ".\nUsing profile " + getVPNProfileFriendly() + ".\nIP address is " + ip + ".") else: debugTrace("VPN is not connected, displaying the connection info") xbmcgui.Dialog().ok( addon_name, "Not connected to PureVPN.\nNetwork location is " + country + ".\nIP address is " + ip + ".") xbmc.executebuiltin("Dialog.Close(busydialog)") return
def listSystem(): lines = [] site, ip, country, isp = getIPInfo(addon) lines.append("[B][COLOR ff0099ff]Connection[/COLOR][/B]") if isVPNConnected(): lines.append("Connected using profile " + getVPNProfileFriendly()) lines.append("VPN provider is " + addon.getSetting("vpn_provider")) else: lines.append("Not connected to a VPN") lines.append("Connection location is " + country) lines.append("External IP address is " + ip) lines.append("Service Provider is " + isp) lines.append("Location sourced from " + site) lines.append("[B][COLOR ff0099ff]Network[/COLOR][/B]") lines.append("IP address is " + xbmc.getInfoLabel("Network.IPAddress")) lines.append("Gateway is " + xbmc.getInfoLabel("Network.GatewayAddress")) lines.append("Subnet mask is " + xbmc.getInfoLabel("Network.SubnetMask")) lines.append("Primary DNS is " + xbmc.getInfoLabel("Network.DNS1Address")) lines.append("Secondary DNS is " + xbmc.getInfoLabel("Network.DNS2Address")) lines.append("[B][COLOR ff0099ff]PureVPN monitor[/COLOR][/B]") lines.append("PureVPN monitor verison is " + addon.getAddonInfo("version")) lines.append("PureVPN monitor behaviour is " + getPlatformString()) if isVPNMonitorRunning(): lines.append("PureVPN monitor add-on split tunneling is playing") else: lines.append("PureVPN monitor add-on split tunneling is stopped") lines.append("[B][COLOR ff0099ff]System[/COLOR][/B]") lines.append("Kodi build version is " + xbmc.getInfoLabel("System.BuildVersion")) lines.append("System name is " + xbmc.getInfoLabel("System.FriendlyName")) lines.append("System date is " + xbmc.getInfoLabel("System.Date")) lines.append("System time is " + xbmc.getInfoLabel("System.Time")) lines.append("Platform is " + sys.platform) lines.append("Free memory is " + xbmc.getInfoLabel("System.FreeMemory")) lines.append("Disk is " + xbmc.getInfoLabel("System.TotalSpace") + ", " + xbmc.getInfoLabel("System.UsedSpace")) for line in lines: url = base_url + "?back" li = xbmcgui.ListItem(line, iconImage=getIconPath() + "enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) return
def listSystem(): lines = [] site, ip, country, isp = getIPInfo(addon) lines.append("[B][COLOR ff0099ff]Connection[/COLOR][/B]") if isVPNConnected(): lines.append("Connected using profile " + getVPNProfileFriendly()) lines.append("VPN provider is " + addon.getSetting("vpn_provider")) else: lines.append("Not connected to a VPN") lines.append("Connection location is " + country) lines.append("External IP address is " + ip) lines.append("Service Provider is " + isp) lines.append("Location sourced from " + site) lines.append("[B][COLOR ff0099ff]Network[/COLOR][/B]") lines.append("IP address is " + xbmc.getInfoLabel("Network.IPAddress")) lines.append("Gateway is " + xbmc.getInfoLabel("Network.GatewayAddress")) lines.append("Subnet mask is " + xbmc.getInfoLabel("Network.SubnetMask")) lines.append("Primary DNS is " + xbmc.getInfoLabel("Network.DNS1Address")) lines.append("Secondary DNS is " + xbmc.getInfoLabel("Network.DNS2Address")) lines.append("[B][COLOR ff0099ff]VPN Manager[/COLOR][/B]") lines.append("VPN Manager verison is " + addon.getAddonInfo("version")) lines.append("VPN Manager behaviour is " + getPlatformString()) if isVPNMonitorRunning(): lines.append("VPN Manager add-on filtering is running") else: lines.append("VPN Manager add-on filtering is paused") lines.append("[B][COLOR ff0099ff]System[/COLOR][/B]") lines.append("Kodi build version is " + xbmc.getInfoLabel("System.BuildVersion")) lines.append("System name is " + xbmc.getInfoLabel("System.FriendlyName")) lines.append("System date is " + xbmc.getInfoLabel("System.Date")) lines.append("System time is " + xbmc.getInfoLabel("System.Time")) lines.append("Platform is " + sys.platform) lines.append("Free memory is " + xbmc.getInfoLabel("System.FreeMemory")) lines.append("Disk is " + xbmc.getInfoLabel("System.TotalSpace") + ", " + xbmc.getInfoLabel("System.UsedSpace")) for line in lines: url = base_url + "?back" li = xbmcgui.ListItem(line, iconImage=getIconPath()+"enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) return
def displayStatus(): _, ip, country, isp = getIPInfo(addon) if isVPNConnected(): debugTrace("VPN is connected, displaying the connection info") xbmcgui.Dialog().ok(addon_name, "Connected to a VPN in " + country + ".\nUsing profile " + getVPNProfileFriendly() + ".\nExternal IP address is " + ip + ".\nService Provider is " + isp) else: debugTrace("VPN is not connected, displaying the connection info") xbmcgui.Dialog().ok(addon_name, "Disconnected from VPN.\nNetwork location is " + country + ".\nIP address is " + ip + ".\nService Provider is " + isp) return
timer = connection_retry_time + 1 # This just checks the connection is still good every hour, providing the player is not busy if vpn_setup and reconnect_on_drop == "true" and timer > connection_retry_time and not player.isPlaying( ): debugTrace("Reconnect timer triggered, checking connection") if not isVPNConnected() and not (getVPNState() == "off"): # Don't know why we're disconnected, but reconnect to the last known VPN errorTrace( "service.py", "VPN monitor service detected VPN connection " + getVPNProfile() + " is not running when it should be") writeVPNLog() if getVPNRequestedProfile() == "": setVPNRequestedProfile(getVPNProfile()) setVPNRequestedProfileFriendly(getVPNProfileFriendly()) setVPNProfile("") setVPNProfileFriendly("") reconnect_vpn = True timer = 0 # Fetch the path and name of the current addon current_path = xbmc.getInfoLabel('Container.FolderPath') current_name = xbmc.getInfoLabel('Container.FolderName') # See if it's a different add-on the last time we checked. If we don't know the # current_name (like when the player is playing within an addon), then skip making a change. #print "Current path = " + current_path #print "Current name = " + current_name if vpn_setup and not (xbmcgui.Window(10000).getProperty(last_addon) == current_name) and not current_name == "": if isVPNMonitorRunning():
clearVPNCycle() if addon.getSetting("table_display_type") == "All connections": # 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 playing and not player.isPlaying(): playing = False timer = connection_retry_time + 1 # This just checks the connection is still good every hour, providing the player is not busy if vpn_setup and not player.isPlaying() and timer > connection_retry_time: addon = xbmcaddon.Addon() if addon.getSetting("vpn_reconnect") == "true": debugTrace("Reconnect timer triggered, checking connection") if not isVPNConnected() and not (getVPNState() == "off"): # Don't know why we're disconnected, but reconnect to the last known VPN errorTrace("service.py", "VPN monitor service detected VPN connection " + getVPNProfile() + " is not running when it should be") writeVPNLog() if getVPNRequestedProfile() == "": setVPNRequestedProfile(getVPNProfile()) setVPNRequestedProfileFriendly(getVPNProfileFriendly()) setVPNProfile("") setVPNProfileFriendly("") reconnect_vpn = True timer = 0 # Check to see if it's time for a reboot (providing we need to, and nothing is playing) if (not player.isPlaying()) and reboot_timer >= seconds_to_reboot_check: addon = xbmcaddon.Addon() reboot_timer = 0 # Assume the next check is in an hour seconds_to_reboot_check = 3600 # Check reboot check file if there is one reboot_file_name = addon.getSetting("reboot_file") if xbmcvfs.exists(reboot_file_name): stats = xbmcvfs.Stat(reboot_file_name)
def topLevel(): xbmc.executebuiltin("ActivateWindow(busydialog)") # Build the top level menu with URL callbacks to this plugin addon = xbmcaddon.Addon("service.purevpn.monitor") vpn_provider = addon.getSetting("vpn_provider") debugTrace("Displaying the top level menu") try: url = base_url + "?disconnect" if getVPNProfileFriendly() != "": li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]", iconImage=getIconPath() + "unlocked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) except: pass url = base_url + "?display" li = xbmcgui.ListItem("Display VPN status", iconImage=getIconPath() + "display.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?list" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("Connect to Country", iconImage=getIconPath() + "locked.png") else: li = xbmcgui.ListItem("Change Country", iconImage=getIconPath() + "locked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?switch" if isVPNMonitorRunning(): li = xbmcgui.ListItem("Stop Split tunneling", iconImage=getIconPath() + "paused.png") else: li = xbmcgui.ListItem("Play Split tunneling", iconImage=getIconPath() + "play.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?settings" li = xbmcgui.ListItem("Add-on Settings", iconImage=getIconPath() + "settings.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) if createUpdateChecker(): addonname = 'PureVPN' response = "PureVPN's Kodi Add-on has a new update. Please download the update from www.purevpn.com/kodi-addon" xbmcgui.Dialog().ok(addonname, response) if addon.getSetting("vpn_system_menu_item") == "true": url = base_url + "?system" li = xbmcgui.ListItem("Display enhanced information", iconImage=getIconPath() + "enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(addon_handle) updateService() createUnPass() xbmc.executebuiltin("Dialog.Close(busydialog)") return
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) else: # Build a list of all validated connections location_connections = getValidatedList(addon, "") # Build the friendly list, displaying any active connection in blue 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"):