0

I have an issue. I am trying to check if a given string is a valid "registered" or "registerable" domainname.

Ideally I want to see if the given string can have a valid "registrar" or not. I am already checking the string format using regex and returns true for:

  1. something.com
  2. something.com.au
  3. domains.google
  4. something.something.com

I want to be able to differentiate between "registerable" or "registered" domain from non-registerable or non-registered domain. And I want to do it without checking whois.

My application needs to accept both domains names and subdomain names. So my regex is just fine for that purpose. But I need to flag in my db if the entered value is subdomain or a domain for which I can find whois.

The whole point is to avoid hitting whois servers to retrieve information if the provided string is not a "registered" or "registerable" domain.

I did a lot of research and played around https://publicsuffix.org/list/public_suffix_list.dat but that isn't the solution. This is because for example "wixsite.com" is a valid public sufix, but it "something.wixsite.com" cannot have a whois.

  • why not use [any ready-to-use library](https://libraries.io/search?q=public+suffix) to do that? – mforsetti Aug 23 '21 at 05:12
  • It sounds like what you are looking for is something that checks for valid DNS names? – NiKiZe Aug 23 '21 at 06:18
  • Thanks, @mforsetti for pointing in the right direction. I am using https://libraries.io/packagist/utopia-php%2Fdomains – Mathew Paret Aug 23 '21 at 06:48
  • @NiKiZe yes, I am. – Mathew Paret Aug 23 '21 at 06:49
  • 1
    It sounds like you want domains that appear in the whois, not registerable/registered domains (which, as you have discovered, do not always have whois records). – Michael Hampton Aug 23 '21 at 14:12
  • Typically only TLDs have whois servers attached to it (both registries and registrars). There are probably exceptions, but those would be rare edge cases not useful to take into account I posit. It all boils down to "The whole point is to avoid hitting whois servers to retrieve information": what kind of information are you trying to extract from whois output (and there are also TLDs without port 43 whois)? Also, look at RDAP, far better choice nowadays even if unfortunately not enough spread already. – Patrick Mevzek Aug 23 '21 at 14:27
  • "Ideally I want to see if the given string can have a valid "registrar" or not. " Why? Even at the TLDs level not all TLDs have a registry/registrar model (and even those that do have exceptions and domains registered directly at registry bypassing any registrar, see `de` for one example). A domain being registered or not, is not synonym for it having a registrar. – Patrick Mevzek Aug 23 '21 at 14:29

0 Answers0