mas-bandwidth/yojimbo

Question on server binding address

fosheus opened this issue · 4 comments

Hi Glenn,
I was wondering why the binding address of the server must be exactly the address the client will use to connect to the server. For example if I want to host my game over the internet, I must bind the public address. The NAT isn't supposed to fulfill this task ? I looked around the code and I haven't found any parameter so I assume this is deliberate. Is there a magic trick to open the server to the internet without binding the public address ?

Thank you in advance

There is no trick. Yojimbo is designed only for servers that have public IP addresses (eg. dedicated servers running in datacenters). There is no NAT support in yojimbo.

So bad, I think this does not meets the need I have. I was really enjoying the way we can build messages.
Thanks

Hey @fosheus , what I do in development of my multiplayer shooter is:

  • Server-side, just to bind to 127.0.0.1 (or ::1 if you're gonna connect over IPv6),
  • Client-side, pass an array of two addresses to InsecureConnect: first the server's public address, and 127.0.0.1 (or ::1 for IPv6) for the second. This way, a connect token is generated that will pass the check inside netcode_server_process_connection_request_packet, which is probably where you're getting disconnected with the message:
netcode_printf( NETCODE_LOG_LEVEL_DEBUG, "server ignored connection request. server address not in connect token whitelist\n" );

Obviously, this does not punch through NAT nor is it anything remotely related to the problem, this just simply lets you bind the server to localhost without further ado.

This is exactly what I'm looking for, Thank you !!