From e58cb37b9b98e5f211881ce7e1ebaee68cdd858f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Sun, 26 Sep 2021 20:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=85=88=E7=AB=AF=E5=8F=A3=E6=AF=94?= =?UTF-8?q?=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.HttpServer/HttpProxyMiddleware.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/FastGithub.HttpServer/HttpProxyMiddleware.cs b/FastGithub.HttpServer/HttpProxyMiddleware.cs index 69bdcc9..194b588 100644 --- a/FastGithub.HttpServer/HttpProxyMiddleware.cs +++ b/FastGithub.HttpServer/HttpProxyMiddleware.cs @@ -78,9 +78,7 @@ namespace FastGithub.HttpServer if (transport != null) { var targetStream = new NetworkStream(targetSocket, ownsSocket: false); - var task1 = targetStream.CopyToAsync(transport.Output); - var task2 = transport.Input.CopyToAsync(targetStream); - await Task.WhenAny(task1, task2); + await Task.WhenAny(targetStream.CopyToAsync(transport.Output), transport.Input.CopyToAsync(targetStream)); } } else @@ -100,9 +98,9 @@ namespace FastGithub.HttpServer /// private bool IsFastGithubServer(HostString host) { - if (host.Host == LOOPBACK || host.Host == LOCALHOST) + if (host.Port == this.fastGithubConfig.HttpProxyPort) { - return host.Port == this.fastGithubConfig.HttpProxyPort; + return host.Host == LOOPBACK || host.Host == LOCALHOST; } return false; }