Bug 48244

Summary: Socket Server configuration does not handle not reverse DNS resolvable hosts
Product: Log4j - Now in Jira Reporter: Mark Farver <mfarver>
Component: OtherAssignee: log4j-dev <log4j-dev>
Status: NEW ---    
Severity: minor    
Priority: P2    
Version: 1.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Proposed patch, fails back to IP in config file name if hostname not available.
Previous patch had some garbage diff info in it

Description Mark Farver 2009-11-19 15:04:03 UTC
2009-11-19 16:22:06,955 () SocketServer [INFO]  - Listening on port 514
2009-11-19 16:22:06,960 () SocketServer [INFO]  - Waiting to accept a new client.
2009-11-19 16:22:37,632 () SocketServer [INFO]  - Connected to client at /10.16.1.16
2009-11-19 16:22:37,632 () SocketServer [INFO]  - Locating configuration file for /10.16.1.16
2009-11-19 16:22:37,633 () SocketServer [WARN]  - Could not find config file [/opt/log4j-server/etc/servers/.lcf].


It seems like this code needs to realize when it gets a blank response back for the hostname and maybe use the IP in the config filename instead.

--snip--
LoggerRepository configureHierarchy(InetAddress inetAddress) {
  cat.info("Locating configuration file for "+inetAddress);
  // We assume that the toSting method of InetAddress returns is in
  // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1
    String s = inetAddress.toString();
    int i = s.indexOf("/");
    if(i == -1) {
      cat.warn("Could not parse the inetAddress ["+inetAddress+
	       "]. Using default hierarchy.");
      return genericHierarchy();
    } else {
      String key = s.substring(0, i);
-----
Also, is it more correct to use InetAddress.getHostname and getHostAddress instead of parsing the .toString output?
Comment 1 Mark Farver 2009-11-20 12:15:54 UTC
Created attachment 24574 [details]
Proposed patch, fails back to IP in config file name if hostname not available.
Comment 2 Mark Farver 2009-11-20 12:18:08 UTC
Created attachment 24575 [details]
Previous patch had some garbage diff info in it