Skip to content

Commit

Permalink
Disconnecting client when server disconnects when tunneling or MITMing
Browse files Browse the repository at this point in the history
  • Loading branch information
jekh committed Jul 19, 2015
1 parent 266c896 commit 6f93194
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,12 @@ private void resumeReadingIfNecessary() {
*/
protected void serverDisconnected(ProxyToServerConnection serverConnection) {
numberOfCurrentlyConnectedServers.decrementAndGet();
// not disconnecting the client from the proxy, even if this was the last server connection. this allows clients
// to continue to use the open connection to the proxy to make future requests.

// But, in case of a HTTPS connection, it seems to be neccessary to
// close the connection, since it can't be reused with MITM.
// see: https://github.com/ganskef/LittleProxy-mitm/issues/7
//
if (sslEngine != null && numberOfCurrentlyConnectedServers.get() == 0) {

// for non-SSL connections, do not disconnect the client from the proxy, even if this was the last server connection.
// this allows clients to continue to use the open connection to the proxy to make future requests. for SSL
// connections, whether we are tunneling or MITMing, we need to disconnect the client because there is always
// exactly one ClientToProxyConnection per ProxyToServerConnection, and vice versa.
if (isTunneling() || isMitming()) {
disconnect();
}
}
Expand Down

0 comments on commit 6f93194

Please sign in to comment.