Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #480 IP could not resolve IPv6 #635

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Senders/CurlSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CurlSender implements SenderInterface
private $maxBatchRequests = 75;
private $batchRequests = array();
private $inflightRequests = array();
private $ipResolve = CURL_IPRESOLVE_V4;

public function __construct($opts)
{
Expand Down Expand Up @@ -54,6 +55,10 @@ public function __construct($opts)
if (array_key_exists('ca_cert_path', $opts)) {
$this->caCertPath = $opts['ca_cert_path'];
}
if (array_key_exists('ip_resolve', $opts)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add testing for this scenario?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some tests to ensure that the value is set. I usually try to avoid testing private properties since they are generally assumed to be safe to refactor. So, I added a comment to the test in case it fails in the future because of some sort of refactoring.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved the PR but it looks like tests are failing.

&& in_array($opts['ip_resolve'], [CURL_IPRESOLVE_V4, CURL_IPRESOLVE_V6, CURL_IPRESOLVE_WHATEVER])) {
$this->ipResolve = $opts['ip_resolve'];
}
}

public function getEndpoint()
Expand Down Expand Up @@ -151,7 +156,7 @@ public function setCurlOptions(CurlHandle $handle, EncodedPayload $payload, stri
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($handle, CURLOPT_HTTPHEADER, array('X-Rollbar-Access-Token: ' . $accessToken));
curl_setopt($handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($handle, CURLOPT_IPRESOLVE, $this->ipResolve);

if (!is_null($this->caCertPath)) {
curl_setopt($handle, CURLOPT_CAINFO, $this->caCertPath);
Expand Down
Loading