From f3de49762b1b4ffc0918c158c6051c4530497b74 Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Thu, 28 Nov 2024 00:40:40 +0100 Subject: [PATCH] Bring back force relay option --- .../client/fa/relay/ice/IceAdapterImpl.java | 5 +++++ .../preferences/ForgedAlliancePrefs.java | 13 ++++++++++++ .../preferences/ui/SettingsController.java | 2 ++ .../resources/theme/settings/settings.fxml | 21 +++++++++++++++++++ .../fa/relay/ice/IceAdapterImplTest.java | 6 ++++-- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/faforever/client/fa/relay/ice/IceAdapterImpl.java b/src/main/java/com/faforever/client/fa/relay/ice/IceAdapterImpl.java index 77bcae072e..f94a566a2a 100644 --- a/src/main/java/com/faforever/client/fa/relay/ice/IceAdapterImpl.java +++ b/src/main/java/com/faforever/client/fa/relay/ice/IceAdapterImpl.java @@ -241,6 +241,11 @@ List buildCommand(Path workDirectory, int adapterPort, int gpgPort, int cmd.addAll(standardIceOptions); + if (forgedAlliancePrefs.isForceRelay()) { + cmd.add("--force-relay"); + log.info("Forcing ice adapter relay connection"); + } + if (forgedAlliancePrefs.isShowIceAdapterDebugWindow()) { cmd.add("--debug-window"); cmd.add("--info-window"); diff --git a/src/main/java/com/faforever/client/preferences/ForgedAlliancePrefs.java b/src/main/java/com/faforever/client/preferences/ForgedAlliancePrefs.java index 6c568e51d8..c1200e1f50 100644 --- a/src/main/java/com/faforever/client/preferences/ForgedAlliancePrefs.java +++ b/src/main/java/com/faforever/client/preferences/ForgedAlliancePrefs.java @@ -22,6 +22,7 @@ public class ForgedAlliancePrefs { private final ObjectProperty preferencesFile = new SimpleObjectProperty<>(); private final ObjectProperty vaultBaseDirectory = new SimpleObjectProperty<>(); private final BooleanProperty warnNonAsciiVaultPath = new SimpleBooleanProperty(true); + private final BooleanProperty forceRelay = new SimpleBooleanProperty(false); private final BooleanProperty autoDownloadMaps = new SimpleBooleanProperty(true); private final BooleanProperty allowIpv6 = new SimpleBooleanProperty(false); @@ -51,6 +52,18 @@ public ObjectProperty preferencesFileProperty() { return preferencesFile; } + public boolean isForceRelay() { + return forceRelay.get(); + } + + public void setForceRelay(boolean forceRelay) { + this.forceRelay.set(forceRelay); + } + + public BooleanProperty forceRelayProperty() { + return forceRelay; + } + public boolean isAutoDownloadMaps() { return autoDownloadMaps.get(); } diff --git a/src/main/java/com/faforever/client/preferences/ui/SettingsController.java b/src/main/java/com/faforever/client/preferences/ui/SettingsController.java index 9e1083a9d3..b62ba9dd8d 100644 --- a/src/main/java/com/faforever/client/preferences/ui/SettingsController.java +++ b/src/main/java/com/faforever/client/preferences/ui/SettingsController.java @@ -119,6 +119,7 @@ public class SettingsController extends NodeController { public Toggle randomColorsToggle; public Toggle defaultColorsToggle; public CheckBox hideFoeToggle; + public CheckBox forceRelayToggle; public TextField dataLocationTextField; public TextField gameLocationTextField; public TextField vaultLocationTextField; @@ -308,6 +309,7 @@ private void bindGeneralPreferences() { private void bindGamePreferences() { ForgedAlliancePrefs forgedAlliancePrefs = preferences.getForgedAlliance(); + forceRelayToggle.selectedProperty().bindBidirectional(forgedAlliancePrefs.forceRelayProperty()); gameLocationTextField.textProperty() .bindBidirectional(forgedAlliancePrefs.installationPathProperty(), PATH_STRING_CONVERTER); autoDownloadMapsToggle.selectedProperty().bindBidirectional(forgedAlliancePrefs.autoDownloadMapsProperty()); diff --git a/src/main/resources/theme/settings/settings.fxml b/src/main/resources/theme/settings/settings.fxml index eaf2330767..d56b46216c 100644 --- a/src/main/resources/theme/settings/settings.fxml +++ b/src/main/resources/theme/settings/settings.fxml @@ -854,6 +854,27 @@ + + + + + + + + + + + + diff --git a/src/test/java/com/faforever/client/fa/relay/ice/IceAdapterImplTest.java b/src/test/java/com/faforever/client/fa/relay/ice/IceAdapterImplTest.java index 99176e20ae..fbc9a961a6 100644 --- a/src/test/java/com/faforever/client/fa/relay/ice/IceAdapterImplTest.java +++ b/src/test/java/com/faforever/client/fa/relay/ice/IceAdapterImplTest.java @@ -118,6 +118,7 @@ public void testBuildCommand() throws Exception { PlayerInfo currentPlayer = PlayerInfoBuilder.create().defaultValues().get(); when(playerService.getCurrentPlayer()).thenReturn(currentPlayer); when(tokenRetriever.getRefreshedTokenValue()).thenReturn(Mono.just("someToken")); + forgedAlliancePrefs.setForceRelay(true); forgedAlliancePrefs.setShowIceAdapterDebugWindow(true); List command = instance.buildCommand(Path.of("."), 0, 0, 4711); @@ -142,8 +143,9 @@ public void testBuildCommand() throws Exception { assertEquals("someToken", command.get(16)); assertEquals("--icebreaker-base-url", command.get(17)); assertEquals("http://faf-api/ice", command.get(18)); - assertEquals("--debug-window", command.get(19)); - assertEquals("--info-window", command.get(20)); + assertEquals("--force-relay", command.get(19)); + assertEquals("--debug-window", command.get(20)); + assertEquals("--info-window", command.get(21)); } @Test