You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-commits@incubator.apache.org by ng...@apache.org on 2007/05/04 18:34:46 UTC
svn commit: r535345 - in /incubator/ftpserver/trunk:
core/src/java/org/apache/ftpserver/
core/src/java/org/apache/ftpserver/command/
core/src/java/org/apache/ftpserver/interfaces/
core/src/java/org/apache/ftpserver/listener/mina/ core/src/test/org/apac...
Author: ngn
Date: Fri May 4 11:34:41 2007
New Revision: 535345
URL: http://svn.apache.org/viewvc?view=rev&rev=535345
Log:
Implemented a configurable external passive address (FTPSERVER-83) as suggested by Clinton Foster
Added:
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DataConnectionException.java (with props)
incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressTest.java (with props)
incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressWithHostnameTest.java (with props)
Removed:
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/listener/mina/FtpRequestDecoder.java
Modified:
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultDataConnectionConfig.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnectionFactory.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ServerDataConnectionFactory.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java
incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/DataConnectionConfig.java
incubator/ftpserver/trunk/distribution/res/conf/ftpd.properties
incubator/ftpserver/trunk/distribution/res/conf/ftpd.xml
incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java
incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/DataConnection.java
Added: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DataConnectionException.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DataConnectionException.java?view=auto&rev=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DataConnectionException.java (added)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DataConnectionException.java Fri May 4 11:34:41 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ftpserver;
+
+import org.apache.ftpserver.ftplet.FtpException;
+
+/**
+ * Thrown if a data connection can not be established
+ */
+public class DataConnectionException extends FtpException {
+ private static final long serialVersionUID = -1328383839917648987L;
+
+ /**
+ * Default constructor.
+ */
+ public DataConnectionException() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>DataConnectionException</code> object with a message.
+ *
+ * @param msg a description of the exception
+ */
+ public DataConnectionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a <code>DataConnectionException</code> object with a
+ * <code>Throwable</code> cause.
+ *
+ * @param th the original cause
+ */
+ public DataConnectionException(Throwable th) {
+ super(th);
+ }
+
+ /**
+ * Constructs a <code>DataConnectionException</code> object with a
+ * <code>Throwable</code> cause.
+ *
+ * @param th the original cause
+ */
+ public DataConnectionException(String msg, Throwable th) {
+ super(msg);
+ }
+}
Propchange: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DataConnectionException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultDataConnectionConfig.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultDataConnectionConfig.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultDataConnectionConfig.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/DefaultDataConnectionConfig.java Fri May 4 11:34:41 2007
@@ -73,6 +73,7 @@
public static class Passive {
private InetAddress address;
+ private InetAddress externalAddress;
private PassivePorts passivePorts =PassivePorts.parse("0");
public InetAddress getAddress() {
@@ -87,6 +88,12 @@
public void setPorts(String ports) {
this.passivePorts = PassivePorts.parse(ports);
}
+ public InetAddress getExternalAddress() {
+ return externalAddress;
+ }
+ public void setExternalAddress(InetAddress externalAddress) {
+ this.externalAddress = externalAddress;
+ }
}
private int maxIdleTimeMillis = 10000;
@@ -153,6 +160,13 @@
*/
public InetAddress getPassiveAddress() {
return passive.getAddress();
+ }
+
+ /**
+ * Get external passive host.
+ */
+ public InetAddress getPassiveExernalAddress() {
+ return passive.getExternalAddress();
}
/**
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnectionFactory.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnectionFactory.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnectionFactory.java Fri May 4 11:34:41 2007
@@ -20,6 +20,7 @@
package org.apache.ftpserver;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -40,7 +41,7 @@
*/
public class IODataConnectionFactory implements ServerDataConnectionFactory {
- static final Logger LOG = LoggerFactory.getLogger(IODataConnectionFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(IODataConnectionFactory.class);
private FtpServerContext serverContext;
private Socket dataSoc;
@@ -51,8 +52,7 @@
long requestTime = 0L;
- boolean isPort = false;
- boolean isPasv = false;
+ boolean passive = false;
boolean secure = false;
private boolean isZip = false;
@@ -112,23 +112,23 @@
/**
* Port command.
*/
- public synchronized void setPortCommand(InetAddress addr, int activePort) {
+ public synchronized void initActiveDataConnection(InetSocketAddress address) {
// close old sockets if any
closeDataConnection();
// set variables
- isPort = true;
- isPasv = false;
- address = addr;
- port = activePort;
+ passive = false;
+ this.address = address.getAddress();
+ port = address.getPort();
requestTime = System.currentTimeMillis();
}
/**
- * Passive command. It returns the success flag.
+ * Initiate a data connection in passive mode (server listening).
+ * It returns the success flag.
*/
- public synchronized boolean setPasvCommand() {
+ public synchronized InetSocketAddress initPassiveDataConnection() throws DataConnectionException {
// close old sockets if any
closeDataConnection();
@@ -136,13 +136,11 @@
// get the passive port
int passivePort = session.getListener().getDataConnectionConfig().getPassivePort();
if(passivePort == -1) {
- LOG.warn("Cannot find an available passive port.");
servSoc = null;
- return false;
+ throw new DataConnectionException("Cannot find an available passive port.");
}
// open passive server socket and get parameters
- boolean bRet = false;
try {
DataConnectionConfig dataCfg = session.getListener().getDataConnectionConfig();
address = dataCfg.getPassiveAddress();
@@ -152,28 +150,30 @@
if(secure) {
Ssl ssl = dataCfg.getSSL();
if(ssl == null) {
- throw new FtpException("Data connection SSL not configured.");
+ throw new DataConnectionException("Data connection SSL required but not configured.");
}
servSoc = ssl.createServerSocket(null, address, passivePort);
+ port = servSoc.getLocalPort();
+ LOG.debug("SSL data connection created on " + address + ":" + port);
}
else {
servSoc = new ServerSocket(passivePort, 1, address);
+ port = servSoc.getLocalPort();
+ LOG.debug("Data connection created on " + address + ":" + port);
}
servSoc.setSoTimeout(dataCfg.getMaxIdleTimeMillis());
- port = servSoc.getLocalPort();
// set different state variables
- isPort = false;
- isPasv = true;
- bRet = true;
+ passive = true;
requestTime = System.currentTimeMillis();
+
+ return new InetSocketAddress(address, port);
}
catch(Exception ex) {
servSoc = null;
closeDataConnection();
- LOG.warn("FtpDataConnection.setPasvCommand()", ex);
+ throw new DataConnectionException("FtpDataConnection.setPasvCommand()", ex);
}
- return bRet;
}
/* (non-Javadoc)
@@ -194,19 +194,19 @@
* @see org.apache.ftpserver.FtpDataConnectionFactory2#openConnection()
*/
public DataConnection openConnection() throws Exception {
- return new IODataConnection(getDataSocket(), session, this);
+ return new IODataConnection(createDataSocket(), session, this);
}
/**
* Get the data socket. In case of error returns null.
*/
- private synchronized Socket getDataSocket() throws Exception {
+ private synchronized Socket createDataSocket() throws Exception {
// get socket depending on the selection
dataSoc = null;
DataConnectionConfig dataConfig = session.getListener().getDataConnectionConfig();
try {
- if(isPort) {
+ if(!passive) {
int localPort = dataConfig.getActiveLocalPort();
if(secure) {
Ssl ssl = dataConfig.getSSL();
@@ -230,9 +230,10 @@
dataSoc = new Socket(address, port, localAddr, localPort);
}
}
- }
- else if(isPasv) {
+ } else {
+ LOG.debug("Opening passive data connection");
dataSoc = servSoc.accept();
+ LOG.debug("Passive data connection opened");
}
}
catch(Exception ex) {
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ServerDataConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ServerDataConnectionFactory.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ServerDataConnectionFactory.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/ServerDataConnectionFactory.java Fri May 4 11:34:41 2007
@@ -20,6 +20,7 @@
package org.apache.ftpserver;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import org.apache.ftpserver.ftplet.DataConnectionFactory;
@@ -28,12 +29,14 @@
/**
* Port command.
*/
- void setPortCommand(InetAddress addr, int activePort);
+ void initActiveDataConnection(InetSocketAddress address);
/**
- * Passive command. It returns the success flag.
+ * Initate the passive data connection.
+ * @return The {@link InetSocketAddress} on which the data connection
+ * if bound.
*/
- boolean setPasvCommand();
+ InetSocketAddress initPassiveDataConnection() throws DataConnectionException;
/**
* Set the security protocol.
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPRT.java Fri May 4 11:34:41 2007
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import org.apache.ftpserver.FtpSessionImpl;
@@ -117,7 +118,7 @@
return;
}
- session.getServerDataConnection().setPortCommand(dataAddr, dataPort);
+ session.getServerDataConnection().initActiveDataConnection(new InetSocketAddress(dataAddr, dataPort));
out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "EPRT", null));
}
}
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/EPSV.java Fri May 4 11:34:41 2007
@@ -20,9 +20,11 @@
package org.apache.ftpserver.command;
import java.io.IOException;
+import java.net.InetSocketAddress;
-import org.apache.ftpserver.ServerDataConnectionFactory;
+import org.apache.ftpserver.DataConnectionException;
import org.apache.ftpserver.FtpSessionImpl;
+import org.apache.ftpserver.ServerDataConnectionFactory;
import org.apache.ftpserver.ftplet.FtpReply;
import org.apache.ftpserver.ftplet.FtpReplyOutput;
import org.apache.ftpserver.ftplet.FtpRequest;
@@ -57,16 +59,19 @@
// set data connection
ServerDataConnectionFactory dataCon = session.getServerDataConnection();
- if (!dataCon.setPasvCommand()) {
+
+ try {
+ InetSocketAddress dataConAddress = dataCon.initPassiveDataConnection();
+ // get connection info
+ int servPort = dataConAddress.getPort();
+
+ // send connection info to client
+ String portStr = "|||" + servPort + '|';
+ out.write(FtpReplyUtil.translate(session, 229, "EPSV", portStr));
+
+ } catch(DataConnectionException e) {
out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "EPSV", null));
return;
}
-
- // get connection info
- int servPort = dataCon.getPort();
-
- // send connection info to client
- String portStr = "|||" + servPort + '|';
- out.write(FtpReplyUtil.translate(session, 229, "EPSV", portStr));
}
}
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PASV.java Fri May 4 11:34:41 2007
@@ -21,15 +21,19 @@
import java.io.IOException;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
-import org.apache.ftpserver.ServerDataConnectionFactory;
+import org.apache.ftpserver.DataConnectionException;
import org.apache.ftpserver.FtpSessionImpl;
+import org.apache.ftpserver.ServerDataConnectionFactory;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.ftplet.FtpReply;
import org.apache.ftpserver.ftplet.FtpReplyOutput;
import org.apache.ftpserver.ftplet.FtpRequest;
import org.apache.ftpserver.listener.Connection;
import org.apache.ftpserver.util.FtpReplyUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <code>PASV <CRLF></code><br>
@@ -43,6 +47,8 @@
public
class PASV extends AbstractCommand {
+ private static final Logger LOG = LoggerFactory.getLogger(PASV.class);
+
/**
* Execute command
*/
@@ -56,17 +62,28 @@
// set data connection
ServerDataConnectionFactory dataCon = session.getServerDataConnection();
- if (!dataCon.setPasvCommand()) {
+ InetAddress externalPassiveAddress = session.getListener().getDataConnectionConfig().getPassiveExernalAddress();
+
+ try {
+ InetSocketAddress dataConAddress = dataCon.initPassiveDataConnection();
+
+ // get connection info
+ InetAddress servAddr;
+ if(externalPassiveAddress != null) {
+ servAddr = externalPassiveAddress;
+ } else {
+ servAddr = dataConAddress.getAddress();
+ }
+ int servPort = dataConAddress.getPort();
+
+ // send connection info to client
+ String addrStr = servAddr.getHostAddress().replace( '.', ',' ) + ',' + (servPort>>8) + ',' + (servPort&0xFF);
+ out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_227_ENTERING_PASSIVE_MODE, "PASV", addrStr));
+ } catch(DataConnectionException e) {
+ LOG.warn("Failed to open passive data connection", e);
out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "PASV", null));
return;
}
- // get connection info
- InetAddress servAddr = dataCon.getInetAddress();
- int servPort = dataCon.getPort();
-
- // send connection info to client
- String addrStr = servAddr.getHostAddress().replace( '.', ',' ) + ',' + (servPort>>8) + ',' + (servPort&0xFF);
- out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_227_ENTERING_PASSIVE_MODE, "PASV", addrStr));
}
}
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/PORT.java Fri May 4 11:34:41 2007
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.StringTokenizer;
@@ -122,7 +123,7 @@
return;
}
- session.getServerDataConnection().setPortCommand(dataAddr, dataPort);
+ session.getServerDataConnection().initActiveDataConnection(new InetSocketAddress(dataAddr, dataPort));
out.write(FtpReplyUtil.translate(session, FtpReply.REPLY_200_COMMAND_OKAY, "PORT", null));
}
Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/DataConnectionConfig.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/DataConnectionConfig.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/DataConnectionConfig.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/DataConnectionConfig.java Fri May 4 11:34:41 2007
@@ -58,6 +58,14 @@
InetAddress getPassiveAddress();
/**
+ * Get the passive address that will be returned to clients on the
+ * PASV command.
+ * @return The passive address to be returned to clients, null if not
+ * configured.
+ */
+ InetAddress getPassiveExernalAddress();
+
+ /**
* Get passive port.
*/
int getPassivePort();
Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressTest.java?view=auto&rev=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressTest.java (added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressTest.java Fri May 4 11:34:41 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ftpserver.clienttests;
+
+import java.util.Properties;
+
+public class PasvAddressTest extends ClientTestTemplate {
+
+ protected Properties createConfig() {
+ Properties config = createDefaultConfig();
+
+ config.setProperty("config.listeners.default.data-connection.class",
+ "org.apache.ftpserver.DefaultDataConnectionConfig");
+ config.setProperty(
+ "config.listeners.default.data-connection.passive.external-address",
+ "1.2.3.4");
+
+ return config;
+ }
+
+ public void testPasvAddress() throws Exception {
+ client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
+ client.pasv();
+
+ assertTrue(client.getReplyString().indexOf("(1,2,3,4,") > -1);
+ }
+}
Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressWithHostnameTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressWithHostnameTest.java?view=auto&rev=535345
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressWithHostnameTest.java (added)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressWithHostnameTest.java Fri May 4 11:34:41 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ftpserver.clienttests;
+
+import java.util.Properties;
+
+/**
+ * Test for external passive address configured as hostname rather than
+ * IP address.
+ */
+public class PasvAddressWithHostnameTest extends ClientTestTemplate {
+
+ protected Properties createConfig() {
+ Properties config = createDefaultConfig();
+
+ config.setProperty("config.listeners.default.data-connection.class",
+ "org.apache.ftpserver.DefaultDataConnectionConfig");
+ config.setProperty(
+ "config.listeners.default.data-connection.passive.external-address",
+ "localhost");
+
+ return config;
+ }
+
+ public void testPasvAddress() throws Exception {
+ client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
+ client.pasv();
+
+ assertTrue(client.getReplyString().indexOf("(127,0,0,1,") > -1);
+ }
+}
Propchange: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/PasvAddressWithHostnameTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/ftpserver/trunk/distribution/res/conf/ftpd.properties
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/distribution/res/conf/ftpd.properties?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/distribution/res/conf/ftpd.properties (original)
+++ incubator/ftpserver/trunk/distribution/res/conf/ftpd.properties Fri May 4 11:34:41 2007
@@ -46,6 +46,7 @@
#config.listeners.default.data-connection.active.ip-check=false
#config.listeners.default.data-connection.passive.address=localhost
#config.listeners.default.data-connection.passive.ports=0
+#config.listeners.default.data-connection.passive.external-address=192.1.2.3
#config.listeners.default.data-connection.ssl.class=org.apache.ftpserver.ssl.DefaultSsl
#config.listeners.default.data-connection.ssl.keystore-file=./res/.keystore
#config.listeners.default.data-connection.ssl.keystore-password=password
Modified: incubator/ftpserver/trunk/distribution/res/conf/ftpd.xml
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/distribution/res/conf/ftpd.xml?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/distribution/res/conf/ftpd.xml (original)
+++ incubator/ftpserver/trunk/distribution/res/conf/ftpd.xml Fri May 4 11:34:41 2007
@@ -55,6 +55,7 @@
<passive>
<address>localhost</address>
<ports>0</ports>
+ <external-address>192.1.2.3</external-address>
</passive>
<ssl>
<class>org.apache.ftpserver.ssl.DefaultSsl</class>
Modified: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java (original)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java Fri May 4 11:34:41 2007
@@ -20,7 +20,7 @@
package org.apache.ftpserver.ftplet;
/**
- * Thrown is an authentication request fails
+ * Thrown if an authentication request fails
*/
public class AuthenticationFailedException extends FtpException {
private static final long serialVersionUID = -1328383839915898987L;
Modified: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/DataConnection.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/DataConnection.java?view=diff&rev=535345&r1=535344&r2=535345
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/DataConnection.java (original)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/DataConnection.java Fri May 4 11:34:41 2007
@@ -29,7 +29,7 @@
* Transfer data from the client (e.g. STOR).
* @param out The {@link OutputStream} containing the destination
* of the data from the client.
- * @return The length of the transefered data
+ * @return The length of the transferred data
* @throws IOException
*/
long transferFromClient(OutputStream out) throws IOException;
@@ -37,7 +37,7 @@
/**
* Transfer data to the client (e.g. RETR).
* @param in Data to be transfered to the client
- * @return The length of the transefered data
+ * @return The length of the transferred data
* @throws IOException
*/
long transferToClient(InputStream in) throws IOException;