[ic] Server.pm logic for NotRobotUA too exclusive

Mike Heins mike at perusion.com
Thu Jul 8 11:38:57 EDT 2004


Quoting John Young (john_young at sonic.net):
> On 30 Apr 2004 Server.pm was modified to accommodate the new NotRobotUA
> config option, and the bit of code looks like (logDebugs indented for
> readability):
> 
>     if ($Global::RobotIP and $CGI::remote_addr =~ $Global::RobotIP) {
>         #::logDebug("It is a robot by IP!");
>         $CGI::values{mv_tmp_session} = 1;
>     }
>     elsif ($Global::HostnameLookups && $Global::RobotHost) {
>         if (!$CGI::remote_host && $CGI::remote_addr) {
>             $CGI::remote_host = 
> gethostbyaddr(Socket::inet_aton($CGI::remote_addr),Socket::AF_INET);
>             $CGI::host = $CGI::remote_host || $CGI::remote_addr;
>         }
>         if ($CGI::remote_host && $CGI::remote_host =~ $Global::RobotHost) {
>             #::logDebug("It is a robot by host!");
>             $CGI::values{mv_tmp_session} = 1;
>         }
>     }
>     elsif ($Global::NotRobotUA and $CGI::useragent =~ 
> $Global::NotRobotUA) {
>         # do nothing
>     }
>     elsif ($Global::RobotUA and $CGI::useragent =~ $Global::RobotUA) {
>         #::logDebug("It is a robot by UA!");
>         $CGI::values{mv_tmp_session} = 1;
>     }
> 
> That logic tends to ignore RobotUA if HostnameLookups and RobotHost are
> true.

This is true, and probably not desirable.

> IOW, any use of HostnameLookups + RobotHost negates the use of
> RobotUA (no Robot identification by a compilation of RobotHost and RobotUA).
> Unless the intent is to ONLY use RobotHost OR RobotUA, something like the
> following logic might be more desirable (three if's instead of one, and
> two return's added to bail early):

I think we need to examine the logic in detail. I think it makes
sense (as your subsequent message shows) to do UA first, as it
is less costly. 

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled. -- Dick Feynman


More information about the interchange-users mailing list