Files
psxrecomp/runtime/tests/test_lobby_launch_transport.c
Shokunin d9ea46249f Lobby: honour transport "ice" launches (same-NAT peers no longer dial themselves)
The lobby server starts a 2-player room the host relay cannot carry on ICE
(recomp-net-server start_transport, launch transport "ice"). This client
knew only "host" and the legacy server relay. It inferred a relay from
equal host/guest endpoints -- which is exactly what two peers behind one NAT
advertise -- and each peer dialled its own public address: the match stayed
at "linking" forever.

- psx_lobby_launch_transport.h: one pure decision (host / ice / relay /
  direct) with a unit test covering ICE, same-NAT endpoints, host relay and
  the legacy relay cases.
- PsxLobbyJoinInfo.transport_ice; the launch handler records it and never
  turns it into a relay; launch fill and resolve_use_ice start ICE p2p
  (signalled over the lobby) for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 18:22:15 -07:00

32 lines
1.6 KiB
C

#include "psx_lobby_launch_transport.h"
#undef NDEBUG
#include <assert.h>
int main(void)
{
/* ICE launch between two peers behind one NAT: same public endpoint on
* both sides must stay ICE, not turn into a relay to ourselves. */
assert(psx_lobby_launch_transport("ice", "", 0, "136.25.29.198:7778",
"136.25.29.198:7778", "") == PSX_LAUNCH_ICE);
assert(psx_lobby_launch_transport("ice", "", 0, "1.2.3.4:7777", "5.6.7.8:7777", "")
== PSX_LAUNCH_ICE);
/* Host relay is unchanged, even with equal endpoints. */
assert(psx_lobby_launch_transport("host", "", 0, "1.2.3.4:7777", "1.2.3.4:7777", "")
== PSX_LAUNCH_HOST);
/* Legacy server relay: explicit relay_endpoint, caps, or equal rewritten
* endpoints with no transport field. */
assert(psx_lobby_launch_transport("", "9.9.9.9:8777", 0, "", "", "") == PSX_LAUNCH_RELAY);
assert(psx_lobby_launch_transport("", "", 1, "1.2.3.4:7777", "5.6.7.8:7777", "")
== PSX_LAUNCH_RELAY);
assert(psx_lobby_launch_transport("", "", 0, "9.9.9.9:8777", "9.9.9.9:8777", "")
== PSX_LAUNCH_RELAY);
/* ...but not our own bind echoed back, and not unusable ports. */
assert(psx_lobby_launch_transport("", "", 0, "1.2.3.4:7777", "1.2.3.4:7777",
"1.2.3.4:7777") == PSX_LAUNCH_DIRECT);
assert(psx_lobby_launch_transport("", "", 0, "1.2.3.4:0", "1.2.3.4:0", "")
== PSX_LAUNCH_DIRECT);
assert(psx_lobby_launch_transport("", "", 0, "1.2.3.4:7777", "5.6.7.8:7777", "")
== PSX_LAUNCH_DIRECT);
return 0;
}