diff options
| author | Mary <me@thog.eu> | 2022-01-03 22:12:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-03 22:12:50 +0100 |
| commit | 60f03cb78a4c7b66ee72dbbfee4b1998474a604a (patch) | |
| tree | 4a4ea186f52ef9d433ce032edeafbb11908b098d /Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres | |
| parent | e24be5edfc6a3eae009dc6d4c4e7f498ad0596b9 (diff) | |
sfdnsres: Implement NSD resolution (#2962)
This fix a missing implementation usage of NSD on IResolver when
requested on GetAddrInfoRequest* and GetHostByNameRequest*.
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs b/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs index c569915f..32346dc7 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/IResolver.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Logging; using Ryujinx.Cpu; +using Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager; using Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy; using Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Types; using Ryujinx.Memory; @@ -242,7 +243,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres ulong optionsBufferPosition, ulong optionsBufferSize) { - string name = MemoryHelper.ReadAsciiString(context.Memory, inputBufferPosition, (int)inputBufferSize); + string host = MemoryHelper.ReadAsciiString(context.Memory, inputBufferPosition, (int)inputBufferSize); // TODO: Use params. bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0; @@ -260,20 +261,28 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres GaiError errno = GaiError.Overflow; ulong serializedSize = 0; - if (name.Length <= byte.MaxValue) + if (host.Length <= byte.MaxValue) { - string targetHost = name; + if (enableNsdResolve) + { + if (FqdnResolver.Resolve(host, out string newAddress) == Nsd.ResultCode.Success) + { + host = newAddress; + } + } + + string targetHost = host; - if (DnsBlacklist.IsHostBlocked(name)) + if (DnsBlacklist.IsHostBlocked(host)) { - Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {name}"); + Logger.Info?.Print(LogClass.ServiceSfdnsres, $"DNS Blocked: {host}"); netDbErrorCode = NetDbError.HostNotFound; errno = GaiError.NoData; } else { - Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Trying to resolve: {name}"); + Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Trying to resolve: {host}"); try { @@ -452,6 +461,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres if (host.Length <= byte.MaxValue) { + if (enableNsdResolve) + { + if (FqdnResolver.Resolve(host, out string newAddress) == Nsd.ResultCode.Success) + { + host = newAddress; + } + } + string targetHost = host; if (DnsBlacklist.IsHostBlocked(host)) |
