----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Jon et. al.,
    First, I'm not unix programmer, but I have done some programming (mac mostly).  
I'm enjoying JServ and Jon has posted a lot of good info and here he was asking for a 
bit of help.  So I figured I'd give it a try.


I don't think getRemoteHost() is broken. 

"HostnameLookups on" must be in httpd.conf file (Note, you have to restart apache for 
this to take effect).


Here's why I think this:

First
-----

I just added a quick piece of test code to jserv_ajpv12.c at roughly line 532 to test 
this a bit.  My code was roughly:

{
    char tyler_buf[256];
    strcpy( tyler_buf, "Tyler Asks Remote Host Name:  " );
   if ( r->connection->remote_host == NULL )
        strcat( tyler_buf, " remote host is NULL !! " );
    else
        strcat ( tyler_buf, r->connection->remote_host );

    jserv_error( JSERV_LOG_EMERG, cfg, tyler_buf );
}


Sure enough, "remote host is NULL" appears in the log.  So, I think Jon is correct 
that the JServ code looks fine, Apache is just passing NULL for remote host name:


In /usr/lib/apache/httpd.h  (apache 1.3.6), I find the following comment on line 804:

    char *remote_host;    /* Client's DNS name, if known.
                                         * NULL if DNS hasn't been checked,
                                         * NULL if it has and no address was found.
                                         * N.B. Only access this through 
get_remote_host() */


SO it looks like the remote_host name can be null in at least two cases.  I happen to 
know that I don't have DNS on my machines so that may be why I find no name.


Second Test
-----------

A simple perl script that can test if apache is sending in a remote_host name might go 
like this (I'm no perl programmer either!):

#!/usr/bin/perl
#test2

use strict;
use CGI qw(:standard escapeHTML);

print header(), start_html("Howdy There!"),
p( "remote hostname:  " ), p( remote_host() ),
p( "remote address:  " ), p( remote_addr() ),
p("Howdy there body!" ), "<hr>", end_html();




the definition of remote_host for a perl distribution I have on my mac says:

#### Method: remote_host
# Return the name of the remote host, or its IP
# address if unavailable.  If this variable isn't
# defined, it returns "localhost" for debugging
# purposes.
####
'remote_host' => <<'END_OF_FUNC',
sub remote_host {
    return $ENV{'REMOTE_HOST'} || $ENV{'REMOTE_ADDR'}
    || 'localhost';
}
END_OF_FUNC

So it will return the remote host IP address if no remote host name has been provided.

And the behavior I see is similar -- I get the IP address for BOTH remote hostname AND 
remote address.  This makes some sense since I have no DNS on my local machines.


Third
-----

I turned on

HostnameLookups on

I then logged on using AOL and used AOL to go hit my machine (easist way I could hit 
it from a DNS named machine)  the output of both the perl script and the servlet show 
a host name ("ww-pa03.proxy.aol.com" in this case).


If I have HostnameLookups off then the HostNameServlet returns an empty string for 
hostname, but if HostnameLookups on then it works.



In conclusion, perhaps JServ should modify it's getRemoteHost() routine to mirror the 
perl remote_host() routine and use the IP address if no name has been provided?

Hope this helps!

peace,
Tyler



>yes, getRemoteHost() is broken. I'm not quite sure what the problem is
>though. The code looks fine.
>
>If someone would like to help me debug this, I would appreciate it.
>
>-jon
>

------------------------------------------------------
Tyler Morrison - [EMAIL PROTECTED]


--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to