-
-
Notifications
You must be signed in to change notification settings - Fork 76
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 server types and P2P connection helper #123
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Implemented server types to allow a match host to use relay (websocket on 6970) or P2P (UDP on 6972) networking. This configuration is defined in coopConfig.json and transmitted to the coop match instance. - Implemented a P2P Connection Helper to allow for NAT punching and UPNP mapping. This only applies to P2P networking. The P2P Helper is communicating with the backend server using websocket on port 6971, configurable in coopConfig.json. - NAT punching uses a public endpoint created by a STUN query. This is necessary because the backend server might be on the same network as the match host and therefore we can't get a public endpoint locally. - Removed all configs related to IPs and ports in com.sit.core.cfg. The ports are now configured in coopConfig.json and the server will listen on all adapters. From now on, three ports will need to be forwarded on the backend server host: 6969, 6970 and 6971. 6972 needs to be forwarded on the match host instead because of P2P networking. If forwarding is not possible, NAT punching will be attempted to establish connection. TODO: - Add upnp mapping - Implement upnp requests in P2P Helper - Logic to attempt nat traversal, upnp or direct port forwarding connection before giving up. - Add security to the p2p helper
Build Successful! You can find a link to the downloadable artifact below. |
- Removed configs from coopConfig.json. - Added configs back to com.sit.core.cfg. - Adjusted logic to use the config from com.sit.core.cfg.
- Made the Nat punching process streamlined between GameClientUDP/GameServerUDP - Refactored some of the code
- Server connection info now lives in the CoopGame instance. - Using /coop/server/connectionInfo route to set and get server connection info. - P2PConnectionHelper is now NatPunchHelper and is only used to perform nat punching. - Refactoring of the code to make other nat traversal processes easier to implement.
- Removed STUN nuget package and added the references in the project to get rid of the DLL - Added Open.NAT references - Changed configs to add ServerType, NatTraversalMethod and added enums for them - Added UPNP mapping in GameServerUDP What is left to do: - Support the enums properly when sending to server and back to clients - Test nat punch and upnp and make sure we can connect - Code refactoring
As the title says. What is left to do: - Change the configs to actual UI settings for the host (server type, server nat. Ip and port will be automatically generated) - Manage local connection for routers which doesn't support hairpin. - Keep nat punch/upnp connection alive until a client joins. - Test a lot to ensure every single scenario works properly (relay, p2p and different nat traversal methods).
- NatPunchHelper is now NatHelper - NatHelper now uses json to provide information between client and server. - NatHelper is a class that creates different nat traversal methods and communicate it between server and clients. Requires port 6971 to be port forwarded by the server. It is now the main process in providing connection to server for clients. - The client will request different endpoints from the server and attempt to connect to them all. First one that succeeds will be the one used by the client. It might generate connection errors during that process. Getting around that would be quite complex so I consider that on a low priority for now. - Some refactoring and improvements Notes - Still need to define ServerType on the UI when hosting to avoid needing to set the value in com.sit.core.cfg. - Further testing is required to ensure this process works for most people.
- Only do STUN (nat punching) if UPNP failed - Added "remote" endpoint which NatHelper will replace with the local or external IP of the host. This is done using the NatHelper's socket information when host sends a packet to NatHelper. - Added a check to disconnect if we connected more than once. This happens if more than one endpoint is reached. - Cleaned up the code a bit and improved the logic.
This reverts commit 1675b79.
…yintarkov/StayInTarkov.Client into server-config-and-p2p-helper
- Removed P2P port from config. Relay is still in config. - Added port in host game UI (p2p only). - Send port to coop match (CreateMatch) - Receive port from coop match (JoinMatch) - Logic improvements to connection handling in GameClientUDP - Added broadcast packet for local connection - Some refactoring in Nat Helper to use IPEndPoint instead of strings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented server types to allow a match host to use relay (websocket on 6970) or P2P (UDP on 6972) networking. This configuration is defined in com.sit.core.cfg and and transmitted to the coop match instance.
Implemented NatPunchHelper which is just a relay server to communicate public end points and nat punch requests.
NAT punching uses a public endpoint created by a STUN query. This is necessary because the backend server might be on the same network as the match host and therefore we can't get a public endpoint locally.
Removed all configs related to IPs in com.sit.core.cfg. The server will listen on all adapters including ipv6.
From now on, three ports will need to be forwarded on the backend server host: 6969, 6970 and 6971. 6972 needs to be forwarded on the match host instead because of P2P networking. If forwarding is not possible, NAT punching will be attempted to establish connection.
TODO: