Skip to content

Commit

Permalink
Add cURL proxy type configuration (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
rleroi authored Sep 6, 2023
1 parent 0601219 commit 6d186c0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Configuration/AbstractConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ abstract class AbstractConfiguration implements ConfigurationInterface
*/
protected ?string $proxyPort = null;

/**
* Proxy type.
*/
protected ?int $proxyType = null;

/**
* Proxy user.
*/
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/Configuration/ConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public function getProxyServer(): ?string;
*/
public function getProxyPort(): ?string;

/**
* Proxy type.
*/
public function getProxyType(): ?int;

/**
* Proxy user.
*/
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/DotEnvConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
5 changes: 5 additions & 0 deletions src/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

/**
Expand Down

0 comments on commit 6d186c0

Please sign in to comment.