1: <?php declare(strict_types=1);
2:
3: /**
4: * Clansuite Server Query
5: *
6: * SPDX-FileCopyrightText: 2003-2025 Jens A. Koch
7: * SPDX-License-Identifier: MIT
8: *
9: * For the full copyright and license information, please view
10: * the LICENSE file that was distributed with this source code.
11: */
12:
13: namespace Clansuite\Capture\Strategy;
14:
15: use function time;
16: use Clansuite\Capture\CaptureResult;
17: use Clansuite\Capture\Protocol\ProtocolInterface;
18: use Clansuite\Capture\ServerAddress;
19: use Override;
20:
21: /**
22: * Capture strategy that performs server queries directly without using worker processes.
23: */
24: final class DirectCaptureStrategy implements CaptureStrategyInterface
25: {
26: /**
27: * capture method.
28: *
29: * @param array<mixed> $options
30: */
31: #[Override]
32: public function capture(ProtocolInterface $protocol, ServerAddress $addr, array $options): CaptureResult
33: {
34: // Stub: query and return result without actual capture
35: $serverInfo = $protocol->query($addr);
36: $rawPackets = []; // TODO: capture packets
37: $metadata = [
38: 'ip' => $addr->ip,
39: 'port' => $addr->port,
40: 'protocol' => $protocol->getProtocolName(),
41: 'timestamp' => time(),
42: ];
43:
44: return new CaptureResult($rawPackets, $serverInfo, $metadata);
45: }
46: }
47: