| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 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: | |
| 23: | |
| 24: | final class DirectCaptureStrategy implements CaptureStrategyInterface |
| 25: | { |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | #[Override] |
| 32: | public function capture(ProtocolInterface $protocol, ServerAddress $addr, array $options): CaptureResult |
| 33: | { |
| 34: | |
| 35: | $serverInfo = $protocol->query($addr); |
| 36: | $rawPackets = []; |
| 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: | |