This small patch adds IP lookup capabilities to the watchdog module using the free external site http://whois.sc. Basically, the IP becomes clickable, and a new window opens which displays a lot of data about the address in question. Might be useful for site administrators who need to look at suspicious activites, spiders, harvesters etc.

I got this idea from the phpBB bulletin board software, which offers this feature for administrators.

One line patch attached.

Comments

kbahey’s picture

+1 for this patch.

Shouldn't target="blank" read target="_blank" (with under score)?

junyor’s picture

-1 for using the target attribute. That's browsers UI functionality.

Bèr Kessels’s picture

another -1 on target blank; As nielsen points out (http://www.useit.com/alertbox/9605.html #9) opening new windows is

Opening up new browser windows is like a vacuum cleaner sales person who starts a visit by emptying an ash tray on the customer's carpet. Don't pollute my screen with any more windows, thanks (particularly since current operating systems have miserable window management).

baudolino’s picture

StatusFileSize
new957 bytes

Updated version, removed "target=_blank".

chx’s picture

removed target? Then now I can +1 this.

killes@www.drop.org’s picture

Why is this usefull? Can't you set up Apache to do the looking up?

Just two random questions.

Chris Johnson’s picture

Several reasons:

1. Yes, Apache can be configured to do this. However, it is resource intensive. Apache would have to do a DNS reverse lookup request for every IP address. This is generally considered to be a bad idea on any Apache server that has any kind of load. Thus, it will be turned off on most hosting arrangements.

2. Not everybody runs Apache. :-)

3. It's convenient, somewhat useful and very lightweight to provide it.

killes@www.drop.org’s picture

ok, more questions: How long is that service already there? How long will it stay available? Does their TOS allow this kind of integration?

kbahey’s picture

This is very useful.

Not all apache installations enable DNS name resolution, and if you are on a shared hosting that does not have it, you are out of luck.

This patch does the lookup selectively for links that are interesting to the admin when viewing the logs.

Moreover, it provides way more info than just a name resolution every did, or will do. You as the site admin can detect abuse, get organization contacts, blacklisted status, ...etc.

whois.sc has been available for a while, and provides a lot of nifty info. For example try http://whois.sc/drupal.org for some fun. Run it on your domain and see more fun.

As far as ToS, this is something that needs to be checked.

baudolino’s picture

Assigned: Unassigned » baudolino

Regarding the TOS, the best that I could find on their website is http://whois.sc/info/webmasters/remote-search.html

It seems to me they allow FREE queries using their website; from my experience I know that you can do around 100 queries per day without a having a FREE account on their website. They implemented the account policy to prevent abuse from automatic bots doing tons of queries per day, so the account is just a means of autentifying yourself as a real person.

If this patch is accepted, it seems to me that we'd have to give credit for the service, as a common courtesy gesture. The search boxes they provide on the link above have the "Powered by whois source" text embedded, although they say at the bottom of the page "Feel free to modify our search boxes on your own site."

BTW, let me assign this issue to myself, since I already suggested a patch.

dries’s picture

I too would prefer to use PHP's gethostbyaddr to lookup the hostname. I'm not too fond of using external services.

Plus, we should probably introduce a format_ip_address() function because there are more places where IP addresses are shown (eg. statistics module).

I'm marking this active.

sneex’s picture

Since I already have an account at whois.sc I am able to use their service as much as I want; I feel that this module feature should be as configurable as generally required:

= Chose to use internal php gethost;
= Chose to use external source (like WhoIS.sc)
= Chose to use internal (read Private DNS) for intranet sites.
= Chose _self or _blank
= Chose active - flowed JS window to auto-display when each details page is requested from watchdog.

Making somethings automatic doesnt mean that there would be anyone other than the site admin looking -- therefore there should not be a possibility of repeated robitic activity causing WHoIS or similar harm.

m3avrck’s picture

+1 as well

Agree with sneex, a few configuration options would be great. Use the PHP function on as-needed-basis, choose whether to use an external source for a list of drop downs, or enter your own, and checkbox to turn this on/off as needed.

baudolino’s picture

Assigned: baudolino » Unassigned

Let me get out of the way; the feature list becomes more complex than what I had originally in mind.

sneex’s picture

Assigned: Unassigned » sneex

I guess I should do it as I have a good idea what I want (and hopefully other would desire them as well) -- It will give me a chance to learn more about Drupal and PHP. Any help during my learning curve would be most appreciate =)

m3avrck’s picture

sneex i'm interested in helping out as well, let me know! be on IRC monday morning to chat.

sneex’s picture

Assigned: sneex » Unassigned

As I am still learning PHP, and related things (mostly inside MediaWiki at present), I do not wish to hold up this plug-ins development; I apologize to the group for butt'ing in -- this module is definitely needed for Drupal but after my long research into the API, etc, I do not feel capable of writing/adding it at this time. I hope to be a strong, value-adding community member when I am better at PHP, etc.

colan’s picture

I submitted a patch with this functionality for the statistics module. Details can be found here:
http://drupal.org/node/63544

LAsan’s picture

Version: x.y.z » 7.x-dev

Still a feature request?

Moving to cvs.

nancydru’s picture

Version: 7.x-dev » 8.x-dev

Gosh, what a shame that this useful feature request has been ignored for so long. Rather than completely internal to the Watchdog module, it would be nice to have a call-able function. I have added a Top Spammers report (using Mollom's info) and it would be super-nice to add this feature to that.

This is probably a duplicate of #16221: Integrate WhoIs facility in to Watchdog, although a nicer patch.

mgifford’s picture

Issue tags: +whois

I was looking to see if there was an easy way to work that change into a themable function that I could just drop into an admin theme.

Would be a nice addition, but I don't know that imbedding:

    $output .= ' <tr><th>'. t('Hostname') .'</th><td><a href="http://www.whois.sc/' . $watchdog->hostname . '" target="blank">' . $watchdog->hostname . "</a></td></tr>";

Is stable enough for core.

arpeggio’s picture

Subscribing.

devin carlson’s picture

Marked #16221: Integrate WhoIs facility in to Watchdog as a duplicate of this issue.

mgifford’s picture

Taking from j.somer's patch: http://drupal.org/node/16221#comment-1166656

We should be able to write a custom function based on dblog_event() in modules/dblog/dblog.admin.inc [say we call it dblog_event_whois()] and simply include this item for the Hostname:

       array(
         array('data' => t('Hostname'), 'header' => TRUE),
         l($dblog->hostname, 'http://whois.domaintools.com/'. $dblog->hostname),
       ),

We can then just use hook_menu_alter() to replace the call to something like:

dblog_menu_alter(&$items) {
    $items['admin/reports/event/%']['page callback'] = 'dblog_event_whois';
}

I think this would work, but haven't tried it. I don't think this could get into core, but it should be either a contrib module or added to a contributed admin theme.

There are also a few other places where presenting more information about the visitor can really help diagnose a problem.

mandreato’s picture

Subscribe.

mgifford’s picture

I've reached out to domaintools.com about this and hope to get some feedback soon about this. Not sure how this fits in their ToS. Also, there may be privacy concerns about doing this that we should investigate.

chx’s picture

This is a won't fix IF it can be done from contrib. Do we have the necessary hooks to make it happen? If not, let's add one.

mgifford’s picture

Agreed with this approach @chx. I don't know if the proper hooks already exist. I'd assume they don't in D7 as folks aren't using them.

arpeggio’s picture

It would be nice to have the hook. For now, I am using mgifford's codes at comment #24 in Geolocate Logs module that I developed to geolocate the Drupal log event's hostname IP with appended whois link.

jhedstrom’s picture

Version: 8.0.x-dev » 8.1.x-dev
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

Needs an update re #28.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dagmar’s picture

Component: watchdog.module » dblog.module

Moved to dblog.module for future triage.

dagmar’s picture

Status: Postponed (maintainer needs more info) » Active

I just checked. There is no hook to modify the IP rendered on the event log page. The current alternative is to alter route to use a different controller to display the event log detail page.

In D7 there is a module that provides this functionality: https://www.drupal.org/project/watchdog_event_extras

Maybe we could provide a service to format IP addresses, like mentioned in #11.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

dagmar’s picture

Status: Active » Closed (won't fix)

I checked again 3 years later and now the module https://www.drupal.org/project/watchdog_event_extras implements the approach of altering the route.

Based on #28 and #29 I'm marking this as won't fix.