|
|
@@ -92,18 +92,30 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
{
|
|
|
newSocket = new ManagedSocket(Socket.Accept());
|
|
|
|
|
|
+ IPEndPoint remoteEndPoint = newSocket.RemoteEndPoint;
|
|
|
+ bool isPrivateIp = remoteEndPoint.Address.ToString().StartsWith("192.168.");
|
|
|
+ Logger.Info?.PrintMsg(LogClass.ServiceBsd,
|
|
|
+ isPrivateIp
|
|
|
+ ? $"Accepted connection from {ProtocolType}/{remoteEndPoint.Address}:{remoteEndPoint.Port}"
|
|
|
+ : $"Accepted connection from {ProtocolType}/***:{remoteEndPoint.Port}");
|
|
|
+
|
|
|
return LinuxError.SUCCESS;
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
newSocket = null;
|
|
|
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public LinuxError Bind(IPEndPoint localEndPoint)
|
|
|
{
|
|
|
+ Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket binding to: {ProtocolType}/{localEndPoint.Port}");
|
|
|
try
|
|
|
{
|
|
|
Socket.Bind(localEndPoint);
|
|
|
@@ -112,6 +124,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
@@ -123,6 +139,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
|
|
|
public LinuxError Connect(IPEndPoint remoteEndPoint)
|
|
|
{
|
|
|
+ bool isLDNPrivateIP = remoteEndPoint.Address.ToString().StartsWith("192.168.");
|
|
|
+ if (isLDNPrivateIP)
|
|
|
+ {
|
|
|
+ Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Connecting to: {ProtocolType}/{remoteEndPoint.Address}:{remoteEndPoint.Port}");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Connecting to: {ProtocolType}/***:{remoteEndPoint.Port}");
|
|
|
+ }
|
|
|
try
|
|
|
{
|
|
|
Socket.Connect(remoteEndPoint);
|
|
|
@@ -137,6 +162,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
@@ -144,11 +173,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
|
|
|
public void Disconnect()
|
|
|
{
|
|
|
+ Logger.Info?.Print(LogClass.ServiceBsd, "Socket disconnecting");
|
|
|
Socket.Disconnect(true);
|
|
|
}
|
|
|
|
|
|
public void Dispose()
|
|
|
{
|
|
|
+ Logger.Info?.Print(LogClass.ServiceBsd, "Socket closed");
|
|
|
Socket.Close();
|
|
|
Socket.Dispose();
|
|
|
}
|
|
|
@@ -159,10 +190,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
{
|
|
|
Socket.Listen(backlog);
|
|
|
|
|
|
+ Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket listening: {ProtocolType}/{(Socket.LocalEndPoint as IPEndPoint).Port}");
|
|
|
+
|
|
|
return LinuxError.SUCCESS;
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
@@ -182,11 +219,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- bool hasEmittedBlockingWarning = false;
|
|
|
+ private bool _hasEmittedBlockingWarning;
|
|
|
|
|
|
public LinuxError Receive(out int receiveSize, Span<byte> buffer, BsdSocketFlags flags)
|
|
|
{
|
|
|
@@ -202,10 +243,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
shouldBlockAfterOperation = true;
|
|
|
}
|
|
|
|
|
|
- if (Blocking && !hasEmittedBlockingWarning)
|
|
|
+ if (Blocking && !_hasEmittedBlockingWarning)
|
|
|
{
|
|
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
|
|
- hasEmittedBlockingWarning = true;
|
|
|
+ _hasEmittedBlockingWarning = true;
|
|
|
}
|
|
|
|
|
|
receiveSize = Socket.Receive(buffer, ConvertBsdSocketFlags(flags));
|
|
|
@@ -214,6 +255,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
receiveSize = -1;
|
|
|
|
|
|
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
@@ -245,10 +290,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
shouldBlockAfterOperation = true;
|
|
|
}
|
|
|
|
|
|
- if (Blocking && !hasEmittedBlockingWarning)
|
|
|
+ if (Blocking && !_hasEmittedBlockingWarning)
|
|
|
{
|
|
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
|
|
- hasEmittedBlockingWarning = true;
|
|
|
+ _hasEmittedBlockingWarning = true;
|
|
|
}
|
|
|
|
|
|
if (!Socket.IsBound)
|
|
|
@@ -265,6 +310,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
receiveSize = -1;
|
|
|
|
|
|
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
@@ -288,6 +337,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
sendSize = -1;
|
|
|
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
@@ -304,6 +357,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
sendSize = -1;
|
|
|
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
@@ -341,6 +398,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
@@ -387,6 +448,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
@@ -519,6 +584,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|
|
|
@@ -557,6 +626,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|
|
}
|
|
|
catch (SocketException exception)
|
|
|
{
|
|
|
+ if (exception.SocketErrorCode != SocketError.WouldBlock)
|
|
|
+ {
|
|
|
+ Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
|
|
+ }
|
|
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
|
|
}
|
|
|
}
|