Compare commits

..

4 Commits

Author SHA1 Message Date
Vudjun
a114657c8a Merge bcbe589964 into 8623452abc 2025-02-13 21:49:39 +08:00
Evan Husted
8623452abc docs: new discord invite 2025-02-13 03:23:02 -06:00
Vudjun
bcbe589964 Decrease timeout on uPNP to avoid timeout issue on smash bros and change debug statements to Info 2025-02-08 23:14:29 +00:00
Vudjun
d406c42e15 Make the uPNP device search more reliable 2025-02-08 18:28:41 +00:00
2 changed files with 46 additions and 23 deletions

View File

@@ -39,12 +39,12 @@
<p align="center">
Click below to join the Discord:
<br>
<a href="https://discord.gg/dHPrkBkkyA">
<a href="https://discord.gg/PEuzjrFXUA">
<img src="https://img.shields.io/discord/1294443224030511104?color=5865F2&label=Ryubing&logo=discord&logoColor=white" alt="Discord">
</a>
<br>
<br>
<img src="https://raw.githubusercontent.com/GreemDev/Ryujinx/refs/heads/master/docs/shell.png">
<img src="https://raw.githubusercontent.com/Ryubing/Ryujinx/refs/heads/master/docs/shell.png">
</p>
## Usage

View File

@@ -110,24 +110,10 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
_broadcastAddress = config.ProxyIp | (~config.ProxySubnetMask);
}
public async Task<ushort> NatPunch()
private async Task<ushort> NatPunchForDevice(NatDevice device)
{
NatDiscoverer discoverer = new();
CancellationTokenSource cts = new(5000);
NatDevice device;
try
{
device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
}
catch (NatDeviceNotFoundException)
{
return 0;
}
Logger.Info?.PrintMsg(LogClass.ServiceLdn, $"Attempting to map port using {device.ToString()}");
_publicPort = PublicPortBase;
for (int i = 0; i < PublicPortRange; i++)
{
try
@@ -138,12 +124,14 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
break;
}
catch (MappingException)
catch (MappingException ex)
{
Logger.Info?.PrintMsg(LogClass.ServiceLdn, $"Failed to map port {_publicPort}: {ex.Message}");
_publicPort++;
}
catch (Exception)
catch (Exception ex)
{
Logger.Info?.PrintMsg(LogClass.ServiceLdn, $"Failed to map port {_publicPort}: {ex.GetType().Name}: {ex.Message}");
return 0;
}
@@ -155,17 +143,52 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
if (_publicPort != 0)
{
_natDevice = device;
_ = Executor.ExecuteAfterDelayAsync(
PortLeaseRenew.Seconds(),
PortLeaseRenew.Seconds(),
_disposedCancellation.Token,
RefreshLease);
}
_natDevice = device;
return _publicPort;
}
public async Task<ushort> NatPunch()
{
NatDiscoverer discoverer = new();
CancellationTokenSource cts = new(500);
NatDevice[] devices;
try
{
devices = (await discoverer.DiscoverDevicesAsync(PortMapper.Upnp, cts)).ToArray();
}
catch (Exception ex)
{
Logger.Error?.PrintMsg(LogClass.ServiceLdn, $"Failed to discover UPnP devices: {ex.Message}");
return 0;
}
if (devices.Length == 0)
{
Logger.Error?.PrintMsg(LogClass.ServiceLdn, "No UPnP devices found.");
return 0;
}
foreach (var device in devices)
{
ushort port = await NatPunchForDevice(device);
if (port != 0)
{
return port;
}
}
Logger.Info?.PrintMsg(LogClass.ServiceLdn, $"Failed to map port using any device");
_publicPort = 0;
return 0;
}
// Proxy handlers
private void RouteMessage(P2pProxySession sender, ref ProxyInfo info, Action<P2pProxySession> action)