Return error on DNS resolution when guest internet access is disabled (#2983)

* Return error on DNS resolution when guest internet access is disabled

* Log DNS lookup calls
This commit is contained in:
gdkchan 2022-01-08 20:18:09 -03:00 committed by GitHub
parent 79adba4402
commit 4864648e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -245,6 +245,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
{
string host = MemoryHelper.ReadAsciiString(context.Memory, inputBufferPosition, (int)inputBufferSize);
if (!context.Device.Configuration.EnableInternetAccess)
{
Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked: {host}");
WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound);
return ResultCode.Success;
}
// TODO: Use params.
bool enableNsdResolve = (context.RequestData.ReadInt32() & 1) != 0;
int timeOut = context.RequestData.ReadInt32();
@ -331,6 +340,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
ulong optionsBufferPosition,
ulong optionsBufferSize)
{
if (!context.Device.Configuration.EnableInternetAccess)
{
Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked.");
WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound);
return ResultCode.Success;
}
byte[] rawIp = new byte[inputBufferSize];
context.Memory.Read(inputBufferPosition, rawIp);
@ -442,6 +460,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
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)
{
Logger.Info?.Print(LogClass.ServiceSfdnsres, $"Guest network access disabled, DNS Blocked: {host}");
WriteResponse(context, withOptions, 0, GaiError.NoData, NetDbError.HostNotFound);
return ResultCode.Success;
}
// NOTE: We ignore hints for now.
DeserializeAddrInfos(context.Memory, (ulong)context.Request.SendBuff[2].Position, (ulong)context.Request.SendBuff[2].Size);