diff --git a/iptable.sh b/iptable.sh index a6c3c3f..777e427 100755 --- a/iptable.sh +++ b/iptable.sh @@ -26,7 +26,7 @@ ip rule flush ip rule add from all lookup main pref 32766 ip rule add from all lookup default pref 32767 echo add fwmark -ip rule add fwmark 11 table novpn +ip rule add fwmark 11 table novpn pref 100 echo add to novpn table ip route flush table novpn ip route add 192.168.122.0/24 dev enp1s0 # src 192.168.122.128 diff --git a/openvpn.py b/openvpn.py index 481cca9..493ec8a 100644 --- a/openvpn.py +++ b/openvpn.py @@ -77,7 +77,8 @@ class Openvpn: if self.status == IDLE: self.status = RUNNING config_fp = self.generate_config_file() - cmd = " ".join(["openvpn", "--config", config_fp]) + route_up_script = os.path.join(self.folder_path, "test.sh") + cmd = " ".join(["openvpn", "--config", config_fp, "--route-noexec", "--route-up", route_up_script ,"--script-security","2"]) self.run_task = self.loop.create_task(self.run(cmd)) def get_log(self): @@ -95,7 +96,7 @@ class Openvpn: async def stop(self): if self.status == RUNNING: try: - os.kill(self.PID, signal.SIGKILL) + os.kill(self.PID, signal.SIGINT) except Exception as err: print("kill failed:", err)