Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NAT Hole punching #412

Open
Kingwolf123 opened this issue Jun 30, 2023 · 7 comments
Open

Implement NAT Hole punching #412

Kingwolf123 opened this issue Jun 30, 2023 · 7 comments

Comments

@Kingwolf123
Copy link
Contributor

Is it possible? Will make port forwarding and other stuff not necessary

@AlexanderCurl
Copy link
Contributor

Currently no, but it is possible to do so, not sure if it's really necessary tho, as the servers never use random ports.
And port forwarding is literally a 2 minute job, I don't think it's needed in the code.

@Kingwolf123
Copy link
Contributor Author

Vast numbers of people behind CGNAT will benefit tremendously. Creation of spontaneous servers is always easier.

@AlexanderCurl
Copy link
Contributor

If people behind CGNAT, they don't have public IP address anyway, so even port forward doesn't help in that situation.

@Kingwolf123
Copy link
Contributor Author

Hole punching is optimal for such users

@Kingwolf123
Copy link
Contributor Author

People behind CGNAT do benefit from hole punching fyi

@proxict
Copy link
Contributor

proxict commented Sep 4, 2023

@Kingwolf123 How exactly would that work? The concept sounds pretty simple, but it seems like it's more suitable for P2P communication and wouldn't really make sense for a game server, correct? Though I've never implemented it myself so I might be missing something. And if I'm not mistaken, it would also require implementing this on the client side as well.

@Kingwolf123
Copy link
Contributor Author

Hello ,
So i have gathered some information and implementation features that will help this move forward

Open source stun and turn servers are already available and ready to use .
This is a very advanced S&T server. Cod4 doesnt need all these features hence they can be stripped down to exactly fit the usage.

The library is integrated into the server, client and the cod4x masterserver.

The system works as follows.

The main server is implemented in the cod4master server where all servers and clients can communicate to get holepunched.
Anyone can host their own cod4x holepunch server.
[Optional] 3rd party people can apply for their hole punch server to be broadcasted via the cod4x server after applying for it .
This ensures that the system never goes down, because even if the master server goes down, the clients still have holepunch server addresses that are working
The holepunching feature is implemented in the client, and the client ships with the default dvar of the holepunching addresses so it can communicated with the master server. IPV6 punching can also be implemented for ipv6 hosts behind firewall for example, which are alot.

Behaviour suggestions
The client should always prefer direct connection, and if that fails lets say within 3 seconds then the client switches to holepunching.
Stun servers should ensure privacy and keep no logs.
Custom stun servers should be easy to setup, as easy as click and run with a few cmd options.

stun is directly shipped with both server and all clients in a patch to enable mass use .

The server clients .adds some cvars such as "sv_stun_sv_list" "add_stun_sv" .
One use case that cannot work is a custom stun server and a custom server.The client cannot connect without stun server knowledge, and server cannot provide that in a p2p way or can it? The client will have to manually add the stun server in .shoudnt be that difficult.
A format for the connect command on the client implemented to give both the server ip and the stun server ip such as
/connect 192.168.5.2:28964 -s 65.543.34.123:5436
-s is an abbreviation for stun .

In conclusion, stun server is ready to be integrated into cod4x with the vast majority of average users benefitting from automated NAT and firewall punch .The argument of for and against stun server implementation clear and a majority average cg-natted users can host and play cod4 with their friends seamlessly.

Appreciate feedback
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants