I am trying to solve the problem of creating a decentralized messaging service, analogous to TOX. The task is to find two nodes on the Internet and establish a connection. While only such an idea occurred to me. Take the abstract scheme of a triangle or three nodes in a network. Each client will consist of two input and output streams. The output will carry out the flood request to the network on the range of the entire Internet, until the first node is found (I am not sure if this is correct, but no other thoughts occurred). Also, each client will have a private key and its hash, which itself will function as a public key. The scheme is as follows. The first node learns the public key of the second node (mail or something else) and starts flooding a request to the Internet for a predetermined port by searching the type of addresses, trying to establish a connection by forwarding the public key of the second node. It is clear that not true nodes will not respond to such a request. As soon as the request reaches the desired node, and the client listens to a predetermined port, he will accept the packet from the first node, parse it and compare the hash of his key with what came to his input. And if the cache is one, then it will put the first client's un IP address and its public key to itself in the database (I plan to use mongo). When the connection is established, the database will be updated on the first client on the basis of replication. Ie now two nodes know about each other. If the third node wants to connect to some of the nodes, then it will be enough for him to find any of the nodes and look in the database to find the desired node (type address) using the desired hash. Thus the network will grow. This is the basic architecture and I am still noob in such matters.
This is what came to my mind. Perhaps there are some other algorithms, more correct. Tell me please.