Files
LorenEteval_Furious/Furious/Core/Tun2socks.py
T
2023-09-07 00:15:55 +08:00

52 lines
1.1 KiB
Python

from Furious.Core.Core import Core
from Furious.Utility.RoutingTable import RoutingTable
def startTun2socks(*args, **kwargs):
try:
import tun2socks
except ImportError:
# Fake running process
while True:
pass
else:
tun2socks.startFromArgs(*args, **kwargs)
class Tun2socks(Core):
class ExitCode:
TunnelStartFailure = 1
# Windows shutting down
SystemShuttingDown = 0x40010004
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@staticmethod
def name():
return 'Tun2socks'
@staticmethod
def version():
try:
import tun2socks
return tun2socks.__version__
except Exception:
# Any non-exit exceptions
return '0.0.0'
def start(self, device, networkInterface, logLevel, proxy, restAPI, **kwargs):
super().start(
target=startTun2socks,
args=(device, networkInterface, logLevel, proxy, restAPI),
waitTime=1000,
**kwargs,
)
def stop(self):
RoutingTable.deleteRelations()
super().stop()