From 20513c7665fb8618d3e5dc44adaa5cc48772f17c Mon Sep 17 00:00:00 2001 From: Kajan0v3zk1 <48596072+Extr3m4R4710@users.noreply.github.com> Date: Sat, 6 Jan 2024 02:38:29 +0900 Subject: [PATCH] Functionalization process done --- files/tor-router | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/files/tor-router b/files/tor-router index 0985ec0..2146ac7 100755 --- a/files/tor-router +++ b/files/tor-router @@ -1,12 +1,10 @@ #!/bin/bash - RULES="/var/tmp/tor-router.save" # Tor's TransPort TRANS_PORT="9040" - -case "$1" in -start) +function startTR() +{ if test -f "$RULES"; then echo "$RULES exists. Either delete it, or stop tor-router first." exit 1 @@ -57,8 +55,9 @@ start) iptables -A OUTPUT -j ACCEPT fi fi - ;; -stop) +} +function stopTR() +{ if test -f "$RULES"; then echo "Restoring previous rules from $RULES" iptables -t nat -F @@ -68,11 +67,24 @@ stop) echo "$RULES does not exist. Not doing anything." exit fi + +} +function restartTR() +{ + stopTR + sleep 2 + startTR +} + +case "$1" in +start) + startTR + ;; +stop) + stopTR ;; restart) - stop - sleep 2 - start + restartTR ;; *) echo "Usage: $0 {start|stop|restart}"