a simple whois registry server

I need to write a simple whois server for my ccTLD. I understand from RFC that it is to be on port 43 and respond the domain entrie , or not found ( due to he size and operations mode I will use an existing hash file of all the registered domain).

The Whois server will be on machines also running an apache 2000 information site. My idea was to make the Apache parameter to be "*" for the ports and to have a virtual host on the whois domain name and a whois.cgi as a default entry page.

- from experience will this work ? What is advisable ?
- has someone experience of building such a Perl web-server on a dedicated part and of the apache proper setting ?

thank you!
versailleschercheur libreAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kanduraCommented:
A whois server does not use the HTTP protocol, so it seems silly to use Apache for this. All you need is a light-weight tcp server, and something like Net::Daemon or Net::Server will help you set that up.

See http://search.cpan.org/author/JWIED/Net-Daemon-0.38/lib/Net/Daemon.pm or http://search.cpan.org/~bbb/Net-Server-0.87/lib/Net/Server.pm for details.
0
versailleschercheur libreAuthor Commented:
O. I understand. Could you develop this?

How do you set up a tcp server? Would you have en empty shell program? I understand I am to only :
- get the requested name
- respond a text with data.

I know how to generate the text, but I am lost with all the details given in these URL.
Thank you.
0
kanduraCommented:
Here's one using Net::Daemon. You must implement the whois sub routine yourself. Other than that, the server works completely.
You can tweak several settings (I would recommend setting user and group if you're going to let the outside world access this). Please read the manual carefully.


#!/usr/bin/perl
# -*- perl -*-
#
# Whois server
#
require 5.004;
use strict;

require Net::Daemon;

package My::Net::Whoisd;

use vars qw($VERSION @ISA);
$VERSION = '0.01';
@ISA = qw(Net::Daemon); # to inherit from Net::Daemon

sub Version ($) { 'Example Whois Server, 0.01'; }

### this is where the real work is done.
sub Run ($) {
  my($self) = @_;
  my($line, $sock);
  $sock = $self->{'socket'};
  if (!defined($line = $sock->getline())) {
      if ($sock->error()) {
          $self->Error("Client connection error %s",
                       $sock->error());
      }
      $sock->close();
      return;
  }
  $line =~ s/\s+$//; # Remove CRLF

  ## get whois result for this question
  my $result = whois($line);
  my $rc = print $sock $result, $/;

  if (!$rc) {
      $self->Error("Client connection error %s",
                   $sock->error());
  }

  $sock->close();
  return;
}

### implement this function to do the actual lookup
sub whois
{
    my $domainname = shift;
   
    return "I don't know!";
}

package main;

my $server = My::Net::Whoisd->new({'pidfile' => 'none',
                            'localport' => 43}, \@ARGV);
$server->Bind();
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

kanduraCommented:
Here's the same server , but now with Net::Server as its base.

Using Net::Server has the advantage that you can pick and choose from a lot of types (forking; pre-forking (like apache: start a number of children first; ertc.)
It offers a lot of configuration options to increase its security, logging, etc.





#!/usr/bin/perl -w
package My::Net::Whoisd;

use Net::Server;
@ISA = qw(Net::Server);

sub process_request {
  my $self = shift;
  my($line, $sock);
  $sock = $self->{server}->{client};
  if (!defined($line = $sock->getline())) {
      if ($sock->error()) {
          $self->Error("Client connection error %s",
                       $sock->error());
      }
      $sock->close();
      return;
  }
  $line =~ s/\s+$//; # Remove CRLF

  ## get whois result for this question
  my $result = whois($line);
  my $rc = print $sock $result, $/;

  if (!$rc) {
      $self->Error("Client connection error %s",
                   $sock->error());
  }

  $sock->close();
  return;
}

### implement this function to do the actual lookup
sub whois
{
    my $domainname = shift;
   
    return "I don't know!";
}

My::Net::Whoisd->run(port => 43);
exit;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TintinCommented:
This begs the question as to why you would want to do this?

I assume this is just for a learning/assignment purposes?
0
versailleschercheur libreAuthor Commented:
No. This as indicated it is for the small ccTLD we are a registry for. As I see it might work and it is important to us, if the system works I will upgrade to 1000 points for the help.

I have some additional questions.

1. I wanted to test it on a virtual server but they do not accept that port.
2. I have a VPS (virtual full machine). But Net::Daemon and Net::Server are not in the Perl library. I wait their response to know if they have an objection and which Redhat version RPM should be compatible with.

3. if this is OK, I do not see how to relate that whoisd daemon with a domain name?I mean that it respond to dn:43 only? Is there something to do in INET?
4. how should I start it at reboot? Can I restart it?
5. how should I access it from the network? Can I use my browser to test it?

As I said I am NOT a system programer :-)
Thank you for your help.

0
TintinCommented:
Now I'm curious.

Which ccTLD will you be looking after?  I notice most ccTLD's don't run their own whois server.
0
versailleschercheur libreAuthor Commented:
Sorry, but I only asked for help.
0
kanduraCommented:
1. Yes, you need to be root in order to run a daemon on privileged ports (<1024).
2. Do you have root access to that VPS? If so,you can install Net::Server by typing

    cpan Net::Server

3. You can give it a "host" parameter in the call to Run, so that it only binds to that address.
4. Either through cron, or by creating an entry in /etc/init.d
5. You access it like any other whois server: by using the "whois" program, or by telnetting to that host on port 43.
    You can't use your web browser, because a whois server has nothing to do with the web.

0
kanduraCommented:
ad 3 and 4, you could also run it through inetd, which would take care of starting and listening on a specific interface for you.
0
TintinCommented:
versailles.

Do you have any ideas as to how you are going to handle/process/parse all the various whois query types?  It's not just a simple matter of building a simple hash and doing a simple word/pattern match.

I suspect you may not be aware of what you're getting yourself into.
0
versailleschercheur libreAuthor Commented:
Hi! I am aware that I need it and that most of the cases are probably different and worth learning. If you have ways/experience to help you are certainly more than welcome. We have a need for reseller to know if a DN is taken or not. No more.
0
versailleschercheur libreAuthor Commented:
I have asked to Leslie Daisgle (IAB Chair, specialized in Whois) about my limited approach. She agrees if I stay in my acceptabe figures. I am setting up a machine to that end (as old the Perl functions did not work). However I do not understand why my initial idea would not work: to accept apache traffic on port 43 with a simple cgi.

Another question I am to solve is how to document that I want to accept a limited set of IP addresses on port 43 and to accept everything on port 80.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.