lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
662 stars 68 forks source link

Remove network host check #78

Closed Marekkon5 closed 1 year ago

Marekkon5 commented 1 year ago

Hello, I don't really get the purprose of this check (in unsecure scenarios) and it makes testing, or connecting remotely + locally impossible.

lucaspoffo commented 1 year ago

This check ensures a valid ConnectToken is only used in the server it was generated for, malicious users could use valid tokens in servers they are not supposed to enter. But, you are right, with insecure connections this check is not useful. There are 2 things that we could do:

  1. Add a config to disable this like disable_host_address_check
  2. Add the possibility to add multiple addresses to the server so that you can add the local address and the remote one

The first is probably easier

Serverator commented 1 year ago

Right now the only way to check if NetcodeServer is using secure connection is to check if connect_key is all zeroed out.

Probably a good idea to add an enum that specifies what connection server is using. That enum can also hold connect_key, as it's not used in unsecure connections.

Also, is public address even used when using unsecure connections? I checked through the code and it seems that it's only used in this host check. If so, I think it'll safe to move it to that connection type enum too.

If this sounds reasonable I can start working on this.

lucaspoffo commented 1 year ago

Done in #102, when choosing the unsecure option, the host check is disabled.