Skip to content

Commit 435ada6

Browse files
authored
Merge pull request #696 from rancher-sandbox/hostname-fallback
Use system_profiler fallback if hostname address cannot be determined
2 parents 66f66e1 + 4d86cee commit 435ada6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hack/test-port-forwarding.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
my $instance = shift;
2424

25-
my $ipv4 = inet_ntoa(scalar gethostbyname(hostname())) or die;
25+
my $addr = scalar gethostbyname(hostname());
26+
# If hostname address cannot be determines, use localhost to trigger fallback to system_profiler lookup
27+
my $ipv4 = length $addr ? inet_ntoa($addr) : "127.0.0.1";
2628
my $ipv6 = ""; # todo
2729

2830
# macOS Github runners seem to use "localhost" as the hostname

0 commit comments

Comments
 (0)