Opened 8 years ago

Closed 8 years ago

Last modified 7 years 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 8 years ago.
some stylefixes
3575_differentPorts.patch (17.4 KB ) - added by Imarok 8 years ago.
3575_differentPorts_v2.1.patch (17.9 KB ) - added by Imarok 8 years 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 8 years ago.
renamed the config values
3575_differentPorts_v2.3.patch (18.3 KB ) - added by Imarok 8 years ago.
Retrieve default port from c++ part. New lines for SwitchGuiPage
3575_differentPorts_v2.5.patch (18.7 KB ) - added by Imarok 8 years ago.
use only u16. Added tooltip for port input field. Only allow valid ports
wip.v1.patch (14.7 KB ) - added by elexis 8 years 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 by elexis, 8 years ago

Component: Core engineNetwork

(set component to network)

by Imarok, 8 years ago

Attachment: prelobby.js.patch added

some stylefixes

comment:2 by elexis, 8 years ago

In 18345:

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

Fix a typo and use let instead of var.

comment:3 by Imarok, 8 years ago

Owner: set to Imarok

by Imarok, 8 years ago

Attachment: 3575_differentPorts.patch added

comment:4 by Imarok, 8 years ago

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

comment:5 by Imarok, 8 years ago

The patch is based on elexis' wip patch

by Imarok, 8 years ago

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

by Imarok, 8 years ago

renamed the config values

by Imarok, 8 years ago

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

by Imarok, 8 years ago

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

comment:6 by Imarok, 8 years ago

Milestone: BacklogAlpha 21

comment:7 by elexis, 8 years ago

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 by elexis, 8 years ago

Resolution: fixed
Status: newclosed

In 18372:

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

by elexis, 8 years ago

Attachment: wip.v1.patch added

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

comment:9 by elexis, 8 years ago

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 by scythetwirler, 7 years ago

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:

  • 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
Version 0, edited 7 years ago by scythetwirler (next)

comment:11 by elexis, 7 years ago

Nope, this ticket is entirely done

Note: See TracTickets for help on using tickets.