0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/Nifm/StaticService/Types/DnsSetting.cs
Ac_K 242e51c7f5
nifm: Fixes IsDynamicDnsEnabled not supported (#2443)
For a strange reason `IPInterfaceProperties.IsDynamicDnsEnabled` returns a `PlatformNotSupported` exception in Linux.
This PR fixes this issue with a `try/catch` and set the value to false. Closes #2415.
2021-07-06 20:41:11 +02:00

38 lines
No EOL
1.2 KiB
C#

using System;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.Types
{
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 9)]
struct DnsSetting
{
[MarshalAs(UnmanagedType.U1)]
public bool IsDynamicDnsEnabled;
public IpV4Address PrimaryDns;
public IpV4Address SecondaryDns;
public DnsSetting(IPInterfaceProperties interfaceProperties)
{
try
{
IsDynamicDnsEnabled = interfaceProperties.IsDynamicDnsEnabled;
}
catch (PlatformNotSupportedException)
{
IsDynamicDnsEnabled = false;
}
if (interfaceProperties.DnsAddresses.Count == 0)
{
PrimaryDns = new IpV4Address();
SecondaryDns = new IpV4Address();
}
else
{
PrimaryDns = new IpV4Address(interfaceProperties.DnsAddresses[0]);
SecondaryDns = new IpV4Address(interfaceProperties.DnsAddresses[interfaceProperties.DnsAddresses.Count > 1 ? 1 : 0]);
}
}
}
}