the8472 / mldht

Bittorrent Mainline DHT implementation in java
Mozilla Public License 2.0
149 stars 45 forks source link

Can I share the UDP socket with an other protocol? #13

Closed marvelous closed 7 years ago

marvelous commented 7 years ago

I would like to use the same socket to run the DHT node and to implement an other protocol like uTP. The mldht API does not seem to allow to intercept UDP packets before passing them to mldht (if they start with the magic 'd' ascii character). Is there something I haven't noticed?

the8472 commented 7 years ago

No, that's currently not supported since mldht manages sockets on its own, bound to individual IP addresses while peer-peer sockets are often bound to the any-local address so there would be some impedance mismatch anyway.

What is the technical need for operating them on the same port? The specs allow tcp+utp to operate on a port separate from the DHT nodes.

marvelous commented 7 years ago

Sharing the same socket allows me to send RPCServer.getConsensusExternalAddress in the announces and avoid having an other external port discovery mechanism.

My goal is not to be bittorrent compliant, so I might encapsulate my protocol inside krpc messages.

the8472 commented 7 years ago

If you're fine with mldht managing all the IO and sockets for you then I could expose low level hooks for sending and receiving bytebuffers over the same socket.

marvelous commented 7 years ago

Don't bother, I will explore using STUN and a separate port first. Thank you for your feedback!