Skip to content

Commit

Permalink
implement getLANAddress and getPublicAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
codenoid committed Jul 30, 2024
1 parent 8c939e9 commit 9e30489
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/LokalSo/Lokal.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ public function setName(string $name): Tunnel
return $this;
}

public function getLANAddress(): string {
if (!str_ends_with($this->address_mdns, '.local')) {
$this->address_mdns = $this->address_mdns.".local";
}
return $this->address_mdns;
}

public function getPublicAddress(): string {
// TODO: implement port fallback like in golang library
return $this->address_public;
}

public function ignoreDuplicate(bool $ignore_duplicate = true): Tunnel
{
$this->ignore_duplicate = $ignore_duplicate;
Expand Down Expand Up @@ -229,7 +241,7 @@ public function jsonSerialize(): array
}

private function __showStartupBanner(): void {
if (!$this->startupBanner) {
if (!$this->startup_banner) {
return;
}

Expand All @@ -251,8 +263,8 @@ private function __showStartupBanner(): void {
printf("%sPublic Address%s\t\thttps://%s\n", $colors['cyan'], $colors['reset'], $this->address_public);
}

if (!empty($this->address_mdns)) {
printf("%sLAN Address%s\t\thttps://%s\n", $colors['green'], $colors['reset'], $this->address_mdns);
if (!empty($this->getLANAddress())) {
printf("%sLAN Address%s\t\thttps://%s\n", $colors['green'], $colors['reset'], $this->getLANAddress());
}

printf("\n");
Expand Down

0 comments on commit 9e30489

Please sign in to comment.