zpl-c / enet

⚡️ ENet reliable UDP networking library

Home Page:https://blog.zpl.pw

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: Implement some kind (or various) of hole punching

Anyeos opened this issue · comments

I am actually developing a game that need to host game servers in user side and the NAT are a problem. UPnP does not work on all routers (no all CPE routers have a public IP neither), so UDP hole punching will be a solution that can works.

I am implementing my own code for that purpose but will be great to have that already included on the library itself simplyfing the things and adding that support out of the box.

I want to suggest:

  • UDP hole punching functions to initiate a connection to some host using a 3rd party server.
  • STUN/TURN and ICE as a second and better option.

Than you for reading and for the interest of making this project.

Hey @Anyeos !

Here is a small project showcasing how to achieve hole punching with an intermediate server: https://github.com/codecat/enet-p2p

Not exactly what you've asked, but might help!

Yes, and thank you for the link.
But because hole punching is a low level thing, I think that it must be implemented directly on the ENET library.

ENET as is does not simplify hole punching because it cannot handle for example a kind of negotiation on peers, it directly listen or connects to. But if hole punching is implemented between ENET we can simply add the server (STUN or a custom one) as an extra parameter and all the rest remains the same.

Right now I need to implement a hole punching outside ENET (i.e.: using UDP socks directly) and next some kind of hacking to make ENET establish the connection. And it took me more than a week and still does not work.

There are various examples lying around but from that to real is a test and fail approach. If it is implemented directly on ENET it will not need the hacking part and it have more probability to work.

For now I will continue testig and trying to make it work outside of ENET because that is my only option.