diff --git a/FastGithub.ReverseProxy/GithubSshHandler.cs b/FastGithub.ReverseProxy/GithubSshHandler.cs index dc948a2..8445d17 100644 --- a/FastGithub.ReverseProxy/GithubSshHandler.cs +++ b/FastGithub.ReverseProxy/GithubSshHandler.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace FastGithub.ReverseProxy { /// - /// github的ssl处理者 + /// github的ssh处理者 /// sealed class GithubSshHandler : ConnectionHandler { @@ -20,7 +20,7 @@ namespace FastGithub.ReverseProxy private readonly IDomainResolver domainResolver; /// - /// github的ssl处理者 + /// github的ssh处理者 /// /// public GithubSshHandler(IDomainResolver domainResolver) @@ -36,11 +36,11 @@ namespace FastGithub.ReverseProxy public override async Task OnConnectedAsync(ConnectionContext connection) { var address = await this.domainResolver.ResolveAsync(GITHUB_COM, CancellationToken.None); - var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + using var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); await socket.ConnectAsync(new IPEndPoint(address, SSH_PORT)); - using var upStream = new NetworkStream(socket, ownsSocket: true); - var downStream = new SshStream(connection.Transport); + var upStream = new NetworkStream(socket, ownsSocket: false); + var downStream = new DuplexStream(connection.Transport); var task1 = upStream.CopyToAsync(downStream); var task2 = downStream.CopyToAsync(upStream); @@ -48,18 +48,18 @@ namespace FastGithub.ReverseProxy } /// - /// 表示Ssh的流 + /// 双工数据流 /// - private class SshStream : Stream + private class DuplexStream : Stream { private readonly Stream readStream; private readonly Stream wirteStream; /// - /// Ssh的流 + /// 双工数据流 /// /// - public SshStream(IDuplexPipe transport) + public DuplexStream(IDuplexPipe transport) { this.readStream = transport.Input.AsStream(); this.wirteStream = transport.Output.AsStream();