Bug 48244 - Socket Server configuration does not handle not reverse DNS resolvable hosts
Summary: Socket Server configuration does not handle not reverse DNS resolvable hosts
Status: NEW
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.2
Hardware: PC Linux
: P2 minor
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-19 15:04 UTC by Mark Farver
Modified: 2009-11-20 12:18 UTC (History)
0 users



Attachments
Proposed patch, fails back to IP in config file name if hostname not available. (1.47 KB, patch)
2009-11-20 12:15 UTC, Mark Farver
Details | Diff
Previous patch had some garbage diff info in it (1.23 KB, patch)
2009-11-20 12:18 UTC, Mark Farver
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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