You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Holthof, Lukas" <lu...@sap.com> on 2020/03/23 22:23:50 UTC

[net] FTPClient should connect with hostname instead of IP

Hello,

I want to connect to a FTP/FTPS server which resides in a different network and it not reachable directly from my client. The FTP server's local hostname (e.g. ftp.server.corp) is not known to the client. Instead the client should use a virtual hostname which gets resolved to the actual local hostname by a Reverse Invoke Proxy (e.g. ftp.virtual::ftp.server.corp).

High level scenario:
FTPClient -> SOCKS5 PROXY -> REVERSE INVOKE PROXY -> FTP SERVER

The SocketClient always tries to determine the IP address of the hostname provided: e.g. InetAddress.getByName(hostname)<https://github.com/apache/commons-net/blob/master/src/main/java/org/apache/commons/net/SocketClient.java#L243>.
I would like to prevent this and use instead: _socket_.connect(InetSocketAddress.createUnresolved(host, port), connectTimeout);
InetAdresses are used in various places in FTPClient, so similar changes are required a couple of times.

Is there a better way preventing the IP resolution on client side? In case not, would this be something which could become a switchable feature in Apache Commons Net FTPClient/SocketClient?

Regards,
Lukas