Add proxy related configuration and Avalonia settings UI

This commit is contained in:
doteq 2023-05-08 15:18:04 +02:00
parent a8950d6ac4
commit 5ae0b84466
9 changed files with 164 additions and 16 deletions

View file

@ -740,6 +740,9 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnablePtc,
ConfigurationState.Instance.System.EnableInternetAccess, 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.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset, ConfigurationState.Instance.System.SystemTimeOffset,

View file

@ -55,6 +55,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public event Action CloseWindow; public event Action CloseWindow;
public event Action SaveSettingsEvent; public event Action SaveSettingsEvent;
private int _networkInterfaceIndex; private int _networkInterfaceIndex;
private bool _enableProxy;
public int ResolutionScale 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() public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this()
{ {
_virtualFileSystem = virtualFileSystem; _virtualFileSystem = virtualFileSystem;
@ -436,6 +450,9 @@ namespace Ryujinx.Ava.UI.ViewModels
// Network // Network
EnableInternetAccess = config.System.EnableInternetAccess; EnableInternetAccess = config.System.EnableInternetAccess;
EnableProxy = config.System.EnableHttpProxy;
ProxyIpAddress = config.System.HttpProxyIpAddress;
ProxyPort = config.System.HttpProxyPort;
// Logging // Logging
EnableFileLog = config.Logger.EnableFileLog; EnableFileLog = config.Logger.EnableFileLog;
@ -536,6 +553,9 @@ namespace Ryujinx.Ava.UI.ViewModels
// Network // Network
config.System.EnableInternetAccess.Value = EnableInternetAccess; config.System.EnableInternetAccess.Value = EnableInternetAccess;
config.System.EnableHttpProxy.Value = EnableProxy;
config.System.HttpProxyIpAddress.Value = ProxyIpAddress;
config.System.HttpProxyPort.Value = ProxyPort;
// Logging // Logging
config.Logger.EnableFileLog.Value = EnableFileLog; config.Logger.EnableFileLog.Value = EnableFileLog;

View file

@ -25,6 +25,7 @@
Orientation="Vertical" Orientation="Vertical"
Spacing="10"> Spacing="10">
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabNetworkConnection}" /> <TextBlock Classes="h1" Text="{locale:Locale SettingsTabNetworkConnection}" />
<StackPanel Margin="10,0,0,0" Orientation="Vertical">
<CheckBox Margin="10,0,0,0" IsChecked="{Binding EnableInternetAccess}"> <CheckBox Margin="10,0,0,0" IsChecked="{Binding EnableInternetAccess}">
<TextBlock Text="{locale:Locale SettingsTabSystemEnableInternetAccess}" <TextBlock Text="{locale:Locale SettingsTabSystemEnableInternetAccess}"
ToolTip.Tip="{locale:Locale EnableInternetAccessTooltip}" /> ToolTip.Tip="{locale:Locale EnableInternetAccessTooltip}" />
@ -41,6 +42,39 @@
Width="250" /> Width="250" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<Separator Height="1" />
<StackPanel Orientation="Vertical" Spacing="2">
<TextBlock Classes="h1" Text="Proxy" />
</StackPanel>
<StackPanel
Margin="10,0,0,0"
HorizontalAlignment="Stretch"
Orientation="Vertical">
<CheckBox Margin="10,0,0,0" IsChecked="{Binding EnableProxy}">
<TextBlock Text="Proxy enabled"
ToolTip.Tip="Sends all HTTP requests through the proxy server. Useful for intercepting network traffic and mocking responses." />
</CheckBox>
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center"
Text="Proxy address"
ToolTip.Tip="IP address and port of your HTTP proxy server"
Width="200" />
<TextBox Margin="0,0,5,0"
Text="{Binding ProxyIpAddress}"
Width="250"
Watermark="IP address"
ToolTip.Tip="IP address"
IsEnabled="{Binding EnableProxy}"/>
<NumericUpDown Width="50"
Value="{Binding ProxyPort}"
ShowButtonSpinner="False"
Minimum="0"
Maximum="65535"
ToolTip.Tip="Port"
IsEnabled="{Binding EnableProxy}"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border> </Border>
</ScrollViewer> </ScrollViewer>
</UserControl> </UserControl>

View file

@ -102,6 +102,22 @@ namespace Ryujinx.HLE
/// </summary> /// </summary>
internal readonly bool EnableInternetAccess; internal readonly bool EnableInternetAccess;
/// <summary>
/// Enables or disables sending HTTP requests through a proxy server
/// </summary>
internal readonly bool EnableHttpProxy;
/// <summary>
/// IP address of HTTP proxy server
/// </summary>
internal readonly string HttpProxyIpAddress;
/// <summary>
/// Port number of HTTP proxy server
/// </summary>
internal readonly int HttpProxyPort;
/// <summary> /// <summary>
/// Control LibHac's integrity check level. /// Control LibHac's integrity check level.
/// </summary> /// </summary>
@ -178,6 +194,9 @@ namespace Ryujinx.HLE
bool enableDockedMode, bool enableDockedMode,
bool enablePtc, bool enablePtc,
bool enableInternetAccess, bool enableInternetAccess,
bool enableHttpProxy,
string httpProxyIpAddress,
int httpProxyPort,
IntegrityCheckLevel fsIntegrityCheckLevel, IntegrityCheckLevel fsIntegrityCheckLevel,
int fsGlobalAccessLogMode, int fsGlobalAccessLogMode,
long systemTimeOffset, long systemTimeOffset,
@ -204,6 +223,9 @@ namespace Ryujinx.HLE
EnableDockedMode = enableDockedMode; EnableDockedMode = enableDockedMode;
EnablePtc = enablePtc; EnablePtc = enablePtc;
EnableInternetAccess = enableInternetAccess; EnableInternetAccess = enableInternetAccess;
EnableHttpProxy = enableHttpProxy;
HttpProxyIpAddress = httpProxyIpAddress;
HttpProxyPort = httpProxyPort;
FsIntegrityCheckLevel = fsIntegrityCheckLevel; FsIntegrityCheckLevel = fsIntegrityCheckLevel;
FsGlobalAccessLogMode = fsGlobalAccessLogMode; FsGlobalAccessLogMode = fsGlobalAccessLogMode;
SystemTimeOffset = systemTimeOffset; SystemTimeOffset = systemTimeOffset;

View file

@ -93,6 +93,15 @@ namespace Ryujinx.Headless.SDL2
[Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")] [Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")]
public bool EnableInternetAccess { get; set; } 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.")] [Option("disable-fs-integrity-checks", Required = false, HelpText = "Disables integrity checks on Game content files.")]
public bool DisableFsIntegrityChecks { get; set; } public bool DisableFsIntegrityChecks { get; set; }

View file

@ -542,6 +542,9 @@ namespace Ryujinx.Headless.SDL2
!options.DisableDockedMode, !options.DisableDockedMode,
!options.DisablePtc, !options.DisablePtc,
options.EnableInternetAccess, options.EnableInternetAccess,
options.EnableHttpProxy,
options.HttpProxyIpAddress,
options.HttpProxyPortNumber,
!options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, !options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
options.FsGlobalAccessLogMode, options.FsGlobalAccessLogMode,
options.SystemTimeOffset, options.SystemTimeOffset,

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Ui.Common.Configuration
/// <summary> /// <summary>
/// The current version of the file format /// The current version of the file format
/// </summary> /// </summary>
public const int CurrentVersion = 47; public const int CurrentVersion = 48;
/// <summary> /// <summary>
/// Version of the configuration file format /// Version of the configuration file format
@ -196,6 +196,22 @@ namespace Ryujinx.Ui.Common.Configuration
/// </summary> /// </summary>
public bool EnableInternetAccess { get; set; } public bool EnableInternetAccess { get; set; }
/// <summary>
/// Enables or disables sending HTTP requests through a proxy server
/// </summary>
public bool EnableHttpProxy { get; set; }
/// <summary>
/// IP address of HTTP proxy server
/// </summary>
public string HttpProxyIpAddress { get; set; }
/// <summary>
/// Port number of HTTP proxy server
/// </summary>
public int HttpProxyPort { get; set; }
/// <summary> /// <summary>
/// Enables integrity checks on Game content files /// Enables integrity checks on Game content files
/// </summary> /// </summary>

View file

@ -323,6 +323,21 @@ namespace Ryujinx.Ui.Common.Configuration
/// </summary> /// </summary>
public ReactiveObject<bool> EnableInternetAccess { get; private set; } public ReactiveObject<bool> EnableInternetAccess { get; private set; }
/// <summary>
/// Enables or disables sending HTTP requests through a proxy server
/// </summary>
public ReactiveObject<bool> EnableHttpProxy { get; private set; }
/// <summary>
/// IP address of HTTP proxy server
/// </summary>
public ReactiveObject<string> HttpProxyIpAddress { get; private set; }
/// <summary>
/// Port number of HTTP proxy server
/// </summary>
public ReactiveObject<int> HttpProxyPort { get; private set; }
/// <summary> /// <summary>
/// Enables integrity checks on Game content files /// Enables integrity checks on Game content files
/// </summary> /// </summary>
@ -375,6 +390,12 @@ namespace Ryujinx.Ui.Common.Configuration
EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc)); EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc));
EnableInternetAccess = new ReactiveObject<bool>(); EnableInternetAccess = new ReactiveObject<bool>();
EnableInternetAccess.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableInternetAccess)); EnableInternetAccess.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableInternetAccess));
EnableHttpProxy = new ReactiveObject<bool>();
EnableHttpProxy.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableHttpProxy));
HttpProxyIpAddress = new ReactiveObject<string>();
HttpProxyIpAddress.Event += static (sender, e) => LogValueChange(sender, e, nameof(HttpProxyIpAddress));
HttpProxyPort = new ReactiveObject<int>();
HttpProxyPort.Event += static (sender, e) => LogValueChange(sender, e, nameof(HttpProxyPort));
EnableFsIntegrityChecks = new ReactiveObject<bool>(); EnableFsIntegrityChecks = new ReactiveObject<bool>();
EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks)); EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks));
FsGlobalAccessLogMode = new ReactiveObject<int>(); FsGlobalAccessLogMode = new ReactiveObject<int>();
@ -669,6 +690,9 @@ namespace Ryujinx.Ui.Common.Configuration
EnableMacroHLE = Graphics.EnableMacroHLE, EnableMacroHLE = Graphics.EnableMacroHLE,
EnablePtc = System.EnablePtc, EnablePtc = System.EnablePtc,
EnableInternetAccess = System.EnableInternetAccess, EnableInternetAccess = System.EnableInternetAccess,
EnableHttpProxy = System.EnableHttpProxy,
HttpProxyIpAddress = System.HttpProxyIpAddress,
HttpProxyPort = System.HttpProxyPort,
EnableFsIntegrityChecks = System.EnableFsIntegrityChecks, EnableFsIntegrityChecks = System.EnableFsIntegrityChecks,
FsGlobalAccessLogMode = System.FsGlobalAccessLogMode, FsGlobalAccessLogMode = System.FsGlobalAccessLogMode,
AudioBackend = System.AudioBackend, AudioBackend = System.AudioBackend,
@ -1397,6 +1421,17 @@ namespace Ryujinx.Ui.Common.Configuration
configurationFileUpdated = true; 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; Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScale.Value = configurationFileFormat.ResScale;
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom; Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
@ -1434,6 +1469,9 @@ namespace Ryujinx.Ui.Common.Configuration
Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE; Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE;
System.EnablePtc.Value = configurationFileFormat.EnablePtc; System.EnablePtc.Value = configurationFileFormat.EnablePtc;
System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess; 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.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks;
System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode; System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode;
System.AudioBackend.Value = configurationFileFormat.AudioBackend; System.AudioBackend.Value = configurationFileFormat.AudioBackend;

View file

@ -585,6 +585,9 @@ namespace Ryujinx.Ui
ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnablePtc,
ConfigurationState.Instance.System.EnableInternetAccess, ConfigurationState.Instance.System.EnableInternetAccess,
ConfigurationState.Instance.System.EnableHttpProxy,
ConfigurationState.Instance.System.HttpProxyIpAddress,
ConfigurationState.Instance.System.HttpProxyPort,
fsIntegrityCheckLevel, fsIntegrityCheckLevel,
ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset, ConfigurationState.Instance.System.SystemTimeOffset,