Skip to content

feat: Allow specifying a different listen address in the adapter #1605

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

Merged
merged 5 commits into from
Jan 26, 2022

Conversation

simon-lemay-unity
Copy link
Contributor

MTT-1902

This PR introduces the possibility of listening to a different address than the one clients will connect to.

Currently you specify an IP address and a port and this endpoint is both what clients will connect to, and what the server will bind and listen on. Typically that's what you want, but there are situations where a user might not want these to be the same. One is if a user wants their server to listen to all addresses (0.0.0.0). Another is if establishing connections through a NAT with port forwarding enabled (clients will connect to the WAN address, but server will listen on the LAN address).

It is possible to do that today by calling SetConnectionData with different values at runtime depending on if we are a server or client, but there's currently no way to do so from the inspector, which is what this PR is addressing.

Changelog

com.unity.netcode.adapter.utp

  • Added: A new 'Listen Address' field under 'Connection Data' in the inspector has been added to specify the address a server should listen to, in case it differs from the main 'Address' field. The SetConnectionData method has been updated accordingly to take an optional parameter to specify that listen address.
  • Changed: Implicit conversions between ConnectionAddressData and NetworkEndPoint are now deprecated, since their semantics are no longer clear with the introduction of the new ListenAddress field (see above).

(A note on the deprecation above: I would be exceedingly surprised if these were actually used by any user. They were only used to convert to/from the UTP NetworkEndPoint type internally to make the code "cleaner". Unfortunately they are public, so proper deprecation is in order.)

Testing and Documentation

  • Includes integration tests.
  • AFAIK, no documentation changes or additions are necessary.

@0xFA11 0xFA11 enabled auto-merge (squash) January 26, 2022 18:49
@0xFA11 0xFA11 merged commit ab93bd5 into develop Jan 26, 2022
@0xFA11 0xFA11 deleted the feat/listen-address-adapter branch January 26, 2022 20:24
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

Successfully merging this pull request may close these issues.

2 participants