句柄无效时退出
This commit is contained in:
parent
f2b248f18d
commit
f67fe2e46f
@ -23,6 +23,7 @@ namespace FastGithub.PacketIntercept.Dns
|
|||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
sealed class DnsInterceptor : IDnsInterceptor
|
sealed class DnsInterceptor : IDnsInterceptor
|
||||||
{
|
{
|
||||||
|
private const int ERROR_INVALID_HANDLE = 0x6;
|
||||||
private const string DNS_FILTER = "udp.DstPort == 53";
|
private const string DNS_FILTER = "udp.DstPort == 53";
|
||||||
private readonly FastGithubConfig fastGithubConfig;
|
private readonly FastGithubConfig fastGithubConfig;
|
||||||
private readonly ILogger<DnsInterceptor> logger;
|
private readonly ILogger<DnsInterceptor> logger;
|
||||||
@ -97,8 +98,12 @@ namespace FastGithub.PacketIntercept.Dns
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var exception = new Win32Exception(Marshal.GetLastWin32Error());
|
var errorCode = Marshal.GetLastWin32Error();
|
||||||
this.logger.LogError(exception.Message);
|
this.logger.LogError(new Win32Exception(errorCode).Message);
|
||||||
|
if (errorCode == ERROR_INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace FastGithub.PacketIntercept.Tcp
|
|||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
abstract class TcpInterceptor : ITcpInterceptor
|
abstract class TcpInterceptor : ITcpInterceptor
|
||||||
{
|
{
|
||||||
|
private const int ERROR_INVALID_HANDLE = 0x6;
|
||||||
private readonly string filter;
|
private readonly string filter;
|
||||||
private readonly ushort oldServerPort;
|
private readonly ushort oldServerPort;
|
||||||
private readonly ushort newServerPort;
|
private readonly ushort newServerPort;
|
||||||
@ -82,8 +83,12 @@ namespace FastGithub.PacketIntercept.Tcp
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var exception = new Win32Exception(Marshal.GetLastWin32Error());
|
var errorCode = Marshal.GetLastWin32Error();
|
||||||
this.logger.LogError(exception.Message);
|
this.logger.LogError(new Win32Exception(errorCode).Message);
|
||||||
|
if (errorCode == ERROR_INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user