TokTok / c-toxcore

The future of online communications.
https://tox.chat
GNU General Public License v3.0
2.24k stars 283 forks source link

An equivalent to the ```other/fun/bootstrap_node_info.py``` script for TCP #2331

Open emdee-is opened 1 year ago

emdee-is commented 1 year ago

We need a an equivalent to the other/fun/bootstrap_node_info.py script for TCP to test TCP connections.

For UDP you can send a packet of len 78 with the magic first bytes and get a version and MOTD reply. Not so for TCP ( in fact if you do send such a packet to the TCP it send the BS node into an infinite loop for which it never recovers). So we need a simple fix to the TCP_server code to at least look for a special packet like this and be nice and send a simple nice reply like the UDP case.

emdee-is commented 1 year ago

A special case 78 bytes starting with magic bytes is fine as a convention and easy to use the existing bootstrap_node_info.py - that's how I found this was simple hacking the .py for TCP.

A TCP packet to be forwarded is really complicated to construct. I am looking for something braindead easy I can contruct in Python to get an intelligent response, and nothing more, to test that I got a Tox TCP tcp_port/BSd through a proxy/router/smoke signal/telepathy...

emdee-is commented 1 year ago

The main test case is can I test a BSd running on an OnionV3 Torred port that can be accessed through Tor.

But there might other similar cases. Does toxic's --tcp_port allow you to use Tor to turn it into an OnionV3 relay? If so we might be able encourage each toxic user to be an OnionV3 provider, which would really help our resilliancy. If we can make it easy for clients to be tcp_servers the numbers change radically.

Anyone that is running a client like toxic over Tor already has a Tor server running, and could, with a 3 line change to torrc, help the network by running an OnionV3 Tox TCP server. Then we could figure out a way of integrating the propagation of the information about the onion addresses.

nurupo commented 1 year ago

https://github.com/Tox/toxstatus can do that, it can be used as a command line tool.

emdee-is commented 1 year ago

Thanks for toxstatus - I missed that - but no, it does not solve the issue here. It doesn't work AFAIK behind SOCKS - I can't even build it behind SOCKS -:)

The issue here is testing a BS node whilst behind a SOCKS proxy. I can reach a TCP port on a BS node over SOCKS but I don't have a simple way of getting a meaningful reply out of a simple utility written easily in any language - Python in this example.

UDP you can send a packet of len 78 with the magic first bytes and get a version and MOTD reply. What little I understood, the TCP handshake is much more complex, too complex for my usecase. I asked @Green-Sky to add it as from looking at the UDP reply code it can't be "much" work.

It's important as this is a complete blocker for me to testing a simple way of providing BS nodes over OnionV3 which will help our resiliency. It's pretty easy to block our small number or nodes, and it's very easy for poisoned guard or exit nodes to try to block Tox over Tor. What I'm trying to explore is Tox in Tor, which should be more tamper resistant.

PS: nice to see a command-line tool for Tox; I just added a Python console to toxygen so it's a command-line CLI for anything wrapped into tox_wrapper.

emdee-is commented 1 year ago

Is there a mailinglist of IRC chat or NGC for node operators to ask them to run an Onion service with their nodes? If so, could it be referred to on tox.chat, and a page on it written up in the wiki?

emdee-is commented 9 months ago

It would be really nice to have some/any simple solution fix to the TCP_server code to at least look for a special packet ping packet and be nice and send a simple nice reply like the UDP case. We need this to make the tcp server testable/usable with Tor, and we need Tor to be resilient against network blocks or snooping. There are people using Tox for serious reasons, and right now it's trivial to observe or block with the small number of boot nodes.

iphydf commented 9 months ago

I see this now. Yes that sounds like a thing we can do. Would you like to join our NGC dev channel to discuss more? I'm interested in making tox in tor (e.g. hidden node) work.

emdee-is commented 9 months ago

I see this now. Yes that sounds like a thing we can do. Would you like to join our NGC dev channel to discuss more? I'm interested in making tox in tor (e.g. hidden node) work.

See also https://github.com/TokTok/c-toxcore/issues/2332

I'm in your Dev channel as of today - let me know in there when you are online.

emdee-is commented 7 months ago

I'm interested in making tox in tor (e.g. hidden node) work.

If you're interested in making tox in tor (e.g. hidden node) work, a pre-requisite is to get all of the big nodes to run a TCP port hooked up to a hidden service, and then report the corresponding onion address in the motd field of their node desctiption, (Unless you can get the node description to have an onions field which is a list of onion_address:tcp_port.) This can be done right now if you want to get a testbed in place to test against.

Configure your boostrap server with an extra tcp_port that is not listed publically in the nodes.json file. We will use 33446 as an example.

In your /etc/tor/torrc or equivalent, you need to add 2 sections.

The first is:

VirtualAddrNetworkV4 10.192.0.0/10
AutomapHostsOnResolve 1
AutomapHostsSuffixes .exit,.onion

The second is:

# Tox hidden service configuration.
HiddenServiceDir /var/lib/tor/tox-hsv3/
HiddenServicePort 33446 127.0.0.1:33446

Replace 33446 with your real port number.

The next time tor starts up, a new directory will be created in /var/lib/tor/tox-hsv3/ and it will have a file called hostname. Look in the file for the onion address to your site.

Now add the onion address followed by a colon and the port to the motd field of the advertised nodes.json entry for your server

emdee-is commented 7 months ago

I'm interested in making tox in tor (e.g. hidden node) work: if onion addresses from the big nodes start showing up in the nodes.json, and the blockers to testing get dealt with https://github.com/TokTok/c-toxcore/issues/2584#issuecomment-1925924797 , I'll try testing it,