Ejemplo n.º 1
0
def checkLatestFailover():
    # Checking for latest failover LOCATIONS.txt file
    rawLoc = str(getAddonPath(True, vpn_provider + "/rawLocations.txt"))
    Locations = str(getAddonPath(True, vpn_provider + "/LOCATIONS.txt"))
    url = 'https://s3.amazonaws.com/purevpn-dialer-assets/kodi/app/LOCATION.json'

    resp = urllib2.urlopen(url, timeout=3)
    data = json.load(resp)
    data1 = data.values()
    with open(rawLoc, 'w') as file:
        if type(data1) == list:
            file.write(str(data1) + "\n")

    if os.path.exists(Locations):
        os.remove(Locations)

    delete_list = ["[[u'", " u'", "'", ", [u", "[", "crt]", "]"]

    fin = open(rawLoc)
    fout = open(Locations, "w+")
    fout.seek(0)
    for line in fin:
        for word in delete_list:
            if word == "crt]":
                line = line.replace(word, "crt\n")
            line = line.replace(word, "")

        fout.write(line[:-1])
    fin.close()
    fout.close()
    os.remove(rawLoc)
Ejemplo n.º 2
0
def updatePureResolver():
    resolverPath = str(getAddonPath(True, vpn_provider + "/dnsLeak.py"))
    dirPath = str(getAddonPath(True, vpn_provider))
    with open(resolverPath, 'r') as f_old:
        read = f_old.readlines()
    with open(resolverPath, 'w') as f_new:
        for line in read:
            if 'purevpnPath=' in line:
                f_new.write('purevpnPath=' + '"' + dirPath + '"\n')
            else:
                f_new.write(line)

    f_old.close()
    f_new.close()
Ejemplo n.º 3
0
def checkLatestCountries():
    #url = 'https://api.atom.purevpn.com/inventory/v1/getCountries/1?iResellerId=1'
    url = "https://atomapi.com/inventory/v1/getCountries/1"
    req = urllib2.Request(
        url,
        headers={
            'User-Agent':
            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30",
            "Content-Type": "application/x-www-form-urlencoded",
            "X-Psk": "utNJGncZCcbFVf3Okvr4"
        })
    try:
        resp = urllib2.urlopen(req, timeout=4)
        html = resp.read()
        data = json.loads(html)
        return_list = {}
        if 'body' in data:
            print 'yes'
            #with open ('hello.json', 'w') as countries_list:
            if 'countries' in data['body']:
                data_body_countries = data['body']['countries']
                for item in data_body_countries:

                    return_list[item['id']] = item['name']

        fname = str(getAddonPath(True, vpn_provider + "/countriesList.json"))
        with open(fname, 'w') as fp:
            json.dump(return_list, fp, indent=4)

    except Exception as e:
        print e
Ejemplo n.º 4
0
            addon.getSetting(str(i) + "_vpn_validated_friendly"))
    return


#addon = xbmcaddon.Addon("service.purevpn.monitor")
#vpn_provider = addon.getSetting("vpn_provider")

if __name__ == '__main__':

    # Initialise some variables we'll be using repeatedly
    monitor = xbmc.Monitor()
    player = xbmc.Player()
    #command = 'chmod +x ' + str(getAddonPath(True, vpn_provider + "/dnsLeak.py"))

    # See if this is a new install...we might want to do things here
    if xbmcvfs.exists(getAddonPath(True, "INSTALL.txt")):
        xbmcvfs.delete(getAddonPath(True, "INSTALL.txt"))
        # This is just wiping out the old way of using pre-generated ovpn files before
        # moving to the brave new world of generating them when they're needed
        if addon.getSetting("version_number") == "":
            infoTrace(
                "service.py", "Resetting the world for 0.1.0, found " +
                addon.getSetting("version_number"))
            cleanPassFiles()
            removeGeneratedFiles()
            resetVPNConfig(addon, 1)
            xbmcgui.Dialog().ok(
                addon_name,
                "This particular update to PureVPN for Kodi requires that all VPN connections are re-validated before use.  Sorry about that, won't happen again..."
            )
            defCred()
Ejemplo n.º 5
0

# Given hh:mm, return the number of seconds into a day this represents
def getSeconds(hour_min):
    return int(hour_min[0:2])*3600 + int(hour_min[3:5])*60
    

if __name__ == '__main__':   

    # Initialise some variables we'll be using repeatedly
    monitor = xbmc.Monitor()
    player = xbmc.Player() 
    addon = xbmcaddon.Addon()
    
    # See if this is a new install...we might want to do things here
    if xbmcvfs.exists(getAddonPath(True, "INSTALL.txt")):
        xbmcvfs.delete(getAddonPath(True, "INSTALL.txt"))
        # This is just wiping out the old way of using pre-generated ovpn files before
        # moving to the brave new world of generating them when they're needed
        if addon.getSetting("version_number") == "":
            infoTrace("service.py", "Resetting the world for 0.1.0, found " + addon.getSetting("version_number"))
            cleanPassFiles()
            removeGeneratedFiles()
            resetVPNConfig(addon, 1)
            xbmcgui.Dialog().ok(addon_name, "This particular update to VPN Manager for OpenVPN requires that all VPN connections are re-validated before use.  Sorry about that, won't happen again...") 
            xbmc.executebuiltin("Addon.OpenSettings(service.vpn.manager)")
        # PIA changed in 1.5.0 to offer different options.  If PIA is using the old connections, force a reconnection
        if addon.getSetting("vpn_provider_validated") == "Private Internet Access" and addon.getSetting("vpn_locations_list") == "":
            addon.setSetting("1_vpn_validated", "reset")
            
    addon.setSetting("version_number", addon.getAddonInfo("version"))
Ejemplo n.º 6
0
def createUpdateChecker():
    global flag
    fname = str(getAddonPath(True, vpn_provider + "/updatechecker.txt"))
    if os.path.isfile(fname):
        with open(fname, 'r+') as file:
            i = file.read()
            if i != timestr:
                try:
                    removeGeneratedFiles()
                    debugTrace("Removed")
                except Exception as e:
                    print str(e) + ' on removing old ovpn files'

                try:
                    updatePureResolver()
                    debugTrace("Resolver Updated")
                except Exception as e:
                    print str(e) + ' on updating resolver'

                try:
                    checkLatestFailover()
                    debugTrace("Failover Checked")
                except Exception as e:
                    print str(e) + ' on checking failover'

                try:
                    checkLatestCountries()
                    debugTrace("Countries List Updated")
                except Exception as e:
                    print str(e) + ' on updating counties list'

                try:
                    checkLatestVersion()
                    debugTrace("Latest Addon version checked")
                except Exception as e:
                    print str(e) + ' on checking latest version'

                file.seek(0)
                file.truncate()
                file.write(timestr)

                debugTrace('file overwritten')

            else:
                debugTrace('No need to check now')

                file.close()

    else:
        try:
            removeGeneratedFiles()
            debugTrace("Removed")
        except Exception as e:
            print str(e) + ' on removing old ovpn files'

        try:
            updatePureResolver()
            debugTrace("Resolver Updated")
        except Exception as e:
            print str(e) + ' on updating resolver'

        try:
            checkLatestFailover()
            debugTrace("Failover Checked")
        except Exception as e:
            print str(e) + ' on checking failover'

        try:
            checkLatestCountries()
            debugTrace("Countries List Updated")
        except Exception as e:
            print str(e) + ' on updating counties list'

        try:
            checkLatestVersion()
            debugTrace("Latest Addon version checked")
        except Exception as e:
            print str(e) + ' on checking latest version'

        with open(fname, 'w') as file:
            file.write(timestr)
            file.close()

        debugTrace('file created and written')

    if flag == 1:
        debugTrace('yes')

        return True
    else:
        debugTrace('no')

        return False