Can be used to add a server for a given TLD.

@param string $tld
@param string $server

@return Whois
967406
public function addServer($tld, $server)
    {
        $this->server[(string) $tld] = (string)$server;
        return $this;
    }
1206438
function whois($addr,$server='whois.internic.net') {
		$socket=@fsockopen($server,43,$errno,$errstr);
		if (!$socket)
			// Can't establish connection
			return FALSE;
		// Set connection timeout parameters
		stream_set_blocking($socket,FALSE);
		stream_set_timeout($socket,ini_get('default_socket_timeout'));
		// Send request
		fputs($socket,$addr."\r\n");
		$info=stream_get_meta_data($socket);
		// Get response
		$response='';
		while (!feof($socket) && !$info['timed_out']) {
			$response.=fgets($socket,4096); // MDFK97
			$info=stream_get_meta_data($socket);
		}
		fclose($socket);
		return $info['timed_out']?FALSE:trim($response);
	}
300649
public function lookupDomain($domain)
    {
        $serverObj = new Server();
        $server = $serverObj->getServerByTld($this->tld);
        if (!$server) {
            throw new Exception("Error: No appropriate Whois server found for $domain domain!");
        }
        $result = $this->queryServer($server, $domain);
        if (!$result) {
            throw new Exception("Error: No results retrieved from $server server for $domain domain!");
        } else {
            while (strpos($result, "Whois Server:") !== false) {
                preg_match("/Whois Server: (.*)/", $result, $matches);
                $secondary = $matches[1];
                if ($secondary) {
                    $result = $this->queryServer($secondary, $domain);
                    $server = $secondary;
                }
            }
        }
        return "$domain domain lookup results from $server server:\n\n" . $result;
    }
990272
private function get_server($domain='')
    {
        if(Request::isHttps()){
            $prefix='https://';
        }else{
            $prefix='http://';
        }
        $c=Config::get('is_simple_url');
        if($domain==''){
            $domain=get_domain();
        }
        return $prefix.$domain;
    }
942595
public function createFromServer(array $server = null){
        $server = $server ?? $_SERVER;

        $scheme     = $this->resolveScheme($server);
        $authority  = $this->resolveAuthority($server, $scheme);
        $path       = $this->resolvePathAndQuery($server);

        return new Uri("{$scheme}://{$authority}{$path}");
    }
199447
public function createUriFromServer(array $server)
    {
        if (isset($server['HTTPS'])) {
            if (!empty($server['HTTPS']) && $server['HTTPS'] !== 'off') {
                $scheme = 'https';
            }
        }
        if (!isset($scheme)) {
            $scheme = 'http';
        }

        $username = isset($server['PHP_AUTH_USER']) ? $server['PHP_AUTH_USER'] : '';
        $password = isset($server['PHP_AUTH_PW']) ? $server['PHP_AUTH_PW'] : '';

        $host = isset($server['HTTP_HOST']) ? $server['HTTP_HOST'] : $server['SERVER_NAME'];

        $port = isset($server['SERVER_PORT']) ? (int)$server['SERVER_PORT'] : 80;
        if (preg_match('/^(\[[a-fA-F0-9:.]+\])(:\d+)?\z/', $host, $matches)) {
            $host = $matches[1];

            if ($matches[2]) {
                $port = (int) substr($matches[2], 1);
            }
        } else {
            $pos = strpos($host, ':');
            if ($pos !== false) {
                $port = (int) substr($host, $pos + 1);
                $host = strstr($host, ':', true);
            }
        }

        $requestScriptName = parse_url($server['SCRIPT_NAME'], PHP_URL_PATH);
        $requestScriptDir = dirname($requestScriptName);

        $requestUri = parse_url('http://example.com' . $server['REQUEST_URI'], PHP_URL_PATH);

        $basePath = '';
        $virtualPath = $requestUri;
        if (stripos($requestUri, $requestScriptName) === 0) {
            $basePath = $requestScriptName;
        } elseif ($requestScriptDir !== '/' && stripos($requestUri, $requestScriptDir) === 0) {
            $basePath = $requestScriptDir;
        }

        if ($basePath) {
            $virtualPath = ltrim(substr($requestUri, strlen($basePath)), '/');
        }

        $queryString = isset($server['QUERY_STRING']) ? $server['QUERY_STRING'] : '';
        if ($queryString === '') {
            $queryString = parse_url('http://example.com' . $server['REQUEST_URI'], PHP_URL_QUERY);
        }

        $fragment = '';

        $uri = new Uri($scheme, $host, $port, $virtualPath, $queryString, $fragment, $username, $password);
        if ($basePath) {
            $uri = $uri->withBasePath($basePath);
        }

        return $uri;
    }
45873
def tld=(new_tld)
      replaced_tld = domain.sub(/#{tld}\z/, new_tld)
      self.host = PublicSuffix::Domain.new(replaced_tld).to_s
    end
224925
protected function addServers($cache, $servers)
    {
        $existingServers = [];
        if ($this->persistentId !== null) {
            foreach ($cache->getServerList() as $s) {
                $existingServers[$s['host'] . ':' . $s['port']] = true;
            }
        }
        foreach ($servers as $server) {
            if (empty($existingServers) || !isset($existingServers[$server->getHost() . ':' . $server->getPort()])) {
                $cache->addServer($server->getHost(), $server->getPort(), $server->getWeight());
            }
        }
    }
412221
function updateTld($oldTld, $newTld)
    {
        $this->files->unlink($this->resolverPath.'/'.$oldTld);

        $this->install($newTld);
    }
1046083
function createCustomConfigFile($tld)
    {
        $customConfigPath = $this->customConfigPath();

        $this->copyExampleConfig();

        $this->appendCustomConfigImport($customConfigPath);

        $this->files->putAsUser($customConfigPath, 'address=/.'.$tld.'/127.0.0.1'.PHP_EOL.'listen-address=127.0.0.1'.PHP_EOL);
    }
1184807
public function getTld($level = null)
    {
        if (is_null($level)) {
            return implode('.', $this->tlds);
        } elseif (isset($this->tlds[ $level ])) {
            return $this->tlds[ $level ];
        }

        return false;
    }
494854
protected function getUdpConnector(string $server): UdpConnector
    {
        if (empty($this->udp[$server])) {
            $this->udp[$server] = new UdpConnector($server, $this->timeout);
        }
        
        return $this->udp[$server];
    }
1272987
public function set($servers){
        $sentence = new SentenceUtil();
        $sentence->addCommand("/ip/dns/set");
        $sentence->setAttribute("servers", $servers);
        $this->talker->send($sentence);
        return "Sucsess";
    }
995291
private function extractServerId($html)
    {
        $server_id = null;

		$regex =
            '#<option value="(\d+)".*?>'
                .preg_quote($this->remoteDbHost, '#').
            '.*?</option>#'
        ;

		if (preg_match($regex, $html, $matches) === 1)
		{
			$server_id = $matches[1];
		}

        return $server_id;
    }
1348120
private static function listenOnBoundSocket(
        $socket,
        Socket\ServerListenContext $listenContext,
        Socket\ServerTlsContext $tlsContext = null
    ): Server {
        if ($tlsContext) {
            $context = \array_merge(
                $listenContext->toStreamContextArray(),
                $tlsContext->toStreamContextArray()
            );
        } else {
            $context = $listenContext->toStreamContextArray();
        }

        \socket_listen($socket, $context["socket"]["backlog"] ?? 0);

        /** @var resource $stream */
        /** @noinspection PhpVoidFunctionResultUsedInspection */
        $stream = \socket_export_stream($socket);
        \stream_context_set_option($stream, $context); // put eventual options like ssl back (per worker)

        return new Server($stream);
    }
783653
public static function getByDomain($domain)
    {
        $slot = new Cache\Slot\ServerByDomain($domain);
        if (false === ($server = $slot->load())) {

            $fields = self::getDbConnection()->fetchAssoc( 'SELECT B.* FROM server_aliases A LEFT JOIN dir_data B USING (ID) WHERE B.hidden<>1 and B.is_server<>0 and A.name = ?', array( $domain ) );
            
            if ($fields) {
                $server = self::fetch($fields); 
            } else {
                $server = self::getDefault();
                if (!$server) return FALSE;
            }
            $slot->addTag(new Cache\Tag\CatalogID($server->id));
            $slot->save($server);
        }
        return $server;
    }
952068
public function compareUrlToTLDs(IUrl $url, array $tlds) {
        if (count($tlds) == 0) {
            return true;
        }

        return array_contains($tlds, $url->getTLD());
    }