Skip to content

Commit

Permalink
fix: print the actual address listened on
Browse files Browse the repository at this point in the history
This is useful when the server is started with an ephemeral port, e.g.:

./rest-server --no-auth --listen "127.0.0.1:0"
Data directory: /tmp/restic
Authentication disabled
Private repositories disabled
start server on 127.0.0.1:46015
  • Loading branch information
ae-govau committed Jan 19, 2024
1 parent 3ce6aaf commit 40e7574
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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 %s", listener.Addr().String())
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 %s", listener.Addr().String())
return listener, nil
}

0 comments on commit 40e7574

Please sign in to comment.