Remote address in client connection channel#17
Conversation
| <artifactId>littleproxy</artifactId> | ||
| <packaging>jar</packaging> | ||
| <version>1.1.3.2-VGS-SNAPSHOT</version> | ||
| <version>1.1.3.3-VGS-SNAPSHOT</version> |
There was a problem hiding this comment.
We will discuss the versioning mechanism when we all get together in one room
| LOG.debug("Starting new connection to: {}", remoteAddress); | ||
|
|
||
| this.clientConnection.channel.attr(remoteAddressAttrKey).set(remoteAddress); | ||
|
|
There was a problem hiding this comment.
There are 2 channels: client to proxy channel and proxy to destination server channel.
The proxy to server channel is created from client to proxy channel and contains reference to it. This reference (to client to proxy channel) is passed to mitm manager factory from ProxyToServerConnection (when a connection to remote server is established). To select a proper mitm manager (with white listed hosts) we need to pass active server connection host to client to proxy channel so it is accessible from ConditionallyInsecureMitmManagerFactory
There was a problem hiding this comment.
do we need to remove this once the connection has completed? otherwise we're going to maintain a reference to these channels forever won't we?
There was a problem hiding this comment.
@mjallday each time a connection is established a new ClientToProxyConnection class is created with its corresponding new channel here https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/DefaultHttpProxyServer.java#L514
https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/ProxyConnection.java#L591
Also I read a book about netty and there was nothing about cleaning up attributes in the channel, it was said that the attributes are a good way of sharing state between components that may use the same channel (as it is thread safe, it can determine if the channel was called from particular thread and if not put it in queue)
But let me clarify it further so I am 100 percent sure
mjallday
left a comment
There was a problem hiding this comment.
This looks reasonable but I want to know about the cleanup process here. I fear this will accumulate references to the channels and never release them.
| */ | ||
| private static final int MINIMUM_RECV_BUFFER_SIZE_BYTES = 64; | ||
|
|
||
| public static final AttributeKey<InetSocketAddress> remoteAddressAttrKey = AttributeKey.valueOf("remoteAddressAttrKey"); |
There was a problem hiding this comment.
should this be named REMOTE_ADDRESS_ATTR_KEY?
|
@mjallday each time a connection is established a new ClientToProxyConnection class is created with its corresponding new channel here https://github.com/adamfisk/LittleProxy/blob/master/src/main/java/org/littleshoot/proxy/impl/DefaultHttpProxyServer.java#L514 But let me clarify it further so I am 100 percent sure |
So |
Littleproxy part for https://github.com/verygoodsecurity/vault/issues/1478