Opened 2 years ago

Closed 18 months ago

Last modified 13 months ago

#3575 closed enhancement (fixed)

[PATCH] Allow hosting on different UDP ports

Reported by: elexis Owned by: Imarok
Priority: Nice to Have Milestone: Alpha 21
Component: Network Keywords: patch
Cc: Patch:

Description

It would be nice to be able to host on different UDP ports.

Once we have dedicated servers (#3556), we could host multiple games simultaneously on a single server with a single IP address.

To be done for this ticket:

  • Hosting players entering the gamesetup in lobbygames need to send the port they use to the lobby server
  • The lobby bot needs to send the port in the gamelist
  • Players that want to join a lobbied game need to use this port when joining

If we could do this in a19, then we could use the dedicated server after the release. Besides allowing users to play that don't find a server to join and can't host (#2305), it would also allow us to switch from a free-for-all lobby to a lobby with only certified hosts. This means that potentially malicious players won't be able to see the IP addresses of other players (they will only be able to see the IPs of the certified hosts, which might be a single wfg server in harsh times).

Attachments (7)

prelobby.js.patch (4.3 KB) - added by Imarok 18 months ago.
some stylefixes
3575_differentPorts.patch (17.4 KB) - added by Imarok 18 months ago.
3575_differentPorts_v2.1.patch (17.9 KB) - added by Imarok 18 months ago.
using u16 instead of unsigned int. Allow to save and restore the port
3575_differentPorts_v2.2.patch (17.9 KB) - added by Imarok 18 months ago.
renamed the config values
3575_differentPorts_v2.3.patch (18.3 KB) - added by Imarok 18 months ago.
Retrieve default port from c++ part. New lines for SwitchGuiPage?
3575_differentPorts_v2.5.patch (18.7 KB) - added by Imarok 18 months ago.
use only u16. Added tooltip for port input field. Only allow valid ports
wip.v1.patch (14.7 KB) - added by elexis 18 months ago.
(This was the mentioned wip patch from november 2015 on which the patch above was based on)

Download all attachments as: .zip

Change History (18)

comment:1 Changed 18 months ago by elexis

Component: Core engineNetwork

(set component to network)

Changed 18 months ago by Imarok

Attachment: prelobby.js.patch added

some stylefixes

comment:2 Changed 18 months ago by elexis

In 18345:

Lobby cleanup. Based on patch by Imarok, refs #3575.

Fix a typo and use let instead of var.

comment:3 Changed 18 months ago by Imarok

Owner: set to Imarok

Changed 18 months ago by Imarok

Attachment: 3575_differentPorts.patch added

comment:4 Changed 18 months ago by Imarok

Keywords: review patch added
Summary: Allow hosting on different UDP ports[PATCH] Allow hosting on different UDP ports

comment:5 Changed 18 months ago by Imarok

The patch is based on elexis' wip patch

Changed 18 months ago by Imarok

using u16 instead of unsigned int. Allow to save and restore the port

Changed 18 months ago by Imarok

renamed the config values

Changed 18 months ago by Imarok

Retrieve default port from c++ part. New lines for SwitchGuiPage?

Changed 18 months ago by Imarok

use only u16. Added tooltip for port input field. Only allow valid ports

comment:6 Changed 18 months ago by Imarok

Milestone: BacklogAlpha 21

comment:7 Changed 18 months ago by elexis

In 18371:

Implement multiplayer dialog retries, fixes #4035, refs #3575.

Cleanup:
Move all code to hide elements to switchSetupPage.
Remove nasty second argument from switchSetupPage by just hiding every page.
To avoid another state variable, immediately set g_IsConnecting to true by calling startConnectionStatus when trying to host.
Use .some instead of a loop.

comment:8 Changed 18 months ago by elexis

Resolution: fixed
Status: newclosed

In 18372:

Host on arbitrary UDP ports. Patch in cooperation with Imarok, fixes #3575.

Changed 18 months ago by elexis

Attachment: wip.v1.patch added

(This was the mentioned wip patch from november 2015 on which the patch above was based on)

comment:9 Changed 18 months ago by elexis

Keywords: review removed
Type: defectenhancement

Thanks picking this up and finishing the patch! Here the things changed:

Ports:

  • Unix port < 1024: Philip is right, on most unix systems you can't host on ports < 1024 without root rights. To run with root permissions, a check from main.cpp needs to be removed. To allow retries comfortably, #4035 was implemented.

GUI:

  • The GUI object positions are ugly. The port is shown in the wrong place (vertical space between two fields). Since only one of the two host wrapper things can be shown simultaneously, they can have the same position. The port field can be placed below that. In the future the resizeMoreOptionsWindow from gamesetup.js might be reused.
  • Showing the hostPortWrapper is not necessary. The other GUI objects only have a wrapper because their visbility depends on whether it's a lobby game or not. Therefore the GUI object should only be added to get cleaner XML, but it's not necessary otherwise (thus removing the name and the hidden attribute).
  • All labels are placed wrong (4px vertical), not the fault of this patch though.

Port validation:

  • getValidPort should be moved to network.js and use isNaN
  • Not convinced we need the translate("The game's port is missing.") error for the lobby. Just replace with default like everywhere else.
  • Added calls to validate the port and optionally replace it with the default on load or when pressed enter.

C++:

  • Switched the server and port argument of NetSession and used const for consistency.

comment:10 Changed 13 months ago by scythetwirler

Was this done in this ticket? (I couldn't find any modifications to the lobby bot in the commits here)

To be done for this ticket:

  • The lobby bot needs to send the port in the gamelist
  • Players that want to join a lobbied game need to use this port when joining
Last edited 13 months ago by scythetwirler (previous) (diff)

comment:11 Changed 13 months ago by elexis

Nope, this ticket is entirely done

Note: See TracTickets for help on using tickets.