Open ozymandiaslone opened 4 weeks ago
I think that in the torstart()
fn, whenever it makes a call to checkstatus
, it always returns true. Even if I manually sudo rm /etc/torbridge/status
, the torstart()
checkstatus
call still returns true
function torstart()
{
if ! [ -z "$(ls -A $torbridgepath)" ];
then
if ! [ -e "$torbridgepath/started" ];
then
touch "$torbridgepath/started"
fi
fi
if checkstatus;
then
loadstatus "[*] TorBridge already started" "!!" "issue"
else
<...>
}
Actually it looks like the torstart()
fn first creates the /etc/torbridge/started
path, if none exists (and if /etc/torbridge
is not empty - which it isn't, due to resolv.conf.bak@
) . Thus, when it calls checkstatus
- which just checks for the existence of that path - it finds that the path exists, and errs that torbridge is already started.
function torstart()
{
if checkstatus;
then
loadstatus "[*] TorBridge already started" "!!" "issue"
else
# Display IP Address
## ------------------
showipaddr
## Backup Tor Config
## -----------------
backuptorrc
## Backup Resolv Config
## --------------------
backupresolv
## Backup Iptables Rules
## ---------------------
backupiptables
## Backup Sysctl Rules
## -------------------
backupsysctl
## Flush Iptables
## --------------
flushiptables
## Build Tor Config
## ----------------
configtorrc
## Build Rsolv Config
## ------------------
configresolv
## Start Services
## --------------
servicestart tor
## Apply Rules
## -----------
rulesiptables
rulessysctl
## Display IP Address
## ------------------
showipaddr
## Return Notice
## -------------
loadstatus "[+] All traffic is being redirected through Tor" "OK" "valid"
touch $torbridgepath/started
fi
if ! [ -z "$(ls -A $torbridgepath)" ];
then
if ! [ -e "$torbridgepath/started" ];
then
touch "$torbridgepath/started"
fi
fi
}
Moving that if block to the end of the fn seems to have fixed all of the issues on my end. I haven't spent the time to really dive into understanding this script, so I do not know if this breaks the script elsewhere; if it seems alright id be happy to open a pull request.
Actually there is absolutely no issue with the script. I believe that you started TorBridge and shutdown your PC without stop TorBridge or something like this. Actually just have a look into /etc/torbridge
and check if there is a file named "started" in such case, just delete it and try to restart
Yeah you're right that the issue stems from my laptop entering hibernation or something while torbridge was still active. I had tried deleting the started
file manually in /etc/torbridge
, but the issue was that the file called resolv.conf.bak@
was still in the /etc/torbridge
directory.
So then when this conditional:
if ! [ -z "$(ls -A $torbridgepath)" ];
then
if ! [ -e "$torbridgepath/started" ];
then
touch "$torbridgepath/started"
fi
fi
is checked at the beginning of the torstart()
function, it leads to errors.
(and --stop or --restart do not recover functionality)
I think I could have solved the problem entirely just by manually deleting the whole /etc/torbridge
directory, or everything in it - but there is still no way for the script to recover once it finds itself in a state where it failed to empty the /etc/torbridge
directory properly
Well actually to solve the issue at the time it happened to you, you just needed to stop torbridge for the script to revert the initial config and delete the started file present in the torbridge directory.
Or another would be to recover the config manually and after that delete the started file. In which OS are you using Torbridge for me to know ?
Oh I'm on linux mint. I think I did try stopping torbridge, and it would successfully delete the 'started' file, but not the 'resolv.conf.bak@' file, which was causing the broken state.
(base) exeo@exeo:~$ sudo torbridge --stop
[+] Remote IP [MY IP] [OK]
[+] Traffic is not redirected through Tor [OK]
(base) exeo@exeo:~$ sudo torbridge --start
[*] TorBridge already started [!!]
I just check more deeply and yes you are right, there is an issue to restore the resolv.conf file since the last Kernel update. Temporary in order to recover your resolv.conf what you can do is :
sudo mv /etc/resolv.conf /etc/resolv.conf.bak
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
sudo rm -rf /etc/torbridge
It could be some form of user error, but I don't see anything in the --help options that would help me troubleshoot