From e5b0d1675853474658bf45e91d8e33d729f43baa Mon Sep 17 00:00:00 2001 From: Kajan0v3zk1 <48596072+Extr3m4R4710@users.noreply.github.com> Date: Thu, 28 Dec 2023 00:20:27 +0900 Subject: [PATCH] fix ip leak and restart section for case minutes --- files/tor-router | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/files/tor-router b/files/tor-router index 0985ec0..793bc69 100755 --- a/files/tor-router +++ b/files/tor-router @@ -5,8 +5,8 @@ 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 @@ -54,12 +54,14 @@ start) done iptables -A OUTPUT -m owner --uid-owner "$TOR_UID" -j ACCEPT - iptables -A OUTPUT -j ACCEPT + iptables -A OUTPUT -j REJECT # ACCEPTから変更 fi fi - ;; -stop) - if test -f "$RULES"; then +} + +function stopTR() +{ + if test -f "$RULES"; then echo "Restoring previous rules from $RULES" iptables -t nat -F iptables-restore <"$RULES" @@ -68,11 +70,23 @@ stop) echo "$RULES does not exist. Not doing anything." exit fi +} + +function restartTR() +{ + stopTR + startTR +} + +case "$1" in +start) + startTR + ;; +stop) + stopTR ;; restart) - stop - sleep 2 - start + restartTR ;; *) echo "Usage: $0 {start|stop|restart}"