Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

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: 24)

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:

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

8. Use Cases

9. Class Skeletons

]]></ac:plain-text-body></ac:macro>

]]></ac:plain-text-body></ac:macro>

Labels:
zend_whois zend_whois Delete
whois whois Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Sep 11, 2007

    <p>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.</p>

  2. Sep 11, 2007

    <p>Ok, I have to revoke my comment, the structure is already clean <ac:emoticon ac:name="smile" />. So sorry for inadequate critism.</p>

  3. Sep 14, 2007

    <p>As only the other whois servers are missing yet, I think this proposal is ready for review.</p>

  4. Dec 28, 2007

    <p>Hi Ben,</p>

    <p>I'm really interested in this proposal.<br />
    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!</p>

    <p>I was having a look at class structured and I don't really understand the difference between the abstract class and the interface.<br />
    Could you post an example of a server class to better understanding the usage?</p>

    1. Dec 28, 2007

      <p>Hi Simone,</p>

      <p>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.</p>

  5. Dec 29, 2007

    <p>Alright, I have checked the current state of the proposal into <a class="external-link" href="http://zend_whois.svn.dasprids.de/">http://zend_whois.svn.dasprids.de/</a>. Go there and take a look at it.</p>

    1. Dec 29, 2007

      <p>Hi Ben,<br />
      I have some questions for you. <ac:emoticon ac:name="smile" /></p>

      <p>Please note they are not all related to the initial proposal, part of them is a "nice to have" list.</p>

      <p>1. Did you plan to handle special socket connection params?<br />
      As far I remember, some whois interfaces require special parameters.</p>

      <p>For example, whois.denic.de requires <em>-T dn</em> while whois.domain-registry.nl might require <em>is</em> parameter.</p>

      <p>2. It would be nice to enhance the class in order to return true/false to a isAvailable() request.<br />
      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.</p>

      <p>Oops. Writing the comment I just noticed there is an isAvailable() function definition.<br />
      I assume the function is on the road to be supported.</p>

      <p>3. I felt really sad when you wrote</p>

      <blockquote><p>This component will not return specific data about domain owners, as the output varies from most of the whois servers.</p></blockquote>

      <p>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.<br />
      It would be excellent if this library support this kind of advanced whois query.</p>

      <p>However, this feature is more compatible with a 'domain' <==> 'class' architecture.<br />
      For each domain where advanced parsing is supported, a Zend_Whois_Ext should be created.<br />
      Basic Zend_Whois_Extension interface and abstract class might probably be necessary.</p>

      <p><a class="external-link" href="http://www.phpwhois.org">http://www.phpwhois.org</a> it's probably the best working example I have ever found in PHP.</p>

      <p>Any change to implement advanced parsing support?<br />
      Ah, I'll be more than happy to provide you some help. <ac:emoticon ac:name="smile" /></p>

      <p>4. I would suggest to introduce Zend_Uri support in Whois class constructor.</p>

      1. Dec 29, 2007

        <p>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?</p>

        1. Dec 30, 2007

          <p>I sent you an email with my contacts.</p>

  6. Jan 19, 2008

    <p>Is there a reason you do not use Zend_Config for configurability? I do not see any.</p>

    1. Jan 19, 2008

      <p>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.</p>

  7. Jan 23, 2008

    <p>Is needed an option to check a domain name against more than one tld with one query.</p>

    <p>Sample: looking for zend.com, zend.org, aso.</p>

    <p>This is a pretty common feature.</p>

    <p>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...</p>

    1. Jan 23, 2008

      <p>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:</p>

      <ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
      $isRegistered = Zend_Whois::isRegistered($domain);
      ]]></ac:plain-text-body></ac:macro>

      <p>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.</p>

      1. Feb 01, 2008

        <p>This 'problem' has been defined since php 4.0.7. For more info I'd advice you to take a look at this: <a class="external-link" href="http://nl3.php.net/manual/en/function.socket-set-nonblock.php">http://nl3.php.net/manual/en/function.socket-set-nonblock.php</a></p>

  8. Jan 23, 2008

    <p>Looks good! <ac:emoticon ac:name="smile" /><br />
    I only have two comments so far.</p>

    <p>The Zend_Whois_Config seems to reinvent the wheel by not utilizing Zend_Config.<br />
    I think it's a better option to have the constructor of Zend_Whois_Config accept a Zend_Config instance:</p>
    <ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
    public function __construct(Zend_Config $config)
    {
    $this->_config = $config;
    }
    ]]></ac:plain-text-body></ac:macro>

    <p>Also, please rename _cidr_match() to _cidrMatch().<br />
    The XML element names also contain underscores. Maybe they should be camelCased as well, so: contentResponses instead of content_responses.<br />
    Although iirc that goes against XML standards, so this point is open for debate.</p>

    1. Jan 23, 2008

      <p>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.</p>

      <p>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).</p>

  9. Feb 11, 2008

    <p>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.</p>

    <p>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. <ac:emoticon ac:name="smile" /></p>

    <p>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?</p>

    <p>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?</p>

    <p>That's why I think drivers are perfect - I implement the bare minimum or a lot on top.</p>

    <p>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. <ac:emoticon ac:name="smile" /></p>

  10. Feb 11, 2008

    <p>Additional questions:</p>

    <p>1) rwhois supported?<br />
    2) What about NIC handles and AS#?</p>

    <p>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?</p>

    <p>Till</p>

    1. Feb 11, 2008

      <p>1) rwhois will not be supported. Maybe in a future release, but not yet.<br />
      2) NIC handles and AS# numbers are supported yes if I'm right.<br />
      3) The system would find out which whois server has to be used.</p>

      <p>To you driver idea:<br />
      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.</p>

      <p>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 <ac:emoticon ac:name="wink" />.</p>

      1. Feb 11, 2008

        <blockquote>
        <p>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.</p></blockquote>

        <p>The idea is that you don't have to. <ac:emoticon ac:name="smile" /> 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.. </p>

        <p>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.</p>

        <p>Just food for thoughts!</p>

  11. Mar 07, 2008

    <p>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).</p>

    <p>I hope this component will make it in ZF <ac:emoticon ac:name="wink" /></p>

  12. May 26, 2008

    <p>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 <ac:emoticon ac:name="wink" /></p>

  13. Jun 24, 2008

    <ac:macro ac:name="note"><ac:parameter ac:name="title">Zend Comments</ac:parameter><ac:rich-text-body>
    <p>Zend_Whois is accepted for inclusion in extras/incubator as is.</p></ac:rich-text-body></ac:macro>

  14. Aug 18, 2008

    <p>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. </p>

  15. Mar 18, 2009

    <p>Ben, what is the status of this proposal?</p>

    1. Mar 29, 2009

      <p>As Zend_Application had a higher priority, this feature wont make it into 1.8. Postponed to 1.9.</p>

  16. Apr 15, 2010

    <p>Pretty shame is not included yet if is ready.</p>

    <p>That's a very useful component for me...</p>

  17. May 06, 2010

    <p>Hi,</p>

    <p>Seems i have some weird behavior for .ro domains.</p>

    <p> $whois = new ZendX_Whois(); <br />
    $result = $whois->query('auto.ro');</p>

    <p>It doesn't get any whois or domain availablity info.</p>

    <p>The whois server should be fine.</p>

    <p>For other tested tld seems to work properly</p>

    1. May 06, 2010

      <p>I have found where the bug is actually located.</p>

      <p>On ZendX_Whois_Adapter_Base::_getResponse</p>

      <p>The line:<br />
      fputs($fp, $host . "\n");</p>

      <p>Should be replaced with:</p>

      <p>fputs($fp, $host . PHP_EOL);</p>

      <p>Probably similar also for (haven't checked):</p>

      <p>fputs($fp, sprintf($serverInfo<ac:link><ri:page ri:content-title="'format'" /></ac:link>, $host) . "\n");</p>

      1. May 06, 2010

        <p>Ben pointed correctly:</p>

        <p>Should be "\r\n" instead of PHP_EOL</p>

        <p>Seems the .ro whois server doesn't follow the standards...</p>

  18. May 06, 2010

    <p>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.</p>