/// <summary> /// Creates a new connection for the tunnel. /// </summary> /// <param name="session">The session that will own the connection.</param> /// <param name="connectionId"></param> /// <returns> /// The <see cref="T:BlueBoxMoon.LocalSubway.Connections.Connection" /> that can now be added to the tunnel. /// </returns> public override async Task <Connection> CreateConnectionAsync(ClientSession session, Guid connectionId) { var socket = new SubwayTcpClient(_hostname, _port); var connection = new TcpClientConnection(connectionId, Id, session, socket); await connection.StartAsync(); return(connection); }
/// <summary> /// Closes the local side of the connection. /// </summary> public override Task CloseLocalAsync() { LocalSocket?.Close(); LocalSocket = null; Session = null; return(Task.CompletedTask); }
/// <summary> /// Creates a new connection for the tunnel. /// </summary> /// <param name="session">The session that will own the connection.</param> /// <param name="connectionId"></param> /// <returns> /// The <see cref="T:BlueBoxMoon.LocalSubway.Connection" /> that can now be added to the tunnel. /// </returns> public override async Task <Connection> CreateConnectionAsync(ClientSession session, Guid connectionId) { SubwayTcpClient socket; if (_useSsl) { socket = new SubwaySslClient(_hostname, _port); } else { socket = new SubwayTcpClient(_hostname, _port); } var connection = new WebClientConnection(connectionId, Id, session, socket, _hostname); await connection.StartAsync(); return(connection); }
/// <summary> /// Initializes a new instance of the <see cref="WebClientConnection"/> class. /// </summary> /// <param name="connectionId">The connection identifier.</param> /// <param name="tunnelId">The tunnel identifier.</param> /// <param name="session">The session.</param> /// <param name="socket">The socket.</param> public WebClientConnection(Guid connectionId, Guid tunnelId, ClientSession session, SubwayTcpClient socket, string hostHeader) : base(connectionId, tunnelId, session, socket) { _interceptor = new HttpWebRequestInterceptor(socket.GetStream()); if (hostHeader != null) { _interceptor.ForcedHeaders.Add("Host", hostHeader); } // // Ensure the connection is closed so our interceptor can properly track requests. // TODO: Without this, the server hangs for some reason. Need to investigate. // _interceptor.ForcedHeaders.Add("Connection", "close"); }
/// <summary> /// Initializes a new instance of the <see cref="SubwayClientConnection"/> class. /// </summary> /// <param name="tunnelId">The tunnel identifier.</param> /// <param name="session">The session.</param> /// <param name="socket">The socket.</param> public TcpClientConnection(Guid id, Guid tunnelId, ClientSession session, SubwayTcpClient socket) : base(id, tunnelId) { Session = session; LocalSocket = socket; }