def install(silent=False): if utils.ADDON.getSetting('OS') == 'Windows': return if utils.ADDON.getSetting('OS') == 'MacOS': installMacOS() return cmdLine = utils.getSudo() cmdLine +='apt-get update;' cmdLine +='sudo apt-get -y install openvpn;' cmdLine +='sudo apt-get -y install psmisc' dp = None if not silent: dp = utils.progress('Installing VPN application', 'Please be patient this may take a few minutes') p = subprocess.Popen(cmdLine, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() if silent: return import xbmc xbmc.sleep(100) dp.close() success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def installMacOS(): import download import extract import stat url = 'http://www.on-tapp.tv/wp-content/vpn/openvpn-macos-2.3.4.zip' bindir = xbmc.translatePath( 'special://profile/addon_data/plugin.program.vpnicity/macos/sbin/') dest = os.path.join(bindir, 'openvpn-macos.zip') macbin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(macbin) os.chmod(macbin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
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
def installMacOS(): import download import extract import stat url = 'http://www.on-tapp.tv/wp-content/vpn/openvpn-macos-2.3.4.zip' bindir = xbmc.translatePath('special://profile/addon_data/plugin.program.vpnicity/macos/sbin/') dest = os.path.join(bindir, 'openvpn-macos.zip') macbin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(macbin) os.chmod(macbin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def CheckUsername(): user = ADDON.getSetting('USER') pwd = ADDON.getSetting('PASS') if user != '' and pwd != '': return True utils.dialogOK('Please enter your username and password') ShowSettings() return False
def CheckUsername(): user = ADDON.getSetting('USER') + '@vpnicity' pwd = ADDON.getSetting('PASS') if user != '' and pwd != '': return True utils.dialogOK('Please enter your username and password') ShowSettings() return False
def Network(): url = 'http://www.iplocation.net/' request = requests.get(url) link = request.content match = re.compile("<td width='80'>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>.+?</td><td>(.+?)</td>").findall(link) count = 1 for ip, region, country, isp in match: if count <2: utils.dialogOK('Your Public IP Address is: ' + ip, 'Your IP Address is based in: ' + country) count = count+1
def CheckVersion(): prev = ADDON.getSetting('VERSION') curr = VERSION if prev == curr: return ADDON.setSetting('VERSION', curr) if prev == '0.0.0': utils.dialogOK('Welcome to VPNicity')
def CheckVersion(): prev = ADDON.getSetting('VERSION') curr = VERSION if prev == curr: return ADDON.setSetting('VERSION', curr) if prev == '0.0.0': utils.dialogOK('Welcome to %s' % TITLE, 'Added IP Country/City Checker')
def VPN(label, abrv, server): 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) utils.dialogOK('%s %s now enabled' % (label, TITLE)) xbmcgui.Window(10000).setProperty('VPNICITY_LABEL', label) xbmcgui.Window(10000).setProperty('VPNICITY_ABRV', abrv) xbmcgui.Window(10000).setProperty('VPNICITY_SERVER', server) ipcheck.Network() else: KillVPN(silent=True) if utils.platform() == "android": xbmc.sleep(5000) utils.dialogOK('%s %s failed to start' % (label, TITLE), 'Please check your settings', 'and try again') ipcheck.Network() success = False #DeleteFile(authPath) #DeleteFile(cfgPath) #DeleteFile(RESPONSE) return success
def VPN(label, abrv, server): 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) utils.dialogOK('%s %s now enabled' % (label, TITLE)) xbmcgui.Window(10000).setProperty('VPNICITY_LABEL', label) xbmcgui.Window(10000).setProperty('VPNICITY_ABRV', abrv) xbmcgui.Window(10000).setProperty('VPNICITY_SERVER', server) ipcheck.Network() else: KillVPN(silent=True) if utils.platform() == "android": xbmc.sleep(5000) utils.dialogOK('%s %s failed to start' % (label, TITLE), 'Please check your settings', 'and try again') ipcheck.Network() success = False #DeleteFile(authPath) #DeleteFile(cfgPath) #DeleteFile(RESPONSE) return success
def install(silent=False): if utils.ADDON.getSetting('OS') == 'Windows': return if utils.ADDON.getSetting('OS') == 'MacOS': installMacOS() return cmdLine = utils.getSudo() cmdLine += 'apt-get update;' cmdLine += 'sudo apt-get -y install openvpn;' cmdLine += 'sudo apt-get -y install psmisc' dp = None if not silent: dp = utils.progress('Installing VPN application', 'Please be patient this may take a few minutes') p = subprocess.Popen(cmdLine, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() if silent: return import xbmc xbmc.sleep(100) dp.close() success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def VPN(label, abrv, server): authPath = os.path.join(PROFILE, 'temp') cfgPath = os.path.join(PROFILE, 'cfg.opvn') KillVPN(silent=True) WriteAuthentication(authPath) WriteConfiguration(server, cfgPath, authPath) busy = utils.showBusy() response = OpenVPN(cfgPath) if busy: busy.close() if response: label = label.rsplit(' (', 1)[0] if IsEnabled(response): utils.dialogOK('%s %s now enabled' % (label, utils.TITLE)) xbmcgui.Window(10000).setProperty('VPNICITY_RUNNING', 'True') else: KillVPN() utils.dialogOK('%s %s failed to start' % (label, utils.TITLE), 'Please check your settings', 'and try again')
def SetupAccount(): utils.checkOS() os = utils.GetSetting('OS') if os == 'MacOS': utils.dialogOK('It appears you are running on Mac OS.', '', 'You may need administrator access to run VPNicity.') sudo = utils.dialogKB('', "Enter the 'User Account' password for your computer.") ADDON.setSetting('SUDO', 'true') ADDON.setSetting('SUDOPASS', sudo) utils.dialogOK('We will now finish your installation.', 'Please double check your settings after we are done.', 'Thank you!') xbmc.executebuiltin('XBMC.RunScript(special://home/addons/plugin.program.vpnicity/install.py)') if os == 'OpenELEC': utils.dialogOK('It appears you are running on OpenELEC.', 'We will now finish your installation.', 'Please double check your settings after we are done.') xbmc.executebuiltin('XBMC.RunScript(/storage/.kodi/addons/plugin.program.vpnicity/install.py)') else: return
def installOpenELEC(): import download import extract import stat url = utils.getOEUrl() if not url: utils.dialogOK('You do not appear to be running OpenELEC', 'Please check your settings') return bindir = xbmc.translatePath('special://profile/addon_data/plugin.program.vpnicity/bin/') dest = os.path.join(bindir, 'openvpn-oe.zip') oebin = os.path.join(bindir, 'openvpn') try: os.makedirs(bindir) except: pass download.download(url, dest) extract.all(dest, bindir) st = os.stat(oebin) os.chmod(oebin, st.st_mode | stat.S_IEXEC) try: os.remove(dest) except: pass success = path.getPath(utils.ADDON.getSetting('OS'), silent=True) if success: utils.dialogOK('VPN application successfully installed') else: utils.dialogOK('VPN application installation failed', 'Please try again later')
def KillVPN(silent=False): kill.KillVPN() if not silent: utils.dialogOK('%s now disabled' % TITLE)
def KillVPN(silent=False): kill.KillVPN() if not silent: utils.dialogOK('%s now disabled' % TITLE) ipcheck.Network()