ProxyCommandHandler extends AbstractCommandHandler { @Override protected void doHandle(String[] args, RedisClient redisClient) { String proxyProtocol = restructCommand(args); logger.info("[doHandle]receive proxy protocol: {}", proxyProtocol); ProxyConnectProtocol protocol = (ProxyConnectProtocol) new DefaultProxyConnectProtocolParser().read(proxyProtocol); protocol.recordForwardFor((InetSocketAddress) redisClient.channel().remoteAddress()); String forwardFor = protocol.getForwardFor(); Endpoint srcEndpoint = getSourceEndpoint(forwardFor); redisClient.setClientIpAddress(srcEndpoint.getHost()); redisClient.setClientEndpoint(new ProxyEnabledEndpoint(srcEndpoint.getHost(), srcEndpoint.getPort(), protocol)); }  @Override String[] getCommands();  }
@Test public void testDoHandle() { final String command = "ROUTE proxy: " tls: DefaultRedisClient client = new DefaultRedisClient(channel, null); handler.doHandle(command.split(WHITE_SPACE), client); Assert.assertEquals("192.168.1.1", client.ip()); }