@@ -100,11 +100,13 @@ private void ensureTargetConnection(ChannelEvent e, boolean websocket, final Obj
100100 // Suspend incoming traffic until connected to the remote host.
101101 final Channel inboundChannel = e .getChannel ();
102102 inboundChannel .setReadable (false );
103+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).info ("Inbound proxy connection from " + inboundChannel .getRemoteAddress () + "." );
103104
104105 // resolve the target
105- InetSocketAddress target = resolver .resolveTarget (e . getChannel () );
106+ final InetSocketAddress target = resolver .resolveTarget (inboundChannel );
106107 if ( target == null )
107108 {
109+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).severe ("Connection from " + inboundChannel .getRemoteAddress () + " failed to resolve target." );
108110 // there is no target
109111 inboundChannel .close ();
110112 return ;
@@ -128,8 +130,10 @@ public void operationComplete(ChannelFuture future) throws Exception {
128130 if (future .isSuccess ()) {
129131 // Connection attempt succeeded:
130132 // Begin to accept incoming traffic.
133+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).info ("Created outbound connection to " + target + "." );
131134 inboundChannel .setReadable (true );
132135 } else {
136+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).severe ("Failed to create outbound connection to " + target + "." );
133137 // Close the connection if the connection attempt has failed.
134138 inboundChannel .close ();
135139 }
@@ -166,6 +170,7 @@ private void handleHttpRequest(ChannelHandlerContext ctx, HttpRequest req, final
166170
167171 String upgradeHeader = req .getHeader ("Upgrade" );
168172 if (upgradeHeader != null && upgradeHeader .toUpperCase ().equals ("WEBSOCKET" )){
173+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).fine ("Websocket request from " + e .getRemoteAddress () + "." );
169174 // Handshake
170175 WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory (
171176 this .getWebSocketLocation (req ), "base64" , false );
@@ -189,6 +194,7 @@ private void handleHttpRequest(ChannelHandlerContext ctx, HttpRequest req, final
189194 HttpRequest request = (HttpRequest ) e .getMessage ();
190195 String redirectUrl = isRedirect (request .getUri ());
191196 if ( redirectUrl != null ) {
197+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).fine ("Redirecting to " + redirectUrl + "." );
192198 HttpResponse response = new DefaultHttpResponse (HTTP_1_1 , TEMPORARY_REDIRECT );
193199 response .setHeader (HttpHeaders .Names .LOCATION , redirectUrl );
194200 sendHttpResponse (ctx , req , response );
@@ -238,6 +244,8 @@ private void handleWebRequest(ChannelHandlerContext ctx, final MessageEvent e) t
238244 sendError (ctx , METHOD_NOT_ALLOWED );
239245 return ;
240246 }
247+
248+ Logger .getLogger (WebsockifyProxyHandler .class .getName ()).info ("Web request from " + e .getRemoteAddress () + " for " + request .getUri () + "." );
241249
242250 final String path = sanitizeUri (request .getUri ());
243251 if (path == null ) {
0 commit comments