Skip to content

Commit

Permalink
set curl_interface based on source ip only
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbakker committed Jul 3, 2020
1 parent bfe86fd commit 25f6660
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,15 @@ public function getAccount(): Account
protected function getHttpClient()
{
if ($this->httpClient === null) {
$this->httpClient = new HttpClient([
'base_uri' => (
$config = [
'base_uri' => (
($this->getOption('mode', self::MODE_LIVE) == self::MODE_LIVE) ?
self::DIRECTORY_LIVE : self::DIRECTORY_STAGING),
'curl.options' => [
'CURLOPT_INTERFACE' => $this->getOption('source_ip', '0.0.0.0')
]
]);
];
if ($this->getOption('source_ip', false) !== false) {
$config['curl.options']['CURLOPT_INTERFACE'] = $this->getOption('source_ip');
}
$this->httpClient = new HttpClient($config);
}
return $this->httpClient;
}
Expand Down Expand Up @@ -536,9 +537,9 @@ protected function getPath($path = null): string
$userDirectory = preg_replace('/[^a-z0-9]+/', '-', strtolower($this->getOption('username')));

return $this->getOption(
'basePath',
'le'
) . DIRECTORY_SEPARATOR . $userDirectory . ($path === null ? '' : DIRECTORY_SEPARATOR . $path);
'basePath',
'le'
) . DIRECTORY_SEPARATOR . $userDirectory . ($path === null ? '' : DIRECTORY_SEPARATOR . $path);
}

/**
Expand Down

0 comments on commit 25f6660

Please sign in to comment.