Ignore:
Timestamp:
2009-09-17T16:24:39+12:00 (15 years ago)
Author:
ak19
Message:
  1. Changes to get localhost to be recognised on Linux and the hostname to be recognised on Windows. Multiple allowed host values are inserted into the configfile (e.g. llssite.cfg) and these are used in httpd.conf. 2. Fixed errors: the Address Resolution Method part of the GSI dialog should not be deactivated when the Allow External Connections is checked.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/server/Server2.java

    r20604 r20618  
    88import java.io.InputStreamReader;
    99import java.io.IOException;
     10import java.net.InetAddress;
    1011import java.net.ServerSocket;
    1112import java.net.Socket;
     13import java.net.UnknownHostException;
    1214import java.net.URL;
    1315//import java.net.URLConnection;
     
    207209        //reloadConfigProperties();
    208210        port = config_properties.getProperty("portnumber", port);
    209         host = config_properties.getProperty("host", host);
    210 
     211       
     212        // The "hosts" property in the config file contains more than one allowed host
     213        // Need to work out the particular host chosen from the address_resolution_method
     214        // Default is address_resolution_method 2: localhost
     215        String addressResolutionMethod = config_properties.getProperty("address_resolution_method");
     216        int address_resolution_method = (addressResolutionMethod == null) ? 2 : Integer.parseInt(addressResolutionMethod);
     217        InetAddress inetAddress = null;
     218        try {
     219        inetAddress = InetAddress.getLocalHost();
     220        } catch(UnknownHostException e) {
     221        logger_.error(e);
     222        logger_.info("Defaulting host IP to "+ host); // use the default       
     223        address_resolution_method = 2;
     224        }
     225        switch(address_resolution_method) {
     226        case 0:
     227        host = inetAddress.getHostName();
     228        break;
     229        case 1:
     230        host = inetAddress.getHostAddress();
     231        break;
     232        case 2:
     233        host = "localhost";
     234        break;
     235        case 3:
     236        host = "127.0.0.1";
     237        break;
     238        default:
     239        host = "localhost";         
     240        }
    211241    } catch(Exception e) {
    212242        recordError("Exception trying to load properties from gsdlsite_cfg. Using default library prefix.", e);
Note: See TracChangeset for help on using the changeset viewer.