Skip to content

Commit

Permalink
fix: should open browser with the correct port (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
clement2026 authored Sep 12, 2024
1 parent 9c86bda commit d0bc22b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/rpc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package internal

import (
"errors"
"fmt"
"log"
"net"
Expand All @@ -25,6 +24,7 @@ func StartServeGrpc(gs *grpc.Server, conf *config.LivePprofConfig) {
if err != nil {
logging.Sugar.Fatal(err)
}
conf.Port = port

logging.Sugar.Infof("listening on %s", l.Addr().String())
addr := fmt.Sprintf("%s:%d", strings.Replace(conf.Host, "0.0.0.0", "localhost", 1), port)
Expand Down Expand Up @@ -59,7 +59,7 @@ func StartServeGrpc(gs *grpc.Server, conf *config.LivePprofConfig) {
func findPort(port uint, host string) (net.Listener, uint, error) {
for {
if port > 65535 || port == 0 {
return nil, 0, errors.New("port out of range [1, 65535]")
return nil, 0, fmt.Errorf("port %d is out of range [1, 65535]", port)
}
addr := fmt.Sprintf("%s:%d", host, port)
l, err := net.Listen("tcp", addr)
Expand Down

0 comments on commit d0bc22b

Please sign in to comment.