mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-15 01:46:28 +02:00
misc: chore: Fix object creation in HLE project
This commit is contained in:
parent
f1fd5c9366
commit
beab133c8d
48 changed files with 194 additions and 194 deletions
|
@ -244,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
|||
|
||||
byte[] ip = address.GetAddressBytes();
|
||||
|
||||
Array6<byte> macAddress = new Array6<byte>();
|
||||
Array6<byte> macAddress = new();
|
||||
new byte[] { 0x02, 0x00, ip[0], ip[1], ip[2], ip[3] }.CopyTo(macAddress.AsSpan());
|
||||
|
||||
return macAddress;
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy
|
|||
|
||||
lock (_scanLock)
|
||||
{
|
||||
Dictionary<ulong, NetworkInfo> results = new Dictionary<ulong, NetworkInfo>();
|
||||
Dictionary<ulong, NetworkInfo> results = new();
|
||||
|
||||
foreach (KeyValuePair<ulong, NetworkInfo> last in _scanResultsLast)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
{
|
||||
public bool NeedsRealId => true;
|
||||
|
||||
private static InitializeMessage InitializeMemory = new InitializeMessage();
|
||||
private static InitializeMessage InitializeMemory = new();
|
||||
|
||||
private const int InactiveTimeout = 6000;
|
||||
private const int FailureTimeout = 4000;
|
||||
|
@ -31,16 +31,16 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
private bool _useP2pProxy;
|
||||
private NetworkError _lastError;
|
||||
|
||||
private readonly ManualResetEvent _connected = new ManualResetEvent(false);
|
||||
private readonly ManualResetEvent _error = new ManualResetEvent(false);
|
||||
private readonly ManualResetEvent _scan = new ManualResetEvent(false);
|
||||
private readonly ManualResetEvent _reject = new ManualResetEvent(false);
|
||||
private readonly AutoResetEvent _apConnected = new AutoResetEvent(false);
|
||||
private readonly ManualResetEvent _connected = new(false);
|
||||
private readonly ManualResetEvent _error = new(false);
|
||||
private readonly ManualResetEvent _scan = new(false);
|
||||
private readonly ManualResetEvent _reject = new(false);
|
||||
private readonly AutoResetEvent _apConnected = new(false);
|
||||
|
||||
private readonly RyuLdnProtocol _protocol;
|
||||
private readonly NetworkTimeout _timeout;
|
||||
|
||||
private readonly List<NetworkInfo> _availableGames = new List<NetworkInfo>();
|
||||
private readonly List<NetworkInfo> _availableGames = new();
|
||||
private DisconnectReason _disconnectReason;
|
||||
|
||||
private P2pProxyServer _hostedProxy;
|
||||
|
@ -490,7 +490,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
SendAsync(_protocol.Encode(PacketId.CreateAccessPoint, request, advertiseData));
|
||||
|
||||
// Send a network change event with dummy data immediately. Necessary to avoid crashes in some games
|
||||
NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
|
||||
NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
|
||||
{
|
||||
Common = new CommonNetworkInfo()
|
||||
{
|
||||
|
@ -610,7 +610,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
|
||||
SendAsync(_protocol.Encode(PacketId.Connect, request));
|
||||
|
||||
NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
|
||||
NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
|
||||
{
|
||||
Common = request.NetworkInfo.Common,
|
||||
Ldn = request.NetworkInfo.Ldn
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
{
|
||||
private const ushort EphemeralBase = 49152;
|
||||
|
||||
private readonly List<ushort> _ephemeralPorts = new List<ushort>();
|
||||
private readonly List<ushort> _ephemeralPorts = new();
|
||||
|
||||
private readonly Lock _lock = new();
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
public EndPoint LocalEndpoint { get; }
|
||||
public IPAddress LocalAddress { get; }
|
||||
|
||||
private readonly List<LdnProxySocket> _sockets = new List<LdnProxySocket>();
|
||||
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new Dictionary<ProtocolType, EphemeralPortPool>();
|
||||
private readonly List<LdnProxySocket> _sockets = new();
|
||||
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new();
|
||||
|
||||
private readonly IProxyClient _parent;
|
||||
private RyuLdnProtocol _protocol;
|
||||
|
@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
|
||||
public void HandleData(LdnHeader header, ProxyDataHeader proxyHeader, byte[] data)
|
||||
{
|
||||
ProxyDataPacket packet = new ProxyDataPacket() { Header = proxyHeader, Data = data };
|
||||
ProxyDataPacket packet = new() { Header = proxyHeader, Data = data };
|
||||
|
||||
ForRoutedSockets(proxyHeader.Info, (socket) =>
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
{
|
||||
// We must ask the other side to initialize a connection, so they can accept a socket for us.
|
||||
|
||||
ProxyConnectRequest request = new ProxyConnectRequest
|
||||
ProxyConnectRequest request = new()
|
||||
{
|
||||
Info = MakeInfo(localEp, remoteEp, type)
|
||||
};
|
||||
|
@ -191,7 +191,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
{
|
||||
// We must tell the other side that we have accepted their request for connection.
|
||||
|
||||
ProxyConnectResponse request = new ProxyConnectResponse
|
||||
ProxyConnectResponse request = new()
|
||||
{
|
||||
Info = MakeInfo(localEp, remoteEp, type)
|
||||
};
|
||||
|
@ -203,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
{
|
||||
// We must tell the other side that our connection is dropped.
|
||||
|
||||
ProxyDisconnectMessage request = new ProxyDisconnectMessage
|
||||
ProxyDisconnectMessage request = new()
|
||||
{
|
||||
Info = MakeInfo(localEp, remoteEp, type),
|
||||
DisconnectReason = 0 // TODO
|
||||
|
@ -217,7 +217,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
// We send exactly as much as the user wants us to, currently instantly.
|
||||
// TODO: handle over "virtual mtu" (we have a max packet size to worry about anyways). fragment if tcp? throw if udp?
|
||||
|
||||
ProxyDataHeader request = new ProxyDataHeader
|
||||
ProxyDataHeader request = new()
|
||||
{
|
||||
Info = MakeInfo(localEp, remoteEp, type),
|
||||
DataLength = (uint)buffer.Length
|
||||
|
|
|
@ -18,21 +18,21 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
private readonly LdnProxy _proxy;
|
||||
|
||||
private bool _isListening;
|
||||
private readonly List<LdnProxySocket> _listenSockets = new List<LdnProxySocket>();
|
||||
private readonly List<LdnProxySocket> _listenSockets = new();
|
||||
|
||||
private readonly Queue<ProxyConnectRequest> _connectRequests = new Queue<ProxyConnectRequest>();
|
||||
private readonly Queue<ProxyConnectRequest> _connectRequests = new();
|
||||
|
||||
private readonly AutoResetEvent _acceptEvent = new AutoResetEvent(false);
|
||||
private readonly AutoResetEvent _acceptEvent = new(false);
|
||||
private readonly int _acceptTimeout = -1;
|
||||
|
||||
private readonly Queue<int> _errors = new Queue<int>();
|
||||
private readonly Queue<int> _errors = new();
|
||||
|
||||
private readonly AutoResetEvent _connectEvent = new AutoResetEvent(false);
|
||||
private readonly AutoResetEvent _connectEvent = new(false);
|
||||
private ProxyConnectResponse _connectResponse;
|
||||
|
||||
private int _receiveTimeout = -1;
|
||||
private readonly AutoResetEvent _receiveEvent = new AutoResetEvent(false);
|
||||
private readonly Queue<ProxyDataPacket> _receiveQueue = new Queue<ProxyDataPacket>();
|
||||
private readonly AutoResetEvent _receiveEvent = new(false);
|
||||
private readonly Queue<ProxyDataPacket> _receiveQueue = new();
|
||||
|
||||
// private int _sendTimeout = -1; // Sends are techically instant right now, so not _really_ used.
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
// private bool _writeShutdown;
|
||||
private bool _closed;
|
||||
|
||||
private readonly Dictionary<SocketOptionName, int> _socketOptions = new Dictionary<SocketOptionName, int>()
|
||||
private readonly Dictionary<SocketOptionName, int> _socketOptions = new()
|
||||
{
|
||||
{ SocketOptionName.Broadcast, 0 }, //TODO: honor this value
|
||||
{ SocketOptionName.DontLinger, 0 },
|
||||
|
@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
}
|
||||
}
|
||||
|
||||
IPEndPoint localEp = new IPEndPoint(_proxy.LocalAddress, _proxy.GetEphemeralPort(ProtocolType));
|
||||
IPEndPoint localEp = new(_proxy.LocalAddress, _proxy.GetEphemeralPort(ProtocolType));
|
||||
LocalEndPoint = localEp;
|
||||
|
||||
return localEp;
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
|
||||
private readonly RyuLdnProtocol _protocol;
|
||||
|
||||
private readonly ManualResetEvent _connected = new ManualResetEvent(false);
|
||||
private readonly ManualResetEvent _ready = new ManualResetEvent(false);
|
||||
private readonly AutoResetEvent _error = new AutoResetEvent(false);
|
||||
private readonly ManualResetEvent _connected = new(false);
|
||||
private readonly ManualResetEvent _ready = new(false);
|
||||
private readonly AutoResetEvent _error = new(false);
|
||||
|
||||
public P2pProxyClient(string address, int port) : base(address, port)
|
||||
{
|
||||
|
|
|
@ -29,22 +29,22 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
|
||||
private const ushort AuthWaitSeconds = 1;
|
||||
|
||||
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
|
||||
private readonly ReaderWriterLockSlim _lock = new(LockRecursionPolicy.SupportsRecursion);
|
||||
|
||||
public ushort PrivatePort { get; }
|
||||
|
||||
private ushort _publicPort;
|
||||
|
||||
private bool _disposed;
|
||||
private readonly CancellationTokenSource _disposedCancellation = new CancellationTokenSource();
|
||||
private readonly CancellationTokenSource _disposedCancellation = new();
|
||||
|
||||
private NatDevice _natDevice;
|
||||
private Mapping _portMapping;
|
||||
|
||||
private readonly List<P2pProxySession> _players = new List<P2pProxySession>();
|
||||
private readonly List<P2pProxySession> _players = new();
|
||||
|
||||
private readonly List<ExternalProxyToken> _waitingTokens = new List<ExternalProxyToken>();
|
||||
private readonly AutoResetEvent _tokenEvent = new AutoResetEvent(false);
|
||||
private readonly List<ExternalProxyToken> _waitingTokens = new();
|
||||
private readonly AutoResetEvent _tokenEvent = new(false);
|
||||
|
||||
private uint _broadcastAddress;
|
||||
|
||||
|
@ -112,8 +112,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
|
||||
public async Task<ushort> NatPunch()
|
||||
{
|
||||
NatDiscoverer discoverer = new NatDiscoverer();
|
||||
CancellationTokenSource cts = new CancellationTokenSource(1000);
|
||||
NatDiscoverer discoverer = new();
|
||||
CancellationTokenSource cts = new(1000);
|
||||
|
||||
NatDevice device;
|
||||
|
||||
|
@ -300,7 +300,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
|
||||
session.SetIpv4(waitToken.VirtualIp);
|
||||
|
||||
ProxyConfig pconfig = new ProxyConfig
|
||||
ProxyConfig pconfig = new()
|
||||
{
|
||||
ProxyIp = session.VirtualIpAddress,
|
||||
ProxySubnetMask = 0xFFFF0000 // TODO: Use from server.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue