summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-06-01 04:50:38 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-06-01 05:06:37 +0000
commit4c9cd88c61cb848e36a45657b7cbc63b9c783dc4 (patch)
tree65f5dfdc3b1e26a2376e0c45d5991c0df2af98d3 /server/fsm.go
parent835d1f38e7f164393494191a5a58b29c8c9a88ac (diff)
server/config: fix md5ed ipv6 active connection
Local address of md5ed active connection was hard-coded as "0.0.0.0". Let's set appropriate default local address (0.0.0.0 or ::) in SetDefaultConfigValues() and clean up (*FSM).connectLoop() instead of ad-hoc connectLoop() fix. Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go35
1 files changed, 13 insertions, 22 deletions
diff --git a/server/fsm.go b/server/fsm.go
index c369b432..3069893b 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -294,30 +294,21 @@ func (fsm *FSM) connectLoop() error {
laddr := fsm.pConf.Transport.Config.LocalAddress
var conn net.Conn
var err error
- if laddr != "" {
- if fsm.pConf.Config.AuthPassword != "" {
- deadline := (MIN_CONNECT_RETRY - 1) * 1000 // msec
- conn, err = DialTCPTimeoutWithMD5Sig(addr, port, laddr, fsm.pConf.Config.AuthPassword, deadline)
- } else {
- lhost := net.JoinHostPort(laddr, "0")
- ltcpaddr, e := net.ResolveTCPAddr("tcp", lhost)
- if e != nil {
- log.WithFields(log.Fields{
- "Topic": "Peer",
- "Key": fsm.pConf.Config.NeighborAddress,
- }).Warnf("failed to resolve ltcpaddr: %s", e)
- return
- }
- d := net.Dialer{LocalAddr: ltcpaddr, Timeout: time.Duration(MIN_CONNECT_RETRY-1) * time.Second}
- conn, err = d.Dial("tcp", host)
- }
+ if fsm.pConf.Config.AuthPassword != "" {
+ deadline := (MIN_CONNECT_RETRY - 1) * 1000 // msec
+ conn, err = DialTCPTimeoutWithMD5Sig(addr, port, laddr, fsm.pConf.Config.AuthPassword, deadline)
} else {
- if fsm.pConf.Config.AuthPassword != "" {
- deadline := (MIN_CONNECT_RETRY - 1) * 1000 // msec
- conn, err = DialTCPTimeoutWithMD5Sig(addr, port, "0.0.0.0", fsm.pConf.Config.AuthPassword, deadline)
- } else {
- conn, err = net.DialTimeout("tcp", host, time.Duration(MIN_CONNECT_RETRY-1)*time.Second)
+ lhost := net.JoinHostPort(laddr, "0")
+ ltcpaddr, e := net.ResolveTCPAddr("tcp", lhost)
+ if e != nil {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Key": fsm.pConf.Config.NeighborAddress,
+ }).Warnf("failed to resolve ltcpaddr: %s", e)
+ return
}
+ d := net.Dialer{LocalAddr: ltcpaddr, Timeout: time.Duration(MIN_CONNECT_RETRY-1) * time.Second}
+ conn, err = d.Dial("tcp", host)
}
if err == nil {