-
Notifications
You must be signed in to change notification settings - Fork 2
/
anonsurf_handler.py
32 lines (29 loc) · 1.29 KB
/
anonsurf_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import subprocess
from time import sleep
def start_anonsurf(password):
try:
# Start anonsurf with sudo password
process = subprocess.Popen(['sudo', '-S', 'anonsurf', 'start'], stdin=subprocess.PIPE, stderr=subprocess.PIPE)
process.communicate(password.encode())
if process.returncode != 0:
raise subprocess.CalledProcessError(process.returncode, 'anonsurf start')
print("Anonsurf started successfully.")
except subprocess.CalledProcessError as e:
print(f"Failed to start Anonsurf: {e}")
def stop_anonsurf(password):
try:
# Stop anonsurf with sudo password
process = subprocess.Popen(['sudo', '-S', 'anonsurf', 'stop'], stdin=subprocess.PIPE, stderr=subprocess.PIPE)
process.communicate(password.encode())
if process.returncode != 0:
raise subprocess.CalledProcessError(process.returncode, 'anonsurf stop')
print("Anonsurf stopped successfully.")
except subprocess.CalledProcessError as e:
print(f"Failed to stop Anonsurf: {e}")
# # Example usage
# password = "Jkl;Fdsa" #"your_sudo_password_here" # Replace with your actual sudo password
# start_anonsurf(password)
# sleep(2)
# gettogo = input("go konim?")
# # Do some tasks while anonsurf is running
# stop_anonsurf(password)