def disconnect_openvpn():
    Script.log('OpenVPN: Disconnecting OpenVPN')
    try:
        vpnlib.disconnect(IP, PORT)
        Script.log('OpenVPN: Disconnect OpenVPN successful')
        Script.notify(
            "OpenVPN",
            Script.localize(30355),
            display_time=3000)
    except Exception as e:
        xbmcgui.Dialog().ok(
            'OpenVPN',
            Script.localize(30362))
        Script.log('OpenVPN: OpenVPN error: ' + str(e))
Exemple #2
0
def disconnect_openvpn():
    log_debug('Disconnecting OpenVPN')
    global _state
    try:
        _state = disconnecting
        response = vpn.is_running(_ip, _port)
        if response[0]:
            vpn.disconnect(_ip, _port)
            if response[1] is not None:
                display_notification(_settings.get_string(4001) % os.path.splitext(os.path.basename(response[1]))[0])
        _state = disconnected
        log_debug('Disconnect OpenVPN successful')
    except vpn.OpenVPNError as exception:
        utils.ok(_settings.get_string(
            3002), _settings.get_string(3011), exception.string)
        _state = failed
Exemple #3
0
def disconnect_openvpn():
    log_debug('Disconnecting OpenVPN')
    global _state
    try:
        _state = disconnecting
        response = vpn.is_running(_ip, _port)
        if response[0]:
            vpn.disconnect(_ip, _port)
            if response[1] is not None:
                display_notification(_settings.get_string(4001) % os.path.splitext(os.path.basename(response[1]))[0])
        _state = disconnected
        log_debug('Disconnect OpenVPN successful')
    except vpn.OpenVPNError as exception:
        utils.ok(_settings.get_string(
            3002), _settings.get_string(3011), exception.string)
        _state = failed
Exemple #4
0
def disconnect_openvpn():
    with storage.PersistentDict('vpn') as db:
        Script.log('OpenVPN: Disconnecting OpenVPN')
        try:
            db['status'] = "disconnecting"
            response = vpnlib.is_running(ip, port)
            if response[0]:
                vpnlib.disconnect(ip, port)
                if response[1] is not None:
                    Script.notify('OpenVPN', Script.localize(30355))
            db['status'] = "disconnected"
            Script.log('OpenVPN: Disconnect OpenVPN successful')
        except vpnlib.OpenVPNError as exception:
            xbmcgui.Dialog().ok('OpenVPN', Script.localize(30358))
            Script.log('OpenVPN: OpenVPN error: ' + str(exception))
            db['status'] = "failed"
        db.flush()
Exemple #5
0
def disconnect_openvpn():
    storage = common.sp.MemStorage('vpn')
    common.PLUGIN.log_debug('Disconnecting OpenVPN')
    try:
        storage['status'] = "disconnecting"
        response = vpnlib.is_running(ip, port)
        if response[0]:
            vpnlib.disconnect(ip, port)
            if response[1] is not None:
                utils.send_notification(_('Stopped VPN connection'),
                                        title="OpenVPN",
                                        time=3000)
        storage['status'] = "disconnected"
        common.PLUGIN.log_debug('Disconnect OpenVPN successful')
    except vpnlib.OpenVPNError as exception:
        common.sp.xbmcgui.Dialog().ok(
            'OpenVPN',
            _('An error has occurred whilst trying to connect OpenVPN'))

        storage['status'] = "failed"