From 5ae0b84466e3af9d15209425452510aa768112f8 Mon Sep 17 00:00:00 2001 From: doteq Date: Mon, 8 May 2023 15:18:04 +0200 Subject: [PATCH] Add proxy related configuration and Avalonia settings UI --- src/Ryujinx.Ava/AppHost.cs | 3 + .../UI/ViewModels/SettingsViewModel.cs | 20 ++++++ .../Views/Settings/SettingsNetworkView.axaml | 64 ++++++++++++++----- src/Ryujinx.HLE/HLEConfiguration.cs | 22 +++++++ src/Ryujinx.Headless.SDL2/Options.cs | 9 +++ src/Ryujinx.Headless.SDL2/Program.cs | 3 + .../Configuration/ConfigurationFileFormat.cs | 18 +++++- .../Configuration/ConfigurationState.cs | 38 +++++++++++ src/Ryujinx/Ui/MainWindow.cs | 3 + 9 files changed, 164 insertions(+), 16 deletions(-) diff --git a/src/Ryujinx.Ava/AppHost.cs b/src/Ryujinx.Ava/AppHost.cs index 0955fb270..837d371f8 100644 --- a/src/Ryujinx.Ava/AppHost.cs +++ b/src/Ryujinx.Ava/AppHost.cs @@ -740,6 +740,9 @@ namespace Ryujinx.Ava ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnableInternetAccess, + ConfigurationState.Instance.System.EnableHttpProxy, + ConfigurationState.Instance.System.HttpProxyIpAddress, + ConfigurationState.Instance.System.HttpProxyPort, ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.SystemTimeOffset, diff --git a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs index 89392f6b2..7ded90a4c 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/SettingsViewModel.cs @@ -55,6 +55,7 @@ namespace Ryujinx.Ava.UI.ViewModels public event Action CloseWindow; public event Action SaveSettingsEvent; private int _networkInterfaceIndex; + private bool _enableProxy; public int ResolutionScale { @@ -272,6 +273,19 @@ namespace Ryujinx.Ava.UI.ViewModels } } + public bool EnableProxy + { + get => _enableProxy; + set + { + _enableProxy = value; + OnPropertyChanged(); + } + } + + public string ProxyIpAddress { get; set; } + public int ProxyPort { get; set; } + public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this() { _virtualFileSystem = virtualFileSystem; @@ -436,6 +450,9 @@ namespace Ryujinx.Ava.UI.ViewModels // Network EnableInternetAccess = config.System.EnableInternetAccess; + EnableProxy = config.System.EnableHttpProxy; + ProxyIpAddress = config.System.HttpProxyIpAddress; + ProxyPort = config.System.HttpProxyPort; // Logging EnableFileLog = config.Logger.EnableFileLog; @@ -536,6 +553,9 @@ namespace Ryujinx.Ava.UI.ViewModels // Network config.System.EnableInternetAccess.Value = EnableInternetAccess; + config.System.EnableHttpProxy.Value = EnableProxy; + config.System.HttpProxyIpAddress.Value = ProxyIpAddress; + config.System.HttpProxyPort.Value = ProxyPort; // Logging config.Logger.EnableFileLog.Value = EnableFileLog; diff --git a/src/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml b/src/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml index ab8a7f6d1..cb3ad90a7 100644 --- a/src/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Settings/SettingsNetworkView.axaml @@ -25,22 +25,56 @@ Orientation="Vertical" Spacing="10"> - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/src/Ryujinx.HLE/HLEConfiguration.cs b/src/Ryujinx.HLE/HLEConfiguration.cs index df8dea6d6..c9b656d02 100644 --- a/src/Ryujinx.HLE/HLEConfiguration.cs +++ b/src/Ryujinx.HLE/HLEConfiguration.cs @@ -102,6 +102,22 @@ namespace Ryujinx.HLE /// internal readonly bool EnableInternetAccess; + + /// + /// Enables or disables sending HTTP requests through a proxy server + /// + internal readonly bool EnableHttpProxy; + + /// + /// IP address of HTTP proxy server + /// + internal readonly string HttpProxyIpAddress; + + /// + /// Port number of HTTP proxy server + /// + internal readonly int HttpProxyPort; + /// /// Control LibHac's integrity check level. /// @@ -178,6 +194,9 @@ namespace Ryujinx.HLE bool enableDockedMode, bool enablePtc, bool enableInternetAccess, + bool enableHttpProxy, + string httpProxyIpAddress, + int httpProxyPort, IntegrityCheckLevel fsIntegrityCheckLevel, int fsGlobalAccessLogMode, long systemTimeOffset, @@ -204,6 +223,9 @@ namespace Ryujinx.HLE EnableDockedMode = enableDockedMode; EnablePtc = enablePtc; EnableInternetAccess = enableInternetAccess; + EnableHttpProxy = enableHttpProxy; + HttpProxyIpAddress = httpProxyIpAddress; + HttpProxyPort = httpProxyPort; FsIntegrityCheckLevel = fsIntegrityCheckLevel; FsGlobalAccessLogMode = fsGlobalAccessLogMode; SystemTimeOffset = systemTimeOffset; diff --git a/src/Ryujinx.Headless.SDL2/Options.cs b/src/Ryujinx.Headless.SDL2/Options.cs index 7dffa1b00..b6651fd62 100644 --- a/src/Ryujinx.Headless.SDL2/Options.cs +++ b/src/Ryujinx.Headless.SDL2/Options.cs @@ -92,6 +92,15 @@ namespace Ryujinx.Headless.SDL2 [Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")] public bool EnableInternetAccess { get; set; } + + [Option("enable-proxy-connection", Required = false, Default = false, HelpText = "Enables using proxy for http requests")] + public bool EnableHttpProxy { get; set; } + + [Option("proxy-ip", Required = false, Default = "127.0.0.1", HelpText = "IP address of HTTP proxy server")] + public string HttpProxyIpAddress { get; set; } + + [Option("proxy-port", Required = false, Default = 8080, HelpText = "Port number of HTTP proxy server")] + public int HttpProxyPortNumber { get; set; } [Option("disable-fs-integrity-checks", Required = false, HelpText = "Disables integrity checks on Game content files.")] public bool DisableFsIntegrityChecks { get; set; } diff --git a/src/Ryujinx.Headless.SDL2/Program.cs b/src/Ryujinx.Headless.SDL2/Program.cs index 643db845f..794ce97bd 100644 --- a/src/Ryujinx.Headless.SDL2/Program.cs +++ b/src/Ryujinx.Headless.SDL2/Program.cs @@ -542,6 +542,9 @@ namespace Ryujinx.Headless.SDL2 !options.DisableDockedMode, !options.DisablePtc, options.EnableInternetAccess, + options.EnableHttpProxy, + options.HttpProxyIpAddress, + options.HttpProxyPortNumber, !options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, options.FsGlobalAccessLogMode, options.SystemTimeOffset, diff --git a/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs b/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs index f0489915d..48a25d106 100644 --- a/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs +++ b/src/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Ui.Common.Configuration /// /// The current version of the file format /// - public const int CurrentVersion = 47; + public const int CurrentVersion = 48; /// /// Version of the configuration file format @@ -195,6 +195,22 @@ namespace Ryujinx.Ui.Common.Configuration /// Enables or disables guest Internet access /// public bool EnableInternetAccess { get; set; } + + /// + /// Enables or disables sending HTTP requests through a proxy server + /// + public bool EnableHttpProxy { get; set; } + + /// + /// IP address of HTTP proxy server + /// + public string HttpProxyIpAddress { get; set; } + + /// + /// Port number of HTTP proxy server + /// + public int HttpProxyPort { get; set; } + /// /// Enables integrity checks on Game content files diff --git a/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs index 146a9b500..fe53f80c8 100644 --- a/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs @@ -322,6 +322,21 @@ namespace Ryujinx.Ui.Common.Configuration /// Enables or disables guest Internet access /// public ReactiveObject EnableInternetAccess { get; private set; } + + /// + /// Enables or disables sending HTTP requests through a proxy server + /// + public ReactiveObject EnableHttpProxy { get; private set; } + + /// + /// IP address of HTTP proxy server + /// + public ReactiveObject HttpProxyIpAddress { get; private set; } + + /// + /// Port number of HTTP proxy server + /// + public ReactiveObject HttpProxyPort { get; private set; } /// /// Enables integrity checks on Game content files @@ -375,6 +390,12 @@ namespace Ryujinx.Ui.Common.Configuration EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc)); EnableInternetAccess = new ReactiveObject(); EnableInternetAccess.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableInternetAccess)); + EnableHttpProxy = new ReactiveObject(); + EnableHttpProxy.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableHttpProxy)); + HttpProxyIpAddress = new ReactiveObject(); + HttpProxyIpAddress.Event += static (sender, e) => LogValueChange(sender, e, nameof(HttpProxyIpAddress)); + HttpProxyPort = new ReactiveObject(); + HttpProxyPort.Event += static (sender, e) => LogValueChange(sender, e, nameof(HttpProxyPort)); EnableFsIntegrityChecks = new ReactiveObject(); EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks)); FsGlobalAccessLogMode = new ReactiveObject(); @@ -669,6 +690,9 @@ namespace Ryujinx.Ui.Common.Configuration EnableMacroHLE = Graphics.EnableMacroHLE, EnablePtc = System.EnablePtc, EnableInternetAccess = System.EnableInternetAccess, + EnableHttpProxy = System.EnableHttpProxy, + HttpProxyIpAddress = System.HttpProxyIpAddress, + HttpProxyPort = System.HttpProxyPort, EnableFsIntegrityChecks = System.EnableFsIntegrityChecks, FsGlobalAccessLogMode = System.FsGlobalAccessLogMode, AudioBackend = System.AudioBackend, @@ -1397,6 +1421,17 @@ namespace Ryujinx.Ui.Common.Configuration configurationFileUpdated = true; } + if (configurationFileFormat.Version < 48) + { + Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 48."); + + configurationFileFormat.EnableHttpProxy = false; + configurationFileFormat.HttpProxyIpAddress = "127.0.0.1"; + configurationFileFormat.HttpProxyPort = 8080; + + configurationFileUpdated = true; + } + Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom; @@ -1434,6 +1469,9 @@ namespace Ryujinx.Ui.Common.Configuration Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE; System.EnablePtc.Value = configurationFileFormat.EnablePtc; System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess; + System.EnableHttpProxy.Value = configurationFileFormat.EnableHttpProxy; + System.HttpProxyIpAddress.Value = configurationFileFormat.HttpProxyIpAddress; + System.HttpProxyPort.Value = configurationFileFormat.HttpProxyPort; System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks; System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode; System.AudioBackend.Value = configurationFileFormat.AudioBackend; diff --git a/src/Ryujinx/Ui/MainWindow.cs b/src/Ryujinx/Ui/MainWindow.cs index f4cb3d072..e8991be99 100644 --- a/src/Ryujinx/Ui/MainWindow.cs +++ b/src/Ryujinx/Ui/MainWindow.cs @@ -585,6 +585,9 @@ namespace Ryujinx.Ui ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnableInternetAccess, + ConfigurationState.Instance.System.EnableHttpProxy, + ConfigurationState.Instance.System.HttpProxyIpAddress, + ConfigurationState.Instance.System.HttpProxyPort, fsIntegrityCheckLevel, ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.SystemTimeOffset,