From 6d186c0581e8a560bda35ec42e767290a6137e07 Mon Sep 17 00:00:00 2001 From: "R. Leroi" Date: Wed, 6 Sep 2023 14:42:00 +0200 Subject: [PATCH] Add cURL proxy type configuration (#519) --- src/Configuration/AbstractConfiguration.php | 10 ++++++++++ src/Configuration/ConfigurationInterface.php | 5 +++++ src/Configuration/DotEnvConfiguration.php | 1 + src/JiraClient.php | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/src/Configuration/AbstractConfiguration.php b/src/Configuration/AbstractConfiguration.php index 993def43..603b28f9 100644 --- a/src/Configuration/AbstractConfiguration.php +++ b/src/Configuration/AbstractConfiguration.php @@ -64,6 +64,11 @@ abstract class AbstractConfiguration implements ConfigurationInterface */ protected ?string $proxyPort = null; + /** + * Proxy type. + */ + protected ?int $proxyType = null; + /** * Proxy user. */ @@ -198,6 +203,11 @@ public function getProxyPort(): ?string return $this->proxyPort; } + public function getProxyType(): ?int + { + return $this->proxyType; + } + public function getProxyUser(): ?string { return $this->proxyUser; diff --git a/src/Configuration/ConfigurationInterface.php b/src/Configuration/ConfigurationInterface.php index 196360bc..e3c41999 100644 --- a/src/Configuration/ConfigurationInterface.php +++ b/src/Configuration/ConfigurationInterface.php @@ -96,6 +96,11 @@ public function getProxyServer(): ?string; */ public function getProxyPort(): ?string; + /** + * Proxy type. + */ + public function getProxyType(): ?int; + /** * Proxy user. */ diff --git a/src/Configuration/DotEnvConfiguration.php b/src/Configuration/DotEnvConfiguration.php index 0aae17d0..d26a469c 100644 --- a/src/Configuration/DotEnvConfiguration.php +++ b/src/Configuration/DotEnvConfiguration.php @@ -37,6 +37,7 @@ public function __construct(string $path = '.') $this->curlOptVerbose = $this->env('CURLOPT_VERBOSE', false); $this->proxyServer = $this->env('PROXY_SERVER'); $this->proxyPort = $this->env('PROXY_PORT'); + $this->proxyType = $this->env('PROXY_TYPE'); $this->proxyUser = $this->env('PROXY_USER'); $this->proxyPassword = $this->env('PROXY_PASSWORD'); diff --git a/src/JiraClient.php b/src/JiraClient.php index fd2ee408..0e055f54 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -605,6 +605,11 @@ private function proxyConfigCurlHandle(\CurlHandle $ch): void $password = $this->getConfiguration()->getProxyPassword(); curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$username:$password"); } + + // Set the proxy type for curl, default is CURLPROXY_HTTP (0) + if ($this->getConfiguration()->getProxyType()) { + curl_setopt($ch, CURLOPT_PROXYTYPE, $this->getConfiguration()->getProxyType()); + } } /**