summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-03-23 15:08:28 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-04-04 13:20:25 +0900
commit1c8c1df2544b8b7382e17968e4eb17aa95157868 (patch)
tree8ace98b4746eced816f649969b4ccccebc0e5d51
parentba5e06f38673acb98375d6ba2e85f8a6cb9c86f1 (diff)
server: use net.SplitHostPort
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--server/server.go9
1 files changed, 1 insertions, 8 deletions
diff --git a/server/server.go b/server/server.go
index b9d0ddf6..ebb7a611 100644
--- a/server/server.go
+++ b/server/server.go
@@ -26,7 +26,6 @@ import (
"os"
"sort"
"strconv"
- "strings"
)
type serverMsgType int
@@ -146,13 +145,7 @@ func (server *BgpServer) Serve() {
for {
select {
case conn := <-acceptCh:
- remoteAddr := func(addrPort string) string {
- if strings.Index(addrPort, "[") == -1 {
- return strings.Split(addrPort, ":")[0]
- }
- idx := strings.LastIndex(addrPort, ":")
- return addrPort[1 : idx-1]
- }(conn.RemoteAddr().String())
+ remoteAddr, _, _ := net.SplitHostPort(conn.RemoteAddr().String())
info, found := server.peerMap[remoteAddr]
if found {
log.Info("accepted a new passive connection from ", remoteAddr)