diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 19 | ||||
-rw-r--r-- | server/rpki.go | 9 |
2 files changed, 6 insertions, 22 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{ diff --git a/server/rpki.go b/server/rpki.go index ec7c9afe..c5e1a850 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -26,6 +26,7 @@ import ( "github.com/osrg/gobgp/packet" "github.com/osrg/gobgp/table" "net" + "strconv" "time" ) @@ -191,12 +192,8 @@ func newROAClient(conf config.RpkiServers) (*roaClient, error) { if len(conf.RpkiServerList) > 1 { log.Warn("currently only one RPKI server is supposed") } - if conf.RpkiServerList[0].RpkiServerConfig.Address.To16() == nil { - url = fmt.Sprintf("%s", conf.RpkiServerList[0].RpkiServerConfig.Address) - } else { - url = fmt.Sprintf("[%s]", conf.RpkiServerList[0].RpkiServerConfig.Address) - } - url += fmt.Sprintf(":%d", conf.RpkiServerList[0].RpkiServerConfig.Port) + c := conf.RpkiServerList[0].RpkiServerConfig + url = net.JoinHostPort(c.Address.String(), strconv.Itoa(int(c.Port))) } conn, err := net.Dial("tcp", url) |