From cd9655dc2e473b37048b7e9c92c515579e2fafd2 Mon Sep 17 00:00:00 2001 From: geneotech Date: Tue, 18 Jun 2024 20:02:34 +0200 Subject: [PATCH] Dockerfile: Mux the ports by default #286 [ds only] --- Dockerfile | 5 ++++- cmake/dockerfile_server_config.lua | 3 +++ hypersomnia/default_config.lua | 2 +- src/application/setups/server/server_setup.cpp | 14 +++++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index bf5f8da88..42b78a7cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,9 @@ COPY cmake/dockerfile_server_config.lua /root/.config/Hypersomnia/user/config.fo CMD ["./Hypersomnia-Headless.AppImage", "--appimage-extract-and-run"] +# For native clients via POSIX sockets EXPOSE 8412/udp -EXPOSE 9000-9010/udp + +# For Web clients via WebRTC +EXPOSE 9000/udp diff --git a/cmake/dockerfile_server_config.lua b/cmake/dockerfile_server_config.lua index a7c4b4df0..6e010b803 100644 --- a/cmake/dockerfile_server_config.lua +++ b/cmake/dockerfile_server_config.lua @@ -5,6 +5,9 @@ return { last_activity = "MAIN_MENU", server = { server_name = "Server" + + webrtc_udp_mux = true, + webrtc_port_range_begin = 9000 }, server_private = { master_rcon_password = "1234", diff --git a/hypersomnia/default_config.lua b/hypersomnia/default_config.lua index 930f3d506..03826054f 100644 --- a/hypersomnia/default_config.lua +++ b/hypersomnia/default_config.lua @@ -791,7 +791,7 @@ treat_as_music_sounds_longer_than_secs = 5, allow_webrtc_clients = true, -- If true, connections will use only single UDP port. - -- In that case set webrtc_port_range_begin and webrtc_port_range_end to the same value. + -- In that case, the chosen port will be set to webrtc_port_range_begin. webrtc_udp_mux = false, webrtc_port_range_begin = 9000, diff --git a/src/application/setups/server/server_setup.cpp b/src/application/setups/server/server_setup.cpp index fb056a8fe..945aa6379 100644 --- a/src/application/setups/server/server_setup.cpp +++ b/src/application/setups/server/server_setup.cpp @@ -401,11 +401,19 @@ class webrtc_server_detail { const std::string& signaling_server_url, const std::vector& iceServers, const port_type ports_begin, - const port_type ports_end, + port_type ports_end, const bool udp_mux ) { - LOG("Web port range: %x-%x", ports_begin, ports_end); - LOG("Web UDP port mux: %x", udp_mux); + LOG("Web UDP port muxing: %x", udp_mux); + + if (udp_mux) { + ports_end = ports_begin; + LOG("Web port range: %x (UDP muxing was enabled)", ports_begin); + } + else { + LOG("Web port range: %x-%x", ports_begin, ports_end); + } + self->config.iceServers = iceServers; #if PLATFORM_WEB (void)ports_begin;