Update RyuSocks to v0.3.1-alpha

This commit is contained in:
TSR Berry 2024-08-14 03:53:56 +02:00
parent ac67adae86
commit fe0c34c639
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2
2 changed files with 84 additions and 20 deletions

View file

@ -36,7 +36,7 @@
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" /> <PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
<PackageVersion Include="Ryujinx.GtkSharp" Version="3.24.24.59-ryujinx" /> <PackageVersion Include="Ryujinx.GtkSharp" Version="3.24.24.59-ryujinx" />
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" /> <PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
<PackageVersion Include="RyuSocks" Version="0.2.0-alpha" /> <PackageVersion Include="RyuSocks" Version="0.3.1-alpha" />
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" /> <PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
<PackageVersion Include="shaderc.net" Version="0.1.0" /> <PackageVersion Include="shaderc.net" Version="0.1.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" /> <PackageVersion Include="SharpZipLib" Version="1.4.2" />

View file

@ -23,13 +23,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
public SocksClient ProxyClient { get; } public SocksClient ProxyClient { get; }
// TODO: Make sure Blocking is used properly public bool Blocking { get => ProxyClient.Blocking; set => ProxyClient.Blocking = value; }
public bool Blocking { get; set; }
public int RefCount { get; set; } public int RefCount { get; set; }
// TODO: Assign LocalEndPoint and RemoteEndPoint public IPEndPoint RemoteEndPoint => (IPEndPoint)ProxyClient.ProxiedRemoteEndPoint;
public IPEndPoint RemoteEndPoint { get; private set; } public IPEndPoint LocalEndPoint => (IPEndPoint)ProxyClient.ProxiedLocalEndPoint;
public IPEndPoint LocalEndPoint { get; private set; }
public AddressFamily AddressFamily => ProxyClient.AddressFamily; public AddressFamily AddressFamily => ProxyClient.AddressFamily;
public SocketType SocketType => ProxyClient.SocketType; public SocketType SocketType => ProxyClient.SocketType;
@ -70,11 +68,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
RefCount = 1; RefCount = 1;
} }
private ManagedProxySocket(ManagedProxySocket oldSocket, SocksClient proxyClient) private ManagedProxySocket(SocksClient proxyClient)
{ {
ProxyClient = proxyClient; ProxyClient = proxyClient;
LocalEndPoint = oldSocket.LocalEndPoint;
RemoteEndPoint = oldSocket.RemoteEndPoint;
_acceptedConnection = true; _acceptedConnection = true;
RefCount = 1; RefCount = 1;
} }
@ -273,22 +269,82 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary>
/// Adapted from <see cref="ManagedSocket.GetSocketOption"/>
/// </summary>
public LinuxError GetSocketOption(BsdSocketOption option, SocketOptionLevel level, Span<byte> optionValue) public LinuxError GetSocketOption(BsdSocketOption option, SocketOptionLevel level, Span<byte> optionValue)
{ {
// TODO: Call ProxyClient.GetSocketOption() when it's implemented try
throw new NotImplementedException(); {
LinuxError result = WinSockHelper.ValidateSocketOption(option, level, write: false);
if (result != LinuxError.SUCCESS)
{
Logger.Warning?.Print(LogClass.ServiceBsd, $"Invalid GetSockOpt Option: {option} Level: {level}");
return result;
} }
if (!WinSockHelper.TryConvertSocketOption(option, level, out SocketOptionName optionName))
{
Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported GetSockOpt Option: {option} Level: {level}");
optionValue.Clear();
return LinuxError.SUCCESS;
}
byte[] tempOptionValue = new byte[optionValue.Length];
ProxyClient.GetSocketOption(level, optionName, tempOptionValue);
tempOptionValue.AsSpan().CopyTo(optionValue);
return LinuxError.SUCCESS;
}
catch (SocketException exception)
{
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
}
}
/// <summary>
/// Adapted from <see cref="ManagedSocket.SetSocketOption"/>
/// </summary>
public LinuxError SetSocketOption(BsdSocketOption option, SocketOptionLevel level, ReadOnlySpan<byte> optionValue) public LinuxError SetSocketOption(BsdSocketOption option, SocketOptionLevel level, ReadOnlySpan<byte> optionValue)
{ {
// TODO: Call ProxyClient.SetSocketOption() when it's implemented try
throw new NotImplementedException(); {
LinuxError result = WinSockHelper.ValidateSocketOption(option, level, write: true);
if (result != LinuxError.SUCCESS)
{
Logger.Warning?.Print(LogClass.ServiceBsd, $"Invalid SetSockOpt Option: {option} Level: {level}");
return result;
}
if (!WinSockHelper.TryConvertSocketOption(option, level, out SocketOptionName optionName))
{
Logger.Warning?.Print(LogClass.ServiceBsd, $"Unsupported SetSockOpt Option: {option} Level: {level}");
return LinuxError.SUCCESS;
}
byte[] value = optionValue.ToArray();
ProxyClient.SetSocketOption(level, optionName, value);
return LinuxError.SUCCESS;
}
catch (SocketException exception)
{
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
}
} }
public bool Poll(int microSeconds, SelectMode mode) public bool Poll(int microSeconds, SelectMode mode)
{ {
// TODO: Call ProxyClient.Poll() when it's implemented return ProxyClient.Poll(microSeconds, mode);
throw new NotImplementedException();
} }
public LinuxError Bind(IPEndPoint localEndPoint) public LinuxError Bind(IPEndPoint localEndPoint)
@ -370,7 +426,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
try try
{ {
SocksClient newProxyClient = ProxyClient.Accept(); SocksClient newProxyClient = ProxyClient.Accept();
newSocket = new ManagedProxySocket(this, newProxyClient); newSocket = new ManagedProxySocket(newProxyClient);
} }
catch (ProxyException exception) catch (ProxyException exception)
{ {
@ -391,14 +447,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
public void Disconnect() public void Disconnect()
{ {
// TODO: Call ProxyClient.Disconnect() when it's implemented ProxyClient.Disconnect();
} }
public LinuxError Shutdown(BsdSocketShutdownFlags how) public LinuxError Shutdown(BsdSocketShutdownFlags how)
{ {
// TODO: Call ProxyClient.Shutdown() when it's implemented try
{
ProxyClient.Shutdown((SocketShutdown)how);
return LinuxError.SUCCESS; return LinuxError.SUCCESS;
} }
catch (SocketException exception)
{
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
}
}
public void Close() public void Close()
{ {