Skip to content

Commit

Permalink
Tidy up net.SplitHostPort
Browse files Browse the repository at this point in the history
Signed-off-by: Chun-Hung Tseng <[email protected]>
Co-authored-by: Iván Valdés Castillo <[email protected]>
  • Loading branch information
henrybear327 and ivanvc committed May 18, 2024
1 parent 4eb584f commit ff5824f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,11 @@ func NewServer(cfg ServerConfig) Server {
pauseRxc: make(chan struct{}),
}

_, fromPort, err := net.SplitHostPort(cfg.From.Host)
if err == nil {
if _, fromPort, err := net.SplitHostPort(cfg.From.Host); err == nil {
s.fromPort, _ = strconv.Atoi(fromPort)
}
if !s.isForwardProxy {
var toPort string
_, toPort, err = net.SplitHostPort(cfg.To.Host)
if err == nil {
if _, toPort, err := net.SplitHostPort(cfg.To.Host); err == nil {
s.toPort, _ = strconv.Atoi(toPort)
}
}
Expand Down Expand Up @@ -260,6 +257,7 @@ func NewServer(cfg ServerConfig) Server {
}

var ln net.Listener
var err error
if !s.tlsInfo.Empty() {
ln, err = transport.NewListener(addr, s.from.Scheme, &s.tlsInfo)
} else {
Expand Down

0 comments on commit ff5824f

Please sign in to comment.