Avoid DNS lookups when parsing PPv2 headers

PPv2 headers should only come from trusted sources, but use a less
error-prone IP parsing mechanism anyways
This commit is contained in:
Ravi Khadiwala authored and Ameya Lokare committed 2026-08-25 13:28:34 -07:00
1 parent 5f66f1c51d
commit 1dd7383af0
1 file changed
+3 -1
@@ -4,6 +4,7 @@
*/
package org.whispersystems.textsecuregcm.grpc.net;
import com.google.common.net.InetAddresses;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.haproxy.HAProxyMessage;
@@ -30,7 +31,8 @@ class ProxyMessageAttributeSetterHandler extends ChannelInboundHandlerAdapter {
try {
final String sourceAddress = proxyMessage.sourceAddress();
if (sourceAddress != null) {
ctx.channel().attr(PROXY_REMOTE_ADDRESS).set(InetAddress.getByName(sourceAddress));
// Assume that the server has been configured to only allow access from a trusted PPv2 provider
ctx.channel().attr(PROXY_REMOTE_ADDRESS).set(InetAddresses.forString(sourceAddress));
} else {
logger.warn("PROXY protocol message has no source address");
}