Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Proxy #11

Open
TimurSeyidov opened this issue Sep 11, 2018 · 0 comments
Open

Proxy #11

TimurSeyidov opened this issue Sep 11, 2018 · 0 comments

Comments

@TimurSeyidov
Copy link

TimurSeyidov commented Sep 11, 2018

Как запустить работу скрипта через прокси (с авторизацией)?
Нашел на просторах интернета вот это

protected function socetOpen()
    {
        $proxy_server = 'proxy_ip';
        $proxy_port = 'proxy_port';
        $this->socet = fsockopen($proxy_server, $proxy_port, $erorno, $errormsg, ($this->timeout_second+$this->timeout_msecond/1000));
        if ($this->socet)
        {
            $out = 'CONNECT '.$this->server_url.':'.$this->server_port.' HTTP/1.0'."\r\n";
            $out .= "\r\n";
# send CONNECT
            fwrite($this->socet, $out);
# check status
            if(strpos(trim(fgets($this->socet, 64).fgets($this->socet, 64)), '200 Connection Established') !== NULL)
            {
                return true;
            }
            fclose($this->socet);
        }
        $this->error = 'Error: Cant establish connection to: '.$this->server_url.':'.$this->server_port."\n".$errormsg;
        return false;
    }

Добавил такую штуку

$id = base64_encode("login:pass");

            $out = 'CONNECT '.$this->server_url.':'.$this->server_port.' HTTP/1.0'."\r\n";
            $out .= "\r\n";
            $out .= 'Proxy-Authorization: Basic ' . $id;
            $out .= "\r\n";
            $out .= "\r\n";

Вроде подключается но сообщения не уходят

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant