summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-04-01 12:23:07 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-04-01 12:23:07 -0600
commit581f1defcb6de580d57f3c3e58b29950d2f42cb7 (patch)
tree7759e7c4f26b72b6ce22a16d0f5e55b983310cf8
parent0d2a3511dc8489abf93cb941b4ffeaf2473529a4 (diff)
caddyhttp: Print actual listener address in log message (closes #2992)
Needed if port is 0, thus chosen by OS
-rw-r--r--modules/caddyhttp/app.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go
index 97290f4..292f934 100644
--- a/modules/caddyhttp/app.go
+++ b/modules/caddyhttp/app.go
@@ -345,8 +345,17 @@ func (app *App) Start() error {
ln = srv.listenerWrappers[i].WrapListener(ln)
}
+ // if binding to port 0, the OS chooses a port for us;
+ // but the user won't know the port unless we print it
+ if listenAddr.StartPort == 0 && listenAddr.EndPort == 0 {
+ app.logger.Info("port 0 listener",
+ zap.String("input_address", lnAddr),
+ zap.String("actual_address", ln.Addr().String()),
+ )
+ }
+
app.logger.Debug("starting server loop",
- zap.String("address", lnAddr),
+ zap.String("address", ln.Addr().String()),
zap.Bool("http3", srv.ExperimentalHTTP3),
zap.Bool("tls", useTLS),
)