Ticket #6700: mythweb-6700-add_ip_address_to_MythBackend_class.patch

File mythweb-6700-add_ip_address_to_MythBackend_class.patch, 1.7 KB (added by sphery <mtdean@…>, 10 years ago)

Alternate approach for IP address resolution. Replaces mythweb-6700-resolve_hostname_in_MythBackend_find.patch .

  • classes/MythBackend.php

    old new  
    4949        return $Backend[$host][$port];
    5050    }
    5151
    52     function __construct($host, $port) {
     52    function __construct($host, $port=null) {
    5353        $this->host = $host;
    54         $this->port = $port;
     54        $this->ip = _or(setting('BackendServerIP', $this->host), $host);
     55        $this->port = _or($port, setting('BackendServerPort', $this->host));
    5556        $this->port_http = _or(setting('BackendStatusPort', $this->host), _or(setting('BackendStatusPort'), 6544));
    5657    }
    5758
     
    6263    private function connect() {
    6364        if ($this->connected)
    6465            return;
    65         $this->fp = @fsockopen($this->host, $this->port, $errno, $errstr, 25);
     66        $this->fp = @fsockopen($this->ip, $this->port, $errno, $errstr, 25);
    6667        if (!$this->fp)
    67             custom_error("Unable to connect to the master backend at {$this->host}:{$this->port}.\nIs it running?");
     68            custom_error("Unable to connect to the master backend at {$this->ip}:{$this->port} (hostname: {$this->host}).\nIs it running?");
    6869        $this->connected = true;
    6970        socket_set_timeout($this->fp, 20);
    7071        $this->checkProtocolVersion();
     
    188189    }
    189190
    190191    public function httpRequest($path, $args = array()) {
    191         $url = "http://{$this->host}:{$this->port_http}/Myth/{$path}?";
     192        $url = "http://{$this->ip}:{$this->port_http}/Myth/{$path}?";
    192193        foreach ($args as $key => $value)
    193194            $url .= $key.'='.urlencode($value).'&';
    194195        return @file_get_contents($url);