Make FOSS proxy treat connections with unknown sources more gracefully

When a connection to the proxy using the PROXY protocol (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt) comes from an IP address that the external load balancer does not recognize, make the source IP 0.0.0.0. This way an appropriate WHOIS quota can be configured for this kind of connections.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224583547
This commit is contained in:
jianglai 2018-12-07 15:00:27 -08:00
parent 305b1edc85
commit 57a53db84e
2 changed files with 10 additions and 1 deletions

View file

@ -57,7 +57,7 @@ public class ProxyProtocolHandlerTest {
assertThat(channel.writeInbound(Unpooled.wrappedBuffer((header + message).getBytes(UTF_8))))
.isTrue();
assertThat(((ByteBuf) channel.readInbound()).toString(UTF_8)).isEqualTo(message);
assertThat(channel.attr(REMOTE_ADDRESS_KEY).get()).isNull();
assertThat(channel.attr(REMOTE_ADDRESS_KEY).get()).isEqualTo("0.0.0.0");
assertThat(channel.pipeline().get(ProxyProtocolHandler.class)).isNull();
assertThat(channel.isActive()).isTrue();
}