Skip to content

Commit

Permalink
webdav: ensure that HttpProtocolInfo is populated with correct client…
Browse files Browse the repository at this point in the history
… address

Motivation:
The DcacheResourceFactory currently always uses zero (0) as the client
source port. However, we ServletRequest provides the real TCP port that
dcache can use.

Modification:
Update DcacheResourceFactory#initializeTransfer method to use client's
real IP and port.

Result:
More correct client IP information.

Acked-by: Paul Millar
Acked-by: Albert Rossi
Target: master
Require-book: no
Require-notes: no
  • Loading branch information
kofemann committed Sep 30, 2022
1 parent 2e1ddf8 commit 532c1c8
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -37,6 +37,7 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Range;
import com.google.common.collect.Sets;
import com.google.common.net.InetAddresses;
import com.google.common.net.MediaType;
import diskCacheV111.poolManager.PoolMonitorV5;
import diskCacheV111.services.space.Space;
Expand Down Expand Up @@ -1411,10 +1412,10 @@ private void initializeTransfer(HttpTransfer transfer, Subject subject)
transfer.setPoolStub(_poolStub);
transfer.setBillingStub(_billingStub);
transfer.setIoQueue(_ioQueue);
List<InetSocketAddress> addresses = Subjects.getOrigin(subject).getClientChain().stream().
map(a -> new InetSocketAddress(a, PROTOCOL_INFO_UNKNOWN_PORT)).
collect(Collectors.toList());
transfer.setClientAddresses(addresses);
transfer.setClientAddresses(List.of(
new InetSocketAddress(InetAddresses.forUriString(
ServletRequest.getRequest().getRemoteAddr()), ServletRequest.getRequest().getRemotePort())
));
transfer.setOverwriteAllowed(_isOverwriteAllowed);
transfer.setKafkaSender(_kafkaSender);
}
Expand Down

0 comments on commit 532c1c8

Please sign in to comment.