Skip to content

Commit

Permalink
Merge pull request #271 from ae-govau/printlistenaddr
Browse files Browse the repository at this point in the history
fix: print the actual address listened on
  • Loading branch information
MichaelEischer authored Feb 5, 2024
2 parents 3ce6aaf + 4bfb2ea commit b28bea1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions changelog/unreleased/pull-271
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Enhancement: print actual listen address after start-up

When started with `--listen :0` the server would print `start server on :0`

Now the message includes the actual address listened on, for example
`start server on 0.0.0.0:37333`.

This is useful when starting a server with an auto-allocated free port number (port 0).

https://github.com/restic/rest-server/pull/271
2 changes: 1 addition & 1 deletion cmd/rest-server/listener_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func findListener(addr string) (listener net.Listener, err error) {
return nil, fmt.Errorf("listen on %v failed: %w", addr, err)
}

log.Printf("start server on %v", addr)
log.Printf("start server on %v", listener.Addr())
return listener, nil

case 1:
Expand Down
2 changes: 1 addition & 1 deletion cmd/rest-server/listener_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ func findListener(addr string) (listener net.Listener, err error) {
return nil, fmt.Errorf("listen on %v failed: %w", addr, err)
}

log.Printf("start server on %v", addr)
log.Printf("start server on %v", listener.Addr())
return listener, nil
}

0 comments on commit b28bea1

Please sign in to comment.