.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from config import ClientInterface
|
||||
|
||||
@@ -27,9 +28,12 @@ ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
||||
"""
|
||||
|
||||
|
||||
def run_subprocess(cmd, check=True):
|
||||
def run_subprocess(cmd, check=True, delay=0):
|
||||
cmd_split = cmd.split(" ")
|
||||
return subprocess.run(cmd_split, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=check).stdout.decode("utf-8")
|
||||
output = subprocess.run(cmd_split, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=check).stdout.decode("utf-8")
|
||||
if delay > 0:
|
||||
time.sleep(delay)
|
||||
return output
|
||||
|
||||
|
||||
def run_subprocess_interface(cmd, check=True):
|
||||
@@ -173,3 +177,21 @@ def vpn_disconnect():
|
||||
if run_subprocess("nordvpn d").find("You are disconnected from NordVPN") != -1:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def killswitch_status():
|
||||
if run_subprocess("nordvpn settings").find("Kill Switch: disabled") != -1:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def killswich_enable():
|
||||
if run_subprocess("nordvpn set killswitch on", delay=2).find("Kill Switch is set to 'enabled' successfully") != -1:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def killswich_disaable():
|
||||
if run_subprocess("nordvpn set killswitch off", delay=2).find("Kill Switch is set to 'disabled' successfully") != -1:
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user