aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-07-16 19:31:14 +0200
committerGitHub <noreply@github.com>2023-07-16 19:31:14 +0200
commit326749498bed4360e5a4b11fc67d5ec7cb9a3076 (patch)
treeae21fb26f99b401ca4e9efaab72b679a81c22369 /src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres
parentfec8291c17fa106c28f58b56419e90d49a41a1ea (diff)
[Ryujinx.HLE] Address dotnet-format issues (#5380)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address or silence dotnet format IDE1006 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA2211 warnings * Address dotnet format CA1822 warnings * Address or silence dotnet format CA1069 warnings * Make dotnet format succeed in style mode * Address or silence dotnet format CA2211 warnings * Address review comments * Address dotnet format CA2208 warnings properly * Make ProcessResult readonly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add previously silenced warnings back I have no clue how these disappeared * Revert formatting changes for while and for-loops * Format if-blocks correctly * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix a few disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Use using declaration instead of block syntax * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Fix typo * Add trailing commas, use targeted new and use array initializer * Fix build issues * Fix remaining build issues * Remove SuppressMessage for CA1069 where possible * Address dotnet format issues * Address formatting issues Co-authored-by: Ac_K <acoustik666@gmail.com> * Add GetHashCode implementation for RenderingSurfaceInfo * Explicitly silence CA1822 for every affected method in Syscall * Address formatting issues in Demangler.cs * Address review feedback Co-authored-by: Ac_K <acoustik666@gmail.com> * Revert marking service methods as static * Next dotnet format pass * Address review feedback --------- Co-authored-by: Ac_K <acoustik666@gmail.com>
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres')
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs220
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs8
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs8
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs14
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs38
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs4
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs4
-rw-r--r--src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs4
8 files changed, 163 insertions, 137 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs
index 64c3acbb..93960d13 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs
@@ -28,8 +28,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode SetDnsAddressesPrivateRequest(ServiceCtx context)
{
uint cancelHandleRequest = context.RequestData.ReadUInt32();
- ulong bufferPosition = context.Request.SendBuff[0].Position;
- ulong bufferSize = context.Request.SendBuff[0].Size;
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ ulong bufferPosition = context.Request.SendBuff[0].Position;
+ ulong bufferSize = context.Request.SendBuff[0].Size;
+#pragma warning restore IDE0059
// TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake of completeness.
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest });
@@ -42,8 +44,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode GetDnsAddressPrivateRequest(ServiceCtx context)
{
uint cancelHandleRequest = context.RequestData.ReadUInt32();
- ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
- ulong bufferSize = context.Request.ReceiveBuff[0].Size;
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
+ ulong bufferSize = context.Request.ReceiveBuff[0].Size;
+#pragma warning restore IDE0059
// TODO: This is stubbed in 2.0.0+, reverse 1.0.0 version for the sake of completeness.
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest });
@@ -56,10 +60,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode GetHostByNameRequest(ServiceCtx context)
{
ulong inputBufferPosition = context.Request.SendBuff[0].Position;
- ulong inputBufferSize = context.Request.SendBuff[0].Size;
+ ulong inputBufferSize = context.Request.SendBuff[0].Size;
ulong outputBufferPosition = context.Request.ReceiveBuff[0].Position;
- ulong outputBufferSize = context.Request.ReceiveBuff[0].Size;
+ ulong outputBufferSize = context.Request.ReceiveBuff[0].Size;
return GetHostByNameRequestImpl(context, inputBufferPosition, inputBufferSize, outputBufferPosition, outputBufferSize, false, 0, 0);
}
@@ -69,10 +73,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode GetHostByAddrRequest(ServiceCtx context)
{
ulong inputBufferPosition = context.Request.SendBuff[0].Position;
- ulong inputBufferSize = context.Request.SendBuff[0].Size;
+ ulong inputBufferSize = context.Request.SendBuff[0].Size;
ulong outputBufferPosition = context.Request.ReceiveBuff[0].Position;
- ulong outputBufferSize = context.Request.ReceiveBuff[0].Size;
+ ulong outputBufferSize = context.Request.ReceiveBuff[0].Size;
return GetHostByAddrRequestImpl(context, inputBufferPosition, inputBufferSize, outputBufferPosition, outputBufferSize, false, 0, 0);
}
@@ -82,20 +86,20 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode GetHostStringErrorRequest(ServiceCtx context)
{
ResultCode resultCode = ResultCode.NotAllocated;
- NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32();
+ NetDbError errorCode = (NetDbError)context.RequestData.ReadInt32();
string errorString = errorCode switch
{
- NetDbError.Success => "Resolver Error 0 (no error)",
+ NetDbError.Success => "Resolver Error 0 (no error)",
NetDbError.HostNotFound => "Unknown host",
- NetDbError.TryAgain => "Host name lookup failure",
- NetDbError.NoRecovery => "Unknown server error",
- NetDbError.NoData => "No address associated with name",
- _ => (errorCode <= NetDbError.Internal) ? "Resolver internal error" : "Unknown resolver error"
+ NetDbError.TryAgain => "Host name lookup failure",
+ NetDbError.NoRecovery => "Unknown server error",
+ NetDbError.NoData => "No address associated with name",
+ _ => (errorCode <= NetDbError.Internal) ? "Resolver internal error" : "Unknown resolver error",
};
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
- ulong bufferSize = context.Request.ReceiveBuff[0].Size;
+ ulong bufferSize = context.Request.ReceiveBuff[0].Size;
if ((ulong)(errorString.Length + 1) <= bufferSize)
{
@@ -112,7 +116,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode GetGaiStringErrorRequest(ServiceCtx context)
{
ResultCode resultCode = ResultCode.NotAllocated;
- GaiError errorCode = (GaiError)context.RequestData.ReadInt32();
+ GaiError errorCode = (GaiError)context.RequestData.ReadInt32();
if (errorCode > GaiError.Max)
{
@@ -122,25 +126,25 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
string errorString = errorCode switch
{
GaiError.AddressFamily => "Address family for hostname not supported",
- GaiError.Again => "Temporary failure in name resolution",
- GaiError.BadFlags => "Invalid value for ai_flags",
- GaiError.Fail => "Non-recoverable failure in name resolution",
- GaiError.Family => "ai_family not supported",
- GaiError.Memory => "Memory allocation failure",
- GaiError.NoData => "No address associated with hostname",
- GaiError.NoName => "hostname nor servname provided, or not known",
- GaiError.Service => "servname not supported for ai_socktype",
- GaiError.SocketType => "ai_socktype not supported",
- GaiError.System => "System error returned in errno",
- GaiError.BadHints => "Invalid value for hints",
- GaiError.Protocol => "Resolved protocol is unknown",
- GaiError.Overflow => "Argument buffer overflow",
- GaiError.Max => "Unknown error",
- _ => "Success"
+ GaiError.Again => "Temporary failure in name resolution",
+ GaiError.BadFlags => "Invalid value for ai_flags",
+ GaiError.Fail => "Non-recoverable failure in name resolution",
+ GaiError.Family => "ai_family not supported",
+ GaiError.Memory => "Memory allocation failure",
+ GaiError.NoData => "No address associated with hostname",
+ GaiError.NoName => "hostname nor servname provided, or not known",
+ GaiError.Service => "servname not supported for ai_socktype",
+ GaiError.SocketType => "ai_socktype not supported",
+ GaiError.System => "System error returned in errno",
+ GaiError.BadHints => "Invalid value for hints",
+ GaiError.Protocol => "Resolved protocol is unknown",
+ GaiError.Overflow => "Argument buffer overflow",
+ GaiError.Max => "Unknown error",
+ _ => "Success",
};
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
- ulong bufferSize = context.Request.ReceiveBuff[0].Size;
+ ulong bufferSize = context.Request.ReceiveBuff[0].Size;
if ((ulong)(errorString.Length + 1) <= bufferSize)
{
@@ -157,7 +161,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode GetAddrInfoRequest(ServiceCtx context)
{
ulong responseBufferPosition = context.Request.ReceiveBuff[0].Position;
- ulong responseBufferSize = context.Request.ReceiveBuff[0].Size;
+ ulong responseBufferSize = context.Request.ReceiveBuff[0].Size;
return GetAddrInfoRequestImpl(context, responseBufferPosition, responseBufferSize, false, 0, 0);
}
@@ -166,8 +170,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
// GetCancelHandleRequest(u64, pid) -> u32
public ResultCode GetCancelHandleRequest(ServiceCtx context)
{
- ulong pidPlaceHolder = context.RequestData.ReadUInt64();
- uint cancelHandleRequest = 0;
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ ulong pidPlaceHolder = context.RequestData.ReadUInt64();
+#pragma warning restore IDE0059
+ uint cancelHandleRequest = 0;
context.ResponseData.Write(cancelHandleRequest);
@@ -180,8 +186,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
// CancelRequest(u32, u64, pid)
public ResultCode CancelRequest(ServiceCtx context)
{
- uint cancelHandleRequest = context.RequestData.ReadUInt32();
- ulong pidPlaceHolder = context.RequestData.ReadUInt64();
+ uint cancelHandleRequest = context.RequestData.ReadUInt32();
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ ulong pidPlaceHolder = context.RequestData.ReadUInt64();
+#pragma warning restore IDE0059
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { cancelHandleRequest });
@@ -192,8 +200,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
// GetHostByNameRequestWithOptions(u8, u32, u64, pid, buffer<unknown, 21, 0>, buffer<unknown, 21, 0>) -> (u32, u32, u32, buffer<unknown, 22, 0>)
public ResultCode GetHostByNameRequestWithOptions(ServiceCtx context)
{
- (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21();
- (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
+ (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21();
+ (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
(ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21();
return GetHostByNameRequestImpl(
@@ -211,8 +219,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
// GetHostByAddrRequestWithOptions(u32, u32, u32, u64, pid, buffer<unknown, 21, 0>, buffer<unknown, 21, 0>) -> (u32, u32, u32, buffer<unknown, 22, 0>)
public ResultCode GetHostByAddrRequestWithOptions(ServiceCtx context)
{
- (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21();
- (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
+ (ulong inputBufferPosition, ulong inputBufferSize) = context.Request.GetBufferType0x21();
+ (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
(ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21();
return GetHostByAddrRequestImpl(
@@ -230,7 +238,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
// GetAddrInfoRequestWithOptions(bool enable_nsd_resolve, u32, u64 pid_placeholder, pid, buffer<i8, 5, 0> host, buffer<i8, 5, 0> service, buffer<packed_addrinfo, 5, 0> hints, buffer<unknown, 21, 0>) -> (i32 ret, u32 bsd_errno, u32 unknown, u32 packed_addrinfo_size, buffer<packed_addrinfo, 22, 0> response)
public ResultCode GetAddrInfoRequestWithOptions(ServiceCtx context)
{
- (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
+ (ulong outputBufferPosition, ulong outputBufferSize) = context.Request.GetBufferType0x22();
(ulong optionsBufferPosition, ulong optionsBufferSize) = context.Request.GetBufferType0x21();
return GetAddrInfoRequestImpl(context, outputBufferPosition, outputBufferSize, true, optionsBufferPosition, optionsBufferSize);
@@ -241,7 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
public ResultCode ResolverSetOptionRequest(ServiceCtx context)
{
ulong bufferPosition = context.Request.SendBuff[0].Position;
- ulong bufferSize = context.Request.SendBuff[0].Size;
+ ulong bufferSize = context.Request.SendBuff[0].Size;
ulong unknown = context.RequestData.ReadUInt64();
@@ -254,7 +262,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
Logger.Stub?.PrintStub(LogClass.ServiceSfdnsres, new { unknown });
NetDbError netDbErrorCode = NetDbError.Success;
- GaiError errno = GaiError.Success;
+ GaiError errno = GaiError.Success;
context.ResponseData.Write((int)errno);
context.ResponseData.Write((int)netDbErrorCode);
@@ -294,9 +302,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
}
// TODO: Use params.
- bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0;
- int timeOut = context.RequestData.ReadInt32();
- ulong pidPlaceholder = context.RequestData.ReadUInt64();
+ bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0;
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ int timeOut = context.RequestData.ReadInt32();
+ ulong pidPlaceholder = context.RequestData.ReadUInt64();
+#pragma warning restore IDE0059
if (withOptions)
{
@@ -306,8 +316,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
IPHostEntry hostEntry = null;
NetDbError netDbErrorCode = NetDbError.Success;
- GaiError errno = GaiError.Overflow;
- int serializedSize = 0;
+ GaiError errno = GaiError.Overflow;
+ int serializedSize = 0;
if (host.Length <= byte.MaxValue)
{
@@ -326,7 +336,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}");
netDbErrorCode = NetDbError.HostNotFound;
- errno = GaiError.NoData;
+ errno = GaiError.NoData;
}
else
{
@@ -339,7 +349,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
catch (SocketException exception)
{
netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode);
- errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno);
+ errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno);
}
}
}
@@ -354,12 +364,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
if (!addresses.Any())
{
- errno = GaiError.NoData;
+ errno = GaiError.NoData;
netDbErrorCode = NetDbError.NoAddress;
}
else
{
- errno = GaiError.Success;
+ errno = GaiError.Success;
serializedSize = SerializeHostEntries(context, outputBufferPosition, outputBufferSize, hostEntry, addresses);
}
}
@@ -381,7 +391,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
{
if (!context.Device.Configuration.EnableInternetAccess)
{
- Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked.");
+ Logger.Info?.Print(LogClass.ServiceSfdnsres, "Guest network access disabled, DNS Blocked.");
WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound);
@@ -393,10 +403,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
context.Memory.Read(inputBufferPosition, rawIp);
// TODO: Use params.
- uint socketLength = context.RequestData.ReadUInt32();
- uint type = context.RequestData.ReadUInt32();
- int timeOut = context.RequestData.ReadInt32();
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ uint socketLength = context.RequestData.ReadUInt32();
+ uint type = context.RequestData.ReadUInt32();
+ int timeOut = context.RequestData.ReadInt32();
ulong pidPlaceholder = context.RequestData.ReadUInt64();
+#pragma warning restore IDE0059
if (withOptions)
{
@@ -406,21 +418,21 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
IPHostEntry hostEntry = null;
NetDbError netDbErrorCode = NetDbError.Success;
- GaiError errno = GaiError.AddressFamily;
- int serializedSize = 0;
+ GaiError errno = GaiError.AddressFamily;
+ int serializedSize = 0;
if (rawIp.Length == 4)
{
try
{
- IPAddress address = new IPAddress(rawIp);
+ IPAddress address = new(rawIp);
hostEntry = Dns.GetHostEntry(address);
}
catch (SocketException exception)
{
netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode);
- errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno);
+ errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno);
}
}
else
@@ -430,7 +442,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
if (hostEntry != null)
{
- errno = GaiError.Success;
+ errno = GaiError.Success;
serializedSize = SerializeHostEntries(context, outputBufferPosition, outputBufferSize, hostEntry, GetIpv4Addresses(hostEntry));
}
@@ -442,7 +454,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
private static int SerializeHostEntries(ServiceCtx context, ulong outputBufferPosition, ulong outputBufferSize, IPHostEntry hostEntry, IEnumerable<IPAddress> addresses = null)
{
ulong originalBufferPosition = outputBufferPosition;
- ulong bufferPosition = originalBufferPosition;
+ ulong bufferPosition = originalBufferPosition;
string hostName = hostEntry.HostName + '\0';
@@ -494,9 +506,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
ulong optionsBufferSize)
{
bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0;
- uint cancelHandle = context.RequestData.ReadUInt32();
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ uint cancelHandle = context.RequestData.ReadUInt32();
+#pragma warning restore IDE0059
- string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size);
+ string host = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[0].Position, (long)context.Request.SendBuff[0].Size);
string service = MemoryHelper.ReadAsciiString(context.Memory, context.Request.SendBuff[1].Position, (long)context.Request.SendBuff[1].Size);
if (!context.Device.Configuration.EnableInternetAccess)
@@ -509,21 +523,27 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
}
// NOTE: We ignore hints for now.
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
List<AddrInfoSerialized> hints = DeserializeAddrInfos(context.Memory, context.Request.SendBuff[2].Position, context.Request.SendBuff[2].Size);
+#pragma warning restore IDE0059
if (withOptions)
{
// TODO: Find unknown, Parse and use options.
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
uint unknown = context.RequestData.ReadUInt32();
+#pragma warning restore IDE0059
}
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong pidPlaceHolder = context.RequestData.ReadUInt64();
+#pragma warning restore IDE0059
IPHostEntry hostEntry = null;
NetDbError netDbErrorCode = NetDbError.Success;
- GaiError errno = GaiError.AddressFamily;
- int serializedSize = 0;
+ GaiError errno = GaiError.AddressFamily;
+ int serializedSize = 0;
if (host.Length <= byte.MaxValue)
{
@@ -542,7 +562,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}");
netDbErrorCode = NetDbError.HostNotFound;
- errno = GaiError.NoData;
+ errno = GaiError.NoData;
}
else
{
@@ -555,7 +575,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
catch (SocketException exception)
{
netDbErrorCode = ConvertSocketErrorCodeToNetDbError(exception.ErrorCode);
- errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno);
+ errno = ConvertSocketErrorCodeToGaiError(exception.ErrorCode, errno);
}
}
}
@@ -566,10 +586,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
if (hostEntry != null)
{
- int.TryParse(service, out int port);
-
- errno = GaiError.Success;
- serializedSize = SerializeAddrInfos(context, responseBufferPosition, responseBufferSize, hostEntry, port);
+ if (int.TryParse(service, out int port))
+ {
+ errno = GaiError.Success;
+ serializedSize = SerializeAddrInfos(context, responseBufferPosition, responseBufferSize, hostEntry, port);
+ }
+ else
+ {
+ errno = GaiError.Service;
+ }
}
WriteResponse(context, withOptions, serializedSize, errno, netDbErrorCode);
@@ -601,37 +626,38 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
private static int SerializeAddrInfos(ServiceCtx context, ulong responseBufferPosition, ulong responseBufferSize, IPHostEntry hostEntry, int port)
{
ulong originalBufferPosition = responseBufferPosition;
- ulong bufferPosition = originalBufferPosition;
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
+ ulong bufferPosition = originalBufferPosition;
byte[] hostName = Encoding.ASCII.GetBytes(hostEntry.HostName + '\0');
+#pragma warning restore IDE0059
- using (WritableRegion region = context.Memory.GetWritableRegion(responseBufferPosition, (int)responseBufferSize))
- {
- Span<byte> data = region.Memory.Span;
+ using WritableRegion region = context.Memory.GetWritableRegion(responseBufferPosition, (int)responseBufferSize);
- for (int i = 0; i < hostEntry.AddressList.Length; i++)
- {
- IPAddress ip = hostEntry.AddressList[i];
+ Span<byte> data = region.Memory.Span;
- if (ip.AddressFamily != AddressFamily.InterNetwork)
- {
- continue;
- }
-
- // NOTE: 0 = Any
- AddrInfoSerializedHeader header = new(ip, 0);
- AddrInfo4 addr = new(ip, (short)port);
- AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName);
+ for (int i = 0; i < hostEntry.AddressList.Length; i++)
+ {
+ IPAddress ip = hostEntry.AddressList[i];
- data = info.Write(data);
+ if (ip.AddressFamily != AddressFamily.InterNetwork)
+ {
+ continue;
}
- uint sentinel = 0;
- MemoryMarshal.Write(data, ref sentinel);
- data = data[sizeof(uint)..];
+ // NOTE: 0 = Any
+ AddrInfoSerializedHeader header = new(ip, 0);
+ AddrInfo4 addr = new(ip, (short)port);
+ AddrInfoSerialized info = new(header, addr, null, hostEntry.HostName);
- return region.Memory.Span.Length - data.Length;
+ data = info.Write(data);
}
+
+ uint sentinel = 0;
+ MemoryMarshal.Write(data, ref sentinel);
+ data = data[sizeof(uint)..];
+
+ return region.Memory.Span.Length - data.Length;
}
private static void WriteResponse(
@@ -669,7 +695,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
11002 => NetDbError.TryAgain,
11003 => NetDbError.NoRecovery,
11004 => NetDbError.NoData,
- _ => NetDbError.Internal
+ _ => NetDbError.Internal,
};
}
@@ -679,8 +705,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
{
11001 => GaiError.NoData,
10060 => GaiError.Again,
- _ => errno
+ _ => errno,
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs
index 776a6f7c..a2ccd190 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs
@@ -19,18 +19,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
[GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)]
private static partial Regex BlockedHost6();
- private static readonly Regex[] BlockedHosts = {
+ private static readonly Regex[] _blockedHosts = {
BlockedHost1(),
BlockedHost2(),
BlockedHost3(),
BlockedHost4(),
BlockedHost5(),
- BlockedHost6()
+ BlockedHost6(),
};
public static bool IsHostBlocked(string host)
{
- foreach (Regex regex in BlockedHosts)
+ foreach (Regex regex in _blockedHosts)
{
if (regex.IsMatch(host))
{
@@ -41,4 +41,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
return false;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs
index 0e18c570..d17a999d 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs
@@ -19,8 +19,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
public void ReloadEntries(ServiceCtx context)
{
- string sdPath = context.Device.Configuration.VirtualFileSystem.GetSdCardPath();
- string filePath = context.Device.Configuration.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath);
+ string sdPath = FileSystem.VirtualFileSystem.GetSdCardPath();
+ string filePath = FileSystem.VirtualFileSystem.GetFullPath(sdPath, HostsFilePath);
_mitmHostEntries.Clear();
@@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
{
AddressList = new[] { hostEntry.Value },
HostName = hostEntry.Key,
- Aliases = Array.Empty<string>()
+ Aliases = Array.Empty<string>(),
};
}
}
@@ -103,4 +103,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
return Dns.GetHostEntry(host);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs
index 0a20e057..68250022 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfo4.cs
@@ -10,17 +10,17 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x10)]
struct AddrInfo4
{
- public byte Length;
- public byte Family;
- public short Port;
+ public byte Length;
+ public byte Family;
+ public short Port;
public Array4<byte> Address;
public Array8<byte> Padding;
public AddrInfo4(IPAddress address, short port)
{
- Length = (byte)Unsafe.SizeOf<Array4<byte>>();
- Family = (byte)AddressFamily.InterNetwork;
- Port = IPAddress.HostToNetworkOrder(port);
+ Length = (byte)Unsafe.SizeOf<Array4<byte>>();
+ Family = (byte)AddressFamily.InterNetwork;
+ Port = IPAddress.HostToNetworkOrder(port);
Address = new Array4<byte>();
address.TryWriteBytes(Address.AsSpan(), out _);
@@ -48,4 +48,4 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs
index 8e304dfa..9c50b1b8 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/AddrInfoSerializedHeader.cs
@@ -10,19 +10,19 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
struct AddrInfoSerializedHeader
{
public uint Magic;
- public int Flags;
- public int Family;
- public int SocketType;
- public int Protocol;
+ public int Flags;
+ public int Family;
+ public int SocketType;
+ public int Protocol;
public uint AddressLength;
public AddrInfoSerializedHeader(IPAddress address, SocketType socketType)
{
- Magic = SfdnsresContants.AddrInfoMagic;
- Flags = 0;
- Family = (int)address.AddressFamily;
+ Magic = SfdnsresContants.AddrInfoMagic;
+ Flags = 0;
+ Family = (int)address.AddressFamily;
SocketType = (int)socketType;
- Protocol = 0;
+ Protocol = 0;
if (address.AddressFamily == AddressFamily.InterNetwork)
{
@@ -36,22 +36,22 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
public void ToNetworkOrder()
{
- Magic = (uint)IPAddress.HostToNetworkOrder((int)Magic);
- Flags = IPAddress.HostToNetworkOrder(Flags);
- Family = IPAddress.HostToNetworkOrder(Family);
- SocketType = IPAddress.HostToNetworkOrder(SocketType);
- Protocol = IPAddress.HostToNetworkOrder(Protocol);
+ Magic = (uint)IPAddress.HostToNetworkOrder((int)Magic);
+ Flags = IPAddress.HostToNetworkOrder(Flags);
+ Family = IPAddress.HostToNetworkOrder(Family);
+ SocketType = IPAddress.HostToNetworkOrder(SocketType);
+ Protocol = IPAddress.HostToNetworkOrder(Protocol);
AddressLength = (uint)IPAddress.HostToNetworkOrder((int)AddressLength);
}
public void ToHostOrder()
{
- Magic = (uint)IPAddress.NetworkToHostOrder((int)Magic);
- Flags = IPAddress.NetworkToHostOrder(Flags);
- Family = IPAddress.NetworkToHostOrder(Family);
- SocketType = IPAddress.NetworkToHostOrder(SocketType);
- Protocol = IPAddress.NetworkToHostOrder(Protocol);
+ Magic = (uint)IPAddress.NetworkToHostOrder((int)Magic);
+ Flags = IPAddress.NetworkToHostOrder(Flags);
+ Family = IPAddress.NetworkToHostOrder(Family);
+ SocketType = IPAddress.NetworkToHostOrder(SocketType);
+ Protocol = IPAddress.NetworkToHostOrder(Protocol);
AddressLength = (uint)IPAddress.NetworkToHostOrder((int)AddressLength);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs
index f9f28b44..46682b3c 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/GaiError.cs
@@ -17,6 +17,6 @@
BadHints,
Protocol,
Overflow,
- Max
+ Max,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs
index 3c04c049..0ded5960 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/NetDBError.cs
@@ -8,6 +8,6 @@
TryAgain,
NoRecovery,
NoData,
- NoAddress = NoData
+ NoAddress = NoData,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs
index d194a3c6..7c51413c 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Types/SfdnsresContants.cs
@@ -1,7 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types
{
- static class SfdnsresContants
+ class SfdnsresContants
{
public const uint AddrInfoMagic = 0xBEEFCAFE;
}
-} \ No newline at end of file
+}