Skip to content

set interface (xxx.xxx.xxx.xxx) with sockets #208

@elnarvi

Description

@elnarvi

Description
To avoid blocks in the whois server we use different IPs. With curl it is possible:

`
$loader = new CurlLoader();

$loader->replaceOptions([ CURLOPT_INTERFACE => xxx.xxx.xxx.xxx, CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4 ]);

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

With socket it is faster but it is not possible...

Example

We have had to modify the code of the file:

vendor/io-developer/php-whois/src/Iodev/Whois/Loaders/SocketLoader.php

Changing:

$handle = @fsockopen($whoisHost, 43, $errno, $errstr, $this->timeout);

By:

`
$socket_context = @stream_context_create(array("socket" => array("bindto" => "xxx.xxx.xxx.xxx:0")));

$handle = @stream_socket_client($whoisHost.":43", $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $socket_context);
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions