- if ($l =~ s!\A([^:]+)://!!) {
- $scheme = $1;
- } elsif ($l =~ /\A(?:\[[^\]]+\]|[^:]+):([0-9])+/) {
- my $s = $KNOWN_TLS{$1} // $KNOWN_STARTTLS{$1};
- $scheme = $s if defined $s;
+ my $port;
+ if ($l =~ s!\A([^:]+)://!!) { $scheme = $1 }
+ if ($l =~ /\A(?:\[[^\]]+\]|[^:]+):([0-9]+)/) {
+ $port = $1 + 0;
+ my $s = $KNOWN_TLS{$port} // $KNOWN_STARTTLS{$port};
+ $scheme //= $s if defined $s;
+ } elsif (index($l, '/') != 0) { # unix socket
+ $port //= $SCHEME2PORT{$scheme} if $scheme;
+ $port // die "no port in listen=$l\n";
+ $l =~ s!\A([^/]+)!$1:$port! or
+ die "unable to add port=$port to $l\n";