Skip to content

Commit

Permalink
Avoid potential for reverse name lookup (#5305)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Feb 8, 2022
1 parent 1bdd88d commit 186c657
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public String transport(ChannelAndMethod channelAndMethod, @Nullable Void unused
@Nullable
@Override
public String peerName(ChannelAndMethod channelAndMethod, @Nullable Void unused) {
return channelAndMethod.getChannel().getConnection().getAddress().getHostName();
// not using InetAddress.getHostName() since that can trigger reverse name lookup
return null;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public String transport(ReceiveRequest request, @Nullable GetResponse response)
@Nullable
@Override
public String peerName(ReceiveRequest request, @Nullable GetResponse response) {
return request.getConnection().getAddress().getHostName();
// not using InetAddress.getHostName() since that can trigger reverse name lookup
return null;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public String url(HttpClientConfig request) {
if (hostAddress instanceof InetSocketAddress) {
InetSocketAddress inetHostAddress = (InetSocketAddress) hostAddress;
return (request.isSecure() ? "https://" : "http://")
+ inetHostAddress.getHostName()
+ inetHostAddress.getHostString()
+ ":"
+ inetHostAddress.getPort()
+ (uri.startsWith("/") ? "" : "/")
Expand Down

0 comments on commit 186c657

Please sign in to comment.