Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy not working #24

Closed
OK93-01-18 opened this issue Nov 11, 2020 · 1 comment
Closed

Proxy not working #24

OK93-01-18 opened this issue Nov 11, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@OK93-01-18
Copy link

OK93-01-18 commented Nov 11, 2020

Hello!
I use your Guzzle-Swoole lib in my local project and found issue when try used proxy. Proxy not working. For fix, I updated code in Yurun\Util\Swoole\Guzzle\SwooleHandler 93:

$yurunRequest = $yurunRequest->withAttribute(Attributes::USE_PROXY, true)
    ->withAttribute(Attributes::PROXY_TYPE, $scheme)
    ->withAttribute(Attributes::PROXY_SERVER, $proxyUri->getHost())
    ->withAttribute(Attributes::PROXY_PORT, $proxyUri->getPort())
    ->withAttribute(Attributes::PROXY_USERNAME, $username)
    ->withAttribute(Attributes::PROXY_PASSWORD, $password);

in Yurun\Util\YurunHttp\Handler\Swoole 525 replace switch block:

$userName = $request->getAttribute(Attributes::PROXY_USERNAME, null);
$password = $request->getAttribute(Attributes::PROXY_PASSWORD, null);
switch($type)
{
    case 'http':
        $settings['http_proxy_host'] = $request->getAttribute(Attributes::PROXY_SERVER);
        $settings['http_proxy_port'] = $request->getAttribute(Attributes::PROXY_PORT);
        $userName = $request->getAttribute(Attributes::PROXY_USERNAME, null);
        $password = $request->getAttribute(Attributes::PROXY_PASSWORD, null);
        if (!is_null($userName)) {
            $settings['http_proxy_user'] = $userName;
        }
        if (!is_null($password)) {
            $settings['http_proxy_password'] = $password;
        }
        break;
    case 'socks5':
        $settings['socks5_host'] = $request->getAttribute(Attributes::PROXY_SERVER);
        $settings['socks5_port'] = $request->getAttribute(Attributes::PROXY_PORT);
        if (!is_null($userName)) {
            $settings['socks5_username'] = $userName;
        }
        if (!is_null($password)) {
            $settings['socks5_password'] = $password;
        }
        break;
}

Best Regards, Alex

@Yurunsoft
Copy link
Owner

Thank you very much for your feedback.
This bug has been fixed in the master branch, you can test it to see if it meets the expectation.

@Yurunsoft Yurunsoft added the bug Something isn't working label Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants