dns监听身份检测

This commit is contained in:
老九 2021-08-30 22:46:50 +08:00
parent e354e80a99
commit 762b6b01da

View File

@ -55,8 +55,20 @@ namespace FastGithub.Dns
const int SIO_UDP_CONNRESET = unchecked((int)0x9800000C); const int SIO_UDP_CONNRESET = unchecked((int)0x9800000C);
this.socket.IOControl(SIO_UDP_CONNRESET, new byte[4], new byte[4]); this.socket.IOControl(SIO_UDP_CONNRESET, new byte[4], new byte[4]);
} }
this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
this.socket.Bind(new IPEndPoint(address, port)); try
{
this.socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
this.socket.Bind(new IPEndPoint(address, port));
}
catch (SocketException ex) when (ex.SocketErrorCode == SocketError.AccessDenied)
{
if (OperatingSystem.IsLinux())
{
throw new FastGithubException($"请以root身份运行", ex);
}
throw;
}
} }
/// <summary> /// <summary>