Skip to content

Commit

Permalink
Always log messages about denying clients
Browse files Browse the repository at this point in the history
These were getting hidden in production when they are vital to debugging why clients were getting denied.
  • Loading branch information
trowski committed Aug 23, 2021
1 parent 1f16f11 commit 681b358
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private function onAcceptable(string $watcherId, $server): void
});

if ($this->clientCount++ === $this->options->getConnectionLimit()) {
\assert($this->logger->debug("Client denied: too many existing connections") || true);
$this->logger->warning("Client denied: too many existing connections");
$client->close();
return;
}
Expand All @@ -381,17 +381,13 @@ private function onAcceptable(string $watcherId, $server): void
&& $ip !== "::1" && \strncmp($ip, "127.", 4) !== 0 && $client->getLocalAddress()->getPort() !== null
&& \strncmp(\inet_pton($ip), '\0\0\0\0\0\0\0\0\0\0\xff\xff\7f', 31)
) {
\assert((function () use ($ip) {
$packedIp = @\inet_pton($ip);
$packedIp = @\inet_pton($ip);

if (isset($packedIp[4])) {
$ip .= "/56";
}

$this->logger->debug("Client denied: too many existing connections from {$ip}");
if (isset($packedIp[4])) {
$ip .= "/56";
}

return true;
})());
$this->logger->warning("Client denied: too many existing connections from {$ip}");

$client->close();
return;
Expand Down

0 comments on commit 681b358

Please sign in to comment.