This commit is contained in:
2026-05-28 20:19:28 +08:00
commit 070fad058f
124 changed files with 22713 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace LayLink\Agent;
use LayLink\Auth\PolicyChecker;
final class TargetConnector
{
public function __construct(private readonly array $nodeConfig)
{
}
public function isAllowed(string $host, int $port): bool
{
if (!in_array($port, $this->nodeConfig['allowed_ports'] ?? [], true)) {
return false;
}
foreach ($this->nodeConfig['allowed_cidrs'] ?? [] as $cidr) {
if (is_string($cidr) && PolicyChecker::cidrContains($cidr, $host)) {
return true;
}
}
return in_array($host, $this->nodeConfig['allowed_hosts'] ?? [], true);
}
}