Skip to content

Commit

Permalink
updates for Swoole 4.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
deminy committed Jan 11, 2021
1 parent 9bc93b2 commit 5b36a97
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
6 changes: 3 additions & 3 deletions output/swoole/constants.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

define('SWOOLE_VERSION', '4.6.0');
define('SWOOLE_VERSION_ID', 40600);
define('SWOOLE_VERSION', '4.6.1');
define('SWOOLE_VERSION_ID', 40601);
define('SWOOLE_MAJOR_VERSION', 4);
define('SWOOLE_MINOR_VERSION', 6);
define('SWOOLE_RELEASE_VERSION', 0);
define('SWOOLE_RELEASE_VERSION', 1);
define('SWOOLE_EXTRA_VERSION', '');
define('SWOOLE_DEBUG', '');
define('SWOOLE_HAVE_COMPRESSION', '1');
Expand Down
33 changes: 22 additions & 11 deletions output/swoole_library/src/core/Curl/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private function setOption(int $opt, $value): bool
case CURLOPT_FILE:
case CURLOPT_INFILE:
if (!is_resource($value)) {
trigger_error(E_USER_WARNING, 'swoole_curl_setopt(): supplied argument is not a valid File-Handle resource');
trigger_error('swoole_curl_setopt(): supplied argument is not a valid File-Handle resource', E_USER_WARNING);
return false;
}
break;
Expand Down Expand Up @@ -426,7 +426,7 @@ private function setOption(int $opt, $value): bool
* Ignore options
*/
case CURLOPT_VERBOSE:
// trigger_error(E_USER_WARNING, 'swoole_curl_setopt(): CURLOPT_VERBOSE is not supported');
// trigger_error('swoole_curl_setopt(): CURLOPT_VERBOSE is not supported', E_USER_WARNING);
case CURLOPT_SSLVERSION:
case CURLOPT_NOSIGNAL:
case CURLOPT_FRESH_CONNECT:
Expand Down Expand Up @@ -645,9 +645,20 @@ private function execute()
* Http Proxy
*/
if ($this->proxy) {
$proxy = explode(':', $this->proxy);
$proxyPort = $proxy[1] ?? $this->proxyPort;
$proxy = $proxy[0];
$parse = parse_url($this->proxy);
$proxy = $parse['host'] ?? $parse['path'];
$proxyPort = $parse['port'] ?? $this->proxyPort;
$proxyUsername = $parse['user'] ?? $this->proxyUsername;
$proxyPassword = $parse['pass'] ?? $this->proxyPassword;
$proxyType = $parse['scheme'] ?? $this->proxyType;
if (is_string($proxyType)) {
if ($proxyType === 'socks5') {
$proxyType = CURLPROXY_SOCKS5;
} else {
$proxyType = CURLPROXY_HTTP;
}
}

if (!filter_var($proxy, FILTER_VALIDATE_IP)) {
$ip = Swoole\Coroutine::gethostbyname($proxy, AF_INET, $this->clientOptions['connect_timeout'] ?? -1);
if (!$ip) {
Expand All @@ -656,25 +667,25 @@ private function execute()
}
$this->proxy = $proxy = $ip;
}
switch ($this->proxyType) {
switch ($proxyType) {
case CURLPROXY_HTTP:
$proxyOptions = [
'http_proxy_host' => $proxy,
'http_proxy_port' => $proxyPort,
'http_proxy_username' => $this->proxyUsername,
'http_proxy_password' => $this->proxyPassword,
'http_proxy_username' => $proxyUsername,
'http_proxy_password' => $proxyPassword,
];
break;
case CURLPROXY_SOCKS5:
$proxyOptions = [
'socks5_host' => $proxy,
'socks5_port' => $proxyPort,
'socks5_username' => $this->proxyUsername,
'socks5_password' => $this->proxyPassword,
'socks5_username' => $proxyUsername,
'socks5_password' => $proxyPassword,
];
break;
default:
throw new CurlException("Unexpected proxy type [{$this->proxyType}]");
throw new CurlException("Unexpected proxy type [{$proxyType}]");
}
}
/*
Expand Down

0 comments on commit 5b36a97

Please sign in to comment.