Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6309907

Browse files
committedApr 30, 2024·
Jira API Configuration Add Proxy
1 parent d6dc7f2 commit 6309907

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed
 

‎application/forms/Config/ConfigForm.php

+11
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ protected function assemble()
5858
'label' => $this->translate('Scheme'),
5959
'description' => $this->translate('Protocol used by Jira (http / https)'),
6060
]
61+
)->addElement(
62+
'text',
63+
'proxy',
64+
[
65+
'label' => $this->translate('Proxy Server'),
66+
'description' => $this->translate(
67+
'Proxy Server used to connect to Jira if needed, '
68+
. 'format <hostname or IP>:<port>'
69+
),
70+
'required' => false,
71+
]
6172
);
6273

6374
$this->addElement(

‎library/Jira/RestApi.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ class RestApi
3131

3232
protected $enumCustomFields;
3333

34-
public function __construct($baseUrl, $username, $password)
34+
protected $proxy;
35+
36+
public function __construct($baseUrl, $username, $password, $proxy)
3537
{
3638
$this->username = $username;
3739
$this->password = $password;
3840
$this->baseUrlForLink = $baseUrl;
3941
$this->baseUrl = \rtrim($baseUrl, '/') . '/rest';
42+
$this->proxy = $proxy;
4043
$this->serverInfo = $this->get('serverInfo')->getResult();
4144
}
4245

@@ -62,7 +65,7 @@ public static function fromConfig()
6265
$user = $config->get('api', 'username');
6366
$pass = $config->get('api', 'password');
6467

65-
$api = new static($url, $user, $pass);
68+
$api = new static($url, $user, $pass, $proxy);
6669

6770
return $api;
6871
}
@@ -448,6 +451,10 @@ protected function request($method, $url, $body = null)
448451
CURLOPT_SSL_VERIFYPEER => false,
449452
);
450453

454+
if ($this->proxy) {
455+
$opts[CURLOPT_PROXY] = $this->proxy;
456+
}
457+
451458
curl_setopt_array($curl, $opts);
452459
// TODO: request headers, validate status code
453460

0 commit comments

Comments
 (0)
Please sign in to comment.