summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-18 21:14:48 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-11-18 21:14:48 -0800
commitc130ea5b11da6974e5dda4613f771a418b05ce9b (patch)
tree93a2eeb4c5ddcf6ba53181604988216f7c982abc
parentf6897fd47f74abf4c33f003063d6cd201c6e4d05 (diff)
gobgp: use net.JoinHostPort
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--gobgp/cmd/common.go10
1 files changed, 2 insertions, 8 deletions
diff --git a/gobgp/cmd/common.go b/gobgp/cmd/common.go
index fa91e326..51cb414a 100644
--- a/gobgp/cmd/common.go
+++ b/gobgp/cmd/common.go
@@ -24,6 +24,7 @@ import (
"net"
"os"
"sort"
+ "strconv"
"time"
)
@@ -378,14 +379,7 @@ func (v vrfs) Less(i, j int) bool {
func connGrpc() *grpc.ClientConn {
timeout := grpc.WithTimeout(time.Second)
-
- // determine IP address version
- host := net.ParseIP(globalOpts.Host)
- target := fmt.Sprintf("%s:%d", globalOpts.Host, globalOpts.Port)
- if host.To4() == nil {
- target = fmt.Sprintf("[%s]:%d", globalOpts.Host, globalOpts.Port)
- }
-
+ target := net.JoinHostPort(globalOpts.Host, strconv.Itoa(globalOpts.Port))
conn, err := grpc.Dial(target, timeout, grpc.WithBlock(), grpc.WithInsecure())
if err != nil {
fmt.Println(err)