You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2005/11/29 00:35:50 UTC

DO NOT REPLY [Bug 37673] New: - Http11AprProcessor.java - getLocalAddr() returns HostName

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37673>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37673

           Summary: Http11AprProcessor.java - getLocalAddr() returns
                    HostName
           Product: Tomcat 5
           Version: 5.5.12
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Connector:HTTP
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: nrock@infinitecampus.org
                CC: remm@apache.org


I have a jsp that uses the getLocalAddr() method for some ssl certificate 
generation utility and it's currently returning the hostname instaed of the IP.

After much digging through the Tomcat source I found the snippet below:

org\apache\coyote\http11\Http11AprProcessor.java

        } else if (actionCode == ActionCode.ACTION_REQ_LOCAL_ADDR_ATTRIBUTE) {

            // Get local host address
            if (localAddr == null) {
                try {
                    long sa = Address.get(Socket.APR_LOCAL, socket);
                    remoteAddr = Address.getip(sa);
                    if (Address.fill(addr, sa)) {
                        localAddr = addr.hostname;
                        localPort = addr.port;
                    }
                } catch (Exception e) {
                    log.warn(sm.getString("http11processor.socket.info"), e);
                }
            }

            request.localAddr().setString(localAddr);

        }

Should the code above be changed to the snipit below so that the ip address is 
coming back instead of the hostname as expected?


        } else if (actionCode == ActionCode.ACTION_REQ_LOCAL_ADDR_ATTRIBUTE) {

            // Get local host address
            if (localAddr == null) {
                try {
                    long sa = Address.get(Socket.APR_LOCAL, socket);
                    localAddr = Address.getip(sa);
                } catch (Exception e) {
                    log.warn(sm.getString("http11processor.socket.info"), e);
                }
            }

            request.localAddr().setString(localAddr);

        }

If not I would love to know why the hostName/port are being returned instead of 
the IP thanx!

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org