Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #92 from AlexNodex/patch-3
Browse files Browse the repository at this point in the history
Source IP
  • Loading branch information
yourivw authored Jun 20, 2021
2 parents 56ae502 + 4084e84 commit 07c3efe
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/LEConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,31 @@ class LEConnector

public $keyChange;
public $newAccount;
public $newNonce;
public $newNonce;
public $newOrder;
public $revokeCert;

public $accountURL;
public $accountDeactivated = false;

private $log;


private $sourceIp = false;
/**
* Initiates the LetsEncrypt Connector class.
*
* @param int $log The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
* @param string $baseURL The LetsEncrypt server URL to make requests to.
* @param array $accountKeys Array containing location of account keys files.
*/
public function __construct($log, $baseURL, $accountKeys)
public function __construct($log, $baseURL, $accountKeys, $sourceIp = false)
{
$this->baseURL = $baseURL;
$this->accountKeys = $accountKeys;
$this->log = $log;
$this->getLEDirectory();
$this->getNewNonce();
$this->sourceIp = false;
}

/**
Expand Down Expand Up @@ -112,7 +114,9 @@ private function request($method, $URL, $data = null)
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HEADER, true);

if($this->sourceIp !== false) {
curl_setopt($handle, CURLOPT_INTERFACE, $this->sourceIp);
}
switch ($method) {
case 'GET':
break;
Expand Down Expand Up @@ -141,11 +145,11 @@ private function request($method, $URL, $data = null)
$body = substr($response, $headerSize);
$jsonbody = json_decode($body, true);
$jsonresponse = array(
'request' => $method . ' ' . $requestURL,
'header' => $header,
'status' => $statusCode,
'body' => $jsonbody === null ? $body : $jsonbody,
);
'request' => $method . ' ' . $requestURL,
'header' => $header,
'status' => $statusCode,
'body' => $jsonbody === null ? $body : $jsonbody,
);
if($this->log instanceof \Psr\Log\LoggerInterface)
{
$this->log->debug($method . ' response received', $jsonresponse);
Expand Down

0 comments on commit 07c3efe

Please sign in to comment.