You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/07/11 02:16:43 UTC
svn commit: r1359960 - in /commons/proper/net/trunk/src: changes/changes.xml
main/java/org/apache/commons/net/ftp/FTPClient.java
Author: sebb
Date: Wed Jul 11 00:16:43 2012
New Revision: 1359960
URL: http://svn.apache.org/viewvc?rev=1359960&view=rev
Log:
NET-462 FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP
Modified:
commons/proper/net/trunk/src/changes/changes.xml
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1359960&r1=1359959&r2=1359960&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Wed Jul 11 00:16:43 2012
@@ -65,6 +65,9 @@ The <action> type attribute can be add,u
<release version="3.2" date="TBA" description="
TBA
">
+ <action issue="NET-462" dev="sebb" type="add" due-to="Bogdan Drozdowski">
+ FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP.
+ </action>
<action issue="NET-467" dev="sebb" type="fix">
IMAPClient#fetch() does not handle literal strings.
</action>
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1359960&r1=1359959&r2=1359960&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Wed Jul 11 00:16:43 2012
@@ -344,6 +344,8 @@ implements Configurable
private int __activeMaxPort;
private InetAddress __activeExternalHost;
private InetAddress __reportActiveExternalHost; // overrides __activeExternalHost in EPRT/PORT commands
+ /** The address to bind to on passive connections, if necessary. */
+ private InetAddress __passiveLocalHost;
private int __fileType;
@SuppressWarnings("unused") // fields are written, but currently not read
@@ -451,6 +453,7 @@ implements Configurable
__listHiddenFiles = false;
__useEPSVwithIPv4 = false;
__random = new Random();
+ __passiveLocalHost = null;
}
@@ -782,6 +785,9 @@ implements Configurable
}
socket = _socketFactory_.createSocket();
+ if (__passiveLocalHost != null) {
+ socket.bind(new InetSocketAddress(__passiveLocalHost, 0));
+ }
socket.connect(new InetSocketAddress(__passiveHost, __passivePort), connectTimeout);
if ((__restartOffset > 0) && !restart(__restartOffset))
{
@@ -1335,6 +1341,40 @@ implements Configurable
}
/**
+ * Set the local IP address to use in passive mode.
+ * Useful when there are multiple network cards.
+ * <p>
+ * @param ipAddress The local IP address of this machine.
+ * @throws UnknownHostException if the ipAddress cannot be resolved
+ */
+ public void setPassiveLocalIPAddress(String ipAddress) throws UnknownHostException
+ {
+ this.__passiveLocalHost = InetAddress.getByName(ipAddress);
+ }
+
+ /**
+ * Set the local IP address to use in passive mode.
+ * Useful when there are multiple network cards.
+ * <p>
+ * @param inetAddress The local IP address of this machine.
+ */
+ public void setPassiveLocalIPAddress(InetAddress inetAddress)
+ {
+ this.__passiveLocalHost = inetAddress;
+ }
+
+ /**
+ * Set the local IP address in passive mode.
+ * Useful when there are multiple network cards.
+ * <p>
+ * @return The local IP address in passive mode.
+ */
+ public InetAddress getPassiveLocalIPAddress()
+ {
+ return this.__passiveLocalHost;
+ }
+
+ /**
* Set the external IP address to report in EPRT/PORT commands in active mode.
* Useful when there are multiple network cards.
* <p>