private void EstablishSslConnection(string host, int port, string version ) { _logger.Info("Starting SSL tunnel"); // When establishing an SSL connection, stop processing data from the client. The data // will be encrypted and is meaningless to the proxy service. This event is re-wired // when the next connection is restarted. _connection.DataAvailable -= ConnectionDataAvailable; // TODO: consider making this a dependency and allowing it to reset (inherit from IPooledObject) _tunnel = CoreFactory.Compose<IHttpsTunnel>(); _tunnel.TunnelClosed += (sender, args) => { _logger.Info("Releasing HTTPS tunnel"); _serverConnectingEvent.Release(); Reset(); }; _tunnel.EstablishTunnel(host, port, version, _connection ); }
public void Reset() { lock ( _mutex ) { if ( _connection != null ) { _logger.Info( "Resetting proxy client connection" ); _connection.ConnectionClosed -= ConnectionConnectionClosed; _connection.DataAvailable -= ConnectionDataAvailable; _connection.Shutdown -= ConnectionReceiveShutdown; _connection.Close(); _connection = null; _parser.ReadRequestHeaderComplete -= ParserReadRequestHeaderComplete; _parser.PartialDataAvailable -= ParserPartialDataAvailable; _parser = null; _serverDispatcher.Reset(); EventHandler sessionEndedEvent = SessionEnded; if ( sessionEndedEvent != null ) { sessionEndedEvent( this, new EventArgs() ); } _tunnel = null; } } }