Skip to content

Conversation

@XMRZombie
Copy link
Contributor

@XMRZombie XMRZombie commented Apr 4, 2025

Helps to externally using Tor for Haveno and configuring Haveno with an external Tor process
For launching: $ chmod +x haveno-with-external-tor.sh && ./haveno-with-external-tor.sh

  • Solves Tor's ControlPort AUTO setting by saving the control port --ControlPortWriteToFile $TORHOME/.tor/control.port and getting it for launching haveno --torControlPort=$(cat $TORHOME/.tor/control.port | sed 's/.*:\([0-9]\+\)/\1/')
  • Bypasses Tor's DisableNetwork 1 config (crashing Haveno at startup) with --DisableNetwork 0

@XMRZombie XMRZombie requested a review from woodser as a code owner April 4, 2025 22:07
@@ -0,0 +1,12 @@
#!/bin/sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this file to haveno-with-external-tor-monerod.sh for consistency with the other script.

@woodser
Copy link
Contributor

woodser commented Apr 6, 2025

Maybe @boldsuck has any feedback on these 2 scripts?

@boldsuck
Copy link
Contributor

boldsuck commented Apr 7, 2025

I can test it tomorrow. Generally, though, the script needs to be rerun every time Haveno starts.
Useful for Tails. On Debian/Ubuntu, Fedora, and other distros, I find DirectBindTor easier.

@XMRZombie
Copy link
Contributor Author

XMRZombie commented Apr 7, 2025

@woodser renaming done. For the script, one it is marked as an executable is really makes a 'flawless' launch of all processes and everything is configured correctly

@woodser
Copy link
Contributor

woodser commented Apr 7, 2025

For the script, one it is marked as an executable

Thinking to add a comment at the top of the scripts instructing to launch:

In haveno-with-external-tor.sh:
chmod +x haveno-with-external-tor.sh && ./haveno-with-external-tor.sh

In haveno-with-external-tor-monerod.sh:
chmod +x haveno-with-external-tor-monerod.sh && ./haveno-with-external-tor.sh

That will help make it clear for newcomers.

Dynamically finds instance wide haveno user data directory
Updating path finding method
@boldsuck
Copy link
Contributor

boldsuck commented Apr 7, 2025

I have testet haveno-with-external-tor.sh on Debian. With a completely empty Haveno folder I have error:

user@t520:~$ /home/user/.local/share/Haveno/haveno-with-external-tor.sh
Apr 07 15:29:29.920 [notice] Tor 0.4.8.16 running on Linux with Libevent 2.1.12-stable, OpenSSL 3.0.15, Zlib 1.2.13, Liblzma 5.4.1, Libzstd 1.5.4 and Glibc 2.36 as libc.
Apr 07 15:29:29.920 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://support.torproject.org/faq/staying-anonymous/
Apr 07 15:29:29.920 [warn] Unable to open configuration file "/home/user/.local/share/Haveno/xmr_stagenet/tor/torrc".
Apr 07 15:29:29.920 [err] Reading config failed--see warnings above.
cat: /home/user/.local/share/Haveno/xmr_stagenet/tor/.tor/control.port: No such file or directory
haveno.common.config.ConfigException: problem parsing option 'torControlPort': java.lang.NumberFormatException: For input string: ""
        at haveno.common.config.Config.<init>(Config.java:761)
        at haveno.core.app.HavenoExecutable.execute(HavenoExecutable.java:118)
        at haveno.desktop.app.HavenoAppMain.main(HavenoAppMain.java:65)
error: problem parsing option 'torControlPort': java.lang.NumberFormatException: For input string: ""
cat: /home/user/.local/share/Haveno/xmr_stagenet/tor/pid: No such file or directory
/home/user/.local/share/Haveno/haveno-with-external-tor.sh: 5: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [exitstatus]

On the second start, after I had previously started Haveno with /opt/haveno/bin/Haveno
Haveno is running and Tor has ControlPort: 42411. A query via the Stem interface then shows me a double config:

Tor Configuration File (/home/user/.local/share/Haveno/xmr_stagenet/tor/torrc):
 1 SafeSocks 0
 2 HiddenServiceStatistics 0
 3 ControlPort auto
 4 CookieAuthentication 1
 5 DisableNetwork 1
 6 AvoidDiskWrites 1
 7 RunAsDaemon 1
 8 SOCKSPort auto
 9
10
11 CookieAuthFile /home/user/.local/share/Haveno/xmr_stagenet/tor/.tor/control_auth_cookie
12 DataDirectory /home/user/.local/share/Haveno/xmr_stagenet/tor
13 GeoIPFile /home/user/.local/share/Haveno/xmr_stagenet/tor/geoip
14 PidFile /home/user/.local/share/Haveno/xmr_stagenet/tor/pid
15 GeoIPv6File /home/user/.local/share/Haveno/xmr_stagenet/tor/geoip6
16
17 ## fteproxy configuration
18 ClientTransportPlugin fte exec ./PluggableTransports/fteproxy.bin --managed
19
20 ## obfs4proxy configuration
21 ClientTransportPlugin obfs4 exec ./PluggableTransports/lyrebird
22
23 ## meek configuration
24 ClientTransportPlugin meek exec ./PluggableTransports/meek-client

I also have a second /home/user/.local/share/Haveno/xmr_stagenet/tor/state file with a different guard set than the system tor.

Back when we didn't have DirectBindTor, I just started Haveno like Bisq with:
/opt/haveno/bin/Haveno --torControlPort=9051 --torControlCookieFile=/var/run/tor/control.authcookie --torControlUseSafeCookieAuth to use ExternalTor.

@XMRZombie
Copy link
Contributor Author

XMRZombie commented Apr 7, 2025

@boldsuck yes, Tor and haveno will crash if theres no user data as the script uses user data's tor data and configuration to launch Tor. And what you see ( /home/user/.local/share/Haveno/xmr_stagenet/tor/torrc ) isnt a "double" but the default Tor's haveno torrc config, the script i made is using additional flags to make it externally usable

@boldsuck
Copy link
Contributor

boldsuck commented Apr 7, 2025

But why is the state file created and updated and consenus & certs? And 4 guards are used instead of 2. It may be different on Tails.
Why don't you use the default Tor ControlPort: 9051

With DirectBindTor my entire ~/.local/share/Haveno-reto/xmr_mainnet/tor/ folder remains empty.

@XMRZombie
Copy link
Contributor Author

XMRZombie commented Apr 7, 2025

@boldsuck idk about the state file. for the controlport, please read the script and haveno's torrc to understand why i did this. and yes since you externaly use a hidden service your tor folder is empty but thats because you use a sophisticated setup

@woodser
Copy link
Contributor

woodser commented Apr 7, 2025

So this will crash on first startup without doing some setup first?

@XMRZombie
Copy link
Contributor Author

Yes, user needs to launch haveno one time to init the tor files and after this the script can be used

@boldsuck
Copy link
Contributor

boldsuck commented Apr 7, 2025

I just don't understand what's wrong with DirectBindTor. Haveno can do it, Bisq can't.

echo "HiddenServiceDir /var/lib/tor/haveno-service/" >> /etc/tor/torrc
echo "HiddenServicePort 9999 127.0.0.1:9999" >> /etc/tor/torrc

service tor reload or systemctl reload tor

HSAddress=$(cat /var/lib/tor/haveno-service/hostname)

/opt/haveno/bin/Haveno --hiddenServiceAddress=$HSAddress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants