1. 46

I’ve been working on this p2p protocol for a few years now as a sort of hobby. For a long time it only had a CLI interface, but I’ve recently wrapped it up as a GTK app. I’m still working on getting it fully documented, as the protocol mostly exists in code and floating around in my head. I spew it out every now and then verbally, but still need to capture it in writing.

Even still, I wanted to share it because I’ve pushed really hard to get it to a minimally useful state to force myself to finally “finish” one of my ridiculous side projects.

The underlying protocol repo is here: https://github.com/zacstewart/comm

Thanks for taking a look!


  2. 18

    Even still, I wanted to share it because I’ve pushed really hard to get it to a minimally useful state to force myself to finally “finish” one of my ridiculous side projects.

    I can relate to that. Congrats on getting this far!

    1. 7

      Thank you.

    2. 5

      Though the PROTOCOL.md is fairly light on details, it sounds a lot like S/Kademlia (PDF), is this by design or just a coincidence?

      Basically it’s the same idea that BitTorrent uses for the Mainline DHT (Kademlia), but with a “Secure” addition which uses IDs that are generated from a public key of the node rather than randomly.

      1. 3

        Very much by design. Then chat layer is built on top of a networking layer that is basically a DHT of nodes. I based this part of the project on the design of the Mainline DHT outlined in BEP 5.

        The network layer is self-bootstrapping, and self-healing. It provides a minimal interface to send a “packet” to any address in the network. It only guarantees that it will deliver that packet as closely to the intended recipient as it can. All the relaying, message acknowledging, etc lives in the chat layer on top of that.

        Glad you could recognize the design. Thanks for looking!

        1. 2

          Very cool. I’m enjoying reading through the code. Good work. :)

          1. 1

            Hope you update PROTOCOL.md once it stabilizes, would be fun to write a compatible client in another language. Chat apps are fun.

            1. 1

              Definitely. I’d like to get a JS version of this out there, using websockets instead of UDP, so that nodes can run in the browser.

              1. 3

                Do you mean WebRTC?

                That’s kinda the challenge that IPFS has (which also uses an S/Kademlia variant). They have WebRTC nodes in their JS implementation, and normal TCP nodes for the Go implementation, and bridging the two is tricky as there’s basically no full implementation of WebRTC aside from the C++ one.

                One fun tangent if you’re into it (something I looked into a few years ago): The IPFS DHT is actually fairly liberal with the kinds of nodes it’ll interface with and messages it’ll pass around. You might be able to graft onto it. (I chatted with the team about this idea, they were not opposed as long as the foreign clients were well-behaving.)

        2. 4

          Very cool, is there an explanation anywhere for how node addresses get mapped to IP addresses and what happens if those change?

          1. 6

            Each node keeps a routing table of other nodes at varying “distances” from itself (distance being the XOR of their addresses). It’s more complicated, but basically, that table works like a hashmap mapping addresses to IP.

            Nodes are regularly announcing themselves to one another. When a node that you already have in your routing table announces itself to you, you update its IP.

            Edit: thanks for checking it out!

          2. 2

            Seems like a new p2p messaging app pops up every year. I wish you luck but I can’t see it even passing tox which is fairly unusable.

            1. 25

              Agreed, but it’s fun to work on.

              1. 23

                THIS is the mentality I admire. Every time I come up with a new project and want to show it off, I’m inundated with “yeah, but X already exists! Why would you make another one?” Because it’s fun! Because I want my own! Because I want to write code!

                Keep it up, it’s a cool project.

                1. 12

                  Thank you! Having my own project like this to refactor and perfect allows me to stay sane in the business-focused “it ain’t broke” environment of the real world.

                2. 8

                  I love this mentality and that’s why I wrote my own p2p chat app too.

                  The most fun part was learning how to punch through firewalls, building messaging on top of UDP, and encryption.

                  Learning is best done through doing.

                  Question , what encryption does your chat app use?

                  1. 3

                    None whatsoever 🙊. All messages are transmitted in the clear right now, to obvious peril. Another goal I’d like to hit is implementing end-to-end encryption I’m interested in using libsignal, but don’t know enough about it to know if it’s applicable in a p2p protocol like this.

                    1. 2

                      I’d like to see yours too if you want to share.

                      1. 1

                        I haven’t worked on it in like a year, though recently started doing some C++17 revamp. It’s called Fire★. It’s interesting that you chose GTK, any reason to pick that over something like Qt?

                        1. 1

                          None other than that the Rust bindings looked mature and are easy enough to work with. I actually started by wrapping it with Swift and making an iOS app. I made some progress but it was pretty hard to maintain the Swift wrapper, wrapping a C interface, wrapping the actual library.

                          Fire(star) looks pretty cool. Next time I have some free time with my laptop I want to play around with it.

                          1. 2

                            Interesting, hopefully the Rust people will get decent Qt bindings. Qt is pretty damn great. If you ever do play with Firestr, PM me your ID and I’ll send you mine.

                  2. 3

                    what’s wrong with tox?

                    1. 3

                      Nothing that I know of.

                      1. 2

                        Last I saw which was a little while ago, It didn’t work well at all on mobile because you need a constant connection to the network which drains your battery and data real fast. Matrix looks a lot more promising for real use.

                        1. 1

                          does matrix have video chat?

                          1. 1

                            It does. It has almost all the features of things like discord and slack but they need to be polished more and sped up.

                        2. 1

                          Doesn’t Tox have occasional developer drama every so often?

                        3. 1

                          Can you clarify what Tox is and, more importantly, why you think it wouldn’t pass?

                          I think you mean “be better than Tox [another messaging system], which has its own usability problems”.

                          1. 2

                            Tox is another P2P messaging system. The Qt client is a little wonky, and I remember having issues when trying to do group chat. Beyond that, it was really nice to use, and the voice chat functionality was surprisingly great. The last time I used Tox was maybe 2014 so maybe it’s changed since then. I think the main thing Tox has going for it ahead of other P2P systems is that it’s relatively popular and well-known.