mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-16 15:46:33 +00:00
Add ProxyManager
This commit is contained in:
parent
aea32c29aa
commit
49acca8cf7
@ -1,6 +1,7 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy;
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
@ -95,10 +96,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
}
|
||||
}
|
||||
|
||||
ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol)
|
||||
{
|
||||
Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking),
|
||||
};
|
||||
ISocket newBsdSocket = ProxyManager.GetSocket(netDomain, (SocketType)type, protocol);
|
||||
newBsdSocket.Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking);
|
||||
|
||||
LinuxError errno = LinuxError.SUCCESS;
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy
|
||||
{
|
||||
public static class ProxyManager
|
||||
{
|
||||
private static readonly Dictionary<string, EndPoint> _proxyEndpoints = new();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static string GetKey(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
|
||||
{
|
||||
return string.Join("-", new[] { (int)addressFamily, (int)socketType, (int)protocolType });
|
||||
}
|
||||
|
||||
internal static ISocket GetSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
|
||||
{
|
||||
// TODO: Return proxy socket if AddressFamily, SocketType and ProtocolType match.
|
||||
|
||||
return new ManagedSocket(addressFamily, socketType, protocolType);
|
||||
}
|
||||
|
||||
public static void AddOrUpdate(EndPoint endPoint,
|
||||
AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
|
||||
{
|
||||
_proxyEndpoints[GetKey(addressFamily, socketType, protocolType)] = endPoint;
|
||||
}
|
||||
|
||||
public static void AddOrUpdate(IPAddress address, int port,
|
||||
AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
|
||||
{
|
||||
_proxyEndpoints[GetKey(addressFamily, socketType, protocolType)] = new IPEndPoint(address, port);
|
||||
}
|
||||
|
||||
public static void AddOrUpdate(string host, int port,
|
||||
AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
|
||||
{
|
||||
_proxyEndpoints[GetKey(addressFamily, socketType, protocolType)] = new DnsEndPoint(host, port);
|
||||
}
|
||||
|
||||
public static bool Remove(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
|
||||
{
|
||||
return _proxyEndpoints.Remove(GetKey(addressFamily, socketType, protocolType));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user