Zend Framework: Zend_Whois Component Proposal
| Proposed Component Name | Zend_Whois |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Whois |
| Proposers | Ben Scholzen (lead) Simone Carletti (contributor) Alexander Veremyev (Zend Liaison) |
| Revision | 1.0 - 6 September 2007: Initial proposal 1.1 - 29 December 2007: Proposal rewrite 1.2 - 30 December 2007: Zend_Whois_Result added 1.3 - 13 January 2008: Finalized proposal (added support for Zend_Uri and last improvements) (wiki revision: 23) |
Table of Contents
1. Overview
Zend_Whois is a component to simply check the availability of domain names and ip addresses and fetch whois server responses about them.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will check for registration availability of domain names.
- This component will allow fetching of server responses.
- This component will not return specific data about domain owners (as a first version), as the output varies from most of the whois servers.
- This component will allow caching results via Zend_Cache.
- This component will be customizable. It will shipped with a default list of whois server that can be completely overwritten or customized.
- This component will allow querying multiple domains simultaneously through a non-blocking socket.
4. Dependencies on Other Framework Components
- Zend_Exception
- Zend_Cache
- Zend_Uri
- Zend_Config (as soon as this component will correctly support XML attributes)
5. Theory of Operation
Zend_Whois will take a Zend_Whois_Config as constructor arguments.
If empty, default configuration set will be loaded from XML.
Once you have a valid instance, it can then be used to either get a whois response from a whois server or to check whether given domain is available.
The former returns a full whois response, the latter only true/false according to whois response.
Domain name can be one of the following formats:
- string, just the domain name (zend.com)
- string, full host name (framework.zend.com, zend.com, http://framework.zend.com)
- string, full path (framework.zend.com/path, zend.com/path, http://framework.zend.com/path)
- Zend_Uri instance
Regardless the format, internally Zend_Whois will handle all host names as an instance of Zend_Uri.
Depending on Zend_Uri Improvements - Shahar Evron proposal implementation, Zend_Uri instance will use http schema or a custom one.
6. Milestones / Tasks
- Milestone 1: [DONE] Creating base class
- Milestone 2: [DONE] Supporting all major Top-Level-Domains
- Milestone 3: [DONE] Checking current state into http://zend_whois.svn.dasprids.de/
- Milestone 4: [DONE] Finalizing the proposal and making it ready for review
- Milestone 5: Proposal acceptance and import of current prototype to incubator SVN
- Milestone 6: Unit tests exist and development.
- Milestone 7: Documentation
7. Class Index
- Zend_Whois
- Zend_Whois_Exception
- Zend_Whois_Config
- Zend_Whois_Result
31 Comments
comments.show.hideSep 11, 2007
Karol Babioch
This could get a very useful tool, but maybe you should isolate the classes "Zend_Whois_Server_De", "Zend_Whois_Server_Com" and "Zend_Whois_Server_Net" or create a posibility to add other servers via method or a factory class.
Sep 11, 2007
Karol Babioch
Ok, I have to revoke my comment, the structure is already clean
. So sorry for inadequate critism.
Sep 14, 2007
Ben Scholzen
As only the other whois servers are missing yet, I think this proposal is ready for review.
Dec 28, 2007
Simone Carletti
Hi Ben,
I'm really interested in this proposal.
I was working on a similar library a few weeks ago, then I moved my efforts to Ruby just for a personal reason but I'm really glad something is in progress for PHP too!
I was having a look at class structured and I don't really understand the difference between the abstract class and the interface.
Could you post an example of a server class to better understanding the usage?
Dec 28, 2007
Ben Scholzen
Hi Simone,
I still had discussions with others about the server class. I will change the this into an XML file, which holds all information about the whois servers. This will not only make the entire proposal smaller, but also make it easier to add new top level domains via own XML files, which can be loaded dinamicly.
Dec 29, 2007
Ben Scholzen
Alright, I have checked the current state of the proposal into http://zend_whois.svn.dasprids.de/. Go there and take a look at it.
Dec 29, 2007
Simone Carletti
Hi Ben,
I have some questions for you.
Please note they are not all related to the initial proposal, part of them is a "nice to have" list.
1. Did you plan to handle special socket connection params?
As far I remember, some whois interfaces require special parameters.
For example, whois.denic.de requires -T dn while whois.domain-registry.nl might require is parameter.
2. It would be nice to enhance the class in order to return true/false to a isAvailable() request.
You should probably add to the configuration file an additional attribute to hold the "Domain Available" response and perform a regular expression match on whois response.
Oops. Writing the comment I just noticed there is an isAvailable() function definition.
I assume the function is on the road to be supported.
3. I felt really sad when you wrote
There is a couple of whois libraries that perform a data parsing and returns a collection of arrays filled with registrant information, technical details and more.
It would be excellent if this library support this kind of advanced whois query.
However, this feature is more compatible with a 'domain' <==> 'class' architecture.
For each domain where advanced parsing is supported, a Zend_Whois_Ext should be created.
Basic Zend_Whois_Extension interface and abstract class might probably be necessary.
http://www.phpwhois.org it's probably the best working example I have ever found in PHP.
Any change to implement advanced parsing support?
Ah, I'll be more than happy to provide you some help.
4. I would suggest to introduce Zend_Uri support in Whois class constructor.
Dec 29, 2007
Ben Scholzen
Hm okay, this are some idea. Is there any way to get in contact with you via IM or IRC to talk a bit deeper about your suggestions?
Dec 30, 2007
Simone Carletti
I sent you an email with my contacts.
Jan 19, 2008
Lars Strojny
Is there a reason you do not use Zend_Config for configurability? I do not see any.
Jan 19, 2008
Ben Scholzen
That's something, two guys asked me yet. The simple answer to this is, that Zend_Config doesn't support that complex configuration files. I could sure split up all the tags with their attributes in a tag-only configuration, but that would blow the config up into a huge and unreadable file. It may be changed, when Zend_Config will support tag-attributes in the xml format.
Jan 23, 2008
Cristian Bichis
Is needed an option to check a domain name against more than one tld with one query.
Sample: looking for zend.com, zend.org, aso.
This is a pretty common feature.
Also, problem with checking one time for more than one tld's same time is it one by one, not multithread. Maybe we need to find out a solution for this too...
Jan 23, 2008
Ben Scholzen
The first thing is quite simple, but does not require changes in Zend_Whois. Simply make an array with all tlds you want to check and loop through it. In every loop you can then check the domain name by using the static method:
The latter is a problem which cannot be fixed with PHP only, as an open socket blocks PHP until it is done with reading. So there won't be a solution. This can only be done by tricking around with proc_open, which then requires you to have access to execute programs. Maybe you could proc_open to a cli php, which executes the whois query then, but this requires special rights on the server, which is not always given.
Feb 01, 2008
Dolf Schimmel (Freeaqingme)
This 'problem' has been defined since php 4.0.7. For more info I'd advice you to take a look at this: http://nl3.php.net/manual/en/function.socket-set-nonblock.php
Jan 23, 2008
Jurrien Stutterheim
Looks good!
I only have two comments so far.
The Zend_Whois_Config seems to reinvent the wheel by not utilizing Zend_Config.
I think it's a better option to have the constructor of Zend_Whois_Config accept a Zend_Config instance:
Also, please rename _cidr_match() to _cidrMatch().
The XML element names also contain underscores. Maybe they should be camelCased as well, so: contentResponses instead of content_responses.
Although iirc that goes against XML standards, so this point is open for debate.
Jan 23, 2008
Ben Scholzen
Renaming of cid_match is clear, will be done. As attributes and tag names must be lowercase in XML, they don't have to be renamed.
As for Zend_Config again, see my other comments about it. Zend_Config does not allow the type of configs I need (multiple items with the same name for example).
Feb 11, 2008
Till Klampaeckel
I guess I don't really understand either why Zend_Config should not be able to be utilized, point taken, my usage of Zend_Config resorts to rather flat .ini-files but I thought that as long as the XML is valid, you can stack in it whatever you want.
In regard to that, I think that your Config.xml should be spread out into smaller files and your class should implement a Driver-like interface. That would be my personal preference.
Reasons why - for example, say I run my own local TLD (company-wide intranet) and assign domains to groups and/or people inside the company - I also run a whois for them - how would I put that into your class?
Or maybe tomorrow I want to implement my own Driver for .com/.net/.org because some provider gives me a nifty API? Or let's say I get access to query .tv directly, or .nu, etc.. Edit your config files, add in an auth layer somewhere?
That's why I think drivers are perfect - I implement the bare minimum or a lot on top.
All in all, I think your proposal is a great idea. Because I personally found it to be a pain to maintain such a thing - I had the pleasure at my last job. With registries sometimes constantly changing behavior (response format, general availability, etc.) it's not too much fun.
Feb 11, 2008
Till Klampaeckel
Additional questions:
1) rwhois supported?
2) What about NIC handles and AS#?
If I know that e.g. a domain is .de - can I specifically query .de, or will I use the standard "method" and let your class first figure out that it is .de indeed and then make the whois query?
Till
Feb 11, 2008
Ben Scholzen
1) rwhois will not be supported. Maybe in a future release, but not yet.
2) NIC handles and AS# numbers are supported yes if I'm right.
3) The system would find out which whois server has to be used.
To you driver idea:
In general it sounds quite good, but it's missing some points. I don't have access to any whois servers with auth access, so I cannot test an implementation. Also I don't think that there is a general auth system for whois servers, so I would have get access to any available.
But a driver system in general would be a good idea. If you get access to an auth protected whois system, you could simply write your own driver and append it to the TLDs you want. In the next days I will think about a good driver layout and maybe I can totally get rid of the config file, so guys cannot complain anymore about not using Zend_Config
.
Feb 11, 2008
Till Klampaeckel
The idea is that you don't have to.
I could implement my own. Also, API calls like this are generally against XMLRPC, or SOAP or maybe a REST API. I think ENOM has XMLRPC, InternetX too, etc..
Who says I shouldn't be able to use the convenience of your CLASS API when I implement my driver to work with it? That's the beauty it. I could just "overwrite" your com Driver with my own for whatever reason.
Just food for thoughts!
Mar 07, 2008
Sven Franke
Sounds good this component. Already using a 'whois' in PHP4 with some extending settings for aqcuiring information (different port for .eu domains, different 'commands for .de, .nl en .eu).
I hope this component will make it in ZF
May 26, 2008
Ben Scholzen
Alright, I'm going to refactor the entire component with either the composite or the adapter pattern, have to see what fits better. Hopefully the component gets approved, else I won't do anything
Jun 24, 2008
Alexander Veremyev
Zend_Whois is accepted for inclusion in extras/incubator as is.
Aug 18, 2008
Sudheer Satyanarayana
After querying for a domain name registration availability, getting a list of autosuggested available domain names would be awesome. This may not be feasible to add to the current component proposal as it would need a large suggestion library or a dictionary. Another component which would make use of Zend_Whois to incorporate this feature seems logical.
Mar 18, 2009
Wil Sinclair
Ben, what is the status of this proposal?
Mar 29, 2009
Ben Scholzen
As Zend_Application had a higher priority, this feature wont make it into 1.8. Postponed to 1.9.
Apr 15, 2010
Cristian Bichis
Pretty shame is not included yet if is ready.
That's a very useful component for me...
May 06, 2010
Cristian Bichis
Hi,
Seems i have some weird behavior for .ro domains.
$whois = new ZendX_Whois();
$result = $whois->query('auto.ro');
It doesn't get any whois or domain availablity info.
The whois server should be fine.
For other tested tld seems to work properly
May 06, 2010
Cristian Bichis
I have found where the bug is actually located.
On ZendX_Whois_Adapter_Base::_getResponse
The line:
fputs($fp, $host . "\n");
Should be replaced with:
fputs($fp, $host . PHP_EOL);
Probably similar also for (haven't checked):
fputs($fp, sprintf($serverInfo['format'], $host) . "\n");
May 06, 2010
Cristian Bichis
Ben pointed correctly:
Should be "\r\n" instead of PHP_EOL
Seems the .ro whois server doesn't follow the standards...
May 06, 2010
Cristian Bichis
Also, from what i read (haven't tested) over couple of websites, using the checkdnsrr function (which on PHP 5.3 is available also on Windows) should get faster results than using the socket approach.