From b77ad77044b6b538c89d88c8e4c5bab4cec5ac2b Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Mon, 22 Apr 2024 16:51:22 +0400 Subject: [PATCH] Fix psalm issues, update docs --- README.md | 15 +++++++++++---- src/Command/Run.php | 10 ++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 80e5e56e..5350a4ed 100644 --- a/README.md +++ b/README.md @@ -141,15 +141,22 @@ $responder->respond(trap($response)->return()); ### Default port -By default, the Trap server operates on port `9912`. However, if you wish to utilize a different port, you can easily -make this adjustment using the `-p` option. - -For example, to switch to port 8000, you would use the following command: +Trap automatically recognizes the type of traffic. +Therefore, there is no need to open separate ports for different protocols. +By default, it operates on port `9912`. +However, if you wish to utilize a different port, you can easily make this adjustment using the `-p` option: ```bash vendor/bin/trap -p 8000 ``` +Sometimes, it's convenient to run Trap on the same ports that [Buggregator](https://github.com/buggregator/server) +uses by default. Well, that's also possible: + +```bash +vendor/bin/trap -p 1025 -p 9912 -p 9913 -p 8000 +``` + ### Choosing Your Senders Buggregator Trap provides a variety of "senders" that dictate where the dumps will be sent. Currently, the available diff --git a/src/Command/Run.php b/src/Command/Run.php index 97552474..c45edb14 100644 --- a/src/Command/Run.php +++ b/src/Command/Run.php @@ -63,11 +63,17 @@ protected function execute( * @var SocketServer[] $servers */ $servers = []; - foreach ($input->getOption('port') ?: [9912] as $port) { + $ports = $input->getOption('port') ?: [9912]; + \assert(\is_array($ports)); + foreach ($ports as $port) { \is_numeric($port) or throw new \InvalidArgumentException( \sprintf('Invalid port `%s`. It must be a number.', $port), ); - $servers[] = new SocketServer((int)$port); + $port = (int)$port; + $port > 0 && $port < 65536 or throw new \InvalidArgumentException( + \sprintf('Invalid port `%s`. It must be in range 1-65535.', $port), + ); + $servers[] = new SocketServer($port); } /** @var non-empty-string[] $senders */