summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-06 00:01:39 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-06 00:49:31 +0900
commite314f8150ce73adeb7bdccc58d34be6e22aa11b2 (patch)
treedb5b9f93ecf2447c14d79750dde2169162d175db /server/fsm.go
parente3aed6abb18f33c65c78d5551219d162b022a850 (diff)
use net.JoinHostPort()
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go19
1 files changed, 3 insertions, 16 deletions
diff --git a/server/fsm.go b/server/fsm.go
index a2b04c6b..215b8803 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -214,25 +214,12 @@ func (fsm *FSM) connectLoop() error {
connect := func() {
if fsm.state == bgp.BGP_FSM_ACTIVE {
- var host string
- var lhost string
-
addr := fsm.pConf.NeighborConfig.NeighborAddress
-
- if addr.To4() != nil {
- host = addr.String() + ":" + strconv.Itoa(bgp.BGP_PORT)
- } else {
- host = "[" + addr.String() + "]:" + strconv.Itoa(bgp.BGP_PORT)
- }
-
- // check if LocalAddress has been configured in Neighbors.NeighborList.Transport.TransportConfig stanza.
+ host := net.JoinHostPort(addr.String(), strconv.Itoa(bgp.BGP_PORT))
+ // check if LocalAddress has been configured
laddr := fsm.pConf.Transport.TransportConfig.LocalAddress
if laddr != nil {
- if laddr.To4() != nil {
- lhost = laddr.String() + ":0"
- } else {
- lhost = "[" + laddr.String() + "]:0"
- }
+ lhost := net.JoinHostPort(laddr.String(), "0")
ltcpaddr, err := net.ResolveTCPAddr("tcp", lhost)
if err != nil {
log.WithFields(log.Fields{