You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ra...@apache.org on 2002/03/08 07:37:12 UTC

cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver FtpConfig.java

rana_b      02/03/07 22:37:12

  Modified:    ftpserver/src/java/org/apache/avalon/ftpserver
                        FtpConfig.java
  Log:
  multihome support
  
  Revision  Changes    Path
  1.11      +91 -15    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpConfig.java
  
  Index: FtpConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpConfig.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FtpConfig.java	6 Mar 2002 13:55:17 -0000	1.10
  +++ FtpConfig.java	8 Mar 2002 06:37:12 -0000	1.11
  @@ -11,6 +11,7 @@
   import java.io.File;
   import java.io.IOException;
   import java.net.InetAddress;
  +import java.net.UnknownHostException;
   
   import org.apache.avalon.phoenix.BlockContext;
   import org.apache.avalon.framework.component.ComponentManager;
  @@ -53,7 +54,8 @@
       private IpRestrictorInterface mIpRestrictor = null;
       private UserManagerInterface mUserManager   = null;
       
  -    private InetAddress  mSelfAddr              = null;
  +    private InetAddress mServerAddress          = null;
  +    private InetAddress mSelfAddress            = null;
       private Configuration mConf                 = null;
       private BlockContext mContext               = null;
       private Logger mLogger                      = null;
  @@ -101,21 +103,88 @@
        */
       public void setConfiguration(Configuration conf) throws Exception {
           mConf = conf;
  +        Configuration tmpConf = null;        
  +
  +        // get server address        
  +        tmpConf = conf.getChild("ftp-host", false);        
  +        if(tmpConf != null) {
  +            mServerAddress = InetAddress.getByName(tmpConf.getValue());
  +        }        
           
  -        mSelfAddr            = InetAddress.getByName(mConf.getChild("ftp-host").getValue("localhost"));
  -        miServerPort         = mConf.getChild("ftp-port").getValueAsInteger(21);
  -        miMaxConnection      = mConf.getChild("max-connection").getValueAsInteger(20);
  -        mbAnonAllowed        = mConf.getChild("anonymous-login-allowed").getValueAsBoolean(true);
  -        miMaxAnonConnection  = mConf.getChild("anonymous-max-connection").getValueAsInteger(10);
  -        miSchedulerInterval  = mConf.getChild("poll-interval").getValueAsInteger(120);
  -        miRmiPort            = mConf.getChild("remote-admin-port").getValueAsInteger(1099);
  -        mbRemoteAdminAllowed = mConf.getChild("remote-admin-allowed").getValueAsBoolean(true);
  -        miDefaultIdle        = mConf.getChild("default-idle-time").getValueAsInteger(300);
  -        mDefaultRoot         = new File(mConf.getChild("default-user-root").getValue("/"));
  -    
  -        mStatistics = new FtpStatistics(this);
  -        mConService = new ConnectionService(this);
  +        // get server port
  +        miServerPort = 21;
  +        tmpConf = conf.getChild("ftp-port", false);        
  +        if(tmpConf != null) {
  +            miServerPort = tmpConf.getValueAsInteger(miServerPort);
  +        }        
  +        
  +        // get maximum number of connections
  +        miMaxConnection = 20;
  +        tmpConf = conf.getChild("max-connection", false);        
  +        if(tmpConf != null) {
  +            miMaxConnection = tmpConf.getValueAsInteger(miMaxConnection);
  +        }        
  +        
  +        // get anonymous login allow flag        
  +        mbAnonAllowed = true;
  +        tmpConf = conf.getChild("anonymous-login-allowed", false);        
  +        if(tmpConf != null) {
  +            mbAnonAllowed = tmpConf.getValueAsBoolean(mbAnonAllowed);
  +        }        
  +
  +        // get maximum number of anonymous connections        
  +        miMaxAnonConnection = 10;
  +        tmpConf = conf.getChild("anonymous-max-connection", false);        
  +        if(tmpConf != null) {
  +            miMaxAnonConnection = tmpConf.getValueAsInteger(miMaxAnonConnection);
  +        }        
  +        
  +        // get scheduler interval        
  +        miSchedulerInterval = 120;
  +        tmpConf = conf.getChild("poll-interval", false);
  +        if(tmpConf != null) {
  +            miSchedulerInterval = tmpConf.getValueAsInteger(miSchedulerInterval);
  +        }
  +        
  +        // get rmi port
  +        miRmiPort = java.rmi.registry.Registry.REGISTRY_PORT;
  +        tmpConf = conf.getChild("remote-admin-port", false);        
  +        if(tmpConf != null) {
  +            miRmiPort = tmpConf.getValueAsInteger(miRmiPort);
  +        }        
           
  +        // get remote admin allow flag
  +        mbRemoteAdminAllowed = true;
  +        tmpConf = conf.getChild("remote-admin-allowed", false);        
  +        if(tmpConf != null) {
  +            mbRemoteAdminAllowed = tmpConf.getValueAsBoolean(mbRemoteAdminAllowed);
  +        }        
  +        
  +        // get default idle time
  +        miDefaultIdle = 300;
  +        tmpConf = conf.getChild("default-idle-time", false);
  +        if(tmpConf != null) {
  +            miDefaultIdle = tmpConf.getValueAsInteger(miDefaultIdle);
  +        }        
  +        
  +        // get default root        
  +        String defaultRoot = "/";        
  +        tmpConf = conf.getChild("default-user-root", false);
  +        if(tmpConf != null) {
  +            defaultRoot = tmpConf.getValue(defaultRoot);
  +        }        
  +        mDefaultRoot = new File(defaultRoot);        
  +    
  +        // get self address
  +        if(mServerAddress != null) {
  +            mSelfAddress = mServerAddress;
  +        }        
  +        else {
  +            mSelfAddress = InetAddress.getLocalHost();
  +        }       
  +
  +        mStatistics = new FtpStatistics(this);
  +        mConService = new ConnectionService(this);        
           if (mbRemoteAdminAllowed) {
               mRemoteHandler = new RemoteHandler(this);
           }
  @@ -181,7 +250,14 @@
        * Get server bind address.
        */
       public InetAddress getServerAddress() {
  -        return mSelfAddr;
  +        return mServerAddress;
  +    }
  +
  +    /**
  +     * Get self address
  +     */
  +    public InetAddress getSelfAddress() {
  +        return mSelfAddress;
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>