Пример #1
0
def KillVPN():
    xbmcgui.Window(10000).clearProperty('VPNICITY_LABEL')
    xbmcgui.Window(10000).clearProperty('VPNICITY_ABRV')
    xbmcgui.Window(10000).clearProperty('VPNICITY_SERVER')

    if os.name == 'nt':
        try:
            si = subprocess.STARTUPINFO
            si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
            si.wShowWindow = subprocess._subprocess.SW_HIDE

            ps = subprocess.Popen('TASKKILL /F /IM openvpn.exe',
                                  shell=True,
                                  stdout=subprocess.PIPE,
                                  startupinfo=None)
            ps.wait()
        except:
            pass
        return

    # Android
    if utils.platform() == "android":
        xbmc.executebuiltin("StartAndroidActivity(%s,%s)" %
                            ("com.vpnicity.openvpn.control",
                             "com.vpnicity.openvpn.control.DISCONNECT"))
        return

    #LINUX
    try:
        cmd = utils.getSudo() + 'killall -9 openvpn'

        ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
        ps.wait()
    except:
        pass
Пример #2
0
def KillVPN(): 
    print '************  in netkill.py kill vpn  ************'
    
    xbmcgui.Window(10000).clearProperty('VPNICITY_LABEL')
    xbmcgui.Window(10000).clearProperty('VPNICITY_ABRV')
    xbmcgui.Window(10000).clearProperty('VPNICITY_SERVER')
    xbmcgui.Window(10000).clearProperty('VPNICITY_CONNECTED')

    if os.name == 'nt':
        try:
            si = subprocess.STARTUPINFO
            si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
            si.wShowWindow = subprocess._subprocess.SW_HIDE

            ps  = subprocess.Popen('TASKKILL /F /IM openvpn.exe', shell=True, stdout=subprocess.PIPE, startupinfo=None)
            ps.wait()
        except:
            pass
        return

    # Android
    if utils.platform() == "android" :
        print '************  in netkill.py kill android vpn  ************'
        xbmc.executebuiltin( "StartAndroidActivity(%s,%s)" % ( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.DISCONNECT") )
        return

    #LINUX
    try:
        cmd = utils.getSudo() + 'killall -9 openvpn'

        print '************  in netkill.py cmd  ************'
        ps  = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
        ps.wait()
    except:
        pass
Пример #3
0
def install(silent=False):
    if utils.ADDON.getSetting('OS') == 'Windows':
        return

    if utils.ADDON.getSetting('OS') == 'MacOS':
        installMacOS()
        return

    if 'OpenELEC' in utils.ADDON.getSetting('OS'):
        installOpenELEC()
        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')
Пример #4
0
def OpenVPN(config):
    import path
    exe = path.getPath(ADDON.getSetting('OS'))

    if not exe:
        return None

    try:    timeout  = int(ADDON.getSetting('TIMEOUT'))
    except: timeout  = 99999

    if utils.platform() == "android":
        cmdline = "StartAndroidActivity(%s,%s,%s,%s)" % \
                    ( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.CONNECT", "com.vpnicity.openvpn.control.PROFILE_PATH", "file://" + config )
    else :
        cmdline  =  utils.getSudo()
        cmdline += '"' + exe + '"'
        cmdline += ' '
        cmdline += '"' + config + '"'
        cmdline  = cmdline.replace('\\', '/')

    return Run(cmdline, timeout)
Пример #5
0
def OpenVPN(config):
    import path
    exe = path.getPath(ADDON.getSetting('OS'))

    if not exe:
        return None

    try:
        timeout = int(ADDON.getSetting('TIMEOUT'))
    except:
        timeout = 99999

    if utils.platform() == "android":
        cmdline = "StartAndroidActivity(%s,%s,%s,%s)" % \
                    ( "com.vpnicity.openvpn.control", "com.vpnicity.openvpn.control.CONNECT", "com.vpnicity.openvpn.control.PROFILE_PATH", "file://" + config )
    else:
        cmdline = utils.getSudo()
        cmdline += '"' + exe + '"'
        cmdline += ' '
        cmdline += '"' + config + '"'
        cmdline = cmdline.replace('\\', '/')

    return Run(cmdline, timeout)