misc: chore: Fix possible NullReferenceExceptions, InvalidOperationExceptions

This commit is contained in:
KeatonTheBot
2025-10-06 11:48:21 -05:00
parent fa5b5b127e
commit 7a5b5dee6a
12 changed files with 63 additions and 45 deletions
@@ -1099,7 +1099,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
}
if (!IPAddress.TryParse(ldnServer, out IPAddress ipAddress))
{
ipAddress = Dns.GetHostEntry(ldnServer).AddressList[0];
ipAddress = Dns.GetHostEntry(ldnServer ?? string.Empty).AddressList[0];
}
NetworkClient = new LdnMasterProxyClient(ipAddress.ToString(), LanPlayPort, context.Device.Configuration);
}
@@ -267,7 +267,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
// Attempt to find matching configuration. If we don't find one, wait for a bit and try again.
// Woken by new tokens coming in from the master server.
IPAddress address = (session.Socket.RemoteEndPoint as IPEndPoint).Address;
IPAddress address = (session.Socket.RemoteEndPoint as IPEndPoint)?.Address;
byte[] addressBytes = ProxyHelpers.AddressTo16Byte(address);
long time;
@@ -282,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
// Allow any client that has a private IP to connect. (indicated by the server as all 0 in the token)
bool isPrivate = waitToken.PhysicalIp.AsSpan().SequenceEqual(new byte[16]);
bool ipEqual = isPrivate || waitToken.AddressFamily == address.AddressFamily && waitToken.PhysicalIp.AsSpan().SequenceEqual(addressBytes);
bool ipEqual = address != null && (isPrivate || waitToken.AddressFamily == address.AddressFamily && waitToken.PhysicalIp.AsSpan().SequenceEqual(addressBytes));
if (ipEqual && waitToken.Token.AsSpan().SequenceEqual(config.Token.AsSpan()))
{