Exemple #1
0
def KillVPN(silent=False):
    kill.KillVPN()
    if not silent:
        message = '%s now disabled' % TITLE
        xbmcgui.Window(10000).setProperty('VPNICITY_CONNECTED', 'False')
        utils.notify(message)
        ipcheck.Network()
Exemple #2
0
def Login():
    utils.log('================ VPNicity Login ================')
    with requests.Session() as s:
        try:
            s.get(LOGINURL)
        except: 
            return False
        
        USER     = ADDON.getSetting('USER')
        PASS     = ADDON.getSetting('PASS')
        PAYLOAD  = { 'log' : USER, 'pwd' : PASS, 'wp-submit' : 'Log In' }
        response = 'login_error'
        code     =  0

        if USER and PASS:
            login    = s.post(LOGINURL, data=PAYLOAD)
            response = login.content
            # code     = login.status_code
            # saveCookies(s.cookies, cookiefile)
        
        if 'no-access-redirect' in response:
            error   = '301 - No Access.'
            message = 'It appears that your subscription has expired.'
            utils.log(message + ' : ' + error)
            utils.dialogOK(message, error, 'Please check your account at www.vpnicity.com')

            KillVPN(silent=True)
            
            return False
            
        areLost    = 'Are you lost' in response
        loginError = 'login_error' in response
        okay       =  (not areLost) and (not loginError)
        
        if okay:
            message = 'Logged into VPNicity'
            utils.log(message)
            utils.notify(message)
            return True
            
        try:
            error = re.compile('<div id="login_error">(.+?)<br />').search(response).groups(1)[0]
            error = error.replace('<strong>',  '')
            error = error.replace('</strong>', '')
            error = error.replace('<a href="https://www.vpnicity.com/wp-login.php?action=lostpassword">Lost your password?</a>', '')
            error = error.strip()
            print error
        except:
            error = ''
            
        message = 'There was a problem logging into VPNicity'
        
        utils.log('************ VPNicity Error ************')
        utils.log(message + ' : ' + error)
        utils.log('****************************************')
        utils.dialogOK(message, error, 'Please check your account at www.vpnicity.com')
        
        KillVPN(silent=True)
        
    return False
Exemple #3
0
def KillVPN(silent=False): 
    kill.KillVPN()
    if not silent:
        message = '%s now disabled' % TITLE
        xbmcgui.Window(10000).setProperty('VPNICITY_CONNECTED', 'False')
        utils.notify(message)
        ipcheck.Network()
def Network():
    address = requests.get('https://api.ipify.org').text
    country = xbmcgui.Window(10000).getProperty('VPNICITY_LABEL')
    
    message = 'IP Address: %s  Country: %s' % (address, country)

    utils.notify(message)
    utils.log('VPNicity location is: ' + message)
Exemple #5
0
def VPN(label, abrv, server):
    if not validToRun():
        utils.log('Login Error via Context Menu')
        return False

    authPath = os.path.join(PROFILE, 'temp')
    cfgPath = os.path.join(PROFILE, 'cfg.ovpn')

    KillVPN(silent=True)

    WriteAuthentication(authPath)
    WriteConfiguration(server, cfgPath, authPath)

    busy = utils.showBusy()

    response = OpenVPN(cfgPath)

    if busy:
        busy.close()

    success = True

    if response:
        label = label.rsplit(' (', 1)[0]
        if IsEnabled(response):
            # if utils.platform() == "android":
            #     xbmc.sleep(10000)
            message = '%s %s now enabled' % (label, TITLE)
            utils.notify(message)
            xbmcgui.Window(10000).setProperty('VPNICITY_LABEL', label)
            xbmcgui.Window(10000).setProperty('VPNICITY_ABRV', abrv)
            xbmcgui.Window(10000).setProperty('VPNICITY_SERVER', server)
            xbmcgui.Window(10000).setProperty('VPNICITY_CONNECTED', 'True')
            ipcheck.Network()

        else:
            KillVPN(silent=True)
            if utils.platform() == "android":
                xbmc.sleep(5000)
            message = '%s %s failed to start. Please check your settings.' % (
                label, TITLE)
            utils.notify(message)
            ipcheck.Network()
            success = False

    #DeleteFile(authPath)
    #DeleteFile(cfgPath)
    #DeleteFile(RESPONSE)

    return success
Exemple #6
0
def VPN(label, abrv, server):
    if not validToRun():
        utils.log('Login Error via Context Menu')
        return False

    authPath = os.path.join(PROFILE, 'temp')
    cfgPath  = os.path.join(PROFILE, 'cfg.ovpn')

    KillVPN(silent=True)

    WriteAuthentication(authPath)
    WriteConfiguration(server, cfgPath, authPath)

    busy = utils.showBusy()

    response = OpenVPN(cfgPath)

    if busy:
        busy.close()

    success = True

    if response:
        label = label.rsplit(' (', 1)[0]
        if IsEnabled(response):
            # if utils.platform() == "android":
            #     xbmc.sleep(10000)
            message = '%s %s now enabled' % (label, TITLE)
            utils.notify(message)         
            xbmcgui.Window(10000).setProperty('VPNICITY_LABEL',  label)
            xbmcgui.Window(10000).setProperty('VPNICITY_ABRV',   abrv)
            xbmcgui.Window(10000).setProperty('VPNICITY_SERVER', server)
            xbmcgui.Window(10000).setProperty('VPNICITY_CONNECTED', 'True')
            ipcheck.Network()

        else:
            KillVPN(silent=True)
            if utils.platform() == "android":
                xbmc.sleep(5000)
            message = '%s %s failed to start. Please check your settings.' % (label, TITLE)
            utils.notify(message)
            ipcheck.Network() 
            success = False

    #DeleteFile(authPath)
    #DeleteFile(cfgPath)
    #DeleteFile(RESPONSE)

    return success
def Network():
    url = 'http://www.iplocation.net/'
    request = requests.get(url)
    link = request.content
    match = re.compile(
        "<td width='80'>(.+?)</td><td>(.+?) <img src='.+?'></td><td>(.+?)</td><td>.+?</td><td>(.+?)</td>"
    ).findall(link)
    count = 1

    for ip, country, region, isp in match:
        if count < 2:
            message = 'IP Address: %s  Country: %s  Region: %s' % (ip, country,
                                                                   region)
            utils.notify(message)
            utils.log('VPNicity location is: %s' % match)
            count = count + 1
def KillVPN(silent=False): 
    kill.KillVPN()
    if not silent:
        message = '%s now disabled' % TITLE
        utils.notify(message)
        ipcheck.Network()
Exemple #9
0
def Login():
    utils.log('================ VPNicity Login ================')
    with requests.Session() as s:
        try:
            s.get(LOGINURL)
        except:
            return False

        USER = ADDON.getSetting('USER')
        PASS = ADDON.getSetting('PASS')
        PAYLOAD = {'log': USER, 'pwd': PASS, 'wp-submit': 'Log In'}
        response = 'login_error'
        code = 0

        if USER and PASS:
            login = s.post(LOGINURL, data=PAYLOAD)
            response = login.content
            # code     = login.status_code
            # saveCookies(s.cookies, cookiefile)

        if 'no-access-redirect' in response:
            error = '301 - No Access.'
            message = 'It appears that your subscription has expired.'
            utils.log(message + ' : ' + error)
            utils.dialogOK(message, error,
                           'Please check your account at www.vpnicity.com')

            KillVPN(silent=True)

            return False

        areLost = 'Are you lost' in response
        loginError = 'login_error' in response
        okay = (not areLost) and (not loginError)

        if okay:
            message = 'Logged into VPNicity'
            utils.log(message)
            utils.notify(message)
            return True

        try:
            error = re.compile('<div id="login_error">(.+?)<br />').search(
                response).groups(1)[0]
            error = error.replace('<strong>', '')
            error = error.replace('</strong>', '')
            error = error.replace(
                '<a href="https://www.vpnicity.com/wp-login.php?action=lostpassword">Lost your password?</a>',
                '')
            error = error.strip()
            print error
        except:
            error = ''

        message = 'There was a problem logging into VPNicity'

        utils.log('************ VPNicity Error ************')
        utils.log(message + ' : ' + error)
        utils.log('****************************************')
        utils.dialogOK(message, error,
                       'Please check your account at www.vpnicity.com')

        KillVPN(silent=True)

    return False
Exemple #10
0
def KillVPN(silent=False):
    kill.KillVPN()
    if not silent:
        message = '%s now disabled' % TITLE
        utils.notify(message)
        ipcheck.Network()