Commit 077eab1b by Arve Knudsen Committed by GitHub

Chore: Use net.JoinHostPort (#28421)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 020dde53
...@@ -107,7 +107,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error { ...@@ -107,7 +107,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
hs.applyRoutes() hs.applyRoutes()
hs.httpSrv = &http.Server{ hs.httpSrv = &http.Server{
Addr: fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort), Addr: net.JoinHostPort(setting.HttpAddr, setting.HttpPort),
Handler: hs.macaron, Handler: hs.macaron,
} }
switch setting.Protocol { switch setting.Protocol {
......
...@@ -7,6 +7,8 @@ import ( ...@@ -7,6 +7,8 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
"net"
"strconv"
"strings" "strings"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
...@@ -110,7 +112,7 @@ func (server *Server) Dial() error { ...@@ -110,7 +112,7 @@ func (server *Server) Dial() error {
} }
} }
for _, host := range strings.Split(server.Config.Host, " ") { for _, host := range strings.Split(server.Config.Host, " ") {
address := fmt.Sprintf("%s:%d", host, server.Config.Port) address := net.JoinHostPort(host, strconv.Itoa(server.Config.Port))
if server.Config.UseSSL { if server.Config.UseSSL {
tlsCfg := &tls.Config{ tlsCfg := &tls.Config{
InsecureSkipVerify: server.Config.SkipVerifySSL, InsecureSkipVerify: server.Config.SkipVerifySSL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment