Skip to content

Commit

Permalink
fix: prevent warning of fsockopen
Browse files Browse the repository at this point in the history
Revert previous change.

Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Jan 29, 2025
1 parent d57d2fc commit c977579
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Handler/CertificateEngine/CfsslHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,15 @@ private function wakeUp(): void {
private function portOpen(): bool {
$host = parse_url($this->getCfsslUri(), PHP_URL_HOST);
$port = parse_url($this->getCfsslUri(), PHP_URL_PORT);
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {

set_error_handler(function () { });
$socket = fsockopen($host, $port, $errno, $errstr, 0.1);
restore_error_handler();
if (!$socket || $errno || $errstr) {
return false;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 0, 'usec' => 100000]); // 100ms
socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => 0, 'usec' => 100000]);
return @socket_connect($socket, $host, $port);
fclose($socket);
return true;
}

private function getServerPid(): int {
Expand Down
5 changes: 5 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<code><![CDATA[addServiceListener]]></code>
</InvalidArgument>
</file>
<file src="lib/Handler/CertificateEngine/CfsslHandler.php">
<InvalidArgument>
<code><![CDATA[function () { }]]></code>
</InvalidArgument>
</file>
<file src="lib/Helper/Pagination.php">
<MissingTemplateParam>
<code><![CDATA[Pagination]]></code>
Expand Down

0 comments on commit c977579

Please sign in to comment.