[HOME] [DOWNLOAD] [DOCS] [NEWS] [SUPPORT] [TIPS] [ISSUES] [DONATE]

tor-ctrl - Tor control port command line tool

I was thinking of using tor-ctrl SETEVENTS GUARD but figuring out exactly what to do on what events would require a lot of testing.
GETINFO entry-guards shows 3 ‘up’ out of 20. When I reboot in immutable mode it’s the same 3 but it seems to favor a different guard for most circuits according to GETINFO circuit-status.

Anyway, tor-ctrl (or something) should have a socat dependency since it’s somehow not installed on Whonix-Gateway-CLI.
I added a monitor mode to tor-ctrl where it does not exit but simply continues to output events. Something like
https://pastebin.com/83RLKxHi

100a101,104
>        [-w]           = wait instead of exiting after command
>                         default: not set
>                         notice: implies verbose. Useful with SETEVENTS.
> 
146c150,154
<         sendcmd "QUIT"
---
>         if [ -z "$WAIT" ]; then
>                 sendcmd "QUIT"
>         else
>                 while sleep 3600; do :; done
>         fi
159,163c167,174
<         STR="$(cat)"
<         vecho "$STR"
< 
<         echo "$STR" | if [ "$(grep -c ^"250 ")" = 3 ]; then
<                 exit 0
---
>         if [ -z "$WAIT" ]; then
>                 STR="$(cat)"
>                 vecho "$STR"
>                 echo "$STR" | if [ "$(grep -c ^"250 ")" = 3 ]; then
>                         exit 0
>                 else
>                         exit 1
>                 fi
165c176
<                 exit 1
---
>                 cat
179c190
< while getopts ":a:c:s:p:P:f:vh" Option
---
> while getopts ":a:c:s:p:P:f:vwh" Option
188a200
>                 w) WAIT=1;;
194c206
< if [ -e "$FILE" ]; then
---
> if [ -e "$FILE" -o "$FILE" = "-" ]; then

I don’t know what the option should be called, wait? filepipe could also wait but the user can keep the pipe open to work around that. I don’t know an elegant way of not exiting in cmdpipe. And piping to cat is inefficient but?

Posting here since I see Patrick is the maintainer and the website listed in the script doesn’t exist.

No more upstream indeed.

Yes, tor-ctrl could use some love. Didn’t work on it much since no one ever cared about it. So even considered deprecation.

Documentation https://www.whonix.org/wiki/Tor_Controller#tor-ctrl currently is needlessly complicated due to deficencies of the script

tor-ctrl -a /var/run/tor/control.authcookie -c "signal newnym"
  • -a /var/run/tor/control.authcookie could be avoided by using Tor auth cookie authentication by default.
  • -c could be the default (and then -c switch could be avoided).
  • -f file does not seem important. Could be removed. And if needed, better to invent a wrapper around it.
  • SLEEP_AFTER_CMD=1 - if we use sleep it means we didn’t figure out a proper event based flow.
  • Tor ControlPort support should be deprecated for code simplification. Debian tor package nowadays sets up Tor ControlSocket by default. No more need to use ControlPort. Then we could remove all references to telnet and the dependency on telnet.
  • I never tested SETEVENTS / long running sessions. If you can make that work, cool.

Help welcome.

Is ok.

I don’t think efficiency (as in speed) is important here?

[Imprint] [Privacy Policy] [Cookie Policy] [Terms of Use] [E-Sign Consent] [DMCA] [Investors] [Priority Support] [Professional Support]