Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print the actual address listened on #271

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading