Warning: This is long and can probably only be answered by a professional perl programmer or someone involved with a domain registrar or registry company.

I run a website hosting, design, and domain registration business. We are a registrar for some TLDs and a couple of them require us to have a whois server for domains registered with us. I have a whois server set up which is working but I know it's not doing it the right way, so I'm trying to figure out what I need to change.

My script is set up so going to whois.xxxxxxxxxx.com via browser or doing whois -h whois.xxxxxxxxxx.com from shell works. A whois on a domain registered with us gives whois data and a domain not registered with us says it's not registered with us.

If needed, I can give the whois url, or it can be figured out from my profile. I just don't want to put it here to look like advertising or for search engines to end up going to.

The problem is how my script does it. My whois url is set up in apache's httpd.conf file as a normal subdomain to listen on port 80, and it's also set up to listen on port 43. When called via browser, it works properly, gives a form to provide a domain and checks our database for that domain. How it works when called from shell is fine as well, but how it distinguishes between the 2 is weird, and how it gets the domain is also weird. It works, but it can't be the right way to do it.

How it distinguishes between shell and http is:

if ($ENV{REQUEST_METHOD} ne "GET") {
    &shell_process;
  }
  else {
    &http_process;
}

It would seem more logical for this to work:

if ($ENV{SERVER_PORT} eq 43) {
    &shell_process;
  }
  else {
    &http_process;
}

That doesn't work because even when called through port 43 as a whois request, the ENV vars are saying "SERVER_PORT = 80".

How it gets the domain name when called from shell is:

$domain = lc($ENV{REQUEST_METHOD});

You would think the domain would be the QUERY_STRING or more likely, in the ARGV vars, but it's not.

Here are the ENV vars (that matter) when called via http:

SERVER_NAME = whois.xxxxxxxxxxxxx.com
REQUEST_METHOD = GET
QUERY_STRING = domain=roughdraft.ws&submit=+Get+Whois+
SERVER_PORT = 80
REQUEST_URI = /index.cgi?domain=premierwebsitesolutions.ws&submit=+Get+Whois+
HTTP_HOST = whois.xxxxxxxxxxxxxx.com

Here are the ENV vars (that matter) when called via shell:

SERVER_NAME = whois.xxxxxxxxxxxxxx.com
REQUEST_METHOD = premierwebsitesolutions.ws
QUERY_STRING = 
SERVER_PORT = 80
REQUEST_URI = 

Notice the SERVER_PORT stays 80 either way, even though through shell it's set up on port 43.

Notice how via shell the REQUEST_METHOD is the domain being looked up.

I've done lots of searching and did find swhoisd: Simple Whois Daemon, but that's only for small databases. I also found the Daemon::Whois perl module, but it uses a cdb database which I know nothing about, it has no instructions to it, and it's a daemon which I don't really need because the script works fine when called through apache on port 43.

Does anyone know how this is supposed to be done? Can I get the script to see that it was called via port 43? Is it normal to use REQUEST_METHOD this way? Is a whois server supposed to be running as a daemon?

Thanks for helping, or trying to.

Mike

有帮助吗?

解决方案

WHOIS is not a HTTP-like protocol, so attempting to serve it through Apache on port 43 will not work correctly. You will need to write a separate daemon to serve WHOIS — if you don't want to use Daemon::Whois, you will probably at least want to use something like Net::Daemon to simplify things for you.

其他提示

https://stackoverflow.com/a/933373/66519 states something could be set to detect cli vs web. It applies to php in this case. Based on the lack of answers here maybe it might help you get to something useful. Sorry for the formatting I am using the mobile SO app.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top