Git Product home page Git Product logo

php-whois's Introduction

PHP WHOIS

PHP version Packagist

PHP WHOIS client implementation. Sends the queries directly to the WHOIS services.

Use case

  • Raw and parsed domain lookup
  • Raw and parsed ASN routes lookup
  • Direct queries to TLD/ASN hosts
  • Extending and customizing the default hosts, parsers, etc.
  • Proxying via CurlLoader

Installation

System requirements:
  • PHP >= 7.2 (old versions supports 5.4+)
  • php-curl
  • php-mbstring
  • Open port 43 in firewall

Optional:

  • php-intl
  • php-memcached + Memcached server
Project requirements:
  • PSR-4 autoloader
Composer:
composer require io-developer/php-whois

or composer.json:

"require": {
    "io-developer/php-whois": "^4.0"
}

Usage

Domain lookup

How to get summary about domain:
<?php

use Iodev\Whois\Factory;

// Creating default configured client
$whois = Factory::get()->createWhois();

// Checking availability
if ($whois->isDomainAvailable("google.com")) {
    print "Bingo! Domain is available! :)";
}

// Supports Unicode (converts to punycode)
if ($whois->isDomainAvailable("почта.рф")) {
    print "Bingo! Domain is available! :)";
}

// Getting raw-text lookup
$response = $whois->lookupDomain("google.com");
print $response->text;

// Getting parsed domain info
$info = $whois->loadDomainInfo("google.com");
print_r([
    'Domain created' => date("Y-m-d", $info->creationDate),
    'Domain expires' => date("Y-m-d", $info->expirationDate),
    'Domain owner' => $info->owner,
]);
Exceptions on domain lookup:
<?php

use Iodev\Whois\Factory;
use Iodev\Whois\Exceptions\ConnectionException;
use Iodev\Whois\Exceptions\ServerMismatchException;
use Iodev\Whois\Exceptions\WhoisException;

try {
    $whois = Factory::get()->createWhois();
    $info = $whois->loadDomainInfo("google.com");
    if (!$info) {
        print "Null if domain available";
        exit;
    }
    print $info->domainName . " expires at: " . date("d.m.Y H:i:s", $info->expirationDate);
} catch (ConnectionException $e) {
    print "Disconnect or connection timeout";
} catch (ServerMismatchException $e) {
    print "TLD server (.com for google.com) not found in current server hosts";
} catch (WhoisException $e) {
    print "Whois server responded with error '{$e->getMessage()}'";
}
Proxy with SOCKS5:
<?php

use Iodev\Whois\Loaders\CurlLoader;
use Iodev\Whois\Factory;

$loader = new CurlLoader();
$loader->replaceOptions([
    CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,
    CURLOPT_PROXY => "127.0.0.1:1080",
    //CURLOPT_PROXYUSERPWD => "user:pass",
]);
$whois = Factory::get()->createWhois($loader);

var_dump([
    'ya.ru' => $whois->loadDomainInfo('ya.ru'),
    'google.de' => $whois->loadDomainInfo('google.de'),
]);
TLD hosts customization:
<?php

use Iodev\Whois\Factory;
use Iodev\Whois\Modules\Tld\TldServer;

$whois = Factory::get()->createWhois();

// Define custom whois host
$customServer = new TldServer(".custom", "whois.nic.custom", false, Factory::get()->createTldParser());

// Or define the same via assoc way
$customServer = TldServer::fromData([
    "zone" => ".custom",
    "host" => "whois.nic.custom",
]);

// Add custom server to existing whois instance
$whois->getTldModule()->addServers([$customServer]);

// Now it can be utilized
$info = $whois->loadDomainInfo("google.custom");

var_dump($info);
TLD default/fallback servers:
<?php

use Iodev\Whois\Factory;
use Iodev\Whois\Modules\Tld\TldServer;

$whois = Factory::get()->createWhois();

// Add default servers
$matchedServers = $whois->getTldModule()
    ->addServers(TldServer::fromDataList([
        ['zone' => '.*.net', 'host' => 'localhost'],
        ['zone' => '.uk.*', 'host' => 'localhost'],
        ['zone' => '.*', 'host' => 'localhost'],
    ]))
    ->matchServers('some.uk.net');

foreach ($matchedServers as $s) {
    echo "{$s->getZone()}  {$s->getHost()}\n";
}

// Matched servers + custom defaults:
//
// .uk.net  whois.centralnic.com
// .uk.net  whois.centralnic.net
// .uk.*  localhost
// .*.net  localhost
// .net  whois.crsnic.net
// .net  whois.verisign-grs.com
// .*  localhost

ASN lookup

How to get summary using ASN number:
<?php

use Iodev\Whois\Factory;

$whois = Factory::get()->createWhois();

// Getting raw-text lookup
$response = $whois->lookupAsn("AS32934");
print $response->text;

// Getting parsed ASN info
$info = $whois->loadAsnInfo("AS32934");
foreach ($info->routes as $route) {
    print_r([
        'route IPv4' => $route->route,
        'route IPv6' => $route->route6,
        'description' => $route->descr,
    ]);   
}

Response caching

Some TLD hosts are very limited for frequent requests. Use cache if in your case requests are repeating.

<?php

use Iodev\Whois\Factory;
use Iodev\Whois\Loaders\SocketLoader;
use Iodev\Whois\Loaders\MemcachedLoader;

$m = new Memcached();
$m->addServer('127.0.0.1', 11211);
$loader = new MemcachedLoader(new SocketLoader(), $m);

$whois = Factory::get()->createWhois($loader);
// do something...

Develompment

Supported php versions are configured in docker-compose.yml

Common use cases:

  1. Set up & run all tests: docker compose up --build
  2. Run tests under specific php version: docker compose up php-8.2_intl --build
  3. Run scripts: docker compose run php-8.2_intl bin/php-whois info google.com

Also see TESTS.md

Contributing

The project is open for pull requests, issues and feedback. Please read the CODE_OF_CONDUCT.md

php-whois's People

Contributors

andrii-pukhalevych avatar aprat84 avatar arnavchaudhary avatar bessone avatar bladeroot avatar chrif avatar daveismynamecom avatar dcblogdev avatar djureko avatar filipbenco avatar greenlogles avatar greghunt avatar io-developer avatar johnroyer avatar kornrunner avatar necenzurat avatar olaulau avatar p0ep0e avatar simonecarnio avatar timsparrow avatar zaherg avatar zim32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-whois's Issues

function outdated

PHP-Whois version: current version from the main branch

PHP version: 7.2

Description
domain availability check

How to reproduce
Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in /www/wwwroot/www.mydomain.com/vendor/io-developer/php-whois/src/Iodev/Whois/Helpers/DomainHelper.php on line 32
Possible Solution
function outdated

Additional context

.io domains not correctly parsed

PHP-Whois version: 3.2.2

PHP version: 7.2.11

Description
When looking up a .io domain the nameservers are not correctly parsed from the response. For example this is in the whois text

Registrant Country: US
Name Server: ALBERT.NS.CLOUDFLARE.COM
Name Server: KRISTIN.NS.CLOUDFLARE.COM
DNSSEC: unsigned

>>> Last update of WHOIS database: 2018-11-11T14:12:00Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

Access to WHOIS information...

The parsed result looks like this

	"nameservers": {
		"dnssec": "Unsigned",
		"0": "URL of the ICANN WHOIS Data Problem Reporting System: http:\/\/wdprs.internic.net\/",
		"1": ">>> Last update of WHOIS database: 2018-11-11T14:22:56Z <<<"
	},

How to reproduce
Lookup a .io domain, I was using codepen.io

$whois = Whois::create()->loadDomainInfo("codepen.io");

$nameservers = $whois->getNameservers();

print_r($nameservers);

fäw.de returned as free

PHP-Whois version: 3.4

PHP version: 7.3

Description

$whois->isDomainAvailable('fäw.de')

returns true

Execution

Hey!

I'm trying to use your package, but I always get "Maximum execution time of 30 seconds exceeded".
What might cause this problem?

try {
$response = Whois::create()->lookupDomain("google.com");
} catch (ServerMismatchException $e) {
$response = $e->getMessage();
}

SocketLoader doesn't work as expected in strict PHP mode with custom error handler

PHP-Whois version: 3.1.0

PHP version: 7.2.7

Description
Unexpected behavior SocketLoader::loadText() In Symfony project:

  1. fsockopen($whoisHost, 43); throw "Warning: fsockopen(): ..." before ConnectionException. For example whois request .vc tld with current default settings must try two whois hosts, but it doesn't.
  2. iconv('windows-1250', 'utf-8', $text); throw "Notice: iconv(): Detected an illegal character in input string" if whois response contains non-latin chars

How to reproduce

<?php

require __DIR__ . '/../vendor/autoload.php';

use Iodev\Whois\Modules\Tld\TldServer;
use Iodev\Whois\Whois;
use Symfony\Component\Debug\Debug;

Debug::enable();

$domains = [
    'nic.vc',
    'nic.ai',
    'президент.укр',
];

$whois = Whois::create();
$whois->getTldModule()->addServers(TldServer::fromDataList([
    ['zone' => '.ai', 'host' => 'whois.nic.ai'],
]));

//error_reporting(E_ERROR);
$errors = [];
foreach ($domains as $domain) {
    try {
        $info = $whois->loadDomainInfo($domain);
        if (!$info) {
            $rawInfo = $whois->lookupDomain($domain);
            throw new \ErrorException("Info is null");
        }

        echo "{$domain}\n";
        var_dump($info->getCreationDate());
        var_dump($info->getExpirationDate());
        var_dump($info->getNameServers());

    } catch (Exception $e) {
        $errors[$domain] = get_class($e) . ": {$e->getMessage()}";
    }
}

foreach ($errors as $domain => $error) {
    echo "{$domain}:\n";
    $matchedServers = $whois->getTldModule()->matchServers($domain);
    foreach ($matchedServers as $s) {
        echo "{$s->getZone()}  {$s->getHost()}\n";
    }
    if (isset($rawInfo)) {
        var_dump($rawInfo->getText());
    }
    echo "{$error}\n-----\n";
}

Possible Solution

        try {
            $handle = fsockopen($whoisHost, 43);
        } catch (\Exception $e) {
            throw new ConnectionException($e->getMessage());
        }
        try {
            $textUtf8 = iconv(mb_detect_encoding($text), 'utf-8', $text);
        } catch (\Exception $e) {
            throw new EncodingException("Can't convert to utf-8");
        }

Additional context
Symfony 4.1.1 (kernel: src, env: dev, debug: true)

DNSSec

Description
Is it possible to add the DNSSec status for a domain to the DomainInfo object, so I can monitor the DNSSec usage?

Deprecated on PHP 7.1 still working as of now (not a bug but how to fixed this warning popping sometimes on command line and page?)

PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Whois has a deprecated constructor in /home/vagrant/code/pixinpics/vendor/phpwhois/phpwhois/src/whois.main.php on line 31

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Whois has a deprecated constructor in /home/vagrant/code/pixinpics/vendor/phpwhois/phpwhois/src/whois.main.php on line 31
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WhoisClient has a deprecated constructor in /home/vagrant/code/pixinpics/vendor/phpwhois/phpwhois/src/whois.client.php on line 30

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WhoisClient has a deprecated constructor in /home/vagrant/code/pixinpics/vendor/phpwhois/phpwhois/src/whois.client.php on line 30
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; idna_convert has a deprecated constructor in /home/vagrant/code/pixinpics/vendor/phpwhois/phpwhois/src/whois.idna.php on line 54

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; idna_convert has a deprecated constructor in /home/vagrant/code/pixinpics/vendor/phpwhois/phpwhois/src/whois.idna.php on line 54

No servers matched for domain *.site

PHP-Whois version: ^3.2

PHP version: 7.2.10

Description
An error 'Iodev\Whois\Exceptions\ServerMismatchException' occurres when trying to check some .site by calling isDomainAvailable()

How to reproduce
Call Whois::create()->isDomainAvailable('some-website.site')

Possible Solution
Add .site domain zone checking server

Change parser type

Hi how can we change parser type or how parser type works?
there is no documentation to learn it.

.be false "taken" report

PHP-Whois version: 3.2.1

PHP version: 5.6.38

Description
php-whois always reports "busy" when querying .be domains

How to reproduce
Query: Whois::create()->isDomainAvailable('somedomainthatdoesnotexist.be');

Expected result: free
Actual result: busy

Additional context
Note: whois server is configured correctly, but whois console command returns a correct result

Add whois.nic.es

Description
The .es domains have activated the whois on port 43 (whois.nic.es), but to get an answer we need to do an accreditation procedure.

The indications are here:
https://www.dominios.es/dominios/en/todo-lo-que-necesitas-saber/valores-anadidos/puerto-43

Without the accreditation of the IP address the server responds but does not provide information, with the accreditation only the domain name and the registrant are provided.

The accreditation is free, to request is sent the IP address from which the calls come.
(https://www.dominios.es/dominios/sites/dominios/files/en_Procedimiento%20de%20alta%20servicio%20whois%20puerto%2043%20v4_cambio%20sede%20%28ult%29_0.pdf)

Example

Answer without accreditation
` Conditions of use for the whois service via port 43 for .es domains

Access will only be enabled for  IP addresses  authorised  by Red.es.  A maximum of one  IP address per
user/organisation is permitted.

Red.es accepts  no responsibility  whatsoever  for  the availability  of access to WHOIS,  which may be
suspended at any time and without prior warning at the discretion of the public entity.

The service will be limited to the data established by Red.es.

The user  promises  to make use of the service and to  carry out any action derived  from the aforesaid
use in accordance with  current applicable  regulations, in particular with legislation on “.es” domain
names and personal data protection.

In particular, the user undertakes not to use  the service  to carry out abusive  or speculative domain
name registrations, pursuant to section 5 of the Sixth Additional Provision of Law 34/2002, of 11 July,
on Services of the  Information  Society and  Electronic Commerce. Likewise, the User undertakes not to
use the service to  obtain data, the possession  of which may  contravene the provisions of Organic Law
15/1999,  of  13 December,  on Personal Data Protection, and  its Regulations, or in Law 34/2002, of 11
July, on Services of the Information Society and Electronic Commerce.

Failure  to comply with these conditions will result in the immediate withdrawal of the service and any
registered domain name which breaches said conditions may be officially cancelled by Red.es.
-------------------------------------------------------------------------------------------------------


The IP address used to perform the query  is not authorised  or  has exceeded the established limit for
queries.To request access to the service,complete the form located at https://sede.red.gob.es/sede/whois,
where you may also consult the service conditions.

-------------------------------------------------------------------------------------------------------
More information on each domain may be consulted at www.dominios.es.`

Answer with accreditation
` Conditions of use for the whois service via port 43 for .es domains

Access will only be enabled for  IP addresses  authorised  by Red.es.  A maximum of one  IP address per
user/organisation is permitted.

Red.es accepts  no responsibility  whatsoever  for  the availability  of access to WHOIS,  which may be
suspended at any time and without prior warning at the discretion of the public entity.

The service will be limited to the data established by Red.es.

The user  promises  to make use of the service and to  carry out any action derived  from the aforesaid
use in accordance with  current applicable  regulations, in particular with legislation on “.es” domain
names and personal data protection.

In particular, the user undertakes not to use  the service  to carry out abusive  or speculative domain
name registrations, pursuant to section 5 of the Sixth Additional Provision of Law 34/2002, of 11 July,
on Services of the  Information  Society and  Electronic Commerce. Likewise, the User undertakes not to
use the service to  obtain data, the possession  of which may  contravene the provisions of Organic Law
15/1999,  of  13 December,  on Personal Data Protection, and  its Regulations, or in Law 34/2002, of 11
July, on Services of the Information Society and Electronic Commerce.

Failure  to comply with these conditions will result in the immediate withdrawal of the service and any
registered domain name which breaches said conditions may be officially cancelled by Red.es.

The  User will be held accountable for the use they make of the service and will be responsible for any
claims that may be filed by third parties in this regard against Red.es and will have to compensate the
public entity for any damages it may incur as a result.

The data which  can  be consulted via  this service include:  availability and  name of the holder of a
domain.

A maximum of 10 queries per minute  can  be  made by each  registered IP address.  Should this limit be
exceeded, the service will be blocked for two hours, after which a new query may be performed.

Queries can be performed on second and third level domains.
-------------------------------------------------------------------------------------------------------


Domain:
-------
   Domain Name:                  google.es

Registrant:
-----------
   Registrant Name:              Google LLC


>>> LAST UPDATE: 10/10/2019 07:00:04
-------------------------------------------------------------------------------------------------------
More information on each domain may be consulted at www.dominios.es.`

CurlLoader: curl_setopt(): cannot represent a stream of type MEMORY as a STDIO FILE*

PHP-Whois version: x.y.z
3.3.1

PHP version: x.y.z
7.1.24

Description
CurlLoader.php:97: curl_setopt_array(): cannot represent a stream of type MEMORY as a STDIO FILE*

How to reproduce
$loader = new CurlLoader();
$whois = Whois::create($loader);

Possible Solution
In the CurlLoader:82 replace
$input = fopen('php://memory','r+');
to
$input = fopen('php://temp','r+');

Additional context
tested on Windows 8.1

[idea] using __call magic function in DomainInfo class

Description
Each domain will return a load of information that we don't process, using __call function within the DomainInfo class will allow us to have dynamic functions that we can use.

Example

1- First we need to add the following code to the DomainInfo class

    // This function will return all the method names they can use
    public function getAvaliableKeys()
    {
        $keys = array_keys($this->data);

        foreach ($keys as $key) {
            $functions[$key] = 'get'.ucfirst($key);
        }

        return implode(', ',$functions);

    }

    public function __call($methodName, $arguments = '')
    {
        $method = lcfirst(substr($methodName, 3));
        
        if(array_key_exists($method, $this->data)) {
            return $this->getval($method, $arguments);
        }

        throw new \Exception("Method {$methodName} does not exists");
    }

2- Update the parsers (in my case here I've updated the CommonParser class to add new values, for example, I added the registrar company URL:
a) Add the key

    /** @var array */
    protected $registrarUrlKeys = [ "registrar url" ];

b) update parseResponse function:

    /**
     * @param DomainResponse $response
     * @return DomainInfo
     */
    public function parseResponse(DomainResponse $response)
    {
        $sel = $this->filterFrom($response)->toSelector();
        $data = [

// deducted for simplicity

            "registrarURL" => $sel->clean()
                ->selectKeys($this->registrarUrlKeys)
                ->getFirst(''),
        ];
        $info = new DomainInfo($response, $data, $this->getType());
        return $info->isValuable($this->notRegisteredStatesDict) ? $info : null;
    }

Now I can use the following code:

    $whois = Whois::create();
    $info = $whois->loadDomainInfo('google.com');

    return $info->getRegistrarURL();

And I'll get the value "http://www.markmonitor.com" successfuly.

Now we can delete the following functions from DomainInfo:

    /**
     * @return string
     */
    public function getDomainName();

    /**
     * @return string
     */
    public function getWhoisServer();

    /**
     * @return string[]
     */
    public function getNameServers();

    /**
     * @return int
     */
    public function getCreationDate();

And it will still work since they become dynamic functions. Also, whenever we add a new selector to the Parsers, it will be automatically available as a function without editing the DomainInfo class.

I am sure the code needs some cleanup, as this is just a draft idea.

[idea] using the builtin linux whois app

Description
Instead of using curl/sockets to communicate with the whois servers, what if we built a new loader which uses Linux whois app instead?

Just an idea that I need some feedback from you before I start trying to implement. As I am semi sure you have thought of something similar.

And make it the default one instead of the socket

lookups fail for .fi domains

.fi domains always return "Domain not found"

In io-developer/php-whois/src/Iodev/Whois/Whois.php:

private function loadDomainDataFrom(Server $server, $domain):
 $p = $server->getParser();
 $response = $this->loader->loadResponse($server->getHost(), $domain);
 $info = $p->parseResponse($response);

$info is always NULL.

In io-developer/php-whois/src/Iodev/Whois/Parsers/CommonParser.php:

public function parseResponse(Response $response)
 $group = $this->groupFrom($response);

$group is always NULL.

Something goes wrong in Iodev/Whois/Helpers/GroupHelper.php

socks proxy connection failed

PHP-Whois version: current stable release

PHP version: 7.2.0

Description
I am usesing this package to query whois data via proxy socks5 and some of the domains response errors.

for example , most of the new gtlds such as .xyz .run .ltd .fun etc proxy connection failed
some cctld such as .gs .cx proxy failed

PHP Fatal error: Uncaught Iodev\Whois\Exceptions\ConnectionException: Can't complete SOCKS5 connection to 2620:0115:3000:5003:0000:0000:0000:0132:43. (8) in /opt/vendor/io-developer/php-whois/src/Iodev/Whois/Loaders/CurlLoader.php:107
Stack trace:
#0 /opt/vendor/io-developer/php-whois/src/Iodev/Whois/Modules/Tld/TldModule.php(165): Iodev\Whois\Loaders\CurlLoader->loadText('whois.donuts.co', '404.run\r\n')
#1 /opt/vendor/io-developer/php-whois/src/Iodev/Whois/Modules/Tld/TldModule.php(210): Iodev\Whois\Modules\Tld\TldModule->loadResponse(Object(Iodev\Whois\Modules\Tld\TldServer), '404.run', false, 'whois.donuts.co')
#2 /opt/vendor/io-developer/php-whois/src/Iodev/Whois/Modules/Tld/TldModule.php(185): Iodev\Whois\Modules\Tld\TldModule->loadParsedTo(NULL, NULL, Object(Iodev\Whois\Modules\Tld\TldServer), '404.run', false, NULL, Object(Iodev\Whois\Exceptions\ConnectionException))
#3 /opt/vendor/io-developer/php-whois/src/Iodev/Whois/Modules/Tld/TldModule.php(148): Iodev\Whois\Modules\Tld\TldModule->loadDomainData('404.run', Array) in /opt/vendor/io-developer/php-whois/src/Iodev/Whois/Loaders/CurlLoader.php on line 107

How to reproduce

require 'vendor/autoload.php';
use Iodev\Whois\Loaders\CurlLoader;
use Iodev\Whois\Whois;
$loader = new CurlLoader();
$loader->replaceOptions([
CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,
CURLOPT_PROXY => "some socks5 ip and port"
]);
$whois = Whois::create($loader);
var_dump([
'404.run' => $whois->loadDomainInfo('404.run')
]);

Possible Solution

Additional context

Autoconfig feature

Description

php-whois configuration for TLDs is centrally distributed, changes in whois servers' config have to be reported as issues, then committed to the config file, then redistributed via git/composer.

However, to find out a whois server name for a particular TLD, one can use the following shell script:

#!/bin/bash
tld=$1
# error checking omitted for demonstration purposes
dig +short CNAME $tld.whois-servers.net

Example

Implement a TldServer::getWhoisServer($tld) method that returns a server name using this command (use php system call for that)

Implement a TldServer::getTldList method to get the TLD list from the official site http://data.iana.org/TLD/tlds-alpha-by-domain.txt

Implement a updateConfig($tld) method (not sure which class it belongs to), that allows to query the server for an individual tld, or the whole list.

Make config file non-distributable, keep only sample file and possible parser-to-tld configuration

Possibility to disable writing file

Reason

{"reason":"file_put_contents(domain.tld\r\n.txt): failed to open stream: Permission denied...

Using your project with Laravel and it's not possible to write the file like that. Also don't see a reason for it.

Description
A possibility to disable writing the file in vendor/io-developer/php-whois/src/Iodev/Whois/Loaders/SocketLoader.php: 40

file_put_contents("$query.txt", $text);

Also, the query is sometimes:

 -T dn,ace repat.de

Including the paragraph as \r\n. So the filename has a paragraph in it. It would be good to at least trim() it.

Example

$writeFlag = false;
Whois::create()->loadDomainInfo($domain, $writeFlag);
...
if ($writeFlag) {
  file_put_contents("$query.txt", $text);
}

whois script performance

PHP-Whois version: current main version

PHP version: 5.5

Description
Checking availability query at low performance

How to reproduce
I debug the running time for the code below

if (Whois::create()->isDomainAvailable("google.com")) {
print "Bingo! Domain is available! :)";
}

I can see that this domain query runs really slow , it will consume around 2-3 seconds per request.
Possible Solution
whois server query socket optimize

Additional context

unwanted characters in domain status

there is an unwanted characters <a href=" within domain status array while querying for spravka-invalidnost.com or wuu059.com

similar issue with other domains as well:

  • puuhastellen.com or tessaana.com has additional -

[RFC] A lot of data get lost only because not supported by DomainInfo (but they are present and correctly parsed!)

Description
This library is really powerful and is able to create an array populated with every data returned by any whois server.

Those data are concretely available as array, but they get lost as the selector only selects part of them.

I'm referring, for example, to the response returned by NIC (the Italian whois), that contains a lot of data about the owner of the domain, including his address.

Unfortunately, the selector only selects a bunch of data to pass to the DomainInfo object and so those data are not accessible (but yet really useful.

Is it possible to add all not selected data to a parsed array to pass to DomainInfo?

This way, the current properties permit to access the common data, but it is anyway possible to access other information as needed, also if they not fit the standard properties of the DomainInfo object.

What do you think about this?

It maybe sufficient to add a fourth argument to the DomainInfo data that may be called something like parsed that contains the parsed $response.

Or it can be added to the Response object itself as parsed property, to pair with the property text already present.

Any solution will be useful: the real thing is to make accessible the response as a parsed array to use as anyone likes.

Docker rest service

How about add docker image as REST service?
Using slim or any micro framework for that.

Domain controle .jp didn't work

PHP-Whois version: 3.3.1

PHP version: 7.2

Description
If you do a domain name check for *.jp it will always indicate 'available'.

How to reproduce
Please check it with enjoymyjapan.jp. This domain name is taken, but does it indicate available? That is not true.

Using private visibility prevent extending

PHP-Whois version 3.x

PHP version: 7.x

Description
Using private visibility for variables within the Whois class (as an example here) makes it very hard to extend and modify the class without editing the original class

For example, there is no way for us to modify the following variables

    /** @var ILoader */
    private $loader;

    /** @var TldModule */
    private $tldModule;

    /** @var AsnModule */
    private $asnModule;

So there is no way for me to modify the getTldModule function, for example:

    /**
     * @return TldModule
     */
    public function getTldModule()
    {
        $this->tldModule = $this->tldModule ?: TldModule::create($this->loader);
        return $this->tldModule;
    }

How to reproduce
Create a new Class and try to extend the Whois class, then try to create a new function with the name getTldModule

Possible Solution

  1. Either to change it them protected (which I don't like much).
  2. Provide a set of functions that we can use to modify those private variables without editing them directly like
    public function setTldModule(TldModule $tldModule = null)
    {
        $this->tldModule = $this->tldModule ?: ((null ===$tldModule) ? TldModule::create($this->loader) : $tldModule);
    }

and change getTldModule function to only return the value instead of setting + returning the value

    /**
     * @return TldModule
     */
    public function getTldModule()
    {
        return $this->tldModule;
    }

The function getTldModule should only return the data, not initiate it too.

Then whenever we call getTldModule in isDomainAvailable, lookupDomain, loadDomainInfo we call setTldModule before it for example isDomainAvailable will become:

    /**
     * @param string $domain
     * @return bool
     * @throws ServerMismatchException
     * @throws ConnectionException
     * @throws WhoisException
     */
    public function isDomainAvailable($domain)
    {
        return $this->setTldModule()->getTldModule()->isDomainAvailable($domain);
    }

I am sure there are many places in the code like this one, but we can always start with the Whois class first, then move to other classes one by one.

I am more than happy to help you with this if you agree with me about this point.

Additional context

Screen Shot 2019-08-15 at 7 57 41 PM

script crash down the servers

PHP-Whois version: current stable

PHP version: 7.2.0
Description
I am using script to query .cm domains such as xxx.cm, it seems that .cm whois server is down, and the script keep loading and wait fro the server response. during this period , script exausted the server resourses and go into 500 error.

How to reproduce
require('vendor/autoload.php');
use Iodev\Whois\Whois;
use Iodev\Whois\Loaders\SocketLoader;
use Iodev\Whois\Loaders\MemcachedLoader;
use Iodev\Whois\Exceptions\ConnectionException;
use Iodev\Whois\Exceptions\ServerMismatchException;
use Iodev\Whois\Exceptions\WhoisException;
$m = new Memcached();
$m->addServer('127.0.0.1', 11211);
$loader = new MemcachedLoader(new SocketLoader(), $m);
try {
$whois = Whois::create($loader);
$info = $whois->lookupDomain("xxx.cm");
print $info->getText();
} catch (ConnectionException $e) {
print "Disconnect or connection timeout";
} catch (ServerMismatchException $e) {
print "TLD server not found in current server hosts";
} catch (WhoisException $e) {
print "Whois server responded with error '{$e->getMessage()}'";
}
Possible Solution
custom timeout for query

Additional context

no whois info for hopsy.beer

PHP-Whois version: 3.1

PHP version: 7.2

Description
whois-dub.mm-registry.com which is the whois server for
"abogado", "bayern", "beer", "budapest", "casa", "cooking", "country", "fashion", "fishing", "fit", "garden", "horse", "luxe", "miami", "rodeo", "surf", "vodka", "wedding", "work", "yoga"
is unreachable.

How to reproduce
kpilo@localhost $ host whois-dub.mm-registry.com
Host whois-dub.mm-registry.com not found: 3(NXDOMAIN)

Possible Solution
Replace with the new server for each zone.

[
    {
        "zone": "abogado",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.abogado"
    },
    {
        "zone": "bayern",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.bayern"
    },
    {
        "zone": "beer",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.beer"
    },
    {
        "zone": "budapest",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.budapest"
    },
    {
        "zone": "casa",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.casa"
    },
    {
        "zone": "cooking",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.cooking"
    },
    {
        "zone": "country",
        "was": "whois-dub.mm-registry.com",
        replacement server not found
    },
    {
        "zone": "fashion",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.fashion"
    },
    {
        "zone": "fishing",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.fishing"
    },
    {
        "zone": "fit",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.fit"
    },
    {
        "zone": "garden",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.garden"
    },
    {
        "zone": "horse",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.horse"
    },
    {
        "zone": "luxe",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.luxe"
    },
    {
        "zone": "miami",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.miami"
    },
    {
        "zone": "rodeo",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.rodeo"
    },
    {
        "zone": "surf",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.surf"
    },
    {
        "zone": "vodka",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.vodka"
    },
    {
        "zone": "wedding",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.wedding"
    },
    {
        "zone": "work",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.work"
    },
    {
        "zone": "yoga",
        "was": "whois-dub.mm-registry.com",
        "now": "whois.nic.yoga"
    }
]

lookups fails for .tn domains

PHP-Whois version: 3.3.1

PHP version: 7.2.11

Description
Cannot check a .tn domain owner or any other useful information

Additional context
Output for "ati.tn":
Array ( [Domain created] => 1998-01-06 [Domain expires] => 1970-01-01 [Domain owner] => )

Problem with .uk / nominet

This library is not working for .uk responses. I've done some debugging but you'll probably be able to figure it out faster than me.

As you know, Whois->loadDomainDataFrom() tries the whois server without strict and then with strict if it fails to parse the first attempt.

The GroupHelper fails to return the top half of the first (valid) nominet response so the parse fails and the strict attempt fails because nominet does not like the = at the start of the domain name and tells you this.

I believe the problem lies in GroupHelper::groupFromText() because I can see here that it receives something like

string(37) "
    Domain name:
        bbc.co.uk"

and returns

array(1) {
  ["Domain name"]=>
  string(0) ""
}

Hope this makes sense.

.shop TLD support request

Description
Currently, php-whois cannot resolve whois servers for .shop domain

Workaround
$customServers = [
new TldServer(".shop", "whois.nic.shop", false, TldParser::create()),
];
$whois = Whois::create();
$whois->getTldModule()->addServers($customServers);

Is there a dev version supporting these domains? Or should I make it and create a pull request?

Edit: frl IS available, only .shop is not supported by default.

idn_to_ascii(): PHP7.2 deprecated.

A PHP Error was encountered
Severity: 8192

Message: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

Filename: Helpers/DomainHelper.php

Line Number: 30

Update the whois servers with the IANA list

Hello,
I made a comparison between the list of official whois servers indicated by IANA and those listed in the JSON, there are more than 300 differences.

Some servers have just changed and the old ones no longer exist, others often correspond to the same server (same IP address) but have changed names (for example with hosts with the same extension as tld).
Locally I'm already updating the json file, can it make sense to report the changes on the master?

A single PR or separate in different blocks to make them more readable?

whois server query ban by registry

I request donuts domain as below :

require_once 'vendor/autoload.php';
use Iodev\Whois\Whois;

$response = Whois::create()->lookupDomain("google.associates");
echo $response->getText();

I got denied msgs as below:

Malformed request. Terms of Use: Users accessing the Donuts WHOIS service must agree to use the data only for lawful purposes, and under under no circumstances use the data to: Allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the registrar's own existing customers. Enable high volume, automated, electronic processes that send queries or data to the systems of Donuts or any ICANN-accredited registrar, except as reasonably necessary to register domain names or modify existing registrations. When using the Donuts Whois service, please consider the following: The Whois service is not a replacement for standard EPP commands to the SRS service. Whois is not considered authoritative for registered domain objects. The Whois service may be scheduled for downtime during production or OT&E maintenance periods. Queries to the Whois services are throttled. If too many queries are received from a single IP address within a specified time, the service will begin to reject further queries for a period of time to prevent disruption of Whois service access.

I am not sure if this issue impacts other newgtld whois query.

Problems with the Turkish domains .com.tr

PHP-Whois version: 3.4.1

PHP version: 7.3.x

Description
When trying to get the WHIOS information about google.com.tr, they will return data like this

** Billing Contact:
NIC Handle		: btl1-metu
Organization Name	: Beril Teknoloji Bili�im Yay�nc�l�k Ticaret A.�.
Address			: Hidden upon user request
Phone			: Hidden upon user request
Fax			: Hidden upon user request

Which make it hard for the TextHelper class to determine the encoding for the value. So the returned value for

$srcEncoding = strtolower(mb_detect_encoding($text));

will be nothing, an empty string.

How to reproduce
Try to query for google.com.tr domain.

Possible Solution
Editing the TextHelper class and change the following

if ($srcEncoding != 'utf-8') {

to the following:

        if ($srcEncoding != 'utf-8' && $srcEncoding !== '') {
            return mb_convert_encoding($text, 'utf-8', $srcEncoding);
        }

        if ($srcEncoding === '') {
            return mb_convert_encoding($text, 'utf-8');
        }

Additional context
Just a small note, the WHOIS server whois.metu.edu.tr is not so stable, the first query you do will work, the second will timeout, I think they block the requests for few minutes before they reply again.

False positive result for .eu domains

PHP-Whois version:3.0.5

PHP version: 5.6, 7.1

Description
php-whois returns that google.eu is available (also happens with apple.eu)

How to reproduce
Whois::create()->isDomainAvailable('google.eu') returns true, expected false;

Possible Solution

Additional context
whois google.eu

returns no status.
Maybe it helps to debug the problem

% WHOIS google.eu
Domain: google.eu

Registrant:
NOT DISCLOSED!
Visit www.eurid.eu for webbased whois.

Onsite(s):
NOT DISCLOSED!
Visit www.eurid.eu for webbased whois.

Registrar:
Name: MarkMonitor Inc.
Website: https://www.markmonitor.com/

custom parser

some tlds are not parsed correctly, such as .cm ,Domain owner is not parsed

I just add key words for .cm "International Organisation" in /src/Iodev/Whois/Configs/ , but not work

nic.cz

PHP-Whois version: master
PHP version: 7.1

Description
Server whois.nic.cz sometimes returns "Your connection limit exceeded. Please slow down and try again later.". The domain then misidentifies it.

Whois server name return

Description

When using the library, one cannot tell which server has returned the result. It could be an advantage to have a possibility to query the name of the server that has served the last request, to see if something goes wrong.

Example

$ts = microtime(true);
$domain = 'somedomain.tld';
$result = $this->whois->isDomainAvailable($domain) ? 'free' : 'busy';
$elapsed = microtime(true) - $ts;
$serverName = $this->whois->getLastServer(); // New method that returns the server name responsible for the last result
$this->log(sprintf(
  "Whois data for %d was served by %s, resullt:%s, obtained in %f seconds", 
  $domain, 
  $serverName, 
  $result, 
  $elapsed
));

null response for .to domains

the library is returning null response for .to domains, Call to a member function getExpirationDate() on null

whois nnmclub.to -h whois.tonic.to
Tonic whoisd V1.1
nnmclub ns1.nnm-club.cc
nnmclub ns2.nnm-club.cc

loadDomainInfo() returns null for .nz domains

PHP-Whois version: 3.2.3

PHP version: 7.1

Description
loadDomainInfo() method returns null for NZ domains

How to reproduce

So far the result has been consistent with all *.nz domains tested. Here's a list of the domains used for testing:

payrollmatters.co.nz
progressbuilders.co.nz
secuirty-services.co.nz
sgtc.org.nz
smarttech.nz
sparklife.net.nz
sticksxstones.co.nz
tasteofsun.co.nz
tenzo.fr
thequeencharlotte.co.nz
titanz.com.au
tradejacks.co.nz
triciaed.co.nz
tutoronline.co.nz
tvcontracting.co.nz
willdofitness.co.nz
wpnz.net.nz

Code snippet used:

<?php
use Iodev\Whois\Whois;
  
Whois::create();
  
// Getting raw-text lookup works
$response = Whois::create()->lookupDomain("payrollmatters.co.nz");
print $response->getText();
  
// Getting parsed domain info will not work
$info = Whois::create()->loadDomainInfo("payrollmatters.co.nz");
print_r([
    'Domain created' => date("Y-m-d", $info->getCreationDate()),
    'Domain expires' => date("Y-m-d", $info->getExpirationDate()),
    'Domain owner' => $info->getOwner(),
]);
?>

Possible Solution
I think that something is not being detected by Iodev\Whois\Modules\Tld\Parsers\CommonParser

I ran the code with Xdebug and the keys used in the response in order to list the nameservers doesn't seem to be matched by any keys of the parser:

ns_name_01: ns1.somensserver.com
ns_name_02: ns2.somensserver.com

It may be that the response body format is different now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.