From e0928acaca2eb0ef97aaad0de541d99dcf5d702f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com>
Date: Thu, 4 Nov 2021 14:26:37 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=A1=8C=E9=9D=A2=E6=A8=A1?=
=?UTF-8?q?=E5=BC=8F=E4=B8=8B=E4=BB=A5=E6=9C=8D=E5=8A=A1=E5=AE=89=E8=A3=85?=
=?UTF-8?q?dnscrypt-proxy?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.DomainResolve/DnscryptProxy.cs | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/FastGithub.DomainResolve/DnscryptProxy.cs b/FastGithub.DomainResolve/DnscryptProxy.cs
index 4a105da..55c4870 100644
--- a/FastGithub.DomainResolve/DnscryptProxy.cs
+++ b/FastGithub.DomainResolve/DnscryptProxy.cs
@@ -80,7 +80,7 @@ namespace FastGithub.DomainResolve
process.WaitForExit();
}
- if (OperatingSystem.IsWindows())
+ if (OperatingSystem.IsWindows() && Process.GetCurrentProcess().SessionId == 0)
{
StartDnscryptProxy("-service uninstall")?.WaitForExit();
StartDnscryptProxy("-service install")?.WaitForExit();
@@ -96,7 +96,7 @@ namespace FastGithub.DomainResolve
{
this.LocalEndPoint = localEndPoint;
this.process.EnableRaisingEvents = true;
- this.process.Exited += Process_Exited;
+ this.process.Exited += (s, e) => this.LocalEndPoint = null;
}
}
@@ -107,7 +107,7 @@ namespace FastGithub.DomainResolve
{
try
{
- if (OperatingSystem.IsWindows())
+ if (OperatingSystem.IsWindows() && Process.GetCurrentProcess().SessionId == 0)
{
StartDnscryptProxy("-service stop")?.WaitForExit();
StartDnscryptProxy("-service uninstall")?.WaitForExit();
@@ -158,16 +158,6 @@ namespace FastGithub.DomainResolve
throw new FastGithubException("当前无可用的端口");
}
- ///
- /// 进程退出时
- ///
- ///
- ///
- private void Process_Exited(object? sender, EventArgs e)
- {
- this.LocalEndPoint = null;
- }
-
///
/// 启动DnscryptProxy进程
///