From ba5b81cf2dc4eb5135c77d5b9a786f2c192f4719 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Mon, 17 Jun 2024 18:15:45 -0400 Subject: [PATCH] Show localhost --- app/Models/Objects/Endpoint.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Models/Objects/Endpoint.php b/app/Models/Objects/Endpoint.php index c4c67542b..18b80b71b 100644 --- a/app/Models/Objects/Endpoint.php +++ b/app/Models/Objects/Endpoint.php @@ -14,6 +14,7 @@ class Endpoint implements Jsonable public const PORT_RANGE_LIMIT = 1000; public const PORT_RANGE_REGEX = '/^(\d{4,5})-(\d{4,5})$/'; public const INADDR_ANY = '0.0.0.0'; + public const INADDR_LOOPBACK = '127.0.0.1'; public int $port; public string $ip; @@ -35,11 +36,17 @@ class Endpoint implements Jsonable public function __toString(): string { - if ($this->ip === self::INADDR_ANY) { + $ip = $this->ip; + + if ($ip === self::INADDR_ANY) { return (string) $this->port; } - return "$this->ip:$this->port"; + if ($ip === self::INADDR_LOOPBACK) { + $ip = 'localhost'; + } + + return "$ip:$this->port"; } public function toJson($options = 0): string